In PublisherPublicKeyDigest, make the value a Blob.
diff --git a/ndn-cpp/key.hpp b/ndn-cpp/key.hpp
index 0717e1b..9f4f30e 100644
--- a/ndn-cpp/key.hpp
+++ b/ndn-cpp/key.hpp
@@ -26,7 +26,7 @@
{
type_ = (ndn_KeyLocatorType)-1;
keyNameType_ = (ndn_KeyNameType)-1;
- keyData_ = Blob(0, 0);
+ keyData_.reset();
}
/**
diff --git a/ndn-cpp/node.hpp b/ndn-cpp/node.hpp
index 9efb742..d9113d6 100644
--- a/ndn-cpp/node.hpp
+++ b/ndn-cpp/node.hpp
@@ -215,7 +215,7 @@
std::vector<ptr_lib::shared_ptr<PitEntry> > pit_;
std::vector<ptr_lib::shared_ptr<PrefixEntry> > registeredPrefixTable_;
Interest ndndIdFetcherInterest_;
- std::vector<unsigned char> ndndId_;
+ Blob ndndId_;
};
}
diff --git a/ndn-cpp/publisher-public-key-digest.hpp b/ndn-cpp/publisher-public-key-digest.hpp
index 0a5a2c5..4d02821 100644
--- a/ndn-cpp/publisher-public-key-digest.hpp
+++ b/ndn-cpp/publisher-public-key-digest.hpp
@@ -30,7 +30,7 @@
{
publisherPublicKeyDigestStruct.publisherPublicKeyDigestLength = publisherPublicKeyDigest_.size();
if (publisherPublicKeyDigest_.size() > 0)
- publisherPublicKeyDigestStruct.publisherPublicKeyDigest = (unsigned char *)&publisherPublicKeyDigest_[0];
+ publisherPublicKeyDigestStruct.publisherPublicKeyDigest = (unsigned char *)publisherPublicKeyDigest_.buf();
else
publisherPublicKeyDigestStruct.publisherPublicKeyDigest = 0;
}
@@ -41,17 +41,16 @@
*/
void set(const struct ndn_PublisherPublicKeyDigest& publisherPublicKeyDigestStruct)
{
- setVector(publisherPublicKeyDigest_, publisherPublicKeyDigestStruct.publisherPublicKeyDigest,
- publisherPublicKeyDigestStruct.publisherPublicKeyDigestLength);
+ publisherPublicKeyDigest_ =
+ Blob(publisherPublicKeyDigestStruct.publisherPublicKeyDigest, publisherPublicKeyDigestStruct.publisherPublicKeyDigestLength);
}
- const std::vector<unsigned char>& getPublisherPublicKeyDigest() const { return publisherPublicKeyDigest_; }
- std::vector<unsigned char>& getPublisherPublicKeyDigest() { return publisherPublicKeyDigest_; }
+ const Blob& getPublisherPublicKeyDigest() const { return publisherPublicKeyDigest_; }
void setPublisherPublicKeyDigest(const std::vector<unsigned char>& publisherPublicKeyDigest) { publisherPublicKeyDigest_ = publisherPublicKeyDigest; }
void setPublisherPublicKeyDigest(const unsigned char *publisherPublicKeyDigest, unsigned int publisherPublicKeyDigestLength)
{
- setVector(publisherPublicKeyDigest_, publisherPublicKeyDigest, publisherPublicKeyDigestLength);
+ publisherPublicKeyDigest_ = Blob(publisherPublicKeyDigest, publisherPublicKeyDigestLength);
}
/**
@@ -59,11 +58,11 @@
*/
void clear()
{
- publisherPublicKeyDigest_.clear();
+ publisherPublicKeyDigest_.reset();
}
private:
- std::vector<unsigned char> publisherPublicKeyDigest_;
+ Blob publisherPublicKeyDigest_;
};
}
diff --git a/ndn-cpp/security/key-chain.cpp b/ndn-cpp/security/key-chain.cpp
index 4a19869..de7399e 100644
--- a/ndn-cpp/security/key-chain.cpp
+++ b/ndn-cpp/security/key-chain.cpp
@@ -60,19 +60,6 @@
};
/**
- * Call digestSha256 and set the digest vector to the result.
- * @param data
- * @param dataLength
- * @param digest
- */
-void setSha256(const unsigned char *data, unsigned int dataLength, vector<unsigned char>& digest)
-{
- unsigned char digestBuffer[SHA256_DIGEST_LENGTH];
- ndn_digestSha256(data, dataLength, digestBuffer);
- setVector(digest, digestBuffer, sizeof(digestBuffer));
-}
-
-/**
* Encode the fields of the Data object and set digest to the sha-256 digest.
* @param data The Data object with the fields to digest.
* @param digest A pointer to a buffer of size SHA256_DIGEST_LENGTH to receive the data.
@@ -92,7 +79,9 @@
// Clear the signature so we don't encode it below.
data.getSignature().clear();
// Set the public key.
- setSha256(publicKeyDer, publicKeyDerLength, data.getSignature().getPublisherPublicKeyDigest().getPublisherPublicKeyDigest());
+ unsigned char publicKeyDigest[SHA256_DIGEST_LENGTH];
+ ndn_digestSha256(publicKeyDer, publicKeyDerLength, publicKeyDigest);
+ data.getSignature().getPublisherPublicKeyDigest().setPublisherPublicKeyDigest(publicKeyDigest, sizeof(publicKeyDigest));
data.getSignature().getKeyLocator().setType(ndn_KeyLocatorType_KEY);
data.getSignature().getKeyLocator().setKeyData(publicKeyDer, publicKeyDerLength);
diff --git a/tests/test-encode-decode-data.cpp b/tests/test-encode-decode-data.cpp
index 6b10104..e8311cf 100644
--- a/tests/test-encode-decode-data.cpp
+++ b/tests/test-encode-decode-data.cpp
@@ -109,7 +109,7 @@
<< (data.getSignature().getSignature().size() > 0 ? toHex(data.getSignature().getSignature()).c_str() : "<none>") << endl;
cout << "signature.publisherPublicKeyDigest: "
<< (data.getSignature().getPublisherPublicKeyDigest().getPublisherPublicKeyDigest().size() > 0 ?
- toHex(data.getSignature().getPublisherPublicKeyDigest().getPublisherPublicKeyDigest()).c_str() : "<none>") << endl;
+ toHex(*data.getSignature().getPublisherPublicKeyDigest().getPublisherPublicKeyDigest()).c_str() : "<none>") << endl;
cout << "signature.keyLocator: ";
if ((int)data.getSignature().getKeyLocator().getType() >= 0) {
if (data.getSignature().getKeyLocator().getType() == ndn_KeyLocatorType_KEY)