diff --git a/src/security/cryptopp.hpp b/src/security/cryptopp.hpp
index 3aac257..d7342cf 100644
--- a/src/security/cryptopp.hpp
+++ b/src/security/cryptopp.hpp
@@ -38,5 +38,8 @@
 #include <cryptopp/pwdbased.h>
 #include <cryptopp/rsa.h>
 #include <cryptopp/sha.h>
+#include <cryptopp/eccrypto.h>
+#include <cryptopp/oids.h>
+#include <cryptopp/dsa.h>
 
 #endif // NDN_SECURITY_CRYPTOPP_HPP
diff --git a/src/security/key-chain.cpp b/src/security/key-chain.cpp
index a04e58b..69d5b48 100644
--- a/src/security/key-chain.cpp
+++ b/src/security/key-chain.cpp
@@ -131,6 +131,14 @@
   try
     {
       keyName = m_pib->getDefaultKeyNameForIdentity(identityName);
+
+      shared_ptr<PublicKey> key = m_pib->getPublicKey(keyName);
+
+      if (key->getKeyType() != params.getKeyType())
+        {
+          keyName = generateKeyPair(identityName, true, params);
+          m_pib->setDefaultKeyNameForIdentity(keyName);
+        }
     }
   catch (SecPublicInfo::Error& e)
     {
@@ -154,7 +162,7 @@
 }
 
 Name
-KeyChain::generateRsaKeyPairAsDefault(const Name& identityName, bool isKsk, int keySize)
+KeyChain::generateRsaKeyPairAsDefault(const Name& identityName, bool isKsk, uint32_t keySize)
 {
   RsaKeyParams params(keySize);
 
@@ -165,6 +173,19 @@
   return keyName;
 }
 
+Name
+KeyChain::generateEcdsaKeyPairAsDefault(const Name& identityName, bool isKsk, uint32_t keySize)
+{
+  EcdsaKeyParams params(keySize);
+
+  Name keyName = generateKeyPair(identityName, isKsk, params);
+
+  m_pib->setDefaultKeyNameForIdentity(keyName);
+
+  return keyName;
+}
+
+
 shared_ptr<IdentityCertificate>
 KeyChain::prepareUnsignedIdentityCertificate(const Name& keyName,
   const Name& signingIdentity,
@@ -266,19 +287,21 @@
 Signature
 KeyChain::sign(const uint8_t* buffer, size_t bufferLength, const Name& certificateName)
 {
-  if (!m_pib->doesCertificateExist(certificateName))
-    throw SecPublicInfo::Error("Requested certificate [" +
-                               certificateName.toUri() + "] doesn't exist");
+  shared_ptr<IdentityCertificate> certificate = m_pib->getCertificate(certificateName);
 
-  Name keyName = IdentityCertificate::certificateNameToPublicKeyName(certificateName);
+  shared_ptr<SignatureWithPublicKey> sig =
+    determineSignatureWithPublicKey(certificate->getPublicKeyInfo().getKeyType());
 
-  SignatureSha256WithRsa signature;
-  // implicit conversion should take care
-  signature.setKeyLocator(certificateName.getPrefix(-1));
+  if (!static_cast<bool>(sig))
+    throw SecTpm::Error("unknown key type");
 
-  // For temporary usage, we support RSA + SHA256 only, but will support more.
-  signature.setValue(m_tpm->signInTpm(buffer, bufferLength, keyName, DIGEST_ALGORITHM_SHA256));
-  return signature;
+  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(),
+                                 DIGEST_ALGORITHM_SHA256));
+
+  return *sig;
 }
 
 shared_ptr<IdentityCertificate>
@@ -317,11 +340,14 @@
   if (!m_tpm->doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE))
     throw SecTpm::Error("Private key does not exist");
 
-  SignatureSha256WithRsa signature;
-  signature.setKeyLocator(cert.getName().getPrefix(-1)); // implicit conversion should take care
+  shared_ptr<SignatureWithPublicKey> sig =
+    determineSignatureWithPublicKey(cert.getPublicKeyInfo().getKeyType());
 
-  // For temporary usage, we support RSA + SHA256 only, but will support more.
-  signPacketWrapper(cert, signature, keyName, DIGEST_ALGORITHM_SHA256);
+  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);
 }
 
 shared_ptr<SecuredBag>
