security: Adjust unlocking TPM process.

Change-Id: Iee8787bb9aaa8e05fab9544bd35ce9fe31eecf29
diff --git a/tests/security/test-keychain.cpp b/tests/security/test-keychain.cpp
index 985ef82..bd44894 100644
--- a/tests/security/test-keychain.cpp
+++ b/tests/security/test-keychain.cpp
@@ -22,7 +22,7 @@
   Name identity(string("/TestKeyChain/ExportIdentity/") + boost::lexical_cast<std::string>(time::now()));
   keyChain.createIdentity(identity);
   
-  Block exported = keyChain.exportIdentity(identity, true, "1234");
+  Block exported = keyChain.exportIdentity(identity, "1234");
 
   Name keyName = keyChain.getDefaultKeyNameForIdentity(identity);
   Name certName = keyChain.getDefaultCertificateNameForKey(keyName);
@@ -35,7 +35,7 @@
   BOOST_REQUIRE(keyChain.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC) == false);
   BOOST_REQUIRE(keyChain.doesCertificateExist(certName) == false);
 
-  keyChain.importIdentity(exported, true, "1234");
+  keyChain.importIdentity(exported, "1234");
 
   BOOST_REQUIRE(keyChain.doesIdentityExist(identity));
   BOOST_REQUIRE(keyChain.doesPublicKeyExist(keyName));
diff --git a/tests/security/test-sec-tpm-file.cpp b/tests/security/test-sec-tpm-file.cpp
index 04adf1f..c16ed24 100644
--- a/tests/security/test-sec-tpm-file.cpp
+++ b/tests/security/test-sec-tpm-file.cpp
@@ -11,6 +11,7 @@
 #include <boost/test/unit_test.hpp>
 
 #include "security/key-chain.hpp"
+#include "util/time.hpp"
 #include <cryptopp/rsa.h>
 #include <cryptopp/hex.h>
 
@@ -23,7 +24,7 @@
 {
   SecTpmFile tpm;
   
-  Name keyName("/tmp/ksk-123456");
+  Name keyName("/TestSecTpmFile/Delete/ksk-" + boost::lexical_cast<string>(time::now()));
   BOOST_CHECK_NO_THROW(tpm.generateKeyPairInTpm(keyName, KEY_TYPE_RSA, 2048));
   
   BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), true);
@@ -39,7 +40,7 @@
 {
   SecTpmFile tpm;
 
-  Name keyName("/tmp/ksk-123456");
+  Name keyName("/TestSecTpmFile/SignVerify/ksk-" + boost::lexical_cast<string>(time::now()));
   BOOST_CHECK_NO_THROW(tpm.generateKeyPairInTpm(keyName, KEY_TYPE_RSA, 2048));
   
   Data data("/tmp/test/1");
@@ -104,7 +105,7 @@
   BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE) == false);
   BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC) == false);
   
-  BOOST_REQUIRE_NO_THROW(tpm.importPrivateKeyPkcs8IntoTpm(keyName, reinterpret_cast<const uint8_t*>(decoded.c_str()), decoded.size(), true, "1234"));
+  BOOST_REQUIRE_NO_THROW(tpm.importPrivateKeyPkcs8IntoTpm(keyName, reinterpret_cast<const uint8_t*>(decoded.c_str()), decoded.size(), "1234"));
 
   BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE) == true);
   BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC) == true);
@@ -129,14 +130,14 @@
     BOOST_REQUIRE_EQUAL(result, true);
   }
 
-  ConstBufferPtr exported = tpm.exportPrivateKeyPkcs8FromTpm(keyName, true, "5678");
+  ConstBufferPtr exported = tpm.exportPrivateKeyPkcs8FromTpm(keyName, "5678");
 
   tpm.deleteKeyPairInTpm(keyName);
 
   BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE) == false);
   BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC) == false);
 
-  BOOST_REQUIRE(tpm.importPrivateKeyPkcs8IntoTpm(keyName, exported->buf(), exported->size(), true, "5678"));
+  BOOST_REQUIRE(tpm.importPrivateKeyPkcs8IntoTpm(keyName, exported->buf(), exported->size(), "5678"));
   
   BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE) == true);
   BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC) == true);
