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
diff --git a/src/communication/nlsr_im.cpp b/src/communication/nlsr_im.cpp
index 7495265..de551bb 100644
--- a/src/communication/nlsr_im.cpp
+++ b/src/communication/nlsr_im.cpp
@@ -186,15 +186,34 @@
     void
     interestManager::processInterestKeys(Nlsr& pnlsr,const ndn::Interest &interest)
     {
-        cout<<" processInterestKeys called "<<endl;
-        ndn::shared_ptr<ndn::IdentityCertificate> cert=pnlsr.getKeyManager().getCertificate("dummy");
+        cout<<"processInterestKeys called "<<endl;
+        string intName=interest.getName().toUri();
+        cout<<"Interest Name for Key: "<<intName<<std::endl;
+        nlsrTokenizer nt(intName,"/");
+        std::string certName=nt.getTokenString(0,nt.getTokenNumber()-2);
+        uint32_t seqNum=boost::lexical_cast<uint32_t>(nt.getToken(nt.getTokenNumber()-1));
+        cout<<"Cert Name: "<<certName<<" Seq Num: "<<seqNum<<std::endl;
+        std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool> chkCert=
+                pnlsr.getKeyManager().getCertificateFromStore(certName,seqNum);
+        if( chkCert.second )
+        {
+           Data data(ndn::Name(interest.getName()).appendVersion()); 
+           data.setFreshnessPeriod(1000); //10 sec
+           data.setContent(chkCert.first->wireEncode());
+           pnlsr.getKeyManager().signData(data);
+           pnlsr.getNlsrFace()->put(data);
+        }
+        //std::pair<ndn::shared_ptr<ndn::IdentityCertificate>, bool> chkCert=
+        /*
+        ndn::shared_ptr<ndn::IdentityCertificate> cert=pnlsr.getKeyManager().getCertificate();
         Data data(ndn::Name(interest.getName()).appendVersion());
         data.setFreshnessPeriod(1000); // 10 sec
         data.setContent(cert->wireEncode());
         pnlsr.getKeyManager().signData(data);
-        std::ofstream outFile("data_sent");
-        ndn::io::save(data,outFile,ndn::io::NO_ENCODING);
+        //std::ofstream outFile("data_sent");
+        //ndn::io::save(data,outFile,ndn::io::NO_ENCODING);
         pnlsr.getNlsrFace()->put(data);
+        */ 
     }
 
 
diff --git a/src/communication/nlsr_slh.cpp b/src/communication/nlsr_slh.cpp
index ac29148..94517ae 100644
--- a/src/communication/nlsr_slh.cpp
+++ b/src/communication/nlsr_slh.cpp
@@ -58,7 +58,8 @@
         if( nt.doesTokenExist(chkString) )
         {
             //process keys update here
-            processKeysUpdateFromSync(updateName,seqNo, pnlsr);
+            std::string certName=nt.getTokenString(0);
+            processKeysUpdateFromSync(certName,seqNo, pnlsr);
         }
     }
 
@@ -108,9 +109,14 @@
     SyncLogicHandler::processKeysUpdateFromSync(std::string certName,
             uint64_t seqNo, Nlsr& pnlsr)
     {
-        string certNamePrefix=certName + "/" + boost::lexical_cast<string>(seqNo);
-        pnlsr.getIm().expressInterest(pnlsr, certNamePrefix, 3,
-                                      pnlsr.getConfParameter().getInterestResendTime());
+        cout<<"Cert Name: "<<certName<<std::endl;
+        if ( pnlsr.getKeyManager().isNewCertificate(certName,seqNo) )
+        {
+            string certNamePrefix=certName + "/" + 
+                                             boost::lexical_cast<string>(seqNo);
+            pnlsr.getIm().expressInterest(pnlsr, certNamePrefix, 3,
+                              pnlsr.getConfParameter().getInterestResendTime());
+        }
     }
 
     void
@@ -124,7 +130,11 @@
     void
     SyncLogicHandler::publishKeyUpdate(KeyManager& km)
     {
-        publishSyncUpdate(km.getRouterCertName().toUri(),km.getCertSeqNo());
+        publishSyncUpdate(km.getRootCertName().toUri(), 10);
+        publishSyncUpdate(km.getSiteCertName().toUri(), 10);
+        publishSyncUpdate(km.getOperatorCertName().toUri(), 10);
+        publishSyncUpdate(km.getRouterCertName().toUri(), km.getCertSeqNo());
+        publishSyncUpdate(km.getProcessCertName().toUri(),km.getCertSeqNo());
     }
 
     void