security: renaming methods

1. renaming Verifier::policies to Verifier::policy
2. appending SecTpm related methods with "InTpm"

Change-Id: I3790947d3f236e8d56fd52eaefc6e2bbaea92385
diff --git a/include/ndn-cpp/security/key-chain.hpp b/include/ndn-cpp/security/key-chain.hpp
index 8e1e81c..fffa05d 100644
--- a/include/ndn-cpp/security/key-chain.hpp
+++ b/include/ndn-cpp/security/key-chain.hpp
@@ -184,7 +184,7 @@
     data.setSignature(signature);
 
     // For temporary usage, we support RSA + SHA256 only, but will support more.
-    Tpm::sign(data, cert->getPublicKeyName(), DIGEST_ALGORITHM_SHA256);
+    Tpm::signInTpm(data, cert->getPublicKeyName(), DIGEST_ALGORITHM_SHA256);
   }
 
   void
@@ -195,7 +195,7 @@
     data.setSignature(signature);
 
     // For temporary usage, we support RSA + SHA256 only, but will support more.
-    Tpm::sign(data, certificate.getPublicKeyName(), DIGEST_ALGORITHM_SHA256);
+    Tpm::signInTpm(data, certificate.getPublicKeyName(), DIGEST_ALGORITHM_SHA256);
   }
   
   /**
@@ -216,7 +216,7 @@
     signature.setKeyLocator(certificateName.getPrefix(-1)); // implicit conversion should take care
   
     // For temporary usage, we support RSA + SHA256 only, but will support more.
-    signature.setValue(Tpm::sign(buffer, bufferLength, cert->getPublicKeyName(), DIGEST_ALGORITHM_SHA256));
+    signature.setValue(Tpm::signInTpm(buffer, bufferLength, cert->getPublicKeyName(), DIGEST_ALGORITHM_SHA256));
     return signature;
   }
 
@@ -296,7 +296,7 @@
     cert.setSignature(signature);
 
     // For temporary usage, we support RSA + SHA256 only, but will support more.
-    Tpm::sign(cert, cert.getPublicKeyName(), DIGEST_ALGORITHM_SHA256);
+    Tpm::signInTpm(cert, cert.getPublicKeyName(), DIGEST_ALGORITHM_SHA256);
   }
 
 
diff --git a/include/ndn-cpp/security/sec-tpm-memory.hpp b/include/ndn-cpp/security/sec-tpm-memory.hpp
index 5761597..8203272 100644
--- a/include/ndn-cpp/security/sec-tpm-memory.hpp
+++ b/include/ndn-cpp/security/sec-tpm-memory.hpp
@@ -67,10 +67,10 @@
    * @return The signature, or a null pointer if signing fails.
    */  
   virtual Block 
-  sign(const uint8_t *data, size_t dataLength, const Name& keyName, DigestAlgorithm digestAlgorithm);
+  signInTpm(const uint8_t *data, size_t dataLength, const Name& keyName, DigestAlgorithm digestAlgorithm);
 
   virtual void 
-  sign(Data &data, const Name& keyName, DigestAlgorithm digestAlgorithm);
+  signInTpm(Data &data, const Name& keyName, DigestAlgorithm digestAlgorithm);
   
   /**
    * Decrypt data.
@@ -81,7 +81,7 @@
    * @return The decrypted data.
    */
   virtual ConstBufferPtr 
-  decrypt(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric);
+  decryptInTpm(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric);
 
   /**
    * Encrypt data.
@@ -92,7 +92,7 @@
    * @return The encrypted data.
    */
   virtual ConstBufferPtr
-  encrypt(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric);
+  encryptInTpm(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric);
 
   /**
    * @brief Generate a symmetric key.
@@ -101,7 +101,7 @@
    * @param keySize The size of the key.
    */
   virtual void 
-  generateSymmetricKey(const Name& keyName, KeyType keyType, int keySize);
+  generateSymmetricKeyInTpm(const Name& keyName, KeyType keyType, int keySize);
 
   /**
    * Check if a particular key exists.
@@ -110,7 +110,7 @@
    * @return True if the key exists, otherwise false.
    */
   virtual bool
