security: Fixing compilation errors and providing backward compatible interface for Signature*
This commit includes missed includes and "re-introduction" of
setKeyLocator method into Signature interface. This method was used in
dependent applications as part of SignatureSha256With(Rsa|Ecdsa) data
structures.
Change-Id: I788f687600bb2729ea8265e23d4a31b990b8ed96
Refs: #1750, #1755
diff --git a/src/security/sec-tpm-osx.cpp b/src/security/sec-tpm-osx.cpp
index b805d4e..3064d84 100644
--- a/src/security/sec-tpm-osx.cpp
+++ b/src/security/sec-tpm-osx.cpp
@@ -34,6 +34,8 @@
#include <stdlib.h>
#include <string.h>
+#include <boost/lexical_cast.hpp>
+
#include <CoreFoundation/CoreFoundation.h>
#include <Security/Security.h>
#include <Security/SecRandom.h>
diff --git a/src/signature-info.cpp b/src/signature-info.cpp
index 1b8203d..2543dd2 100644
--- a/src/signature-info.cpp
+++ b/src/signature-info.cpp
@@ -20,6 +20,7 @@
*/
#include "signature-info.hpp"
+#include <boost/lexical_cast.hpp>
namespace ndn {
diff --git a/src/signature-info.hpp b/src/signature-info.hpp
index 9fd0f62..c0a2d88 100644
--- a/src/signature-info.hpp
+++ b/src/signature-info.hpp
@@ -24,6 +24,7 @@
#include "encoding/tlv.hpp"
#include "key-locator.hpp"
+#include <list>
namespace ndn {
diff --git a/src/signature.hpp b/src/signature.hpp
index d6dd730..66a3f52 100644
--- a/src/signature.hpp
+++ b/src/signature.hpp
@@ -22,6 +22,7 @@
#ifndef NDN_SIGNATURE_HPP
#define NDN_SIGNATURE_HPP
+#include "common.hpp"
#include "signature-info.hpp"
namespace ndn {
@@ -122,6 +123,12 @@
return m_info.getKeyLocator();
}
+ /// @brief Set KeyLocator
+ void
+ setKeyLocator(const KeyLocator& keyLocator)
+ {
+ m_info.setKeyLocator(keyLocator);
+ }
public: // EqualityComparable concept
bool
diff --git a/tests/unit-tests/security/test-signature-sha256-ecdsa.cpp b/tests/unit-tests/security/test-signature-sha256-ecdsa.cpp
index 34f25bf..cebf9ed 100644
--- a/tests/unit-tests/security/test-signature-sha256-ecdsa.cpp
+++ b/tests/unit-tests/security/test-signature-sha256-ecdsa.cpp
@@ -78,6 +78,11 @@
sigInfoBlock.wire() + sigInfoBlock.size(),
encodeSigInfoBlock.wire(),
encodeSigInfoBlock.wire() + encodeSigInfoBlock.size());
+
+ sig.setKeyLocator(Name("/test/another/key/locator"));
+
+ const Block& encodeSigInfoBlock2 = sig.getInfo();
+ BOOST_CHECK(sigInfoBlock != encodeSigInfoBlock2);
}
BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/unit-tests/security/test-signature-sha256-rsa.cpp b/tests/unit-tests/security/test-signature-sha256-rsa.cpp
index cd717d7..2fd0c3a 100644
--- a/tests/unit-tests/security/test-signature-sha256-rsa.cpp
+++ b/tests/unit-tests/security/test-signature-sha256-rsa.cpp
@@ -83,6 +83,11 @@
sigInfoBlock.wire() + sigInfoBlock.size(),
encodeSigInfoBlock.wire(),
encodeSigInfoBlock.wire() + encodeSigInfoBlock.size());
+
+ sig.setKeyLocator(Name("/test/another/key/locator"));
+
+ const Block& encodeSigInfoBlock2 = sig.getInfo();
+ BOOST_CHECK(sigInfoBlock != encodeSigInfoBlock2);
}
BOOST_AUTO_TEST_SUITE_END()