security: Changing security storage location. Adding test case
1. The default location of publilc info storage of SecPublicInfoSqlite3 is changed to ~/.ndnx/ndnsec-public-info.db
2. The default location of key directory of SecTpmFile is changed to ~/.ndnx/ndnsec-tpm-file/
3. Add a test case for SecTpmFile.
Change-Id: I2e314072ff05e3b8da308b577bc85d417ff22476
diff --git a/tests_boost/Makefile.am b/tests_boost/Makefile.am
index 3564e82..8968a60 100644
--- a/tests_boost/Makefile.am
+++ b/tests_boost/Makefile.am
@@ -8,6 +8,7 @@
test-encode-decode-data.cpp \
test-encode-decode-interest.cpp \
test-encode-decode-forwarding-entry.cpp \
- test-encode-decode-block.cpp
+ test-encode-decode-block.cpp \
+ test-sec-tpm-file.cpp
unit_tests_LDADD = ../libndn-cpp-dev.la @BOOST_SYSTEM_LIB@ @BOOST_UNIT_TEST_FRAMEWORK_LIB@ @OPENSSL_LIBS@ @CRYPTOPP_LIBS@ @OSX_SECURITY_LIBS@
diff --git a/tests_boost/test-sec-tpm-file.cpp b/tests_boost/test-sec-tpm-file.cpp
new file mode 100644
index 0000000..9d75a38
--- /dev/null
+++ b/tests_boost/test-sec-tpm-file.cpp
@@ -0,0 +1,63 @@
+/**
+ * Copyright (C) 2013 Regents of the University of California.
+ * @author: Yingdi Yu <yingdi0@cs.ucla.edu>
+ * See COPYING for copyright and distribution information.
+ */
+
+#if __clang__
+#pragma clang diagnostic ignored "-Wtautological-compare"
+// #pragma clang diagnostic push
+// #pragma clang diagnostic ignored "-Wreorder"
+// #pragma clang diagnostic ignored "-Wunused-variable"
+// #pragma clang diagnostic ignored "-Wunused-function"
+// #elif __GNUC__
+// #pragma GCC diagnostic ignored "-Wreorder"
+// #pragma GCC diagnostic ignored "-Wunused-variable"
+// #pragma GCC diagnostic ignored "-Wunused-function"
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include <ndn-cpp-dev/security/key-chain.hpp>
+#include <cryptopp/rsa.h>
+
+using namespace std;
+using namespace ndn;
+
+
+BOOST_AUTO_TEST_SUITE(TestSecTpmFile)
+
+BOOST_AUTO_TEST_CASE (SignVerify)
+{
+ SecTpmFile tpm;
+
+ Name keyName("/tmp/ksk-123456");
+ tpm.generateKeyPairInTpm(keyName, KEY_TYPE_RSA, 2048);
+
+
+
+ Data data("/tmp/test/1");
+ const uint8_t content[] = {0x01, 0x02, 0x03, 0x04};
+
+ Block sigBlock = tpm.signInTpm(content, sizeof(content), keyName, DIGEST_ALGORITHM_SHA256);
+ ptr_lib::shared_ptr<PublicKey> pubkeyPtr = tpm.getPublicKeyFromTpm(keyName);
+
+ {
+ using namespace CryptoPP;
+
+ RSA::PublicKey publicKey;
+ ByteQueue queue;
+ queue.Put(reinterpret_cast<const byte*>(pubkeyPtr->get().buf()), pubkeyPtr->get().size());
+ publicKey.Load(queue);
+
+ RSASS<PKCS1v15, SHA256>::Verifier verifier (publicKey);
+ bool result = verifier.VerifyMessage(content, sizeof(content),
+ sigBlock.value(), sigBlock.value_size());
+
+ BOOST_REQUIRE_EQUAL(result, true);
+ }
+
+ //We should remove the temporary test key, this should be fixed in a later commit which will add delete operation in SecTpm.
+}
+
+BOOST_AUTO_TEST_SUITE_END()