Data Packet Verification Added
diff --git a/src/communication/nlsr_dm.cpp b/src/communication/nlsr_dm.cpp
index 92a911d..5365630 100644
--- a/src/communication/nlsr_dm.cpp
+++ b/src/communication/nlsr_dm.cpp
@@ -9,6 +9,7 @@
#include "nlsr_dm.hpp"
#include "utility/nlsr_tokenizer.hpp"
#include "nlsr_lsdb.hpp"
+#include "security/nlsr_km.hpp"
namespace nlsr
{
@@ -22,12 +23,7 @@
{
cout << "I: " << interest.toUri() << endl;
string dataName(data.getName().toUri());
- //cout << "D: " << dataName << endl;
- //cout << "Data Content: " << dataContent << endl;
nlsrTokenizer nt(dataName,"/");
- //SignatureSha256WithRsa sig(data.getSignature());
- //ndn::Name keyName=sig.getKeyLocator().getName();
- //cout<<"Key Locator Name: "<<keyName.toUri()<<endl;
string chkString("info");
if( nt.doesTokenExist(chkString) )
{
@@ -184,19 +180,16 @@
void
DataManager::processContentKeys(Nlsr& pnlsr, const ndn::Data& data)
{
- std::ofstream outFile("data_received");
- ndn::io::save(data,outFile,ndn::io::NO_ENCODING);
cout<<" processContentKeys called "<<endl;
- SignatureSha256WithRsa signature(data.getSignature());
- cout<<"D: <<"<<data<<endl;
- cout<<"Key Locator: "<<signature.getKeyLocator().getName().toUri()<<endl;
ndn::shared_ptr<ndn::IdentityCertificate> cert=ndn::make_shared<ndn::IdentityCertificate>();
cert->wireDecode(data.getContent().blockFromValue());
cout<<*(cert)<<endl;
-
- if( pnlsr.getKeyManager().verifySignature(*(cert),cert->getPublicKeyInfo()))
- {
- cout<<"Verified Data"<<endl;
- }
+ std::string dataName=data.getName().toUri();
+ nlsrTokenizer nt(dataName,"/");
+ std::string certName=nt.getTokenString(0,nt.getTokenNumber()-3);
+ uint32_t seqNum=boost::lexical_cast<uint32_t>(nt.getToken(nt.getTokenNumber()-2));
+ cout<<"Cert Name: "<<certName<<" Seq Num: "<<seqNum<<std::endl;
+ pnlsr.getKeyManager().addCertificate(cert, seqNum, true);
+ pnlsr.getKeyManager().printCertStore();
}
}//namespace nlsr