blob: 10e59d98298c7078e5de29e87c8937c36bcf8005 [file] [log] [blame]
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2017-2019, Regents of the University of California.
4 *
5 * This file is part of ndncert, a certificate management system based on NDN.
6 *
7 * ndncert is free software: you can redistribute it and/or modify it under the terms
8 * of the GNU General Public License as published by the Free Software Foundation, either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * ndncert is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License along with
16 * ndncert, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * See AUTHORS.md for complete list of ndncert authors and contributors.
19 */
20
21#include "crypto-support/enc-tlv.hpp"
22#include "crypto-support/crypto-helper.hpp"
Zhiyi Zhang42d992d2019-07-07 16:46:50 -070023#include "boost-test.hpp"
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070024
25namespace ndn {
26namespace ndncert {
27namespace tests {
28
29BOOST_AUTO_TEST_SUITE(TestEncTlv)
30
31BOOST_AUTO_TEST_CASE(Test0)
32{
33 ECDHState aliceState;
34 auto alicePub = aliceState.getRawSelfPubKey();
35 BOOST_CHECK(aliceState.context->publicKeyLen != 0);
36
37 ECDHState bobState;
38 auto bobPub = bobState.getRawSelfPubKey();
39 BOOST_CHECK(bobState.context->publicKeyLen != 0);
40
41 auto aliceResult = aliceState.deriveSecret(bobPub, bobState.context->publicKeyLen);
42 BOOST_CHECK(aliceState.context->sharedSecretLen != 0);
43
44 auto bobResult = bobState.deriveSecret(alicePub, aliceState.context->publicKeyLen);
45 BOOST_CHECK(bobState.context->sharedSecretLen != 0);
46
47 BOOST_CHECK_EQUAL_COLLECTIONS(aliceResult, aliceResult + 32,
48 bobResult, bobResult + 32);
49}
50
51BOOST_AUTO_TEST_SUITE_END()
52
53} // namespace tests
54} // namespace ndncert
55} // namespace ndn