security: KeyChain: implement sign for buffers.
diff --git a/ndn-cpp/security/key-chain.cpp b/ndn-cpp/security/key-chain.cpp
index 3fc3f77..c17960d 100644
--- a/ndn-cpp/security/key-chain.cpp
+++ b/ndn-cpp/security/key-chain.cpp
@@ -104,6 +104,12 @@
identityManager_->signByCertificate(data, certificateName, wireFormat);
}
+shared_ptr<Signature>
+KeyChain::sign(const uint8_t* buffer, size_t bufferLength, const Name& certificateName)
+{
+ return identityManager_->signByCertificate(buffer, bufferLength, certificateName);
+}
+
void
KeyChain::signByIdentity(Data& data, const Name& identityName, WireFormat& wireFormat)
{
@@ -128,6 +134,17 @@
identityManager_->signByCertificate(data, signingCertificateName);
}
+ shared_ptr<Signature>
+ KeyChain::signByIdentity(const uint8_t* buffer, size_t bufferLength, const Name& identityName)
+ {
+ Name signingCertificateName = identityManager_->getDefaultCertificateNameForIdentity(identityName);
+
+ if (signingCertificateName.size() == 0)
+ throw SecurityException("No qualified certificate name found!");
+
+ return identityManager_->signByCertificate(buffer, bufferLength, signingCertificateName);
+ }
+
void
KeyChain::verifyData
(const shared_ptr<Data>& data, const OnVerified& onVerified, const OnVerifyFailed& onVerifyFailed, int stepCount)