diff --git a/src/security/conf/checker.hpp b/src/security/conf/checker.hpp
index 11f4da1..9284191 100644
--- a/src/security/conf/checker.hpp
+++ b/src/security/conf/checker.hpp
@@ -166,20 +166,17 @@
     if (signature.getType() == Tlv::DigestSha256)
       return 0;
 
-    shared_ptr<SignatureWithPublicKey> publicKeySig;
-
     try
       {
         switch (signature.getType())
           {
           case Tlv::SignatureSha256WithRsa:
-            {
-              publicKeySig = make_shared<SignatureSha256WithRsa>(signature);
-              break;
-            }
           case Tlv::SignatureSha256WithEcdsa:
             {
-              publicKeySig = make_shared<SignatureSha256WithEcdsa>(signature);
+              if (!signature.hasKeyLocator()) {
+                onValidationFailed(packet.shared_from_this(),
+                                   "Missing KeyLocator in SignatureInfo");
+              }
               break;
             }
           default:
@@ -205,7 +202,7 @@
       }
 
     std::string failInfo;
-    if (m_keyLocatorChecker->check(packet, publicKeySig->getKeyLocator(), failInfo))
+    if (m_keyLocatorChecker->check(packet, signature.getKeyLocator(), failInfo))
       return 0;
     else
       {
@@ -308,20 +305,17 @@
         return -1;
       }
 
-    shared_ptr<SignatureWithPublicKey> publicKeySig;
-
     try
       {
         switch (signature.getType())
           {
           case Tlv::SignatureSha256WithRsa:
-            {
-              publicKeySig = make_shared<SignatureSha256WithRsa>(signature);
-              break;
-            }
           case Tlv::SignatureSha256WithEcdsa:
             {
-              publicKeySig = make_shared<SignatureSha256WithEcdsa>(signature);
+              if (!signature.hasKeyLocator()) {
+                onValidationFailed(packet.shared_from_this(),
+                                   "Missing KeyLocator in SignatureInfo");
+              }
               break;
             }
           default:
@@ -333,7 +327,7 @@
             }
           }
 
-        const Name& keyLocatorName = publicKeySig->getKeyLocator().getName();
+        const Name& keyLocatorName = signature.getKeyLocator().getName();
 
         if (m_signers.find(keyLocatorName) == m_signers.end())
           {
@@ -343,7 +337,7 @@
             return -1;
           }
 
-        if (Validator::verifySignature(packet, *publicKeySig,
+        if (Validator::verifySignature(packet, signature,
                                        m_signers[keyLocatorName]->getPublicKeyInfo()))
           {
             onValidated(packet.shared_from_this());
diff --git a/src/security/digest-sha256.cpp b/src/security/digest-sha256.cpp
new file mode 100644
index 0000000..6d450a2
--- /dev/null
+++ b/src/security/digest-sha256.cpp
@@ -0,0 +1,38 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2014 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#include "digest-sha256.hpp"
+
+namespace ndn {
+
+DigestSha256::DigestSha256()
+  : Signature(SignatureInfo(Tlv::DigestSha256))
+{
+}
+
+DigestSha256::DigestSha256(const Signature& signature)
+  : Signature(signature)
+{
+  if (getType() != Tlv::DigestSha256)
+    throw Error("Incorrect signature type");
+}
+
+} // namespace ndn
diff --git a/src/security/digest-sha256.hpp b/src/security/digest-sha256.hpp
index 6221ee6..d3a15de 100644
--- a/src/security/digest-sha256.hpp
+++ b/src/security/digest-sha256.hpp
@@ -43,21 +43,11 @@
     }
   };
 
-  DigestSha256()
-  {
-    m_info = Block(Tlv::SignatureInfo);
-
-    m_type = Tlv::DigestSha256;
-    m_info.push_back(nonNegativeIntegerBlock(Tlv::SignatureType, Tlv::DigestSha256));
-  }
+  DigestSha256();
 
   explicit
-  DigestSha256(const Signature& signature)
-    : Signature(signature)
-  {
-    if (getType() != Tlv::DigestSha256)
-      throw Error("Incorrect signature type");
-  }
+  DigestSha256(const Signature& signature);
+
 };
 
 } // namespace ndn
diff --git a/src/security/key-chain.cpp b/src/security/key-chain.cpp
index 1d9f100..180d37d 100644
--- a/src/security/key-chain.cpp
+++ b/src/security/key-chain.cpp
@@ -297,13 +297,14 @@
 {
   shared_ptr<IdentityCertificate> certificate = m_pib->getCertificate(certificateName);
 
-  shared_ptr<SignatureWithPublicKey> sig =
-    determineSignatureWithPublicKey(certificate->getPublicKeyInfo().getKeyType());
+  KeyLocator keyLocator(certificate->getName().getPrefix(-1));
+  shared_ptr<Signature> sig =
+    determineSignatureWithPublicKey(keyLocator, certificate->getPublicKeyInfo().getKeyType());
 
   if (!static_cast<bool>(sig))
     throw SecTpm::Error("unknown key type");
 
-  sig->setKeyLocator(certificate->getName().getPrefix(-1));
+
   // For temporary usage, we support SHA256 only, but will support more.
   sig->setValue(m_tpm->signInTpm(buffer, bufferLength,
                                  certificate->getPublicKeyName(),
@@ -349,13 +350,14 @@
   if (!m_tpm->doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE))
     throw SecTpm::Error("Private key does not exist");
 
-  shared_ptr<SignatureWithPublicKey> sig =
-    determineSignatureWithPublicKey(cert.getPublicKeyInfo().getKeyType());
+
+  KeyLocator keyLocator(cert.getName().getPrefix(-1));
+  shared_ptr<Signature> sig =
+    determineSignatureWithPublicKey(keyLocator, cert.getPublicKeyInfo().getKeyType());
 
   if (!static_cast<bool>(sig))
     throw SecTpm::Error("unknown key type");
 
-  sig->setKeyLocator(cert.getName().getPrefix(-1)); // implicit conversion should take care
   signPacketWrapper(cert, *sig, keyName, DIGEST_ALGORITHM_SHA256);
 }
 
@@ -419,8 +421,9 @@
   m_pib->addCertificateAsIdentityDefault(securedBag.getCertificate());
 }
 
-shared_ptr<SignatureWithPublicKey>
-KeyChain::determineSignatureWithPublicKey(KeyType keyType, DigestAlgorithm digestAlgorithm)
+shared_ptr<Signature>
+KeyChain::determineSignatureWithPublicKey(const KeyLocator& keyLocator,
+                                          KeyType keyType, DigestAlgorithm digestAlgorithm)
 {
   switch (keyType)
     {
@@ -428,20 +431,20 @@
       {
         // For temporary usage, we support SHA256 only, but will support more.
         if (digestAlgorithm != DIGEST_ALGORITHM_SHA256)
-          return shared_ptr<SignatureWithPublicKey>();
+          return shared_ptr<Signature>();
 
-        return make_shared<SignatureSha256WithRsa>();
+        return make_shared<SignatureSha256WithRsa>(keyLocator);
       }
     case KEY_TYPE_ECDSA:
       {
         // For temporary usage, we support SHA256 only, but will support more.
         if (digestAlgorithm != DIGEST_ALGORITHM_SHA256)
-          return shared_ptr<SignatureWithPublicKey>();
+          return shared_ptr<Signature>();
 
-        return make_shared<SignatureSha256WithEcdsa>();
+        return make_shared<SignatureSha256WithEcdsa>(keyLocator);
       }
     default:
-      return shared_ptr<SignatureWithPublicKey>();
+      return shared_ptr<Signature>();
     }
 }
 
