Adapting to TLV-specific ndn-cpp
Change-Id: I5f39f38156221fc978db5048c1ff4a3bbb0c17d9
diff --git a/src/addcontactpanel.cpp b/src/addcontactpanel.cpp
index f43cddb..dc6618f 100644
--- a/src/addcontactpanel.cpp
+++ b/src/addcontactpanel.cpp
@@ -13,7 +13,7 @@
#include <QMessageBox>
#ifndef Q_MOC_RUN
-#include <ndn-cpp/security/signature/sha256-with-rsa-handler.hpp>
+#include <ndn-cpp/security/verifier.hpp>
#include <boost/iostreams/stream.hpp>
#include "null-ptrs.h"
#include "endorse-collection.pb.h"
@@ -207,7 +207,8 @@
{
// _LOG_TRACE("displayContactInfo");
const Profile& profile = m_currentEndorseCertificate->getProfileData().getProfile();
- const Blob& profileBlob = m_currentEndorseCertificate->getProfileData().getContent();
+ const Block& profileContent = m_currentEndorseCertificate->getProfileData().getContent();
+ Buffer profileBlock(profileContent.value(), profileContent.value_size());
map<string, int> endorseCount;
@@ -216,7 +217,8 @@
Chronos::EndorseCollection endorseCollection;
boost::iostreams::stream
- <boost::iostreams::array_source> is ((const char*)m_currentCollectEndorse->getContent().buf(), m_currentCollectEndorse->getContent().size());
+ <boost::iostreams::array_source> is (reinterpret_cast<const char*>(m_currentCollectEndorse->getContent().value()),
+ m_currentCollectEndorse->getContent().value_size());
endorseCollection.ParseFromIstream(&is);
@@ -224,7 +226,8 @@
{
try{
Data data;
- data.wireDecode((const uint8_t*)endorseCollection.endorsement(i).blob().c_str(), endorseCollection.endorsement(i).blob().size());
+ data.wireDecode(Block(reinterpret_cast<const uint8_t*>(endorseCollection.endorsement(i).blob().c_str()),
+ endorseCollection.endorsement(i).blob().size()));
EndorseCertificate endorseCert(data);
Name signerKeyName = endorseCert.getSigner();
@@ -237,11 +240,12 @@
if(!contact->isIntroducer() || !contact->canBeTrustedFor(m_currentEndorseCertificate->getProfileData().getIdentityName()))
continue;
- if(!Sha256WithRsaHandler::verifySignature(data, contact->getSelfEndorseCertificate().getPublicKeyInfo()))
+ if(!Verifier::verifySignature(data, data.getSignature(), contact->getSelfEndorseCertificate().getPublicKeyInfo()))
continue;
- const Blob& tmpProfileBlob = endorseCert.getProfileData().getContent();
- if(!isSameBlob(profileBlob, tmpProfileBlob))
+ const Block& tmpProfileContent = endorseCert.getProfileData().getContent();
+ Buffer tmpProfileBlock(tmpProfileContent.value(), tmpProfileContent.value_size());
+ if(profileBlock != tmpProfileBlock)
continue;
const vector<string>& endorseList = endorseCert.getEndorseList();
@@ -286,26 +290,26 @@
}
}
-bool
-AddContactPanel::isSameBlob(const ndn::Blob& blobA, const ndn::Blob& blobB)
-{
- size_t size = blobA.size();
+// bool
+// AddContactPanel::isSameBlob(const ndn::Blob& blobA, const ndn::Blob& blobB)
+// {
+// size_t size = blobA.size();
- if(size != blobB.size())
- return false;
+// if(size != blobB.size())
+// return false;
- const uint8_t* ap = blobA.buf();
- const uint8_t* bp = blobB.buf();
+// const uint8_t* ap = blobA.buf();
+// const uint8_t* bp = blobB.buf();
- for(int i = 0; i < size; i++)
- {
- if(ap[i] != bp[i])
- return false;
- }
+// for(int i = 0; i < size; i++)
+// {
+// if(ap[i] != bp[i])
+// return false;
+// }
- return true;
+// return true;
-}
+// }
#if WAF