-  doesKeyExist(const Name& keyName, KeyClass keyClass);  
+  doesKeyExistInTpm(const Name& keyName, KeyClass keyClass);  
   
 private:
   class RsaPrivateKey;
diff --git a/include/ndn-cpp/security/sec-tpm-osx.hpp b/include/ndn-cpp/security/sec-tpm-osx.hpp
index 71efa13..47e83ab 100644
--- a/include/ndn-cpp/security/sec-tpm-osx.hpp
+++ b/include/ndn-cpp/security/sec-tpm-osx.hpp
@@ -43,10 +43,10 @@
   getPublicKeyFromTpm(const Name& keyName);
   
   virtual Block
-  sign(const uint8_t *data, size_t dataLength, const Name& keyName, DigestAlgorithm digestAlgorithm);
+  signInTpm(const uint8_t *data, size_t dataLength, const Name& keyName, DigestAlgorithm digestAlgorithm);
 
   virtual void
-  sign(Data &data, const Name& keyName, DigestAlgorithm digestAlgorithm);
+  signInTpm(Data &data, const Name& keyName, DigestAlgorithm digestAlgorithm);
   
   /**
    * Decrypt data.
@@ -57,7 +57,7 @@
    * @return The decrypted data.
    */
   virtual ConstBufferPtr 
-  decrypt(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric);
+  decryptInTpm(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric);
 
   /**
    * Encrypt data.
@@ -68,7 +68,7 @@
    * @return The encrypted data.
    */
   virtual ConstBufferPtr
-  encrypt(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric);
+  encryptInTpm(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric);
 
   /**
    * Generate a symmetric key.
@@ -77,7 +77,7 @@
    * @param keySize The size of the key.
    */
   virtual void 
-  generateSymmetricKey(const Name& keyName, KeyType keyType, int keySize);
+  generateSymmetricKeyInTpm(const Name& keyName, KeyType keyType, int keySize);
 
   /**
    * Check if a particular key exists.
@@ -86,7 +86,7 @@
    * @return True if the key exists, otherwise false.
    */
   virtual bool
-  doesKeyExist(const Name& keyName, KeyClass keyClass);  
+  doesKeyExistInTpm(const Name& keyName, KeyClass keyClass);  
 
 
   ////////////////////////////////////////////////////////////////////////////////////
diff --git a/include/ndn-cpp/security/sec-tpm.hpp b/include/ndn-cpp/security/sec-tpm.hpp
index d7a8e04..c6b5328 100644
--- a/include/ndn-cpp/security/sec-tpm.hpp
+++ b/include/ndn-cpp/security/sec-tpm.hpp
@@ -53,10 +53,10 @@
    * @return The signature, or a null pointer if signing fails.
    */  
   virtual Block
-  sign(const uint8_t *data, size_t dataLength, const Name& keyName, DigestAlgorithm digestAlgorithm) = 0;
+  signInTpm(const uint8_t *data, size_t dataLength, const Name& keyName, DigestAlgorithm digestAlgorithm) = 0;
 
   virtual void
-  sign(Data &data, const Name& keyName, DigestAlgorithm digestAlgorithm) = 0;
+  signInTpm(Data &data, const Name& keyName, DigestAlgorithm digestAlgorithm) = 0;
   
   /**
    * Decrypt data.
@@ -67,7 +67,7 @@
    * @return The decrypted data.
    */
   virtual ConstBufferPtr 
-  decrypt(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric) = 0;
+  decryptInTpm(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric) = 0;
 
   /**
    * Encrypt data.
@@ -78,7 +78,7 @@
    * @return The encrypted data.
    */
   virtual ConstBufferPtr
-  encrypt(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric) = 0;
+  encryptInTpm(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric) = 0;
 
   /**
    * @brief Generate a symmetric key.
@@ -87,7 +87,7 @@
    * @param keySize The size of the key.
    */
   virtual void 
