Actions
Bug #3723
closedValidator::verifySignature(const Interest&, const PublicKey&) throws if Signature TLV is invalid
Start date:
08/07/2016
Due date:
% Done:
100%
Estimated time:
2.00 h
Description
Snippet to reproduce:
// g++ -o x -std=c++0x x.cpp $(pkg-config --cflags --libs libndn-cxx)
#include <iostream>
#include <ndn-cxx/security/key-chain.hpp>
#include <ndn-cxx/security/validator.hpp>
using namespace ndn;
template<typename...A>
void
setNameComponent(Name& name, ssize_t index, const A& ...a)
{
Name name2 = name.getPrefix(index);
name2.append(name::Component(a...));
name2.append(name.getSubName(name2.size()));
name = name2;
}
int main()
{
KeyChain keyChain;
auto interest = make_shared<Interest>("/prefix");
keyChain.sign(*interest);
Name name = interest->getName();
//setNameComponent(name, signed_interest::POS_SIG_INFO, "not-SignatureInfo");
setNameComponent(name, signed_interest::POS_SIG_VALUE, "bad-signature-bits");
interest->setName(name);
bool res = Validator::verifySignature(*interest, keyChain.getDefaultCertificate()->getPublicKeyInfo());
std::cout << static_cast<int>(res) << std::endl;
return 0;
}
Expected: output "0"
Actual: throw ndn::tlv::Error
"TLV length mismatches buffer length"
Actions