security: Support ECDSA verification in all related classes.
This commit also addresses some old issues, such as "using namespace std".
Change-Id: I62b8ff97fb2b6f6cfe04b0ad5866bc0797e6e43b
Refs: #1660
diff --git a/src/security/validator-regex.cpp b/src/security/validator-regex.cpp
index 0ae4da4..e998d8c 100644
--- a/src/security/validator-regex.cpp
+++ b/src/security/validator-regex.cpp
@@ -27,8 +27,6 @@
#include "signature-sha256-with-rsa.hpp"
#include "certificate-cache-ttl.hpp"
-using namespace std;
-
namespace ndn {
const shared_ptr<CertificateCache> ValidatorRegex::DEFAULT_CERTIFICATE_CACHE;
@@ -75,7 +73,7 @@
void
ValidatorRegex::onCertificateValidationFailed(const shared_ptr<const Data>& signCertificate,
- const string& failureInfo,
+ const std::string& failureInfo,
const shared_ptr<const Data>& data,
const OnDataValidationFailed& onValidationFailed)
{
@@ -87,7 +85,7 @@
int nSteps,
const OnDataValidated& onValidated,
const OnDataValidationFailed& onValidationFailed,
- vector<shared_ptr<ValidationRequest> >& nextSteps)
+ std::vector<shared_ptr<ValidationRequest> >& nextSteps)
{
if (m_stepLimit == nSteps)
return onValidationFailed(data.shared_from_this(),
@@ -110,7 +108,7 @@
{
try
{
- SignatureSha256WithRsa sig(data.getSignature());
+ SignatureWithPublicKey sig(data.getSignature());
Name keyLocatorName = sig.getKeyLocator().getName();
shared_ptr<const Certificate> trustedCert;
@@ -153,12 +151,17 @@
return;
}
}
- catch (SignatureSha256WithRsa::Error& e)
+ catch (SignatureWithPublicKey::Error& e)
{
return onValidationFailed(data.shared_from_this(),
- "Not SignatureSha256WithRsa signature: " +
+ "Require sub-class of SignatureWithPublicKey: " +
data.getName().toUri());
}
+ catch (Tlv::Error& e)
+ {
+ return onValidationFailed(data.shared_from_this(),
+ "Cannot decode signature");
+ }
catch (KeyLocator::Error& e)
{
return onValidationFailed(data.shared_from_this(),