-  generateSymmetricKey(const Name& keyName, KeyType keyType, int keySize) = 0;
+  generateSymmetricKeyInTpm(const Name& keyName, KeyType keyType, int keySize) = 0;
 
   /**
    * Check if a particular key exists.
@@ -96,7 +96,7 @@
    * @return True if the key exists, otherwise false.
    */
   virtual bool
-  doesKeyExist(const Name& keyName, KeyClass keyClass) = 0;  
+  doesKeyExistInTpm(const Name& keyName, KeyClass keyClass) = 0;  
 };
 
 }
diff --git a/include/ndn-cpp/security/verifier.hpp b/include/ndn-cpp/security/verifier.hpp
index 764dcd4..2dbd995 100644
--- a/include/ndn-cpp/security/verifier.hpp
+++ b/include/ndn-cpp/security/verifier.hpp
@@ -43,7 +43,7 @@
    * @return The Policy.
    */
   inline SecPolicy&
-  policies()
+  policy()
   {
     if (!policy_)
       throw Error("policy is not assigned to the KeyChain");
diff --git a/src/security/sec-tpm-memory.cpp b/src/security/sec-tpm-memory.cpp
index fd6a79c..205e93a 100644
--- a/src/security/sec-tpm-memory.cpp
+++ b/src/security/sec-tpm-memory.cpp
@@ -76,7 +76,7 @@
 }
 
 Block 
