security: Add a set of signature verification helpers
This commit introduces a set of security::v2::verifySignature and
security::v2::verifyDigest overloads to simplify signature verification
operations.
This commit also updates operator== of util::Digest class to
constant-time `CRYPTO_memcmp` comparison to mitigate potential timing
attacks.
Change-Id: I30c5a315b612062a96b289c4a5292dd6eb3d410f
diff --git a/tests/unit-tests/security/signature-sha256-with-rsa.t.cpp b/tests/unit-tests/security/signature-sha256-with-rsa.t.cpp
index c6397ac..510bb1f 100644
--- a/tests/unit-tests/security/signature-sha256-with-rsa.t.cpp
+++ b/tests/unit-tests/security/signature-sha256-with-rsa.t.cpp
@@ -20,11 +20,11 @@
*/
#include "security/signature-sha256-with-rsa.hpp"
+#include "security/verification-helpers.hpp"
#include "util/scheduler.hpp"
#include "boost-test.hpp"
#include "../identity-management-time-fixture.hpp"
-#include "v2/validator.hpp"
namespace ndn {
namespace security {
@@ -122,7 +122,7 @@
Data testData2;
testData2.wireDecode(dataBlock);
- BOOST_CHECK(v2::Validator::verifySignature(testData2, identity.getDefaultKey().getPublicKey()));
+ BOOST_CHECK(verifySignature(testData2, identity.getDefaultKey()));
}
BOOST_AUTO_TEST_CASE(InterestSignature)
@@ -147,7 +147,7 @@
Interest interest2;
interest2.wireDecode(interestBlock);
- BOOST_CHECK(v2::Validator::verifySignature(interest2, identity.getDefaultKey().getPublicKey()));
+ BOOST_CHECK(verifySignature(interest2, identity.getDefaultKey()));
}
BOOST_AUTO_TEST_SUITE_END() // TestSignatureSha256WithRsa