blob: ecd25690978fcd383b0d4db54a30d7988107063c [file] [log] [blame]
Junxiao Shi81206d52017-07-23 12:43:22 +00001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2013-2017 Regents of the University of California.
4 *
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 "signature.hpp"
23#include "security/digest-sha256.hpp"
24#include "security/signature-sha256-with-rsa.hpp"
25
26#include "boost-test.hpp"
27
28namespace ndn {
29namespace tests {
30
31BOOST_AUTO_TEST_SUITE(TestSignature)
32
33BOOST_AUTO_TEST_CASE(Equality)
34{
35 Signature a;
36 Signature b;
37
38 BOOST_CHECK_EQUAL(a == b, true);
39 BOOST_CHECK_EQUAL(a != b, false);
40
41 a = SignatureSha256WithRsa();
42 BOOST_CHECK_EQUAL(a == b, false);
43 BOOST_CHECK_EQUAL(a != b, true);
44
45 b = SignatureSha256WithRsa();
46 static const uint8_t someData[256] = {};
47 Block signatureValue = makeBinaryBlock(tlv::SignatureValue, someData, sizeof(someData));
48 b.setValue(signatureValue);
49 BOOST_CHECK_EQUAL(a == b, false);
50 BOOST_CHECK_EQUAL(a != b, true);
51
52 a.setValue(signatureValue);
53 BOOST_CHECK_EQUAL(a == b, true);
54 BOOST_CHECK_EQUAL(a != b, false);
55
56 a = DigestSha256();
57 b = SignatureSha256WithRsa();
58 BOOST_CHECK_EQUAL(a == b, false);
59 BOOST_CHECK_EQUAL(a != b, true);
60
61 b = DigestSha256();
62 BOOST_CHECK_EQUAL(a == b, true);
63 BOOST_CHECK_EQUAL(a != b, false);
64}
65
66BOOST_AUTO_TEST_SUITE_END() // TestSignature
67
68} // namespace tests
69} // namespace ndn