diff --git a/src/security/key-chain.hpp b/src/security/key-chain.hpp
index bb04f5c..0cc3cb3 100644
--- a/src/security/key-chain.hpp
+++ b/src/security/key-chain.hpp
@@ -642,8 +642,9 @@
    *
    * An empty pointer will be returned if there is no valid signature.
    */
-  shared_ptr<SignatureWithPublicKey>
-  determineSignatureWithPublicKey(KeyType keyType,
+  shared_ptr<Signature>
+  determineSignatureWithPublicKey(const KeyLocator& keyLocator,
+                                  KeyType keyType,
                                   DigestAlgorithm digestAlgorithm = DIGEST_ALGORITHM_SHA256);
 
   /**
@@ -773,15 +774,14 @@
 void
 KeyChain::sign(T& packet, const IdentityCertificate& certificate)
 {
+  KeyLocator keyLocator(certificate.getName().getPrefix(-1));
 
-  shared_ptr<SignatureWithPublicKey> signature =
-    determineSignatureWithPublicKey(certificate.getPublicKeyInfo().getKeyType());
+  shared_ptr<Signature> signature =
+    determineSignatureWithPublicKey(keyLocator, certificate.getPublicKeyInfo().getKeyType());
 
   if (!static_cast<bool>(signature))
     throw SecPublicInfo::Error("unknown key type!");
 
-  signature->setKeyLocator(certificate.getName().getPrefix(-1));
-
   signPacketWrapper(packet, *signature,
                     certificate.getPublicKeyName(),
                     DIGEST_ALGORITHM_SHA256);
diff --git a/src/security/sec-public-info-sqlite3.cpp b/src/security/sec-public-info-sqlite3.cpp
index 354c5aa..b2bd512 100644
--- a/src/security/sec-public-info-sqlite3.cpp
+++ b/src/security/sec-public-info-sqlite3.cpp
@@ -481,29 +481,14 @@
     {
       // this will throw an exception if the signature is not the standard one
       // or there is no key locator present
-      switch (certificate.getSignature().getType())
-        {
-        case Tlv::SignatureSha256WithRsa:
-          {
-            SignatureSha256WithRsa signature(certificate.getSignature());
-            std::string signerName = signature.getKeyLocator().getName().toUri();
-
-            sqlite3_bind_text(statement, 2, signerName, SQLITE_STATIC);
-            break;
-          }
-        case Tlv::SignatureSha256WithEcdsa:
-          {
-            SignatureSha256WithEcdsa signature(certificate.getSignature());
-            std::string signerName = signature.getKeyLocator().getName().toUri();
-
-            sqlite3_bind_text(statement, 2, signerName, SQLITE_STATIC);
-            break;
-          }
-        default:
-          return;
-        }
+      std::string signerName = certificate.getSignature().getKeyLocator().getName().toUri();
+      sqlite3_bind_text(statement, 2, signerName, SQLITE_STATIC);
     }
-  catch (std::runtime_error& e)
+  catch (Tlv::Error& e)
+    {
+      return;
+    }
+  catch (KeyLocator::Error& e)
     {
       return;
     }
diff --git a/src/security/sec-rule-relative.cpp b/src/security/sec-rule-relative.cpp
index 6350fd5..42272bc 100644
--- a/src/security/sec-rule-relative.cpp
+++ b/src/security/sec-rule-relative.cpp
@@ -59,8 +59,14 @@
   Name dataName = data.getName();
   try
     {
-      SignatureWithPublicKey sig(data.getSignature());
-      Name signerName = sig.getKeyLocator().getName();
+      if (!data.getSignature().hasKeyLocator())
+        return false;
+
+      const KeyLocator& keyLocator = data.getSignature().getKeyLocator();
+      if (keyLocator.getType() != KeyLocator::KeyLocator_Name)
+        return false;
+
+      const Name& signerName = keyLocator.getName();
       return satisfy(dataName, signerName);
     }
   catch (Tlv::Error& e)
@@ -104,8 +110,14 @@
 {
   try
     {
-      SignatureWithPublicKey sig(data.getSignature());
-      Name signerName = sig.getKeyLocator().getName();
+      if (!data.getSignature().hasKeyLocator())
+        return false;
+
+      const KeyLocator& keyLocator = data.getSignature().getKeyLocator();
+      if (keyLocator.getType() != KeyLocator::KeyLocator_Name)
+        return false;
+
+      const Name& signerName = keyLocator.getName();
       return m_signerNameRegex.match(signerName);
     }
   catch (Tlv::Error& e)
diff --git a/src/security/sec-rule-specific.cpp b/src/security/sec-rule-specific.cpp
index 75f45b9..af89e91 100644
--- a/src/security/sec-rule-specific.cpp
+++ b/src/security/sec-rule-specific.cpp
@@ -66,8 +66,14 @@
 
   try
     {
-      SignatureWithPublicKey sig(data.getSignature());
-      Name signerName = sig.getKeyLocator().getName();
+      if (!data.getSignature().hasKeyLocator())
+        return false;
+
+      const KeyLocator& keyLocator = data.getSignature().getKeyLocator();
+      if (keyLocator.getType() != KeyLocator::KeyLocator_Name)
+        return false;
+
+      const Name& signerName = keyLocator.getName();
       return m_signerRegex->match(signerName);
     }
   catch (Tlv::Error& e)
diff --git a/src/security/signature-sha256-with-ecdsa.cpp b/src/security/signature-sha256-with-ecdsa.cpp
new file mode 100644
index 0000000..1f67425
--- /dev/null
+++ b/src/security/signature-sha256-with-ecdsa.cpp
@@ -0,0 +1,42 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2014 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#include "signature-sha256-with-ecdsa.hpp"
+
+namespace ndn {
+
+SignatureSha256WithEcdsa::SignatureSha256WithEcdsa(const KeyLocator& keyLocator)
+  : Signature(SignatureInfo(Tlv::SignatureSha256WithEcdsa, keyLocator))
+{
+}
+
+SignatureSha256WithEcdsa::SignatureSha256WithEcdsa(const Signature& signature)
+  : Signature(signature)
+{
+  if (getType() != Tlv::SignatureSha256WithEcdsa)
+    throw Error("Incorrect signature type");
+
+  if (!hasKeyLocator()) {
+    throw Error("KeyLocator is missing");
+  }
+}
+
+} // namespace ndn
diff --git a/src/security/signature-sha256-with-ecdsa.hpp b/src/security/signature-sha256-with-ecdsa.hpp
index 5bf0500..a20e6b0 100644
--- a/src/security/signature-sha256-with-ecdsa.hpp
+++ b/src/security/signature-sha256-with-ecdsa.hpp
@@ -22,38 +22,32 @@
 #ifndef NDN_SECURITY_SIGNATURE_SHA256_WITH_ECDSA_HPP
 #define NDN_SECURITY_SIGNATURE_SHA256_WITH_ECDSA_HPP
 
-#include "signature-with-public-key.hpp"
+#include "../signature.hpp"
 
 namespace ndn {
 
 /**
  * represents a Sha256WithEcdsa signature.
  */
-class SignatureSha256WithEcdsa : public SignatureWithPublicKey
+class SignatureSha256WithEcdsa : public Signature
 {
 public:
-  class Error : public SignatureWithPublicKey::Error
+  class Error : public Signature::Error
   {
   public:
     explicit
     Error(const std::string& what)
-      : SignatureWithPublicKey::Error(what)
+      : Signature::Error(what)
     {
     }
   };
 
-  SignatureSha256WithEcdsa()
-    : SignatureWithPublicKey(Tlv::SignatureSha256WithEcdsa)
-  {
-  }
+  explicit
+  SignatureSha256WithEcdsa(const KeyLocator& keyLocator = KeyLocator());
 
   explicit
-  SignatureSha256WithEcdsa(const Signature& signature)
-    : SignatureWithPublicKey(signature)
-  {
-    if (getType() != Tlv::SignatureSha256WithEcdsa)
-      throw Error("Incorrect signature type");
-  }
+  SignatureSha256WithEcdsa(const Signature& signature);
+
 };
 
 } // namespace ndn
