blob: 3cfc61cc120d4cf3cb091b9bfb4def1d215a6856 [file] [log] [blame]
Yingdi Yu7036ce22014-06-19 18:53:37 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Spyridon Mastorakis429634f2015-02-19 17:35:33 -08003 * Copyright (c) 2013-2015 Regents of the University of California.
Yingdi Yu7036ce22014-06-19 18:53:37 -07004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6 *
7 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later version.
10 *
11 * ndn-cxx library 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 Lesser General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License and GNU Lesser
16 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20 */
21
22#include "security/key-params.hpp"
23
24#include "boost-test.hpp"
25
26
27namespace ndn {
Spyridon Mastorakis429634f2015-02-19 17:35:33 -080028namespace tests {
Yingdi Yu7036ce22014-06-19 18:53:37 -070029
Spyridon Mastorakis429634f2015-02-19 17:35:33 -080030BOOST_AUTO_TEST_SUITE(SecurityKeyParams)
Yingdi Yu7036ce22014-06-19 18:53:37 -070031
32BOOST_AUTO_TEST_CASE(RsaParameter)
33{
34 RsaKeyParams params;
35 BOOST_CHECK_EQUAL(params.getKeyType(), KEY_TYPE_RSA);
36 BOOST_CHECK_EQUAL(params.getKeySize(), 2048);
37
38 RsaKeyParams params2(1024);
39 BOOST_CHECK_EQUAL(params2.getKeyType(), KEY_TYPE_RSA);
40 BOOST_CHECK_EQUAL(params2.getKeySize(), 1024);
41
42 RsaKeyParams params3(3);
43 BOOST_CHECK_EQUAL(params3.getKeyType(), KEY_TYPE_RSA);
44 BOOST_CHECK_EQUAL(params3.getKeySize(), 2048);
45}
46
47BOOST_AUTO_TEST_CASE(EcdsaParameter)
48{
49 EcdsaKeyParams params;
50 BOOST_CHECK_EQUAL(params.getKeyType(), KEY_TYPE_ECDSA);
51 BOOST_CHECK_EQUAL(params.getKeySize(), 256);
52
53 EcdsaKeyParams params2(384);
54 BOOST_CHECK_EQUAL(params2.getKeyType(), KEY_TYPE_ECDSA);
55 BOOST_CHECK_EQUAL(params2.getKeySize(), 384);
56
57 EcdsaKeyParams params3(3);
58 BOOST_CHECK_EQUAL(params3.getKeyType(), KEY_TYPE_ECDSA);
59 BOOST_CHECK_EQUAL(params3.getKeySize(), 256);
60}
61
62BOOST_AUTO_TEST_CASE(AesParameter)
63{
64 AesKeyParams params;
65 BOOST_CHECK_EQUAL(params.getKeyType(), KEY_TYPE_AES);
66 BOOST_CHECK_EQUAL(params.getKeySize(), 64);
67
68 AesKeyParams params2(128);
69 BOOST_CHECK_EQUAL(params2.getKeyType(), KEY_TYPE_AES);
70 BOOST_CHECK_EQUAL(params2.getKeySize(), 128);
71
72 AesKeyParams params3(256);
73 BOOST_CHECK_EQUAL(params3.getKeyType(), KEY_TYPE_AES);
74 BOOST_CHECK_EQUAL(params3.getKeySize(), 256);
75
76 AesKeyParams params4(4);
77 BOOST_CHECK_EQUAL(params4.getKeyType(), KEY_TYPE_AES);
78 BOOST_CHECK_EQUAL(params4.getKeySize(), 64);
79}
80
81BOOST_AUTO_TEST_CASE(Error)
82{
83 EcdsaKeyParams params;
84 BOOST_REQUIRE_THROW((RsaKeyParams(params)), KeyParams::Error);
85
86 AesKeyParams params2;
87 BOOST_REQUIRE_THROW((RsaKeyParams(params2)), KeyParams::Error);
88}
89
90BOOST_AUTO_TEST_SUITE_END()
91
Spyridon Mastorakis429634f2015-02-19 17:35:33 -080092} // namespace tests
Yingdi Yu7036ce22014-06-19 18:53:37 -070093} // namespace ndn