-SecTpmMemory::sign(const uint8_t *data, size_t dataLength,
+SecTpmMemory::signInTpm(const uint8_t *data, size_t dataLength,
                 const Name& keyName,
                 DigestAlgorithm digestAlgorithm)
 {
@@ -110,7 +110,7 @@
 }
 
 void
-SecTpmMemory::sign(Data &d,
+SecTpmMemory::signInTpm(Data &d,
                 const Name& keyName,
                 DigestAlgorithm digestAlgorithm)
 {
@@ -149,7 +149,7 @@
 }
 
 ConstBufferPtr
-SecTpmMemory::decrypt(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric)
+SecTpmMemory::decryptInTpm(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric)
 {
 #if 1
   throw Error("MemoryPrivateKeyStorage::decrypt not implemented");
@@ -157,7 +157,7 @@
 }
 
 ConstBufferPtr
-SecTpmMemory::encrypt(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric)
+SecTpmMemory::encryptInTpm(const Name& keyName, const uint8_t* data, size_t dataLength, bool isSymmetric)
 {
 #if 1
   throw Error("MemoryPrivateKeyStorage::encrypt not implemented");
@@ -165,7 +165,7 @@
 }
 
 void 
-SecTpmMemory::generateSymmetricKey(const Name& keyName, KeyType keyType, int keySize)
+SecTpmMemory::generateSymmetricKeyInTpm(const Name& keyName, KeyType keyType, int keySize)
 {
 #if 1
   throw Error("MemoryPrivateKeyStorage::generateKey not implemented");
@@ -173,7 +173,7 @@
 }
 
 bool
-SecTpmMemory::doesKeyExist(const Name& keyName, KeyClass keyClass)
+SecTpmMemory::doesKeyExistInTpm(const Name& keyName, KeyClass keyClass)
 {
   if (keyClass == KEY_CLASS_PUBLIC)
     return publicKeyStore_.find(keyName.toUri()) != publicKeyStore_.end();
diff --git a/src/security/sec-tpm-osx.cpp b/src/security/sec-tpm-osx.cpp
index cfe7579..cd1b17f 100644
--- a/src/security/sec-tpm-osx.cpp
+++ b/src/security/sec-tpm-osx.cpp
@@ -137,7 +137,7 @@
   SecTpmOsx::generateKeyPairInTpm(const Name & keyName, KeyType keyType, int keySize)
   { 
     
-    if(doesKeyExist(keyName, KEY_CLASS_PUBLIC)){
+    if(doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC)){
       _LOG_DEBUG("keyName has existed");
       throw Error("keyName has existed");
     }
@@ -171,10 +171,10 @@
   }
 
   void 
-  SecTpmOsx::generateSymmetricKey(const Name & keyName, KeyType keyType, int keySize)
+  SecTpmOsx::generateSymmetricKeyInTpm(const Name & keyName, KeyType keyType, int keySize)
   {
 
-    if(doesKeyExist(keyName, KEY_CLASS_SYMMETRIC))
+    if(doesKeyExistInTpm(keyName, KEY_CLASS_SYMMETRIC))
         throw Error("keyName has existed!");
 
     string keyNameUri =  impl_->toInternalKeyName(keyName, KEY_CLASS_SYMMETRIC);
@@ -220,7 +220,7 @@
   }
 
   Block
-  SecTpmOsx::sign(const uint8_t *data, size_t dataLength, const Name& keyName, DigestAlgorithm digestAlgorithm)
+  SecTpmOsx::signInTpm(const uint8_t *data, size_t dataLength, const Name& keyName, DigestAlgorithm digestAlgorithm)
   {
     _LOG_TRACE("OSXPrivateKeyStorage::Sign");
     
@@ -280,16 +280,16 @@
   }
 
   void
-  SecTpmOsx::sign(Data &data, const Name& keyName, DigestAlgorithm digestAlgorithm)
+  SecTpmOsx::signInTpm(Data &data, const Name& keyName, DigestAlgorithm digestAlgorithm)
   {
     data.setSignatureValue
-      (sign(data.wireEncode().value(),
+      (signInTpm(data.wireEncode().value(),
             data.wireEncode().value_size() - data.getSignature().getValue().size(),
             keyName, digestAlgorithm));
   }
 
   ConstBufferPtr
-  SecTpmOsx::decrypt(const Name & keyName, const uint8_t* data, size_t dataLength, bool sym)
+  SecTpmOsx::decryptInTpm(const Name & keyName, const uint8_t* data, size_t dataLength, bool sym)
   {
     _LOG_TRACE("OSXPrivateKeyStorage::Decrypt");
 
@@ -429,7 +429,7 @@
   // }
 
   ConstBufferPtr
-  SecTpmOsx::encrypt(const Name & keyName, const uint8_t* data, size_t dataLength, bool sym)
+  SecTpmOsx::encryptInTpm(const Name & keyName, const uint8_t* data, size_t dataLength, bool sym)
   {
     _LOG_TRACE("OSXPrivateKeyStorage::Encrypt");
 
@@ -465,7 +465,7 @@
   }
 
   bool
-  SecTpmOsx::doesKeyExist(const Name & keyName, KeyClass keyClass)
+  SecTpmOsx::doesKeyExistInTpm(const Name & keyName, KeyClass keyClass)
   {
     _LOG_TRACE("OSXPrivateKeyStorage::doesKeyExist");
 
diff --git a/src/security/verifier.cpp b/src/security/verifier.cpp
index 992d1f0..67a9273 100644
--- a/src/security/verifier.cpp
+++ b/src/security/verifier.cpp
@@ -72,7 +72,7 @@
 Verifier::verifyData
   (const ptr_lib::shared_ptr<Data>& data, const OnVerified& onVerified, const OnVerifyFailed& onVerifyFailed, int stepCount)
 {
-  if (policies().requireVerify(*data)) {
+  if (policy().requireVerify(*data)) {
     ptr_lib::shared_ptr<ValidationRequest> nextStep = policy_->checkVerificationPolicy
       (data, stepCount, onVerified, onVerifyFailed);
     if (static_cast<bool>(nextStep))
@@ -86,7 +86,7 @@
            bind(&Verifier::onCertificateInterestTimeout, this, _1, nextStep->retry_, onVerifyFailed, data, nextStep));
       }
   }
-  else if (policies().skipVerifyAndTrust(*data))
+  else if (policy().skipVerifyAndTrust(*data))
     onVerified(data);
   else
     onVerifyFailed(data);