blob: c3210574f3490d89f00b10cdb90ca3f2cfd74215 [file] [log] [blame]
/**
* Copyright (C) 2013 Regents of the University of California.
* @author: Yingdi Yu <yingdi0@cs.ucla.edu>
* See COPYING for copyright and distribution information.
*/
#include <boost/test/unit_test.hpp>
#include "security/key-chain.hpp"
#include "security/verifier.hpp"
#include <iostream>
using namespace std;
using namespace ndn;
BOOST_AUTO_TEST_SUITE(TestSignedInterest)
BOOST_AUTO_TEST_CASE (SignVerify)
{
KeyChainImpl<SecPublicInfoSqlite3, SecTpmFile> keyChain;
Name identityName("/test");
Name certificateName = keyChain.createIdentity(identityName);
Interest interest("/test/interest");
keyChain.signByIdentity(interest, identityName);
Block interestBlock(interest.wireEncode().wire(), interest.wireEncode().size());
Interest interest2;
interest2.wireDecode(interestBlock);
ptr_lib::shared_ptr<PublicKey> publicKey = keyChain.getPublicKeyFromTpm(keyChain.getDefaultKeyNameForIdentity(identityName));
bool result = Verifier::verifySignature(interest2, *publicKey);
BOOST_REQUIRE_EQUAL(result, true);
}
BOOST_AUTO_TEST_SUITE_END()