security: Fix Validator::verifySignature bug

Refs: #1467

Change-Id: I2b69ccf15ede35c8b201c74ddf786e7b136fe421
diff --git a/src/security/validator.hpp b/src/security/validator.hpp
index 2b55782..32a5ab6 100644
--- a/src/security/validator.hpp
+++ b/src/security/validator.hpp
@@ -114,10 +114,10 @@
     if (interest.getName().size() < 2)
       return false;
 
-    Name signedName = interest.getName().getPrefix(-2);
+    const Name& name = interest.getName();
 
-    return verifySignature(signedName.wireEncode().value(),
-                           signedName.wireEncode().value_size(),
+    return verifySignature(name.wireEncode().value(),
+                           name.wireEncode().value_size() - name[-1].size(),
                            sig, publicKey);
   }
 
diff --git a/tests-integrated/security/test-validator-config.cpp b/tests-integrated/security/test-validator-config.cpp
index 2432739..e8849a9 100644
--- a/tests-integrated/security/test-validator-config.cpp
+++ b/tests-integrated/security/test-validator-config.cpp
@@ -772,6 +772,10 @@
   shared_ptr<Interest> interest2 = make_shared<Interest>(interestName2);
   BOOST_CHECK_NO_THROW(keyChain.signByIdentity(*interest2, nld));
 
+  Name interestName3("/localhost/nrd/register/option/timestamp/nonce");
+  shared_ptr<Interest> interest3 = make_shared<Interest>(interestName3);
+  BOOST_CHECK_NO_THROW(keyChain.signByIdentity(*interest3, root));
+
 
   const std::string CONFIG =
     "rule\n"
@@ -829,6 +833,10 @@
                           bind(&FacesFixture::validate4, this,
                                validator, interest2));
 
+  scheduler.scheduleEvent(time::milliseconds(600),
+                          bind(&FacesFixture::validate3, this,
+                               validator, interest3));
+
   BOOST_REQUIRE_NO_THROW(face->processEvents());
 
   keyChain.deleteIdentity(root);