diff --git a/tests/security/test-sec-tpm-osx.cpp b/tests/security/test-sec-tpm-osx.cpp
index f801018..7a94f33 100644
--- a/tests/security/test-sec-tpm-osx.cpp
+++ b/tests/security/test-sec-tpm-osx.cpp
@@ -11,7 +11,10 @@
 #include <boost/test/unit_test.hpp>
 
 #include "security/key-chain.hpp"
+#include "util/time.hpp"
 #include <cryptopp/rsa.h>
+#include <cryptopp/files.h>
+#include <cryptopp/hex.h>
 
 using namespace std;
 namespace ndn {
@@ -22,7 +25,7 @@
 {
   SecTpmOsx tpm;
   
-  Name keyName("/tmp/ksk-123456");
+  Name keyName("/TestSecTpmOsx/Delete/ksk-123456");
   BOOST_CHECK_NO_THROW(tpm.generateKeyPairInTpm(keyName, KEY_TYPE_RSA, 2048));
   
   BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), true);
@@ -38,14 +41,14 @@
 {
   SecTpmOsx tpm;
 
-  Name keyName("/tmp/ksk-123456");
+  Name keyName("/TestSecTpmOsx/SignVerify/ksk-123456");
   BOOST_CHECK_NO_THROW(tpm.generateKeyPairInTpm(keyName, KEY_TYPE_RSA, 2048));
   
-  Data data("/tmp/test/1");
+  Data data("/TestSecTpmOsx/SignVaerify/Data/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);
+  shared_ptr<PublicKey> pubkeyPtr = tpm.getPublicKeyFromTpm(keyName);
 
   {
     using namespace CryptoPP;
@@ -57,7 +60,7 @@
 
     RSASS<PKCS1v15, SHA256>::Verifier verifier (publicKey);
     bool result = verifier.VerifyMessage(content, sizeof(content),
-				  sigBlock.value(), sigBlock.value_size());
+					 sigBlock.value(), sigBlock.value_size());
   
     BOOST_REQUIRE_EQUAL(result, true);
   }
@@ -92,14 +95,14 @@
 
   SecTpmOsx tpm;
 
-  Name keyName("/TestSecTpmFile/ExportImportKey/ksk-" + boost::lexical_cast<string>(time::now()));
+  Name keyName("/TestSecTpmOsx/ExportImportKey/ksk-" + boost::lexical_cast<string>(time::now()));
   
   BOOST_CHECK_NO_THROW(tpm.generateKeyPairInTpm(keyName, KEY_TYPE_RSA, 2048));
 
   BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE) == true);
   BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC) == true);
 
-  ConstBufferPtr exported = tpm.exportPrivateKeyPkcs8FromTpm(keyName, true, "1234");
+  ConstBufferPtr exported = tpm.exportPrivateKeyPkcs8FromTpm(keyName, "1234");
   shared_ptr<PublicKey> pubkeyPtr = tpm.getPublicKeyFromTpm(keyName);
 
   tpm.deleteKeyPairInTpm(keyName);
@@ -107,7 +110,7 @@
   BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE) == false);
   BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC) == false);
 
-  BOOST_REQUIRE(tpm.importPrivateKeyPkcs8IntoTpm(keyName, exported->buf(), exported->size(), true, "1234"));
+  BOOST_REQUIRE(tpm.importPrivateKeyPkcs8IntoTpm(keyName, exported->buf(), exported->size(), "1234"));
   
   BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC) == true);
   BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE) == true);
diff --git a/tests/security/test-validator.cpp b/tests/security/test-validator.cpp
index 19e2b78..48e1eec 100644
--- a/tests/security/test-validator.cpp
+++ b/tests/security/test-validator.cpp
@@ -28,6 +28,7 @@
 BOOST_AUTO_TEST_CASE (Null)
 {
   KeyChainImpl<SecPublicInfoSqlite3, SecTpmFile> keyChain;
+
   Name identity(string("/TestValidator/Null/") + boost::lexical_cast<std::string>(time::now()));
   keyChain.createIdentity(identity);