@@ -384,6 +410,32 @@
   m_pib->addCertificateAsIdentityDefault(securedBag.getCertificate());
 }
 
+shared_ptr<SignatureWithPublicKey>
+KeyChain::determineSignatureWithPublicKey(KeyType keyType, DigestAlgorithm digestAlgorithm)
+{
+  switch (keyType)
+    {
+    case KEY_TYPE_RSA:
+      {
+        // For temporary usage, we support SHA256 only, but will support more.
+        if (digestAlgorithm != DIGEST_ALGORITHM_SHA256)
+          return shared_ptr<SignatureWithPublicKey>();
+
+        return make_shared<SignatureSha256WithRsa>();
+      }
+    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 make_shared<SignatureSha256WithEcdsa>();
+      }
+    default:
+      return shared_ptr<SignatureWithPublicKey>();
+    }
+}
+
 void
 KeyChain::setDefaultCertificateInternal()
 {
@@ -422,7 +474,7 @@
 }
 
 void
-KeyChain::signPacketWrapper(Data& data, const SignatureSha256WithRsa& signature,
+KeyChain::signPacketWrapper(Data& data, const Signature& signature,
                             const Name& keyName, DigestAlgorithm digestAlgorithm)
 {
   data.setSignature(signature);
@@ -436,7 +488,7 @@
 }
 
 void
-KeyChain::signPacketWrapper(Interest& interest, const SignatureSha256WithRsa& signature,
+KeyChain::signPacketWrapper(Interest& interest, const Signature& signature,
                             const Name& keyName, DigestAlgorithm digestAlgorithm)
 {
   time::milliseconds timestamp = time::toUnixTimestamp(time::system_clock::now());
diff --git a/src/security/key-chain.hpp b/src/security/key-chain.hpp
index 44ff1de..b6b9bbf 100644
--- a/src/security/key-chain.hpp
+++ b/src/security/key-chain.hpp
@@ -29,6 +29,7 @@
 #include "key-params.hpp"
 #include "secured-bag.hpp"
 #include "signature-sha256-with-rsa.hpp"
+#include "signature-sha256-with-ecdsa.hpp"
 #include "digest-sha256.hpp"
 
 #include "../interest.hpp"
@@ -103,8 +104,10 @@
    * @return The generated key name.
    */
   inline Name
-  generateRsaKeyPair(const Name& identityName, bool isKsk = false, int keySize = 2048);
+  generateRsaKeyPair(const Name& identityName, bool isKsk = false, uint32_t keySize = 2048);
 
+  inline Name
+  generateEcdsaKeyPair(const Name& identityName, bool isKsk = false, uint32_t keySize = 256);
   /**
    * @brief Generate a pair of RSA keys for the specified identity and set it as default key for
    *        the identity.
@@ -115,7 +118,11 @@
    * @return The generated key name.
    */
   Name
-  generateRsaKeyPairAsDefault(const Name& identityName, bool isKsk = false, int keySize = 2048);
+  generateRsaKeyPairAsDefault(const Name& identityName, bool isKsk = false,
+                              uint32_t keySize = 2048);
+
+  Name
+  generateEcdsaKeyPairAsDefault(const Name& identityName, bool isKsk, uint32_t keySize = 256);
 
   /**
    * @brief prepare an unsigned identity certificate
@@ -635,6 +642,15 @@
 
 private:
   /**
+   * @brief Determine signature type
+   *
+   * An empty pointer will be returned if there is no valid signature.
+   */
+  shared_ptr<SignatureWithPublicKey>
+  determineSignatureWithPublicKey(KeyType keyType,
+                                  DigestAlgorithm digestAlgorithm = DIGEST_ALGORITHM_SHA256);
+
+  /**
    * @brief Set default certificate if it is not initialized
    */
   void
@@ -672,7 +688,7 @@
    * @throws Tpm::Error
    */
   void
-  signPacketWrapper(Data& data, const SignatureSha256WithRsa& signature,
+  signPacketWrapper(Data& data, const Signature& signature,
                     const Name& keyName, DigestAlgorithm digestAlgorithm);
 
   /**
@@ -685,7 +701,7 @@
    * @throws Tpm::Error
    */
   void
-  signPacketWrapper(Interest& interest, const SignatureSha256WithRsa& signature,
+  signPacketWrapper(Interest& interest, const Signature& signature,
                     const Name& keyName, DigestAlgorithm digestAlgorithm);
 
 
@@ -705,12 +721,19 @@
 }
 
 inline Name
-KeyChain::generateRsaKeyPair(const Name& identityName, bool isKsk, int keySize)
+KeyChain::generateRsaKeyPair(const Name& identityName, bool isKsk, uint32_t keySize)
 {
   RsaKeyParams params(keySize);
   return generateKeyPair(identityName, isKsk, params);
 }
 
+inline Name
+KeyChain::generateEcdsaKeyPair(const Name& identityName, bool isKsk, uint32_t keySize)
+{
+  EcdsaKeyParams params(keySize);
+  return generateKeyPair(identityName, isKsk, params);
+}
+
 template<typename T>
 void
 KeyChain::sign(T& packet)
@@ -725,18 +748,8 @@
 void
 KeyChain::sign(T& packet, const Name& certificateName)
 {
-  if (!m_pib->doesCertificateExist(certificateName))
-    throw SecPublicInfo::Error("Requested certificate [" +
-                               certificateName.toUri() + "] doesn't exist");
-
-  SignatureSha256WithRsa signature;
-  // implicit conversion should take care
-  signature.setKeyLocator(certificateName.getPrefix(-1));
-
-  // For temporary usage, we support RSA + SHA256 only, but will support more.
-  signPacketWrapper(packet, signature,
-                    IdentityCertificate::certificateNameToPublicKeyName(certificateName),
-                    DIGEST_ALGORITHM_SHA256);
+  shared_ptr<IdentityCertificate> certificate = m_pib->getCertificate(certificateName);
+  sign(packet, *certificate);
 }
 
 template<typename T>
@@ -764,11 +777,35 @@
 void
 KeyChain::sign(T& packet, const IdentityCertificate& certificate)
 {
-  SignatureSha256WithRsa signature;
-  signature.setKeyLocator(certificate.getName().getPrefix(-1));
+  switch (certificate.getPublicKeyInfo().getKeyType())
+    {
+    case KEY_TYPE_RSA:
+      {
+        // For temporary usage, we support SHA256 only, but will support more.
+        SignatureSha256WithRsa signature;
+        // implicit conversion should take care
+        signature.setKeyLocator(certificate.getName().getPrefix(-1));
 
-  // For temporary usage, we support RSA + SHA256 only, but will support more.
-  signPacketWrapper(packet, signature, certificate.getPublicKeyName(), DIGEST_ALGORITHM_SHA256);
+        signPacketWrapper(packet, signature,
+                          certificate.getPublicKeyName(),
+                          DIGEST_ALGORITHM_SHA256);
+        return;
+      }
+    case KEY_TYPE_ECDSA:
+      {
+        // For temporary usage, we support SHA256 only, but will support more.
+        SignatureSha256WithEcdsa signature;
+        // implicit conversion should take care
+        signature.setKeyLocator(certificate.getName().getPrefix(-1));
+
+        signPacketWrapper(packet, signature,
+                          certificate.getPublicKeyName(),
+                          DIGEST_ALGORITHM_SHA256);
+        return;
+      }
+    default:
+      throw SecPublicInfo::Error("unknown key type!");
+    }
 }
 
 }
diff --git a/src/security/sec-public-info-sqlite3.cpp b/src/security/sec-public-info-sqlite3.cpp
index a690bef..7e86773 100644
--- a/src/security/sec-public-info-sqlite3.cpp
+++ b/src/security/sec-public-info-sqlite3.cpp
@@ -27,6 +27,7 @@
 #include "sec-public-info-sqlite3.hpp"
 #include "identity-certificate.hpp"
 #include "signature-sha256-with-rsa.hpp"
+#include "signature-sha256-with-ecdsa.hpp"
 #include "../data.hpp"
 
 #include <sqlite3.h>
@@ -479,10 +480,27 @@
     {
       // this will throw an exception if the signature is not the standard one
       // or there is no key locator present
-      SignatureSha256WithRsa signature(certificate.getSignature());
-      std::string signerName = signature.getKeyLocator().getName().toUri();
+      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);
+            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;
+        }
     }
   catch (std::runtime_error& e)
     {
diff --git a/src/security/sec-tpm-file.cpp b/src/security/sec-tpm-file.cpp
index 6634f68..03ce634 100644
--- a/src/security/sec-tpm-file.cpp
+++ b/src/security/sec-tpm-file.cpp
@@ -142,6 +142,51 @@
             chmod(publicKeyFileName.c_str(), 0000444);
             return;
           }
+        case KEY_TYPE_ECDSA:
+          {
+            using namespace CryptoPP;
+
+            const EcdsaKeyParams& ecdsaParams = static_cast<const EcdsaKeyParams&>(params);
+
+            OID curveName;
+            switch (ecdsaParams.getKeySize())
+              {
+              case 256:
+                curveName = ASN1::secp256r1();
+                break;
+              case 384:
+                curveName = ASN1::secp384r1();
+                break;
+              default:
+                curveName = ASN1::secp256r1();
+              }
+
+            AutoSeededRandomPool rng;
+
+            ECDSA<ECP, SHA256>::PrivateKey privateKey;
+            DL_GroupParameters_EC<ECP> cryptoParams(curveName);
+            cryptoParams.SetEncodeAsOID(true);
+            privateKey.Initialize(rng, cryptoParams);
+
+            ECDSA<ECP, SHA256>::PublicKey publicKey;
+            privateKey.MakePublicKey(publicKey);
+            publicKey.AccessGroupParameters().SetEncodeAsOID(true);
+
+            string privateKeyFileName = keyFileName + ".pri";
+            Base64Encoder privateKeySink(new FileSink(privateKeyFileName.c_str()));
+            privateKey.DEREncode(privateKeySink);
+            privateKeySink.MessageEnd();
+
+            string publicKeyFileName = keyFileName + ".pub";
+            Base64Encoder publicKeySink(new FileSink(publicKeyFileName.c_str()));
+            publicKey.Save(publicKeySink);
+            publicKeySink.MessageEnd();
+
+            /*set file permission*/
+            chmod(privateKeyFileName.c_str(), 0000400);
+            chmod(publicKeyFileName.c_str(), 0000444);
+            return;
+          }
         default:
           throw Error("Unsupported key type!");
         }