diff --git a/src/security/signature-sha256-with-rsa.cpp b/src/security/signature-sha256-with-rsa.cpp
new file mode 100644
index 0000000..bc4fe65
--- /dev/null
+++ b/src/security/signature-sha256-with-rsa.cpp
@@ -0,0 +1,42 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2014 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#include "signature-sha256-with-rsa.hpp"
+
+namespace ndn {
+
+SignatureSha256WithRsa::SignatureSha256WithRsa(const KeyLocator& keyLocator)
+  : Signature(SignatureInfo(Tlv::SignatureSha256WithRsa, keyLocator))
+{
+}
+
+SignatureSha256WithRsa::SignatureSha256WithRsa(const Signature& signature)
+  : Signature(signature)
+{
+  if (getType() != Tlv::SignatureSha256WithRsa)
+    throw Error("Incorrect signature type");
+
+  if (!hasKeyLocator()) {
+    throw Error("KeyLocator is missing");
+  }
+}
+
+} // namespace ndn
diff --git a/src/security/signature-sha256-with-rsa.hpp b/src/security/signature-sha256-with-rsa.hpp
index fc60248..94f9e30 100644
--- a/src/security/signature-sha256-with-rsa.hpp
+++ b/src/security/signature-sha256-with-rsa.hpp
@@ -22,38 +22,31 @@
 #ifndef NDN_SECURITY_SIGNATURE_SHA256_WITH_RSA_HPP
 #define NDN_SECURITY_SIGNATURE_SHA256_WITH_RSA_HPP
 
-#include "signature-with-public-key.hpp"
+#include "../signature.hpp"
 
 namespace ndn {
 
 /**
  * Represent a SHA256-with-RSA signature.
  */
-class SignatureSha256WithRsa : public SignatureWithPublicKey
+class SignatureSha256WithRsa : public Signature
 {
 public:
-  class Error : public SignatureWithPublicKey::Error
+  class Error : public Signature::Error
   {
   public:
     explicit
     Error(const std::string& what)
-      : SignatureWithPublicKey::Error(what)
+      : Signature::Error(what)
     {
     }
   };
 
-  SignatureSha256WithRsa()
-    : SignatureWithPublicKey(Tlv::SignatureSha256WithRsa)
-  {
-  }
+  explicit
+  SignatureSha256WithRsa(const KeyLocator& keyLocator = KeyLocator());
 
   explicit
-  SignatureSha256WithRsa(const Signature& signature)
-    : SignatureWithPublicKey(signature)
-  {
-    if (getType() != Tlv::SignatureSha256WithRsa)
-      throw Error("Incorrect signature type");
-  }
+  SignatureSha256WithRsa(const Signature& signature);
 };
 
 } // namespace ndn
diff --git a/src/security/signature-with-public-key.hpp b/src/security/signature-with-public-key.hpp
deleted file mode 100644
index abaa85a..0000000
--- a/src/security/signature-with-public-key.hpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2014 Regents of the University of California.
- *
- * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
- *
- * ndn-cxx library is free software: you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later version.
- *
- * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- *
- * You should have received copies of the GNU General Public License and GNU Lesser
- * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
- */
-
-#ifndef NDN_SECURITY_SIGNATURE_WITH_PUBLIC_KEY_HPP
-#define NDN_SECURITY_SIGNATURE_WITH_PUBLIC_KEY_HPP
-
-#include "../data.hpp"
-#include "../encoding/tlv.hpp"
-
-namespace ndn {
-
-/**
- * Base class of public key signature.
- */
-class SignatureWithPublicKey : public Signature
-{
-public:
-  class Error : public Signature::Error
-  {
-  public:
-    explicit
-    Error(const std::string& what)
-      : Signature::Error(what)
-    {
-    }
-  };
-
-  explicit
-  SignatureWithPublicKey(const Tlv::SignatureTypeValue& signatureType)
-  {
-    m_info = Block(Tlv::SignatureInfo);
-
-    m_type = signatureType;
-    m_info.push_back(nonNegativeIntegerBlock(Tlv::SignatureType, signatureType));
-    m_info.push_back(m_keyLocator.wireEncode());
-  }
-
-  explicit
-  SignatureWithPublicKey(const Signature& signature)
-    : Signature(signature)
-  {
-    m_info.parse();
-    Block::element_const_iterator i = m_info.find(Tlv::KeyLocator);
-    if (i != m_info.elements_end())
-      {
-        m_keyLocator.wireDecode(*i);
-      }
-  }
-
-  const KeyLocator&
-  getKeyLocator() const
-  {
-    return m_keyLocator;
-  }
-
-  void
-  setKeyLocator(const KeyLocator& keyLocator)
-  {
-    m_keyLocator = keyLocator;
-
-    m_info.remove(ndn::Tlv::KeyLocator);
-    m_info.push_back(m_keyLocator.wireEncode());
-  }
-
-private:
-  KeyLocator m_keyLocator;
-};
-
-} // namespace ndn
-
-#endif //NDN_SECURITY_SIGNATURE_WITH_PUBLIC_KEY_HPP
diff --git a/src/security/validator-config.cpp b/src/security/validator-config.cpp
index b9b1bed..387cfe0 100644
--- a/src/security/validator-config.cpp
+++ b/src/security/validator-config.cpp
@@ -490,9 +490,11 @@
       Signature signature(interestName[signed_interest::POS_SIG_INFO].blockFromValue(),
                           interestName[signed_interest::POS_SIG_VALUE].blockFromValue());
 
