security: In KeyChain constructor, added PolicyManager. Use in sign().
diff --git a/tests/test-encode-decode-data.cpp b/tests/test-encode-decode-data.cpp
index 70cf81c..189397f 100644
--- a/tests/test-encode-decode-data.cpp
+++ b/tests/test-encode-decode-data.cpp
@@ -12,6 +12,7 @@
#include "../ndn-cpp/data.hpp"
#include "../ndn-cpp/security/identity/memory-identity-storage.hpp"
#include "../ndn-cpp/security/identity/memory-private-key-storage.hpp"
+#include "../ndn-cpp/security/policy/no-verify-policy-manager.hpp"
#include "../ndn-cpp/security/key-chain.hpp"
#include "../ndn-cpp/sha256-with-rsa-signature.hpp"
@@ -212,7 +213,7 @@
cout << prefix << " signature verification: VERIFIED" << endl;
}
-static void onVerifyFailed(const char *prefix)
+static void onVerifyFailed(const char *prefix, const shared_ptr<Data>& data)
{
cout << prefix << " signature verification: FAILED" << endl;
}
@@ -238,8 +239,9 @@
freshData->getMetaInfo().setTimestampMilliseconds(time(NULL) * 1000.0);
shared_ptr<MemoryPrivateKeyStorage> privateKeyStorage(new MemoryPrivateKeyStorage());
- KeyChain keyChain(shared_ptr<IdentityManager>
- (new IdentityManager(make_shared<MemoryIdentityStorage>(), privateKeyStorage)));
+ KeyChain keyChain
+ (make_shared<IdentityManager>(make_shared<MemoryIdentityStorage>(), privateKeyStorage),
+ make_shared<NoVerifyPolicyManager>());
// Initialize the storage.
Name keyName("/testname/DSK-123");
@@ -247,11 +249,11 @@
privateKeyStorage->setKeyPairForKeyName
(keyName, DEFAULT_PUBLIC_KEY_DER, sizeof(DEFAULT_PUBLIC_KEY_DER), DEFAULT_PRIVATE_KEY_DER, sizeof(DEFAULT_PRIVATE_KEY_DER));
- keyChain.signData(*freshData, certificateName);
+ keyChain.sign(*freshData, certificateName);
cout << endl << "Freshly-signed Data:" << endl;
dumpData(*freshData);
- keyChain.verifyData(freshData, bind(&onVerified, "Freshly-signed Data", _1), bind(&onVerifyFailed, "Freshly-signed Data"));
+ keyChain.verifyData(freshData, bind(&onVerified, "Freshly-signed Data", _1), bind(&onVerifyFailed, "Freshly-signed Data", _1));
} catch (std::exception& e) {
cout << "exception: " << e.what() << endl;
}
diff --git a/tests/test-publish-async.cpp b/tests/test-publish-async.cpp
index 467780e..2e99357 100644
--- a/tests/test-publish-async.cpp
+++ b/tests/test-publish-async.cpp
@@ -11,12 +11,12 @@
#include "../ndn-cpp/face.hpp"
#include "../ndn-cpp/security/identity/memory-identity-storage.hpp"
#include "../ndn-cpp/security/identity/memory-private-key-storage.hpp"
+#include "../ndn-cpp/security/policy/no-verify-policy-manager.hpp"
#include "../ndn-cpp/security/key-chain.hpp"
using namespace std;
using namespace ndn;
-using namespace ptr_lib;
-using namespace func_lib;
+using namespace ndn::ptr_lib;
static uint8_t DEFAULT_PUBLIC_KEY_DER[] = {
0x30, 0x81, 0x9F, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81,
@@ -82,7 +82,7 @@
string content(string("Echo ") + interest->getName().toUri());
data.setContent((const uint8_t *)&content[0], content.size());
data.getMetaInfo().setTimestampMilliseconds(time(NULL) * 1000.0);
- keyChain_.signData(data, certificateName_);
+ keyChain_.sign(data, certificateName_);
Blob encodedData = data.wireEncode();
cout << "Sent content " << content << endl;
@@ -90,7 +90,7 @@
}
// onRegisterFailed.
- void operator()(const ptr_lib::shared_ptr<const Name>& prefix)
+ void operator()(const shared_ptr<const Name>& prefix)
{
++responseCount_;
cout << "Register failed for prefix " << prefix->toUri() << endl;
@@ -107,8 +107,9 @@
Face face("localhost");
shared_ptr<MemoryPrivateKeyStorage> privateKeyStorage(new MemoryPrivateKeyStorage());
- KeyChain keyChain(shared_ptr<IdentityManager>
- (new IdentityManager(make_shared<MemoryIdentityStorage>(), privateKeyStorage)));
+ KeyChain keyChain
+ (make_shared<IdentityManager>(make_shared<MemoryIdentityStorage>(), privateKeyStorage),
+ make_shared<NoVerifyPolicyManager>());
keyChain.setFace(&face);
// Initialize the storage.