@@ -258,31 +303,79 @@
       using namespace CryptoPP;
       AutoSeededRandomPool rng;
 
-      //Read private key
-      ByteQueue bytes;
-      FileSource file(m_impl->transformName(keyURI, ".pri").string().c_str(),
-                      true, new Base64Decoder);
-      file.TransferTo(bytes);
-      bytes.MessageEnd();
-      RSA::PrivateKey privateKey;
-      privateKey.Load(bytes);
+      //Read public key
+      shared_ptr<PublicKey> pubkeyPtr;
+      pubkeyPtr = getPublicKeyFromTpm(keyName);
 
-      //Sign message
-      switch (digestAlgorithm)
+      switch (pubkeyPtr->getKeyType())
         {
-        case DIGEST_ALGORITHM_SHA256:
+          case KEY_TYPE_RSA:
+            {
+              //Read private key
+              ByteQueue bytes;
+              FileSource file(m_impl->transformName(keyURI, ".pri").string().c_str(),
+                              true, new Base64Decoder);
+              file.TransferTo(bytes);
+              bytes.MessageEnd();
+              RSA::PrivateKey privateKey;
+              privateKey.Load(bytes);
+
+              //Sign message
+              switch (digestAlgorithm)
+                {
+                case DIGEST_ALGORITHM_SHA256:
+                  {
+                    RSASS<PKCS1v15, SHA256>::Signer signer(privateKey);
+
+                    OBufferStream os;
+                    StringSource(data, dataLength,
+                                 true,
+                                 new SignerFilter(rng, signer, new FileSink(os)));
+
+                    return Block(Tlv::SignatureValue, os.buf());
+                  }
+                default:
+                  throw Error("Unsupported digest algorithm!");
+                }
+            }
+        case KEY_TYPE_ECDSA:
           {
-            RSASS<PKCS1v15, SHA256>::Signer signer(privateKey);
+            //Read private key
+            ByteQueue bytes;
+            FileSource file(m_impl->transformName(keyURI, ".pri").string().c_str(),
+                            true, new Base64Decoder);
+            file.TransferTo(bytes);
+            bytes.MessageEnd();
 
-            OBufferStream os;
-            StringSource(data, dataLength,
-                         true,
-                         new SignerFilter(rng, signer, new FileSink(os)));
+            //Sign message
+            switch (digestAlgorithm)
+              {
+              case DIGEST_ALGORITHM_SHA256:
+                {
+                  ECDSA<ECP, SHA256>::PrivateKey privateKey;
+                  privateKey.Load(bytes);
+                  ECDSA<ECP, SHA256>::Signer signer(privateKey);
 
-            return Block(Tlv::SignatureValue, os.buf());
+                  OBufferStream os;
+                  StringSource(data, dataLength,
+                               true,
+                               new SignerFilter(rng, signer, new FileSink(os)));
+
+                  uint8_t buf[200];
+                  size_t bufSize = DSAConvertSignatureFormat(buf, 200, DSA_DER,
+                                                             os.buf()->buf(), os.buf()->size(),
+                                                             DSA_P1363);
+
+                  shared_ptr<Buffer> sigBuffer = make_shared<Buffer>(buf, bufSize);
+
+                  return Block(Tlv::SignatureValue, sigBuffer);
+                }
+              default:
+                throw Error("Unsupported digest algorithm!");
+              }
           }
         default:
-          throw Error("Unsupported digest algorithm!");
+          throw Error("Unsupported key type!");
         }
     }
   catch (CryptoPP::Exception& e)