-      SignatureWithPublicKey publicKeySig(signature);
+      if (!signature.hasKeyLocator())
+        return onValidationFailed(interest.shared_from_this(),
+                                  "No valid KeyLocator");
 
-      const KeyLocator& keyLocator = publicKeySig.getKeyLocator();
+      const KeyLocator& keyLocator = signature.getKeyLocator();
 
       if (keyLocator.getType() != KeyLocator::KeyLocator_Name)
         return onValidationFailed(interest.shared_from_this(),
@@ -523,7 +525,7 @@
       if (checkResult == 0)
         {
           checkSignature<Interest, OnInterestValidated, OnInterestValidationFailed>
-            (interest, publicKeySig, nSteps,
+            (interest, signature, nSteps,
              bind(&ValidatorConfig::checkTimestamp, this, _1,
                   keyName, onValidated, onValidationFailed),
              onValidationFailed,
diff --git a/src/security/validator-config.hpp b/src/security/validator-config.hpp
index 4a2ce58..d3e4be4 100644
--- a/src/security/validator-config.hpp
+++ b/src/security/validator-config.hpp
@@ -304,18 +304,15 @@
                                   "Sha256 Signature cannot be verified!");
     }
 
-  shared_ptr<SignatureWithPublicKey> publicKeySig;
-
   try {
     switch (signature.getType()) {
     case Tlv::SignatureSha256WithRsa:
-      {
-        publicKeySig = make_shared<SignatureSha256WithRsa>(signature);
-        break;
-      }
     case Tlv::SignatureSha256WithEcdsa:
       {
-        publicKeySig = make_shared<SignatureSha256WithEcdsa>(signature);
+        if (!signature.hasKeyLocator()) {
+          return onValidationFailed(packet.shared_from_this(),
+                                    "Missing KeyLocator in SignatureInfo");
+        }
         break;
       }
     default:
@@ -332,8 +329,11 @@
                               "Cannot decode KeyLocator in public key signature");
   }
 
+  if (signature.getKeyLocator().getType() != KeyLocator::KeyLocator_Name) {
+    return onValidationFailed(packet.shared_from_this(), "Unsupported KeyLocator type");
+  }
 
-  Name keyLocatorName = publicKeySig->getKeyLocator().getName();
+  const Name& keyLocatorName = signature.getKeyLocator().getName();
 
   shared_ptr<const Certificate> trustedCert;
 
@@ -347,7 +347,7 @@
 
   if (static_cast<bool>(trustedCert))
     {
-      if (verifySignature(packet, *publicKeySig, trustedCert->getPublicKeyInfo()))
+      if (verifySignature(packet, signature, trustedCert->getPublicKeyInfo()))
         return onValidated(packet.shared_from_this());
       else
         return onValidationFailed(packet.shared_from_this(),
@@ -379,7 +379,7 @@
       return;
     }
 
-  return onValidationFailed(packet.shared_from_this(), "Unsupported Signature Type!");
+  return onValidationFailed(packet.shared_from_this(), "Unsupported Signature Type");
 }
 
 template<class Packet, class OnValidated, class OnFailed>
diff --git a/src/security/validator-regex.cpp b/src/security/validator-regex.cpp
index e998d8c..97f796c 100644
--- a/src/security/validator-regex.cpp
+++ b/src/security/validator-regex.cpp
@@ -108,9 +108,19 @@
         {
           try
             {
-              SignatureWithPublicKey sig(data.getSignature());
+              if (!data.getSignature().hasKeyLocator())
+                return onValidationFailed(data.shared_from_this(),
+                                          "Key Locator is missing in Data packet: " +
+                                          data.getName().toUri());
 
-              Name keyLocatorName = sig.getKeyLocator().getName();
+              const KeyLocator& keyLocator = data.getSignature().getKeyLocator();
+              if (keyLocator.getType() != KeyLocator::KeyLocator_Name)
+                return onValidationFailed(data.shared_from_this(),
+                                          "Key Locator is not a name: " +
+                                          data.getName().toUri());
+
+
+              const Name& keyLocatorName = keyLocator.getName();
               shared_ptr<const Certificate> trustedCert;
               if (m_trustAnchors.end() == m_trustAnchors.find(keyLocatorName))
                 trustedCert = m_certificateCache->getCertificate(keyLocatorName);
@@ -119,7 +129,7 @@
 
               if (static_cast<bool>(trustedCert))
                 {
-                  if (verifySignature(data, sig, trustedCert->getPublicKeyInfo()))
+                  if (verifySignature(data, data.getSignature(), trustedCert->getPublicKeyInfo()))
                     return onValidated(data.shared_from_this());
                   else
                     return onValidationFailed(data.shared_from_this(),
@@ -138,7 +148,7 @@
                     bind(&ValidatorRegex::onCertificateValidationFailed, this, _1, _2,
                          data.shared_from_this(), onValidationFailed);
 
-                  Interest interest(sig.getKeyLocator().getName());
+                  Interest interest(keyLocatorName);
                   shared_ptr<ValidationRequest> nextStep =
                     make_shared<ValidationRequest>(interest,
                                                    onKeyValidated,
@@ -151,12 +161,6 @@
                   return;
                 }
             }
-          catch (SignatureWithPublicKey::Error& e)
-            {
-              return onValidationFailed(data.shared_from_this(),
-                                        "Require sub-class of SignatureWithPublicKey: " +
-                                        data.getName().toUri());
-            }
           catch (Tlv::Error& e)
             {
               return onValidationFailed(data.shared_from_this(),
diff --git a/src/security/validator.cpp b/src/security/validator.cpp
index 5edb852..2bc9364 100644
--- a/src/security/validator.cpp
+++ b/src/security/validator.cpp
@@ -121,16 +121,13 @@
 bool
 Validator::verifySignature(const Data& data, const PublicKey& key)
 {
-  shared_ptr<SignatureWithPublicKey> publicKeySig =
-    determineSignatureWithPublicKey(data.getSignature());
-
-  if (!static_cast<bool>(publicKeySig))
+  if (!data.getSignature().hasKeyLocator())
     return false;
 
   return verifySignature(data.wireEncode().value(),
                          data.wireEncode().value_size() -
                          data.getSignature().getValue().size(),
-                         *publicKeySig, key);
+                         data.getSignature(), key);
 }
 
 bool
@@ -148,14 +145,12 @@
       Signature sig(interestName[-2].blockFromValue(),
                     interestName[-1].blockFromValue());
 
-      shared_ptr<SignatureWithPublicKey> publicKeySig = determineSignatureWithPublicKey(sig);
-
-      if (!static_cast<bool>(publicKeySig))
+      if (!sig.hasKeyLocator())
         return false;
 
       return verifySignature(nameBlock.value(),
                              nameBlock.value_size() - interestName[-1].size(),
-                             *publicKeySig, key);
+                             sig, key);
     }
   catch (Block::Error& e)
     {
@@ -166,7 +161,7 @@
 bool
 Validator::verifySignature(const uint8_t* buf,
                            const size_t size,
-                           const SignatureWithPublicKey& sig,
+                           const Signature& sig,
                            const PublicKey& key)
 {
   try
@@ -286,28 +281,6 @@
     }
 }
 
-shared_ptr<SignatureWithPublicKey>
-Validator::determineSignatureWithPublicKey(const Signature& signature)
-{
-  try {
-    switch (signature.getType())
-      {
-      case Tlv::SignatureSha256WithRsa:
-        return make_shared<SignatureSha256WithRsa>(signature);
-      case Tlv::SignatureSha256WithEcdsa:
-        return make_shared<SignatureSha256WithEcdsa>(signature);
-      default:
-        return shared_ptr<SignatureWithPublicKey>();
-      }
-  }
-  catch (Tlv::Error& e) {
-    return shared_ptr<SignatureWithPublicKey>();
-  }
-  catch (KeyLocator::Error& e) {
-    return shared_ptr<SignatureWithPublicKey>();
-  }
-}
-
 void
 Validator::onTimeout(const Interest& interest,
                      int remainingRetries,
diff --git a/src/security/validator.hpp b/src/security/validator.hpp
index e9bf37e..9a3b4a3 100644
--- a/src/security/validator.hpp
+++ b/src/security/validator.hpp
@@ -107,7 +107,7 @@
 
   /// @brief Verify the blob using the publicKey against the signature.
   static bool
-  verifySignature(const Buffer& blob, const SignatureWithPublicKey& sig, const PublicKey& publicKey)
+  verifySignature(const Buffer& blob, const Signature& sig, const PublicKey& publicKey)
   {
     return verifySignature(blob.buf(), blob.size(), sig, publicKey);
   }
@@ -115,7 +115,7 @@
   /// @brief Verify the data using the publicKey against the SHA256-RSA signature.
   static bool
   verifySignature(const Data& data,
-                  const SignatureWithPublicKey& sig,
+                  const Signature& sig,
                   const PublicKey& publicKey)
   {
     return verifySignature(data.wireEncode().value(),
@@ -129,7 +129,7 @@
    */
   static bool
   verifySignature(const Interest& interest,
-                  const SignatureWithPublicKey& sig,
+                  const Signature& sig,
                   const PublicKey& publicKey)
   {
     if (interest.getName().size() < 2)
@@ -146,7 +146,7 @@
   static bool
   verifySignature(const uint8_t* buf,
                   const size_t size,
-                  const SignatureWithPublicKey& sig,
+                  const Signature& sig,
                   const PublicKey& publicKey);
 
 
@@ -248,9 +248,6 @@
            const OnInterestValidationFailed& onValidationFailed,
            int nSteps);
 
-  static shared_ptr<SignatureWithPublicKey>
-  determineSignatureWithPublicKey(const Signature& signature);
-
   /// Hooks
 
   /**
diff --git a/src/signature-info.cpp b/src/signature-info.cpp
new file mode 100644
index 0000000..1b8203d
--- /dev/null
+++ b/src/signature-info.cpp
@@ -0,0 +1,186 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2014 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#include "signature-info.hpp"
+
+namespace ndn {
+
+SignatureInfo::SignatureInfo()
+  : m_type(-1)
+  , m_hasKeyLocator(false)
+{
+}
+
+SignatureInfo::SignatureInfo(Tlv::SignatureTypeValue type)
+  : m_type(type)
+  , m_hasKeyLocator(false)
+{
+}
+
+SignatureInfo::SignatureInfo(Tlv::SignatureTypeValue type, const KeyLocator& keyLocator)
+  : m_type(type)
+  , m_hasKeyLocator(true)
+  , m_keyLocator(keyLocator)
+{
+}
+
+SignatureInfo::SignatureInfo(const Block& block)
+{
+  wireDecode(block);
+}
+
+void
+SignatureInfo::setSignatureType(Tlv::SignatureTypeValue type)
+{
+  m_wire.reset();
+  m_type = type;
+}
+
+void
+SignatureInfo::setKeyLocator(const KeyLocator& keyLocator)
+{
+  m_wire.reset();
+  m_keyLocator = keyLocator;
+  m_hasKeyLocator = true;
+}
+
+const KeyLocator&
+SignatureInfo::getKeyLocator() const
+{
+  if (m_hasKeyLocator)
+    return m_keyLocator;
+  else
+    throw Error("KeyLocator does not exist");
+}
+
+void
+SignatureInfo::appendTypeSpecificTlv(const Block& block)
+{
+  m_otherTlvs.push_back(block);
+}
+
+
+const Block&
+SignatureInfo::getTypeSpecificTlv(uint32_t type) const
+{
+  for (std::list<Block>::const_iterator i = m_otherTlvs.begin();
+       i != m_otherTlvs.end(); i++) {
+    if (i->type() == type)
+      return *i;
+  }
+
+  throw Error("(SignatureInfo::getTypeSpecificTlv) Requested a non-existed type [" +
+              boost::lexical_cast<std::string>(type) + "] from SignatureInfo");
+}
+
+template<bool T>
+size_t
+SignatureInfo::wireEncode(EncodingImpl<T>& block) const
+{
+  size_t totalLength = 0;
+
+  for (std::list<Block>::const_reverse_iterator i = m_otherTlvs.rbegin();
+       i != m_otherTlvs.rend(); i++) {
+    totalLength += block.appendBlock(*i);
+  }
+
+  if (m_hasKeyLocator)
+    totalLength += m_keyLocator.wireEncode(block);
+
+  totalLength += prependNonNegativeIntegerBlock(block, Tlv::SignatureType, m_type);
+
+  totalLength += block.prependVarNumber(totalLength);
+  totalLength += block.prependVarNumber(Tlv::SignatureInfo);
+  return totalLength;
+}
+
+template size_t
+SignatureInfo::wireEncode<true>(EncodingImpl<true>& block) const;
+
+template size_t
+SignatureInfo::wireEncode<false>(EncodingImpl<false>& block) const;
+
+
+const Block&
+SignatureInfo::wireEncode() const
+{
+  if (m_wire.hasWire())
+    return m_wire;
+
+  EncodingEstimator estimator;
+  size_t estimatedSize = wireEncode(estimator);
+
+  EncodingBuffer buffer(estimatedSize, 0);
+  wireEncode(buffer);
+
+  m_wire = buffer.block();
+  return m_wire;
+}
+
+void
+SignatureInfo::wireDecode(const Block& wire)
+{
+  if (!wire.hasWire()) {
+    throw Error("The supplied block does not contain wire format");
+  }
+
+  m_hasKeyLocator = false;
+
+  m_wire = wire;
+  m_wire.parse();
+
+  if (m_wire.type() != Tlv::SignatureInfo)
+    throw Tlv::Error("Unexpected TLV type when decoding Name");
+
+  Block::element_const_iterator it = m_wire.elements_begin();
+
+  // the first block must be SignatureType
+  if (it != m_wire.elements_end() && it->type() == Tlv::SignatureType) {
+    m_type = readNonNegativeInteger(*it);
+    it++;
+  }
+  else
+    throw Error("SignatureInfo does not have sub-TLV or the first sub-TLV is not SignatureType");
+
+  // the second block could be KeyLocator
+  if (it != m_wire.elements_end() && it->type() == Tlv::KeyLocator) {
+    m_keyLocator.wireDecode(*it);
+    m_hasKeyLocator = true;
+    it++;
+  }
+
+  // Decode the rest of type-specific TLVs, if any
+  while (it != m_wire.elements_end()) {
+    appendTypeSpecificTlv(*it);
+    it++;
+  }
+}
+
+bool
+SignatureInfo::operator==(const SignatureInfo& rhs) const
+{
+  return (m_type == rhs.m_type &&
+          m_hasKeyLocator == rhs.m_hasKeyLocator &&
+          m_keyLocator == rhs.m_keyLocator &&
+          m_otherTlvs == rhs.m_otherTlvs);
+}
+
+} // namespace ndn
diff --git a/src/signature-info.hpp b/src/signature-info.hpp
new file mode 100644
index 0000000..9fd0f62
--- /dev/null
+++ b/src/signature-info.hpp
@@ -0,0 +1,134 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2014 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#ifndef NDN_SIGNATURE_INFO_HPP
+#define NDN_SIGNATURE_INFO_HPP
+
+#include "encoding/tlv.hpp"
+#include "key-locator.hpp"
+
+namespace ndn {
+
+class SignatureInfo
+{
+public:
+  class Error : public Tlv::Error
+  {
+  public:
+    explicit
+    Error(const std::string& what)
+      : Tlv::Error(what)
+    {
+    }
+  };
+
+  SignatureInfo();
+
+  explicit
+  SignatureInfo(Tlv::SignatureTypeValue type);
+
+  SignatureInfo(Tlv::SignatureTypeValue type, const KeyLocator& keyLocator);
+
+  /**
+   * @brief Generate SignatureInfo from a block
+   *
+   * @throws Tlv::Error if supplied block is not formatted correctly
+   */
+  explicit
+  SignatureInfo(const Block& block);
+
+  /// @brief Set SignatureType
+  void
+  setSignatureType(Tlv::SignatureTypeValue type);
+
+  /// @brief Get SignatureType
+  int32_t
+  getSignatureType() const
+  {
+    return m_type;
+  }
+
+  /// @brief Check if KeyLocator is set
+  bool
+  hasKeyLocator() const
+  {
+    return m_hasKeyLocator;
+  }
+
+  /// @brief Set KeyLocator
+  void
+  setKeyLocator(const KeyLocator& keyLocator);
+
+  /**
+   * @brief Get KeyLocator
+   *
+   * @throws SignatureInfo::Error if keyLocator does not exist
+   */
+  const KeyLocator&
+  getKeyLocator() const;
+
+  /// @brief Append signature type specific tlv block
+  void
+  appendTypeSpecificTlv(const Block& block);
+
+  /**
+   * @brief Get signature type specific tlv block
+   *
+   * @throws SignatureInfo::Error if the block does not exist
+   */
+  const Block&
+  getTypeSpecificTlv(uint32_t type) const;
+
+  /// @brief Encode to a wire format or estimate wire format
+  template<bool T>
+  size_t
+  wireEncode(EncodingImpl<T>& block) const;
+
+  /// @brief Encode to a wire format
+  const Block&
+  wireEncode() const;
+
+  /// @brief Decode from a wire format
+  void
+  wireDecode(const Block& wire);
+
+public: // EqualityComparable concept
+  bool
+  operator==(const SignatureInfo& rhs) const;
+
+  bool
+  operator!=(const SignatureInfo& rhs) const
+  {
+    return !(*this == rhs);
+  }
+
+private:
+  int32_t m_type;
+  bool m_hasKeyLocator;
+  KeyLocator m_keyLocator;
+  std::list<Block> m_otherTlvs;
+
+  mutable Block m_wire;
+};
+
+} // namespace ndn
+
+#endif // NDN_SIGNATURE_INFO_HPP
diff --git a/src/signature.cpp b/src/signature.cpp
new file mode 100644
index 0000000..5ec68d5
--- /dev/null
+++ b/src/signature.cpp
@@ -0,0 +1,45 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2014 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#include "signature.hpp"
+
+namespace ndn {
+
+Signature::Signature(const Block& info, const Block& value)
+  : m_info(info)
+  , m_value(value)
+{
+}
+
+
+Signature::Signature(const SignatureInfo& info, const Block& value)
+  : m_info(info)
+  , m_value(value)
+{
+}
+
+void
+Signature::setInfo(const Block& info)
+{
+  m_info = SignatureInfo(info);
+}
+
+} // namespace ndn
diff --git a/src/signature.hpp b/src/signature.hpp
index f7853dd..d6dd730 100644
--- a/src/signature.hpp
+++ b/src/signature.hpp
@@ -22,7 +22,7 @@
 #ifndef NDN_SIGNATURE_HPP
 #define NDN_SIGNATURE_HPP
 
-#include "encoding/tlv.hpp"
+#include "signature-info.hpp"
 
 namespace ndn {
 
@@ -50,49 +50,40 @@
   };
 
   Signature()
-    : m_type(-1)
   {
   }
 
   explicit
-  Signature(const Block& info, const Block& value = Block())
-    : m_value(value)
-  {
-    setInfo(info);
-  }
+  Signature(const Block& info, const Block& value = Block());
+
+  explicit
+  Signature(const SignatureInfo& info, const Block& value = Block());
 
   operator bool() const
   {
-    return m_type != -1;
+    return m_info.getSignatureType() != -1;
   }
 
-  uint32_t
-  getType() const
-  {
-    return m_type;
-  }
-
+  /// @brief Get SignatureInfo in the wire format
   const Block&
   getInfo() const
   {
-    m_info.encode(); // will do nothing if wire already exists
-    return m_info;
+    return m_info.wireEncode(); // will do nothing if wire already exists
   }
 
+  /**
+   * @brief Set SignatureInfo from a block
+   *
+   * @throws Tlv::Error if supplied block is not formatted correctly
+   */
   void
-  setInfo(const Block& info)
+  setInfo(const Block& info);
+
+  /// @brief Set SignatureInfo
+  void
+  setInfo(const SignatureInfo& info)
   {
     m_info = info;
-    if (m_info.hasWire() || m_info.hasValue())
-      {
-        m_info.parse();
-        const Block& signatureType = m_info.get(Tlv::SignatureType);
-        m_type = readNonNegativeInteger(signatureType);
-      }
-    else
-      {
-        m_type = -1;
-      }
   }
 
   const Block&
@@ -108,14 +99,30 @@
     m_value = value;
   }
 
-  void
-  reset()
+  uint32_t
+  getType() const
   {
-    m_type = -1;
-    m_info.reset();
-    m_value.reset();
+    return m_info.getSignatureType();
   }
 
+  bool
+  hasKeyLocator() const
+  {
+    return m_info.hasKeyLocator();
+  }
+
+  /**
+   * @brief Get KeyLocator
+   *
+   * @throws Signature::Error if keyLocator does not exist
+   */
+  const KeyLocator&
+  getKeyLocator() const
+  {
+    return m_info.getKeyLocator();
+  }
+
+
 public: // EqualityComparable concept
   bool
   operator==(const Signature& other) const
@@ -131,9 +138,7 @@
   }
 
 protected:
-  int32_t m_type;
-
-  mutable Block m_info;
+  SignatureInfo m_info;
   mutable Block m_value;
 };
 
diff --git a/tests/unit-tests/security/test-digest-sha256.cpp b/tests/unit-tests/security/test-digest-sha256.cpp
index 94ded5b..264078c 100644
--- a/tests/unit-tests/security/test-digest-sha256.cpp
+++ b/tests/unit-tests/security/test-digest-sha256.cpp
@@ -26,26 +26,25 @@
 
 #include "boost-test.hpp"
 
-using namespace std;
 namespace ndn {
 
 BOOST_AUTO_TEST_SUITE(SecurityTestDigestSha256)
 
-string SHA256_RESULT("a883dafc480d466ee04e0d6da986bd78eb1fdd2178d04693723da3a8f95d42f4");
+std::string SHA256_RESULT("a883dafc480d466ee04e0d6da986bd78eb1fdd2178d04693723da3a8f95d42f4");
 
-BOOST_AUTO_TEST_CASE (Sha256)
+BOOST_AUTO_TEST_CASE(Sha256)
 {
   using namespace CryptoPP;
 
   char content[6] = "1234\n";
   ConstBufferPtr buf = crypto::sha256(reinterpret_cast<uint8_t*>(content), 5);
-  string result;
+  std::string result;
   StringSource(buf->buf(), buf->size(), true, new HexEncoder(new StringSink(result), false));
 
-  BOOST_REQUIRE_EQUAL(SHA256_RESULT, result);
+  BOOST_CHECK_EQUAL(SHA256_RESULT, result);
 }
 
-BOOST_AUTO_TEST_CASE (Signature)
+BOOST_AUTO_TEST_CASE(Signature)
 {
   using namespace CryptoPP;
 
@@ -63,7 +62,9 @@
 
   DigestSha256 sig(testData.getSignature());
 
-  BOOST_REQUIRE(Validator::verifySignature(testData, sig));
+  BOOST_CHECK(Validator::verifySignature(testData, sig));
+
+  BOOST_CHECK_THROW(sig.getKeyLocator(), ndn::SignatureInfo::Error);
 }
 
 BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/unit-tests/security/test-signature-sha256-ecdsa.cpp b/tests/unit-tests/security/test-signature-sha256-ecdsa.cpp
index bcf01be..34f25bf 100644
--- a/tests/unit-tests/security/test-signature-sha256-ecdsa.cpp
+++ b/tests/unit-tests/security/test-signature-sha256-ecdsa.cpp
@@ -57,17 +57,18 @@
   Block sigValueBlock(sigValue, sizeof(sigValue));
 
   Signature sig(sigInfoBlock, sigValueBlock);
-  BOOST_REQUIRE_NO_THROW(SignatureSha256WithEcdsa(sig));
+  BOOST_CHECK_NO_THROW(SignatureSha256WithEcdsa(sig));
+  BOOST_CHECK_NO_THROW(sig.getKeyLocator());
 }
 
 BOOST_AUTO_TEST_CASE(Encoding)
 {
-  SignatureSha256WithEcdsa sig;
-
   Name name("/test/key/locator");
   KeyLocator keyLocator(name);
 
-  sig.setKeyLocator(keyLocator);
+  SignatureSha256WithEcdsa sig(keyLocator);
+
+  BOOST_CHECK_NO_THROW(sig.getKeyLocator());
 
   const Block& encodeSigInfoBlock = sig.getInfo();
 
diff --git a/tests/unit-tests/security/test-signature-sha256-rsa.cpp b/tests/unit-tests/security/test-signature-sha256-rsa.cpp
index e1ea73c..cd717d7 100644
--- a/tests/unit-tests/security/test-signature-sha256-rsa.cpp
+++ b/tests/unit-tests/security/test-signature-sha256-rsa.cpp
@@ -62,17 +62,18 @@
   Block sigValueBlock(sigValue, sizeof(sigValue));
 
   Signature sig(sigInfoBlock, sigValueBlock);
-  BOOST_REQUIRE_NO_THROW(SignatureSha256WithRsa(sig));
+  BOOST_CHECK_NO_THROW(SignatureSha256WithRsa(sig));
+  BOOST_CHECK_NO_THROW(sig.getKeyLocator());
 }
 
 BOOST_AUTO_TEST_CASE(Encoding)
 {
-  SignatureSha256WithRsa sig;
-
   Name name("/test/key/locator");
   KeyLocator keyLocator(name);
 
-  sig.setKeyLocator(keyLocator);
+  SignatureSha256WithRsa sig(keyLocator);
+
+  BOOST_CHECK_NO_THROW(sig.getKeyLocator());
 
   const Block& encodeSigInfoBlock = sig.getInfo();
 
diff --git a/tests/unit-tests/test-interest.cpp b/tests/unit-tests/test-interest.cpp
index 0b397cf..2f465ae 100644
--- a/tests/unit-tests/test-interest.cpp
+++ b/tests/unit-tests/test-interest.cpp
@@ -466,8 +466,7 @@
           .setExclude(Exclude().excludeBefore(name::Component("C")));
 
   Data data("ndn:/A/D");
-  SignatureSha256WithRsa signature;
-  signature.setKeyLocator(KeyLocator("ndn:/B"));
+  SignatureSha256WithRsa signature(KeyLocator("ndn:/B"));
   data.setSignature(signature);
   data.wireEncode();
   BOOST_CHECK_EQUAL(interest.matchesData(data), true);
@@ -491,8 +490,7 @@
   interest.setMaxSuffixComponents(2);
 
   Data data3 = data;
-  SignatureSha256WithRsa signature3;
-  signature3.setKeyLocator(KeyLocator("ndn:/G")); // violates PublisherPublicKeyLocator
+  SignatureSha256WithRsa signature3(KeyLocator("ndn:/G")); // violates PublisherPublicKeyLocator
   data3.setSignature(signature3);
   data3.wireEncode();
   BOOST_CHECK_EQUAL(interest.matchesData(data3), false);
diff --git a/tests/unit-tests/test-signature-info.cpp b/tests/unit-tests/test-signature-info.cpp
new file mode 100644
index 0000000..605b325
--- /dev/null
+++ b/tests/unit-tests/test-signature-info.cpp
@@ -0,0 +1,174 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2014 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#include "signature-info.hpp"
+
+#include "boost-test.hpp"
+
+namespace ndn {
+
+BOOST_AUTO_TEST_SUITE(TestSignatureInfo)
+
+const uint8_t sigInfoRsa[] = {
+0x16, 0x1b, // SignatureInfo
+  0x1b, 0x01, // SignatureType
+    0x01, // Sha256WithRsa
+  0x1c, 0x16, // KeyLocator
+    0x07, 0x14, // Name
+      0x08, 0x04,
+        0x74, 0x65, 0x73, 0x74,
+      0x08, 0x03,
+        0x6b, 0x65, 0x79,
+      0x08, 0x07,
+        0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72
+};
+
+BOOST_AUTO_TEST_CASE(Constructor)
+{
+  SignatureInfo info;
+  BOOST_CHECK_EQUAL(info.getSignatureType(), -1);
+  BOOST_CHECK_EQUAL(info.hasKeyLocator(), false);
+  BOOST_CHECK_THROW(info.getKeyLocator(), SignatureInfo::Error);
+
+  SignatureInfo sha256Info(Tlv::DigestSha256);
+  BOOST_CHECK_EQUAL(sha256Info.getSignatureType(), Tlv::DigestSha256);
+  BOOST_CHECK_EQUAL(sha256Info.hasKeyLocator(), false);
+  BOOST_CHECK_THROW(sha256Info.getKeyLocator(), SignatureInfo::Error);
+
+  KeyLocator keyLocator("/test/key/locator");
+  SignatureInfo sha256RsaInfo(Tlv::SignatureSha256WithRsa, keyLocator);
+  BOOST_CHECK_EQUAL(sha256RsaInfo.getSignatureType(), Tlv::SignatureSha256WithRsa);
+  BOOST_CHECK_EQUAL(sha256RsaInfo.hasKeyLocator(), true);
+  BOOST_CHECK_NO_THROW(sha256RsaInfo.getKeyLocator());
+  BOOST_CHECK_EQUAL(sha256RsaInfo.getKeyLocator().getName(), Name("/test/key/locator"));
+
+  const Block& encoded = sha256RsaInfo.wireEncode();
+  Block sigInfoBlock(sigInfoRsa, sizeof(sigInfoRsa));
+
+  BOOST_CHECK_EQUAL_COLLECTIONS(sigInfoBlock.wire(),
+                                sigInfoBlock.wire() + sigInfoBlock.size(),
+                                encoded.wire(),
+                                encoded.wire() + encoded.size());
+
+  sha256RsaInfo = SignatureInfo(sigInfoBlock);
+  BOOST_CHECK_EQUAL(sha256RsaInfo.getSignatureType(), Tlv::SignatureSha256WithRsa);
+  BOOST_CHECK_EQUAL(sha256RsaInfo.hasKeyLocator(), true);
+  BOOST_CHECK_NO_THROW(sha256RsaInfo.getKeyLocator());
+  BOOST_CHECK_EQUAL(sha256RsaInfo.getKeyLocator().getName(), Name("/test/key/locator"));
+}
+
+BOOST_AUTO_TEST_CASE(ConstructorError)
+{
+  const uint8_t error1[] = {
+    0x15, 0x1b, // Wrong SignatureInfo (0x16, 0x1b)
+      0x1b, 0x01, // SignatureType
+        0x01, // Sha256WithRsa
+      0x1c, 0x16, // KeyLocator
+        0x07, 0x14, // Name
+          0x08, 0x04,
+            0x74, 0x65, 0x73, 0x74,
+          0x08, 0x03,
+            0x6b, 0x65, 0x79,
+          0x08, 0x07,
+            0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72
+  };
+  Block errorBlock1(error1, sizeof(error1));
+  BOOST_CHECK_THROW(SignatureInfo info(errorBlock1), Tlv::Error);
+
+  const uint8_t error2[] = {
+    0x16, 0x01, // SignatureInfo
+      0x01 // Wrong SignatureInfo value
+  };
+  Block errorBlock2(error2, sizeof(error2));
+  BOOST_CHECK_THROW(SignatureInfo info(errorBlock2), Tlv::Error);
+
+  const uint8_t error3[] = {
+    0x16, 0x01, // SignatureInfo
+      0x1a, 0x01, // Wrong SignatureType (0x1b, 0x1b)
+        0x01, // Sha256WithRsa
+      0x1c, 0x16, // KeyLocator
+        0x07, 0x14, // Name
+          0x08, 0x04,
+            0x74, 0x65, 0x73, 0x74,
+          0x08, 0x03,
+            0x6b, 0x65, 0x79,
+          0x08, 0x07,
+            0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72
+  };
+  Block errorBlock3(error3, sizeof(error3));
+  BOOST_CHECK_THROW(SignatureInfo info(errorBlock3), Tlv::Error);
+
+  const uint8_t error4[] = {
+    0x16, 0x00 // Empty SignatureInfo
+  };
+  Block errorBlock4(error4, sizeof(error4));
+  BOOST_CHECK_THROW(SignatureInfo info(errorBlock4), Tlv::Error);
+
+}
+
+BOOST_AUTO_TEST_CASE(SetterGetter)
+{
+  SignatureInfo info;
+  BOOST_CHECK_EQUAL(info.getSignatureType(), -1);
+  BOOST_CHECK_EQUAL(info.hasKeyLocator(), false);
+  BOOST_CHECK_THROW(info.getKeyLocator(), SignatureInfo::Error);
+
+  info.setSignatureType(Tlv::SignatureSha256WithRsa);
+  BOOST_CHECK_EQUAL(info.getSignatureType(), Tlv::SignatureSha256WithRsa);
+  BOOST_CHECK_EQUAL(info.hasKeyLocator(), false);
+
+  KeyLocator keyLocator("/test/key/locator");
+  info.setKeyLocator(keyLocator);
+  BOOST_CHECK_EQUAL(info.hasKeyLocator(), true);
+  BOOST_CHECK_NO_THROW(info.getKeyLocator());
+  BOOST_CHECK_EQUAL(info.getKeyLocator().getName(), Name("/test/key/locator"));
+
+  const Block& encoded = info.wireEncode();
+  Block sigInfoBlock(sigInfoRsa, sizeof(sigInfoRsa));
+
+  BOOST_CHECK_EQUAL_COLLECTIONS(sigInfoBlock.wire(),
+                                sigInfoBlock.wire() + sigInfoBlock.size(),
+                                encoded.wire(),
+                                encoded.wire() + encoded.size());
+}
+
+BOOST_AUTO_TEST_CASE(OtherTlvs)
+{
+  SignatureInfo info;
+  BOOST_CHECK_EQUAL(info.getSignatureType(), -1);
+  BOOST_CHECK_EQUAL(info.hasKeyLocator(), false);
+  BOOST_CHECK_THROW(info.getKeyLocator(), SignatureInfo::Error);
+
+  const uint8_t tlv1[] = {
+    0x81, // T
+    0x01, // L
+    0x01, // V
+  };
+  Block block1(tlv1, sizeof(tlv1));
+
+  info.appendTypeSpecificTlv(block1);
+  BOOST_CHECK_THROW(info.getTypeSpecificTlv(0x82), SignatureInfo::Error);
+  BOOST_REQUIRE_NO_THROW(info.getTypeSpecificTlv(0x81));
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace ndn
