tests+Makefile: updates corresponding to refactored KeyChain and related classes
Change-Id: I0c80e3bc5043764090569ea75edf56c5b799eb7d
diff --git a/tests/test-encode-decode-benchmark.cpp b/tests/test-encode-decode-benchmark.cpp
index b4e227f..57b888a 100644
--- a/tests/test-encode-decode-benchmark.cpp
+++ b/tests/test-encode-decode-benchmark.cpp
@@ -12,9 +12,7 @@
#include <stdexcept>
#include <ndn-cpp/data.hpp>
#include <ndn-cpp/security/key-chain.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/self-verify-policy-manager.hpp>
+// #include <ndn-cpp/security/policy/self-verify-policy-manager.hpp>
// Hack: Hook directly into non-API functions.
#include "../src/c/encoding/binary-xml-decoder.h"
@@ -139,21 +137,19 @@
std::cout << "Content size: " << content.value_size() << std::endl;
// Initialize the KeyChain storage in case useCrypto is true.
- ptr_lib::shared_ptr<MemoryIdentityStorage> identityStorage(new MemoryIdentityStorage());
- ptr_lib::shared_ptr<MemoryPrivateKeyStorage> privateKeyStorage(new MemoryPrivateKeyStorage());
- KeyChain keyChain(identityStorage, privateKeyStorage);
+ KeyChainImpl<SecPublicInfoMemory, SecTpmMemory> keyChain;
Name keyName("/testname/dsk-123");
// Initialize the storage.
- identityStorage->addKey(keyName, KEY_TYPE_RSA,
- PublicKey(DEFAULT_PUBLIC_KEY_DER, sizeof(DEFAULT_PUBLIC_KEY_DER)));
+ keyChain.addPublicKey(keyName, KEY_TYPE_RSA,
+ PublicKey(DEFAULT_PUBLIC_KEY_DER, sizeof(DEFAULT_PUBLIC_KEY_DER)));
- privateKeyStorage->setKeyPairForKeyName(keyName,
- DEFAULT_PUBLIC_KEY_DER, sizeof(DEFAULT_PUBLIC_KEY_DER),
- DEFAULT_PRIVATE_KEY_DER, sizeof(DEFAULT_PRIVATE_KEY_DER));
+ keyChain.setKeyPairForKeyName(keyName,
+ DEFAULT_PUBLIC_KEY_DER, sizeof(DEFAULT_PUBLIC_KEY_DER),
+ DEFAULT_PRIVATE_KEY_DER, sizeof(DEFAULT_PRIVATE_KEY_DER));
- keyChain.addCertificateAsDefault(*keyChain.selfSign(keyName));
+ keyChain.addCertificateAsKeyDefault(*keyChain.selfSign(keyName));
Name certificateName = keyChain.getDefaultCertificateName();
// Set up publisherPublicKeyDigest and signatureBits in case useCrypto is false.
diff --git a/tests/test-publish-async.cpp b/tests/test-publish-async.cpp
index a57a857..839bd06 100644
--- a/tests/test-publish-async.cpp
+++ b/tests/test-publish-async.cpp
@@ -10,8 +10,6 @@
#include <time.h>
#include <unistd.h>
#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/key-chain.hpp>
using namespace std;
@@ -65,7 +63,7 @@
class Echo {
public:
- Echo(KeyChain &keyChain, Face &face)
+ Echo(KeyChainImpl<SecPublicInfoMemory, SecTpmMemory> &keyChain, Face &face)
: keyChain_(keyChain)
, face_(face)
, responseCount_(0)
@@ -102,7 +100,7 @@
cout << "Register failed for prefix " << prefix->toUri() << endl;
}
- KeyChain &keyChain_;
+ KeyChainImpl<SecPublicInfoMemory, SecTpmMemory> &keyChain_;
Face &face_;
int responseCount_;
};
@@ -112,21 +110,19 @@
try {
Face face;
- ptr_lib::shared_ptr<MemoryIdentityStorage> identityStorage(new MemoryIdentityStorage());
- ptr_lib::shared_ptr<MemoryPrivateKeyStorage> privateKeyStorage(new MemoryPrivateKeyStorage());
- KeyChain keyChain(identityStorage, privateKeyStorage);
+ KeyChainImpl<SecPublicInfoMemory, SecTpmMemory> keyChain;
Name keyName("/testname/dsk-123");
// Initialize the storage.
- identityStorage->addKey(keyName, KEY_TYPE_RSA,
- PublicKey(DEFAULT_PUBLIC_KEY_DER, sizeof(DEFAULT_PUBLIC_KEY_DER)));
+ keyChain.addPublicKey(keyName, KEY_TYPE_RSA,
+ PublicKey(DEFAULT_PUBLIC_KEY_DER, sizeof(DEFAULT_PUBLIC_KEY_DER)));
- privateKeyStorage->setKeyPairForKeyName(keyName,
+ keyChain.setKeyPairForKeyName(keyName,
DEFAULT_PUBLIC_KEY_DER, sizeof(DEFAULT_PUBLIC_KEY_DER),
DEFAULT_PRIVATE_KEY_DER, sizeof(DEFAULT_PRIVATE_KEY_DER));
- keyChain.addCertificateAsDefault(*keyChain.selfSign(keyName));
+ keyChain.addCertificateAsKeyDefault(*keyChain.selfSign(keyName));
Echo echo(keyChain, face);