diff --git a/src/security/sec-tpm-osx.cpp b/src/security/sec-tpm-osx.cpp
index 031632d..f3a782b 100644
--- a/src/security/sec-tpm-osx.cpp
+++ b/src/security/sec-tpm-osx.cpp
@@ -396,6 +396,12 @@
         keySize = rsaParams.getKeySize();
         break;
       }
+    case KEY_TYPE_ECDSA:
+      {
+        const EcdsaKeyParams& ecdsaParams = static_cast<const EcdsaKeyParams&>(params);
+        keySize = ecdsaParams.getKeySize();
+        break;
+      }
     default:
       throw Error("Fail to create a key pair: Unsupported key type");
     }
@@ -1039,6 +1045,8 @@
   switch (keyType) {
   case KEY_TYPE_RSA:
     return kSecAttrKeyTypeRSA;
+  case KEY_TYPE_ECDSA:
+    return kSecAttrKeyTypeECDSA;
   default:
     return 0;
   }
diff --git a/src/security/validator.cpp b/src/security/validator.cpp
index 29a4801..df7b0e6 100644
--- a/src/security/validator.cpp
+++ b/src/security/validator.cpp
@@ -29,10 +29,11 @@
 
 #include "cryptopp.hpp"
 
-using namespace std;
-
 namespace ndn {
 
+static OID SECP256R1("1.2.840.10045.3.1.7");
+static OID SECP384R1("1.3.132.0.34");
+
 Validator::Validator()
   : m_hasFace(false)
   , m_face(*static_cast<Face*>(0))
@@ -51,7 +52,7 @@
                     const OnInterestValidationFailed& onValidationFailed,
                     int nSteps)
 {
-  vector<shared_ptr<ValidationRequest> > nextSteps;
+  std::vector<shared_ptr<ValidationRequest> > nextSteps;
   checkPolicy(interest, nSteps, onValidated, onValidationFailed, nextSteps);
 
   if (!nextSteps.empty())
@@ -63,7 +64,7 @@
           return;
         }
 
