security: Add helpers for Command Interest

refs: #1238

Change-Id: I5a42f888b83bcc6dc51ea02045e438a4905ed145
diff --git a/src/security/key-chain.hpp b/src/security/key-chain.hpp
index e79b9c2..86589eb 100644
--- a/src/security/key-chain.hpp
+++ b/src/security/key-chain.hpp
@@ -201,7 +201,7 @@
   void 
   sign(Data& data, const Name& certificateName)
   {
-    ptr_lib::shared_ptr<IdentityCertificate> cert = Info::getCertificate(certificateName);
+    shared_ptr<IdentityCertificate> cert = Info::getCertificate(certificateName);
     if (!cert)
       throw InfoError("Requested certificate [" + certificateName.toUri() + "] doesn't exist");
 
@@ -216,14 +216,14 @@
   void
   sign(Interest &interest, const Name &certificateName)
   {
-    ptr_lib::shared_ptr<IdentityCertificate> cert = Info::getCertificate(certificateName);
+    shared_ptr<IdentityCertificate> cert = Info::getCertificate(certificateName);
     if(!static_cast<bool>(cert))
       throw InfoError("Requested certificate [" + certificateName.toUri() + "] doesn't exist");
 
     SignatureSha256WithRsa signature;
     signature.setKeyLocator(certificateName.getPrefix(-1)); // implicit conversion should take care
 
-    Name interestName = interest.getName().append(Name::Component::fromNumber(getNow())).append(signature.getInfo());
+    Name& interestName = interest.getName().append(signature.getInfo());
 
     signature.setValue(Tpm::signInTpm(interestName.wireEncode().value(), 
                                       interestName.wireEncode().value_size(), 
@@ -402,8 +402,7 @@
     SignatureSha256WithRsa signature;
     signature.setKeyLocator(certificate.getName().getPrefix(-1)); // implicit conversion should take care
 
-    Name &interestName = interest.getName();
-    interestName.append(Name::Component::fromNumber(getNow())).append(signature.getInfo());
+    Name& interestName = interest.getName().append(signature.getInfo());
 
     signature.setValue(Tpm::signInTpm(interestName.wireEncode().value(), 
                                       interestName.wireEncode().value_size(), 
diff --git a/src/security/validator.cpp b/src/security/validator.cpp
index 7979120..a44c333 100644
--- a/src/security/validator.cpp
+++ b/src/security/validator.cpp
@@ -138,14 +138,14 @@
 {
   const Name &interestName = interest.getName();
 
-  if(interestName.size() < 3)
+  if(interestName.size() < 2)
     return false;
 
   try{
-    const Block &nameBlock = interestName.wireEncode();
+    const Block& nameBlock = interestName.wireEncode();
 
-    Signature sig((++nameBlock.elements().rbegin())->blockFromValue(), 
-                  (nameBlock.elements().rbegin())->blockFromValue());
+    Signature sig(interestName[-2].blockFromValue(), 
+                  interestName[-1].blockFromValue());
 
     switch(sig.getType()){
     case Signature::Sha256WithRsa:
@@ -153,7 +153,7 @@
         SignatureSha256WithRsa sigSha256Rsa(sig);
 
         return verifySignature(nameBlock.value(), 
-                               nameBlock.value_size() - (nameBlock.elements().rbegin())->size(), 
+                               nameBlock.value_size() - interestName[-1].size(), 
                                sigSha256Rsa, key);
       }
     default: