security: remove redundant overloads of verifySignature() and verifyDigest()
Change-Id: I5fe14876acea04fe979ffe0872855f1b5bbede24
diff --git a/tests/unit/security/key-chain.t.cpp b/tests/unit/security/key-chain.t.cpp
index d3fb67e..1aa76b8 100644
--- a/tests/unit/security/key-chain.t.cpp
+++ b/tests/unit/security/key-chain.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2020 Regents of the University of California.
+ * Copyright (c) 2013-2021 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -526,7 +526,7 @@
bool
verify(const SigningInfo&) const
{
- return verifyDigest(this->packet, DigestAlgorithm::SHA256);
+ return verifySignature(this->packet, nullopt);
}
};
@@ -544,7 +544,9 @@
Sha256Signing<InterestV02Pkt>,
Sha256Signing<InterestV03Pkt>,
SigningWithNonDefaultIdentity<DataPkt>,
- SigningWithNonDefaultKey<DataPkt>
+ SigningWithNonDefaultIdentity<InterestV03Pkt>,
+ SigningWithNonDefaultKey<DataPkt>,
+ SigningWithNonDefaultKey<InterestV03Pkt>
>;
BOOST_FIXTURE_TEST_CASE_TEMPLATE(SigningInterface, T, SigningTests, T)
diff --git a/tests/unit/security/transform/signer-filter.t.cpp b/tests/unit/security/transform/signer-filter.t.cpp
index 4f3fa04..4f84582 100644
--- a/tests/unit/security/transform/signer-filter.t.cpp
+++ b/tests/unit/security/transform/signer-filter.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2019 Regents of the University of California.
+ * Copyright (c) 2013-2021 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -92,7 +92,7 @@
bufferSource(DATA, sizeof(DATA)) >> signerFilter(DigestAlgorithm::SHA256, sKey) >> streamSink(os2);
auto sig = os2.buf();
- BOOST_CHECK(verifySignature(DATA, sizeof(DATA), sig->data(), sig->size(), pubKey->data(), pubKey->size()));
+ BOOST_TEST(verifySignature({{DATA, sizeof(DATA)}}, sig->data(), sig->size(), pubKey->data(), pubKey->size()));
}
BOOST_AUTO_TEST_CASE(Ecdsa)
@@ -128,7 +128,7 @@
bufferSource(DATA, sizeof(DATA)) >> signerFilter(DigestAlgorithm::SHA256, sKey) >> streamSink(os2);
auto sig = os2.buf();
- BOOST_CHECK(verifySignature(DATA, sizeof(DATA), sig->data(), sig->size(), pubKey->data(), pubKey->size()));
+ BOOST_TEST(verifySignature({{DATA, sizeof(DATA)}}, sig->data(), sig->size(), pubKey->data(), pubKey->size()));
}
BOOST_AUTO_TEST_SUITE(Hmac)
diff --git a/tests/unit/security/verification-helpers.t.cpp b/tests/unit/security/verification-helpers.t.cpp
index 74ffbe0..f35f93f 100644
--- a/tests/unit/security/verification-helpers.t.cpp
+++ b/tests/unit/security/verification-helpers.t.cpp
@@ -41,7 +41,7 @@
// BOOST_FIXTURE_TEST_CASE(Generator, KeyChainFixture)
// {
// Identity wrongIdentity = m_keyChain.createIdentity("/Security/TestVerificationHelpers/Wrong");
-// std::map<std::string, SigningInfo> identities = {
+// const std::map<std::string, SigningInfo> identities = {
// {"Ecdsa", signingByIdentity(m_keyChain.createIdentity("/Security/TestVerificationHelpers/EC", EcKeyParams()))},
// {"Rsa", signingByIdentity(m_keyChain.createIdentity("/Security/TestVerificationHelpers/RSA", RsaKeyParams()))},
// {"Sha256", signingWithSha256()}
@@ -545,7 +545,7 @@
BOOST_AUTO_TEST_CASE_TEMPLATE(VerifySignature, Dataset, SignatureDatasets)
{
- Dataset dataset;
+ const Dataset dataset;
Certificate cert(Block(dataset.cert.data(), dataset.cert.size()));
Buffer keyRaw = cert.getPublicKey();
transform::PublicKey key;
@@ -630,7 +630,7 @@
BOOST_AUTO_TEST_CASE_TEMPLATE(VerifyDigest, Dataset, DigestDatasets)
{
- Dataset dataset;
+ const Dataset dataset;
Data data(Block(dataset.goodData.data(), dataset.goodData.size()));
Data badSigData(Block(dataset.badSigData.data(), dataset.badSigData.size()));
Interest interest(Block(dataset.goodInterest.data(), dataset.goodInterest.size()));
@@ -641,15 +641,8 @@
dataset.badSigInterestOldFormat.size()));
BOOST_CHECK(verifySignature(data, nullopt));
- BOOST_CHECK(verifyDigest(data, DigestAlgorithm::SHA256));
BOOST_CHECK(verifySignature(interest, nullopt));
- BOOST_CHECK(verifyDigest(interest, DigestAlgorithm::SHA256));
BOOST_CHECK(verifySignature(interestOldFormat, nullopt));
- BOOST_CHECK(verifyDigest(interestOldFormat, DigestAlgorithm::SHA256));
-
- BOOST_CHECK(!verifyDigest(badSigData, DigestAlgorithm::SHA256));
- BOOST_CHECK(!verifyDigest(badSigInterest, DigestAlgorithm::SHA256));
- BOOST_CHECK(!verifyDigest(badSigInterestOldFormat, DigestAlgorithm::SHA256));
BOOST_CHECK(!verifySignature(badSigData, nullopt));
BOOST_CHECK(!verifySignature(badSigInterest, nullopt));
@@ -661,15 +654,9 @@
Interest unsignedInterest2("/interest-with-one-name-component");
unsignedInterest2.setCanBePrefix(false);
- BOOST_CHECK(!verifyDigest(unsignedData, DigestAlgorithm::SHA256));
- BOOST_CHECK(!verifyDigest(unsignedInterest1, DigestAlgorithm::SHA256));
- BOOST_CHECK(!verifyDigest(unsignedInterest2, DigestAlgorithm::SHA256));
-
BOOST_CHECK(!verifySignature(unsignedData, nullopt));
BOOST_CHECK(!verifySignature(unsignedInterest1, nullopt));
BOOST_CHECK(!verifySignature(unsignedInterest2, nullopt));
-
- // - base version of verifyDigest is tested transitively
}
const uint8_t sha256DataUnrecognizedElements[] = {
@@ -696,8 +683,8 @@
Data data(Block(sha256DataUnrecognizedElements, sizeof(sha256DataUnrecognizedElements)));
Interest interest(Block(sha256InterestUnrecognizedElements, sizeof(sha256InterestUnrecognizedElements)));
- BOOST_CHECK(verifyDigest(data, DigestAlgorithm::SHA256));
- BOOST_CHECK(verifyDigest(interest, DigestAlgorithm::SHA256));
+ BOOST_CHECK(verifySignature(data, nullopt));
+ BOOST_CHECK(verifySignature(interest, nullopt));
}
BOOST_AUTO_TEST_SUITE_END() // TestVerificationHelpers