-      vector<shared_ptr<ValidationRequest> >::const_iterator it = nextSteps.begin();
+      std::vector<shared_ptr<ValidationRequest> >::const_iterator it = nextSteps.begin();
       OnFailure onFailure = bind(onValidationFailed, interest.shared_from_this(), _1);
       for (; it != nextSteps.end(); it++)
         m_face.expressInterest((*it)->m_interest,
@@ -87,7 +88,7 @@
                     const OnDataValidationFailed& onValidationFailed,
                     int nSteps)
 {
-  vector<shared_ptr<ValidationRequest> > nextSteps;
+  std::vector<shared_ptr<ValidationRequest> > nextSteps;
   checkPolicy(data, nSteps, onValidated, onValidationFailed, nextSteps);
 
   if (!nextSteps.empty())
@@ -98,7 +99,7 @@
                              "Require more information to validate the data!");
         }
 
-      vector<shared_ptr<ValidationRequest> >::const_iterator it = nextSteps.begin();
+      std::vector<shared_ptr<ValidationRequest> >::const_iterator it = nextSteps.begin();
       OnFailure onFailure = bind(onValidationFailed, data.shared_from_this(), _1);
       for (; it != nextSteps.end(); it++)
         m_face.expressInterest((*it)->m_interest,
@@ -147,13 +148,25 @@
     {
       switch (data.getSignature().getType())
         {
-        case Signature::Sha256WithRsa:
+        case Tlv::SignatureSha256WithRsa:
           {
             SignatureSha256WithRsa sigSha256Rsa(data.getSignature());
-            return verifySignature(data, sigSha256Rsa, key);
+            return verifySignature(data.wireEncode().value(),
+                                   data.wireEncode().value_size() -
+                                   data.getSignature().getValue().size(),
+                                   sigSha256Rsa, key);
           }
+        case Tlv::SignatureSha256WithEcdsa:
+          {
+            SignatureSha256WithEcdsa sigSha256Ecdsa(data.getSignature());
+            return verifySignature(data.wireEncode().value(),
+                                   data.wireEncode().value_size() -
+                                   data.getSignature().getValue().size(),
+                                   sigSha256Ecdsa, key);
+           }
         default:
           {
+            // Unsupported sig type
             return false;
           }
         }
@@ -182,7 +195,7 @@
 
       switch (sig.getType())
         {
-        case Signature::Sha256WithRsa:
+        case Tlv::SignatureSha256WithRsa:
           {
             SignatureSha256WithRsa sigSha256Rsa(sig);
 
@@ -190,8 +203,17 @@
                                    nameBlock.value_size() - interestName[-1].size(),
                                    sigSha256Rsa, key);
           }
+        case Tlv::SignatureSha256WithEcdsa:
+          {
+            SignatureSha256WithEcdsa sigSha256Ecdsa(sig);
+
+            return verifySignature(nameBlock.value(),
+                                   nameBlock.value_size() - interestName[-1].size(),
+                                   sigSha256Ecdsa, key);
+          }
         default:
           {
+            // Unsupported sig type
             return false;
           }
         }
@@ -208,50 +230,94 @@
 }
 
 bool
