security: Added IdentityCertificate::certificateNameToPublicKeyName and use it in signByCertificate so that it doesn't t need to retrieve the certificate just to get the key name.
diff --git a/src/security/identity/identity-manager.cpp b/src/security/identity/identity-manager.cpp
index 6ee3082..90bc043 100644
--- a/src/security/identity/identity-manager.cpp
+++ b/src/security/identity/identity-manager.cpp
@@ -187,9 +187,8 @@
ptr_lib::shared_ptr<Signature>
IdentityManager::signByCertificate(const uint8_t* buffer, size_t bufferLength, const Name& certificateName)
-{
- shared_ptr<IdentityCertificate> certificate = getCertificate(certificateName);
- Name keyName = certificate->getPublicKeyName();
+{
+ Name keyName = IdentityCertificate::certificateNameToPublicKeyName(certificateName);
shared_ptr<PublicKey> publicKey = privateKeyStorage_->getPublicKey(keyName.toUri());
Blob sigBits = privateKeyStorage_->sign(buffer, bufferLength, keyName.toUri());
@@ -211,8 +210,7 @@
void
IdentityManager::signByCertificate(Data &data, const Name &certificateName, WireFormat& wireFormat)
{
- shared_ptr<IdentityCertificate> certificate = getCertificate(certificateName);
- Name keyName = certificate->getPublicKeyName();
+ Name keyName = IdentityCertificate::certificateNameToPublicKeyName(certificateName);
shared_ptr<PublicKey> publicKey = privateKeyStorage_->getPublicKey(keyName);
// For temporary usage, we support RSA + SHA256 only, but will support more.