blob: 5c7e68441d2657496e1369c032707f68087568fe [file] [log] [blame]
Yingdi Yu4270f202014-01-28 14:19:16 -08001/**
2 * Copyright (C) 2013 Regents of the University of California.
3 * @author: Yingdi Yu <yingdi0@cs.ucla.edu>
4 * See COPYING for copyright and distribution information.
5 */
6
7#include <boost/test/unit_test.hpp>
8
9#include "security/key-chain.hpp"
10#include "security/verifier.hpp"
11#include <iostream>
12
13using namespace std;
14using namespace ndn;
15
16
17BOOST_AUTO_TEST_SUITE(TestSignedInterest)
18
19BOOST_AUTO_TEST_CASE (SignVerify)
20{
21 KeyChainImpl<SecPublicInfoSqlite3, SecTpmFile> keyChain;
22
23 Name identityName("/test");
24 Name keyName = keyChain.createIdentity(identityName);
25
26 Interest interest("/test/interest");
27 keyChain.signByIdentity(interest, identityName);
28
29 Block interestBlock(interest.wireEncode().wire(), interest.wireEncode().size());
30
31 Interest interest2;
32 interest2.wireDecode(interestBlock);
33
34 ptr_lib::shared_ptr<PublicKey> publicKey = keyChain.getPublicKeyFromTpm(keyName);
35 bool result = Verifier::verifySignature(interest2, *publicKey);
36
37 BOOST_REQUIRE_EQUAL(result, true);
38}
39
40BOOST_AUTO_TEST_SUITE_END()