encoding: make Block convertible to span
Change-Id: Idb501467d1c56b95e7fdb76acda63b919fe98f85
diff --git a/tests/unit/security/additional-description.t.cpp b/tests/unit/security/additional-description.t.cpp
index 56a9090..2779816 100644
--- a/tests/unit/security/additional-description.t.cpp
+++ b/tests/unit/security/additional-description.t.cpp
@@ -72,10 +72,7 @@
it++;
BOOST_CHECK(it == aDescription.end());
- BOOST_CHECK_EQUAL_COLLECTIONS(aDescription.wireEncode().wire(),
- aDescription.wireEncode().wire() + aDescription.wireEncode().size(),
- DESC,
- DESC + sizeof(DESC));
+ BOOST_TEST(aDescription.wireEncode() == DESC, boost::test_tools::per_element());
AdditionalDescription aDescription2(Block{DESC});
BOOST_CHECK_EQUAL(aDescription2, aDescription);
diff --git a/tests/unit/security/detail/certificate-bundle-decoder.t.cpp b/tests/unit/security/detail/certificate-bundle-decoder.t.cpp
index 630aaec..1199994 100644
--- a/tests/unit/security/detail/certificate-bundle-decoder.t.cpp
+++ b/tests/unit/security/detail/certificate-bundle-decoder.t.cpp
@@ -99,7 +99,7 @@
{
// First segment contains first 250 bytes of cert1
Data d;
- d.setContent(make_span(certBlock1.wire(), 250));
+ d.setContent(make_span(certBlock1).first(250));
// Second segment contains the rest of cert1 and the first 100 bytes of cert2
auto buf = std::make_shared<Buffer>(certBlock1.begin() + 250, certBlock1.end());
diff --git a/tests/unit/security/pib/pib-data-fixture.cpp b/tests/unit/security/pib/pib-data-fixture.cpp
index 37e1e6d..4fb5e36 100644
--- a/tests/unit/security/pib/pib-data-fixture.cpp
+++ b/tests/unit/security/pib/pib-data-fixture.cpp
@@ -63,7 +63,7 @@
// EncodingBuffer buf;
// cert.wireEncode(buf, true);
-// cert.setSignatureValue(tpm.sign(buf.buf(), buf.size(), keyName, DigestAlgorithm::SHA256));
+// cert.setSignatureValue(tpm.sign({buf}, keyName, DigestAlgorithm::SHA256));
// printBytes(prefix + "_KEY" + to_string(keyId) + "_CERT" + to_string(certVersion),
// cert.wireEncode());
@@ -72,18 +72,12 @@
// }
// static void
-// printBytes(const std::string& name, const Block& block)
-// {
-// printBytes(name, make_span(block.wire(), block.size()));
-// }
-
-// static void
-// printBytes(const std::string& name, span<const uint8_t> buf)
+// printBytes(const std::string& name, span<const uint8_t> bytes)
// {
// std::cout << "\nconst uint8_t " << name << "[] = {\n"
// << " ";
-// std::string hex = toHex(buf);
+// std::string hex = toHex(bytes);
// for (size_t i = 0; i < hex.size(); i++) {
// if (i > 0 && i % 40 == 0)
diff --git a/tests/unit/security/validation-policy-config.t.cpp b/tests/unit/security/validation-policy-config.t.cpp
index 32fbf01..83c6f52 100644
--- a/tests/unit/security/validation-policy-config.t.cpp
+++ b/tests/unit/security/validation-policy-config.t.cpp
@@ -247,7 +247,7 @@
{
using namespace ndn::security::transform;
const auto& cert = this->identity.getDefaultKey().getDefaultCertificate().wireEncode();
- bufferSource(make_span(cert.wire(), cert.size())) >> base64Encode(false) >> streamSink(os);
+ bufferSource(cert) >> base64Encode(false) >> streamSink(os);
}
this->policy.load(this->baseConfig + R"CONF(
diff --git a/tests/unit/security/validation-policy-simple-hierarchy.t.cpp b/tests/unit/security/validation-policy-simple-hierarchy.t.cpp
index d5734a8..70fb49e 100644
--- a/tests/unit/security/validation-policy-simple-hierarchy.t.cpp
+++ b/tests/unit/security/validation-policy-simple-hierarchy.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2021 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -73,15 +73,15 @@
BOOST_AUTO_TEST_CASE(NonKeyNameInsideLocator)
{
- // auto cert = identity.getDefaultKey().getDefaultCertificate().wireEncode();
- // std::cerr << "Certificate idCert{\"" << toHex(cert.wire(), cert.size()) << "\"_block};" << std::endl;
+// auto cert = identity.getDefaultKey().getDefaultCertificate().wireEncode();
+// std::cerr << "Certificate idCert{\"" << toHex(cert) << "\"_block};" << std::endl;
- // cert = subIdentity.getDefaultKey().getDefaultCertificate().wireEncode();
- // std::cerr << "Certificate subIdCert{\"" << toHex(cert.wire(), cert.size()) << "\"_block};" << std::endl;
+// cert = subIdentity.getDefaultKey().getDefaultCertificate().wireEncode();
+// std::cerr << "Certificate subIdCert{\"" << toHex(cert) << "\"_block};" << std::endl;
- // Data packet("/Security/ValidatorFixture/Sub1/Sub2/Packet");
- // m_keyChain.sign(packet, signingByIdentity(subIdentity));
- // std::cerr << "Data packet{\"" << toHex(packet.wireEncode().wire(), packet.wireEncode().size()) << "\"_block};" << std::endl;
+// Data pkt("/Security/ValidatorFixture/Sub1/Sub2/Packet");
+// m_keyChain.sign(pkt, signingByIdentity(subIdentity));
+// std::cerr << "Data packet{\"" << toHex(pkt.wireEncode()) << "\"_block};" << std::endl;
// These are hard-coded with a key locator that is the exact name of the certificate
Certificate idCert{"06FD014C073C08085365637572697479081056616C696461746F724669787475726508034B455"
diff --git a/tests/unit/security/verification-helpers.t.cpp b/tests/unit/security/verification-helpers.t.cpp
index d15f8f2..79cc41c 100644
--- a/tests/unit/security/verification-helpers.t.cpp
+++ b/tests/unit/security/verification-helpers.t.cpp
@@ -48,10 +48,10 @@
// {"Sha256", signingWithSha256()}
// };
-// auto print = [] (const std::string& name, const uint8_t* buf, size_t size) {
+// auto print = [] (const std::string& name, span<const uint8_t> buf) {
// std::cout << " const Block " + name + "{{\n ";
-// std::string hex = toHex({buf, size});
+// std::string hex = toHex(buf);
// for (size_t i = 0; i < hex.size(); i++) {
// if (i > 0 && i % 32 == 0)
@@ -74,23 +74,22 @@
// std::cout << " const std::string name = \"" << type << "\";\n";
// if (signingInfo.getSignerType() == SigningInfo::SIGNER_TYPE_ID) {
-// print("cert", signingInfo.getPibIdentity().getDefaultKey().getDefaultCertificate().wireEncode().wire(),
-// signingInfo.getPibIdentity().getDefaultKey().getDefaultCertificate().wireEncode().size());
+// print("cert", signingInfo.getPibIdentity().getDefaultKey().getDefaultCertificate().wireEncode());
// }
// else {
-// print("cert", nullptr, 0);
+// print("cert", {});
// }
// std::cout << "\n";
// // Create data that can be verified by cert
// Data data(Name("/test/data").append(type));
// m_keyChain.sign(data, signingInfo);
-// print("goodData", data.wireEncode().wire(), data.wireEncode().size());
+// print("goodData", data.wireEncode());
// std::cout << "\n";
// // Create data that cannot be verified by cert
// m_keyChain.sign(data, signingByIdentity(wrongIdentity));
-// print("badSigData", data.wireEncode().wire(), data.wireEncode().size());
+// print("badSigData", data.wireEncode());
// std::cout << "\n";
// // Create interest that can be verified by cert
@@ -99,13 +98,13 @@
// signingInfoV03.setSignedInterestFormat(SignedInterestFormat::V03);
// interest1.setNonce(0xF72C8A4B);
// m_keyChain.sign(interest1, signingInfoV03);
-// print("goodInterest", interest1.wireEncode().wire(), interest1.wireEncode().size());
+// print("goodInterest", interest1.wireEncode());
// std::cout << "\n";
// // Create interest that cannot be verified by cert
// m_keyChain.sign(interest1, signingByIdentity(wrongIdentity)
// .setSignedInterestFormat(SignedInterestFormat::V03));
-// print("badSigInterest", interest1.wireEncode().wire(), interest1.wireEncode().size());
+// print("badSigInterest", interest1.wireEncode());
// std::cout << "\n";
// // Create interest that can be verified by cert (old signed Interest format)
@@ -114,13 +113,13 @@
// signingInfoV02.setSignedInterestFormat(SignedInterestFormat::V03);
// interest2.setNonce(0xF72C8A4B);
// m_keyChain.sign(interest2, signingInfoV02);
-// print("goodInterestOldFormat", interest2.wireEncode().wire(), interest2.wireEncode().size());
+// print("goodInterestOldFormat", interest2.wireEncode());
// std::cout << "\n";
// // Create interest that cannot be verified by cert (old signed Interest format)
// m_keyChain.sign(interest2, signingByIdentity(wrongIdentity)
// .setSignedInterestFormat(SignedInterestFormat::V02));
-// print("badSigInterestOldFormat", interest2.wireEncode().wire(), interest2.wireEncode().size());
+// print("badSigInterestOldFormat", interest2.wireEncode());
// std::cout << "\n};\n\n";
// }
// }