-Validator::verifySignature(const Buffer& data, const Signature& sig, const PublicKey& key)
-{
-  try
-    {
-      switch (sig.getType())
-        {
-        case Signature::Sha256WithRsa:
-          {
-            SignatureSha256WithRsa sigSha256Rsa(sig);
-            return verifySignature(data, sigSha256Rsa, key);
-          }
-        default:
-          {
-            return false;
-          }
-        }
-    }
-  catch (Signature::Error& e)
-    {
-      return false;
-    }
-  return false;
-}
-
-bool
 Validator::verifySignature(const uint8_t* buf,
                            const size_t size,
-                           const SignatureSha256WithRsa& sig,
+                           const SignatureWithPublicKey& sig,
                            const PublicKey& key)
 {
   try
     {
       using namespace CryptoPP;
 
-      RSA::PublicKey publicKey;
-      ByteQueue queue;
+      switch (sig.getType())
+        {
+        case Tlv::SignatureSha256WithRsa:
+          {
+            if (key.getKeyType() != KEY_TYPE_RSA)
+              return false;
 
-      queue.Put(reinterpret_cast<const byte*>(key.get().buf()), key.get().size());
-      publicKey.Load(queue);
+            RSA::PublicKey publicKey;
+            ByteQueue queue;
 
-      RSASS<PKCS1v15, SHA256>::Verifier verifier(publicKey);
-      return verifier.VerifyMessage(buf, size,
-                                    sig.getValue().value(),
-                                    sig.getValue().value_size());
+            queue.Put(reinterpret_cast<const byte*>(key.get().buf()), key.get().size());
+            publicKey.Load(queue);
+
+            RSASS<PKCS1v15, SHA256>::Verifier verifier(publicKey);
+            return verifier.VerifyMessage(buf, size,
+                                          sig.getValue().value(), sig.getValue().value_size());
+          }
+        case Tlv::SignatureSha256WithEcdsa:
+          {
+            if (key.getKeyType() != KEY_TYPE_ECDSA)
+              return false;
+
+            ECDSA<ECP, SHA256>::PublicKey publicKey;
+            ByteQueue queue;
+
+            queue.Put(reinterpret_cast<const byte*>(key.get().buf()), key.get().size());
+            publicKey.Load(queue);
+
+            ECDSA<ECP, SHA256>::Verifier verifier(publicKey);
+
+            uint32_t length = 0;
+            StringSource src(key.get().buf(), key.get().size(), true);
+            BERSequenceDecoder subjectPublicKeyInfo(src);
+            {
+              BERSequenceDecoder algorithmInfo(subjectPublicKeyInfo);
+              {
+                OID algorithm;
+                algorithm.decode(algorithmInfo);
+
+                OID curveId;
+                curveId.decode(algorithmInfo);
+
+                if (curveId == SECP256R1)
+                  length = 256;
+                else if (curveId == SECP384R1)
+                  length = 384;
+                else
+                  return false;
+              }
+            }
+
+            switch (length)
+              {
+              case 256:
+                {
+                  uint8_t buffer[64];
+                  size_t usedSize = DSAConvertSignatureFormat(buffer, 64, DSA_P1363,
+                                                              sig.getValue().value(),
+                                                              sig.getValue().value_size(),
+                                                              DSA_DER);
+                  return verifier.VerifyMessage(buf, size, buffer, usedSize);
+                }
+              case 384:
+                {
+                  uint8_t buffer[96];
+                  size_t usedSize = DSAConvertSignatureFormat(buffer, 96, DSA_P1363,
+                                                              sig.getValue().value(),
+                                                              sig.getValue().value_size(),
+                                                              DSA_DER);
+                  return verifier.VerifyMessage(buf, size, buffer, usedSize);
+                }
+              default:
+                return false;
+              }
+          }
+        default:
+          // Unsupported sig type
+          return false;
+        }
     }
   catch (CryptoPP::Exception& e)
     {
diff --git a/src/security/validator.hpp b/src/security/validator.hpp
index 5d66367..87c2bfd 100644
--- a/src/security/validator.hpp
+++ b/src/security/validator.hpp
@@ -31,6 +31,7 @@
 #include "../face.hpp"
 #include "public-key.hpp"
 #include "signature-sha256-with-rsa.hpp"
+#include "signature-sha256-with-ecdsa.hpp"
 #include "digest-sha256.hpp"
 #include "validation-request.hpp"
 
@@ -106,12 +107,15 @@
 
   /// @brief Verify the blob using the publicKey against the signature.
   static bool
-  verifySignature(const Buffer& blob, const Signature& sig, const PublicKey& publicKey);
+  verifySignature(const Buffer& blob, const SignatureWithPublicKey& sig, const PublicKey& publicKey)
+  {
+    return verifySignature(blob.buf(), blob.size(), sig, publicKey);
+  }
 
   /// @brief Verify the data using the publicKey against the SHA256-RSA signature.
   static bool
   verifySignature(const Data& data,
-                  const SignatureSha256WithRsa& sig,
+                  const SignatureWithPublicKey& sig,
                   const PublicKey& publicKey)
   {
     return verifySignature(data.wireEncode().value(),
@@ -125,7 +129,7 @@
    */
   static bool
   verifySignature(const Interest& interest,
-                  const SignatureSha256WithRsa& sig,
+                  const SignatureWithPublicKey& sig,
                   const PublicKey& publicKey)
   {
     if (interest.getName().size() < 2)
@@ -140,18 +144,9 @@
 
   /// @brief Verify the blob using the publicKey against the SHA256-RSA signature.
   static bool
-  verifySignature(const Buffer& blob,
-                  const SignatureSha256WithRsa& sig,
-                  const PublicKey& publicKey)
-  {
-    return verifySignature(blob.buf(), blob.size(), sig, publicKey);
-  }
-
-  /// @brief Verify the blob using the publicKey against the SHA256-RSA signature.
-  static bool
   verifySignature(const uint8_t* buf,
                   const size_t size,
-                  const SignatureSha256WithRsa& sig,
+                  const SignatureWithPublicKey& sig,
                   const PublicKey& publicKey);
 
 
