security: Add helpers for Command Interest

refs: #1238

Change-Id: I5a42f888b83bcc6dc51ea02045e438a4905ed145
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: