encoding: convert to span
Change-Id: I8bd73284fbd5acc0ff8ad2626af9b4324e9df7a1
diff --git a/tests/unit/security/additional-description.t.cpp b/tests/unit/security/additional-description.t.cpp
index 657870f..56a9090 100644
--- a/tests/unit/security/additional-description.t.cpp
+++ b/tests/unit/security/additional-description.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-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -30,7 +30,7 @@
BOOST_AUTO_TEST_SUITE(Security)
BOOST_AUTO_TEST_SUITE(TestAdditionalDescription)
-const uint8_t description[] = {
+const uint8_t DESC[] = {
0xfd, 0x01, 0x02, 0x28,
0xfd, 0x02, 0x00, 0x10, // DescriptionEntry
0xfd, 0x02, 0x01, 0x04, // DescriptionKey
@@ -44,8 +44,6 @@
0x76, 0x61, 0x6c, 0x32, // "val2"
};
-const std::string text = "[(key1:val1), (key2:val2)]";
-
BOOST_AUTO_TEST_CASE(Basic)
{
AdditionalDescription aDescription;
@@ -76,12 +74,10 @@
BOOST_CHECK_EQUAL_COLLECTIONS(aDescription.wireEncode().wire(),
aDescription.wireEncode().wire() + aDescription.wireEncode().size(),
- description,
- description + sizeof(description));
+ DESC,
+ DESC + sizeof(DESC));
- BOOST_REQUIRE_NO_THROW(AdditionalDescription(Block(description, sizeof(description))));
- AdditionalDescription aDescription2(Block(description, sizeof(description)));
-
+ AdditionalDescription aDescription2(Block{DESC});
BOOST_CHECK_EQUAL(aDescription2, aDescription);
AdditionalDescription aDescription3;
@@ -92,7 +88,7 @@
std::ostringstream os;
os << aDescription;
- BOOST_CHECK_EQUAL(os.str(), text);
+ BOOST_CHECK_EQUAL(os.str(), "[(key1:val1), (key2:val2)]");
}
BOOST_AUTO_TEST_SUITE_END() // TestAdditionalDescription
diff --git a/tests/unit/security/certificate.t.cpp b/tests/unit/security/certificate.t.cpp
index 7626e04..63b29a6 100644
--- a/tests/unit/security/certificate.t.cpp
+++ b/tests/unit/security/certificate.t.cpp
@@ -126,7 +126,7 @@
static void
generateFakeSignature(Data& data)
{
- SignatureInfo signatureInfo(Block(SIG_INFO, sizeof(SIG_INFO)));
+ SignatureInfo signatureInfo(Block{SIG_INFO});
signatureInfo.setKeyLocator(KeyLocator(Name("/ndn/site1/KEY/ksk-2516425377094")));
signatureInfo.setValidityPeriod(ValidityPeriod(time::fromIsoString("20141111T050000"),
time::fromIsoString("20141111T060000")));
@@ -137,7 +137,7 @@
BOOST_AUTO_TEST_CASE(Construction)
{
- Block block(CERT, sizeof(CERT));
+ Block block(CERT);
Certificate certificate(block);
BOOST_CHECK_EQUAL(certificate.getName(), "/ndn/site1/KEY/ksk-1416425377094/0123/%FD%00%00%01I%C9%8B");
@@ -201,7 +201,7 @@
public:
InvalidCertFixture()
{
- Certificate certBase(Block(CERT, sizeof(CERT)));
+ Certificate certBase(Block{CERT});
BOOST_CHECK_NO_THROW((Certificate(certBase)));
m_certBase = Data(certBase);
@@ -267,7 +267,7 @@
Key Locator: Name=/ndn/site1/KEY/ksk-2516425377094
)INFO").substr(1);
- Certificate certificate(Block(CERT, sizeof(CERT)));
+ Certificate certificate(Block{CERT});
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(certificate), expectedCertificateInfo);
// TODO: Check output formats of other certificates
diff --git a/tests/unit/security/detail/certificate-bundle-decoder.t.cpp b/tests/unit/security/detail/certificate-bundle-decoder.t.cpp
index ae81c82..630aaec 100644
--- a/tests/unit/security/detail/certificate-bundle-decoder.t.cpp
+++ b/tests/unit/security/detail/certificate-bundle-decoder.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-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -99,7 +99,7 @@
{
// First segment contains first 250 bytes of cert1
Data d;
- d.setContent(certBlock1.wire(), 250);
+ d.setContent(make_span(certBlock1.wire(), 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());
@@ -145,7 +145,7 @@
};
// Second segment contains non-Certificate data
Data d2;
- d2.setContent(buf, sizeof(buf));
+ d2.setContent(buf);
// Third segment contains all of cert2
Data d3;
diff --git a/tests/unit/security/pib/pib-data-fixture.cpp b/tests/unit/security/pib/pib-data-fixture.cpp
index d27c742..37e1e6d 100644
--- a/tests/unit/security/pib/pib-data-fixture.cpp
+++ b/tests/unit/security/pib/pib-data-fixture.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).
*
@@ -360,15 +360,15 @@
};
PibDataFixture::PibDataFixture()
- : id1Key1Cert1(Block(ID1_KEY1_CERT1, sizeof(ID1_KEY1_CERT1)))
- , id1Key1Cert2(Block(ID1_KEY1_CERT2, sizeof(ID1_KEY1_CERT2)))
- , id1Key2Cert1(Block(ID1_KEY2_CERT1, sizeof(ID1_KEY2_CERT1)))
- , id1Key2Cert2(Block(ID1_KEY2_CERT2, sizeof(ID1_KEY2_CERT2)))
+ : id1Key1Cert1(Block(ID1_KEY1_CERT1))
+ , id1Key1Cert2(Block(ID1_KEY1_CERT2))
+ , id1Key2Cert1(Block(ID1_KEY2_CERT1))
+ , id1Key2Cert2(Block(ID1_KEY2_CERT2))
- , id2Key1Cert1(Block(ID2_KEY1_CERT1, sizeof(ID2_KEY1_CERT1)))
- , id2Key1Cert2(Block(ID2_KEY1_CERT2, sizeof(ID2_KEY1_CERT2)))
- , id2Key2Cert1(Block(ID2_KEY2_CERT1, sizeof(ID2_KEY2_CERT1)))
- , id2Key2Cert2(Block(ID2_KEY2_CERT2, sizeof(ID2_KEY2_CERT2)))
+ , id2Key1Cert1(Block(ID2_KEY1_CERT1))
+ , id2Key1Cert2(Block(ID2_KEY1_CERT2))
+ , id2Key2Cert1(Block(ID2_KEY2_CERT1))
+ , id2Key2Cert2(Block(ID2_KEY2_CERT2))
, id1(id1Key1Cert1.getIdentity())
, id2(id2Key1Cert1.getIdentity())
diff --git a/tests/unit/security/safe-bag.t.cpp b/tests/unit/security/safe-bag.t.cpp
index c3cc7c2..5d24112 100644
--- a/tests/unit/security/safe-bag.t.cpp
+++ b/tests/unit/security/safe-bag.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).
*
@@ -121,10 +121,10 @@
BOOST_AUTO_TEST_CASE(Constructor)
{
- Data data(Block(CERT, sizeof(CERT)));
- SafeBag safeBag1(data, ENCRYPTED_KEY);
- SafeBag safeBag2(Block(SAFE_BAG, sizeof(SAFE_BAG)));
+ Data data(Block{CERT});
auto encKey = make_span(ENCRYPTED_KEY);
+ SafeBag safeBag1(data, encKey);
+ SafeBag safeBag2(Block{SAFE_BAG});
BOOST_CHECK(safeBag1.getCertificate() == data);
BOOST_CHECK_EQUAL_COLLECTIONS(safeBag1.getEncryptedKey().begin(), safeBag1.getEncryptedKey().end(),
@@ -136,13 +136,12 @@
BOOST_AUTO_TEST_CASE(EncoderAndDecoder)
{
- Block dataBlock(CERT, sizeof(CERT));
- Data data(dataBlock);
+ Data data(Block{CERT});
SafeBag safeBag(data, ENCRYPTED_KEY);
// wire encode
- Block wireBlock = safeBag.wireEncode();
- Block block(SAFE_BAG, sizeof(SAFE_BAG));
+ const auto& wireBlock = safeBag.wireEncode();
+ Block block(SAFE_BAG);
// check safe bag block
BOOST_CHECK_EQUAL(wireBlock, block);
diff --git a/tests/unit/security/validation-policy-command-interest.t.cpp b/tests/unit/security/validation-policy-command-interest.t.cpp
index 478b2d5..4fe05b7 100644
--- a/tests/unit/security/validation-policy-command-interest.t.cpp
+++ b/tests/unit/security/validation-policy-command-interest.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).
*
@@ -176,7 +176,7 @@
{
auto i1 = makeCommandInterest(identity);
KeyLocator kl;
- kl.setKeyDigest(makeBinaryBlock(tlv::KeyDigest, "\xDD\xDD\xDD\xDD\xDD\xDD\xDD\xDD", 8));
+ kl.setKeyDigest(makeBinaryBlock(tlv::KeyDigest, {0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD}));
SignatureInfo sigInfo(tlv::SignatureSha256WithRsa);
sigInfo.setKeyLocator(kl);
setNameComponent(i1, command_interest::POS_SIG_INFO,
diff --git a/tests/unit/security/validity-period.t.cpp b/tests/unit/security/validity-period.t.cpp
index 1dc7740..5dc8d9d 100644
--- a/tests/unit/security/validity-period.t.cpp
+++ b/tests/unit/security/validity-period.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-2022 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -87,15 +87,11 @@
{
time::system_clock::TimePoint notBefore = time::getUnixEpoch();
time::system_clock::TimePoint notAfter = notBefore + 1_day;
-
ValidityPeriod v1(notBefore, notAfter);
-
BOOST_CHECK_EQUAL_COLLECTIONS(v1.wireEncode().begin(), v1.wireEncode().end(),
VP1, VP1 + sizeof(VP1));
- BOOST_REQUIRE_NO_THROW(ValidityPeriod(Block(VP1, sizeof(VP1))));
- Block block(VP1, sizeof(VP1));
- ValidityPeriod v2(block);
+ ValidityPeriod v2(Block{VP1});
BOOST_CHECK(v1.getPeriod() == v2.getPeriod());
}
@@ -159,21 +155,17 @@
0x54, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30
};
-
BOOST_AUTO_TEST_CASE(DecodingError)
{
- BOOST_CHECK_THROW(ValidityPeriod(Block(VP_E1, sizeof(VP_E1))), ValidityPeriod::Error);
-
- BOOST_CHECK_THROW(ValidityPeriod(Block(VP_E2, sizeof(VP_E2))), ValidityPeriod::Error);
- BOOST_CHECK_THROW(ValidityPeriod(Block(VP_E3, sizeof(VP_E3))), ValidityPeriod::Error);
-
- BOOST_CHECK_THROW(ValidityPeriod(Block(VP_E4, sizeof(VP_E4))), ValidityPeriod::Error);
- BOOST_CHECK_THROW(ValidityPeriod(Block(VP_E5, sizeof(VP_E5))), ValidityPeriod::Error);
+ BOOST_CHECK_THROW(ValidityPeriod(Block{VP_E1}), ValidityPeriod::Error);
+ BOOST_CHECK_THROW(ValidityPeriod(Block{VP_E2}), ValidityPeriod::Error);
+ BOOST_CHECK_THROW(ValidityPeriod(Block{VP_E3}), ValidityPeriod::Error);
+ BOOST_CHECK_THROW(ValidityPeriod(Block{VP_E4}), ValidityPeriod::Error);
+ BOOST_CHECK_THROW(ValidityPeriod(Block{VP_E5}), ValidityPeriod::Error);
+ BOOST_CHECK_THROW(ValidityPeriod(Block{VP_E6}), ValidityPeriod::Error);
Block emptyBlock;
- BOOST_CHECK_THROW((ValidityPeriod(emptyBlock)), ValidityPeriod::Error);
-
- BOOST_CHECK_THROW(ValidityPeriod(Block(VP_E6, sizeof(VP_E6))), ValidityPeriod::Error);
+ BOOST_CHECK_THROW(ValidityPeriod{emptyBlock}, ValidityPeriod::Error);
}
BOOST_AUTO_TEST_CASE(Comparison)
diff --git a/tests/unit/security/verification-helpers.t.cpp b/tests/unit/security/verification-helpers.t.cpp
index 479a655..5e313ec 100644
--- a/tests/unit/security/verification-helpers.t.cpp
+++ b/tests/unit/security/verification-helpers.t.cpp
@@ -49,7 +49,7 @@
// };
// auto print = [] (const std::string& name, const uint8_t* buf, size_t size) {
-// std::cout << " std::vector<uint8_t> " + name + " = {\n ";
+// std::cout << " const Block " + name + "{{\n ";
// std::string hex = toHex(buf, size);
@@ -63,7 +63,7 @@
// if ((i + 1) != hex.size())
// std::cout << ", ";
// }
-// std::cout << "\n };";
+// std::cout << "\n }};";
// };
// for (const auto& i : identities) {
@@ -130,7 +130,7 @@
struct EcdsaDataset
{
const std::string name = "Ecdsa";
- std::vector<uint8_t> cert = {
+ const Block cert{{
0x06, 0xFD, 0x01, 0x62, 0x07, 0x47, 0x08, 0x08, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79,
0x08, 0x17, 0x54, 0x65, 0x73, 0x74, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69,
0x6F, 0x6E, 0x48, 0x65, 0x6C, 0x70, 0x65, 0x72, 0x73, 0x08, 0x02, 0x45, 0x43, 0x08, 0x03, 0x4B,
@@ -154,8 +154,8 @@
0x6B, 0x24, 0xF5, 0x7F, 0x02, 0x20, 0x1C, 0x88, 0xDE, 0x32, 0x3F, 0x1A, 0xE6, 0x60, 0xA2, 0x29,
0x94, 0xD9, 0x05, 0x8F, 0x57, 0x14, 0xD6, 0x17, 0x3C, 0x78, 0xBF, 0x85, 0xF5, 0x1D, 0xCC, 0x03,
0x35, 0x9E, 0xC9, 0xA9, 0x6B, 0x09
- };
- std::vector<uint8_t> goodData = {
+ }};
+ const Block goodData{{
0x06, 0xA2, 0x07, 0x13, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x04, 0x64, 0x61, 0x74, 0x61,
0x08, 0x05, 0x45, 0x63, 0x64, 0x73, 0x61, 0x14, 0x00, 0x15, 0x00, 0x16, 0x3D, 0x1B, 0x01, 0x03,
0x1C, 0x38, 0x07, 0x36, 0x08, 0x08, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x08, 0x17,
@@ -167,8 +167,8 @@
0xC3, 0x02, 0x21, 0x00, 0xB5, 0xA3, 0x87, 0xD8, 0x9B, 0xB6, 0x92, 0xAD, 0x19, 0x84, 0xAE, 0x4D,
0xF5, 0x64, 0xEC, 0x1C, 0xF2, 0xA0, 0xB7, 0x4D, 0x6B, 0x74, 0xFF, 0x39, 0x38, 0xFD, 0x5D, 0x9D,
0x46, 0xE0, 0xD2, 0xB4
- };
- std::vector<uint8_t> badSigData = {
+ }};
+ const Block badSigData{{
0x06, 0xA5, 0x07, 0x13, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x04, 0x64, 0x61, 0x74, 0x61,
0x08, 0x05, 0x45, 0x63, 0x64, 0x73, 0x61, 0x14, 0x00, 0x15, 0x00, 0x16, 0x40, 0x1B, 0x01, 0x03,
0x1C, 0x3B, 0x07, 0x39, 0x08, 0x08, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x08, 0x17,
@@ -180,8 +180,8 @@
0x13, 0xB4, 0xB8, 0x95, 0x02, 0x21, 0x00, 0xDA, 0x54, 0x99, 0xF8, 0xE5, 0xC1, 0x74, 0xAC, 0xE0,
0xF2, 0xDF, 0x0D, 0xC5, 0xE1, 0xCF, 0x99, 0x28, 0x6C, 0xB0, 0x2D, 0x55, 0xC8, 0x74, 0x63, 0x56,
0x2A, 0x1A, 0xB0, 0x00, 0xBD, 0xFF, 0xC5
- };
- std::vector<uint8_t> goodInterest = {
+ }};
+ const Block goodInterest{{
0x05, 0xCA, 0x07, 0x39, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x08, 0x69, 0x6E, 0x74, 0x65,
0x72, 0x65, 0x73, 0x74, 0x08, 0x05, 0x45, 0x63, 0x64, 0x73, 0x61, 0x02, 0x20, 0x8F, 0x41, 0x49,
0x40, 0xDA, 0x38, 0xC1, 0x0E, 0x75, 0x5A, 0x6D, 0x4A, 0xD4, 0xFC, 0xE2, 0xDF, 0xBA, 0x52, 0xAF,
@@ -195,8 +195,8 @@
0xDB, 0xEA, 0x3A, 0x71, 0x83, 0x0D, 0xC4, 0x26, 0xB7, 0x24, 0x02, 0x20, 0x0F, 0x14, 0x10, 0xDB,
0xDB, 0x24, 0xCB, 0xB3, 0xD2, 0x4B, 0x45, 0x6D, 0xA0, 0xBB, 0x4B, 0x87, 0xC1, 0x59, 0x9F, 0xC8,
0xBE, 0x75, 0xF5, 0xCC, 0xCB, 0xD2, 0x4F, 0xD8, 0x87, 0x26, 0x51, 0xBF
- };
- std::vector<uint8_t> badSigInterest = {
+ }};
+ const Block badSigInterest{{
0x05, 0xCF, 0x07, 0x39, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x08, 0x69, 0x6E, 0x74, 0x65,
0x72, 0x65, 0x73, 0x74, 0x08, 0x05, 0x45, 0x63, 0x64, 0x73, 0x61, 0x02, 0x20, 0x53, 0x14, 0x5E,
0xA3, 0x31, 0x41, 0xD8, 0xA1, 0x10, 0x06, 0x3C, 0x8E, 0xF3, 0x51, 0xA0, 0xC2, 0x8A, 0xBC, 0xFC,
@@ -211,8 +211,8 @@
0x00, 0xC7, 0x23, 0x25, 0xF7, 0xFA, 0x6A, 0x2D, 0x3D, 0xF4, 0xD8, 0xDB, 0xE9, 0x76, 0x6A, 0x63,
0xD4, 0x11, 0x17, 0x4A, 0xDB, 0x7F, 0x85, 0x52, 0x97, 0xFC, 0x5B, 0x0B, 0x1B, 0xBA, 0xE5, 0xED,
0x9A
- };
- std::vector<uint8_t> goodInterestOldFormat = {
+ }};
+ const Block goodInterestOldFormat{{
0x05, 0xCB, 0x07, 0x39, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x08, 0x69, 0x6E, 0x74, 0x65,
0x72, 0x65, 0x73, 0x74, 0x08, 0x05, 0x45, 0x63, 0x64, 0x73, 0x61, 0x02, 0x20, 0xDB, 0x6D, 0x5E,
0xA7, 0xBF, 0xAF, 0xEC, 0xA0, 0xC6, 0x20, 0x4E, 0xF2, 0x04, 0xF8, 0xFF, 0x39, 0x2A, 0x5F, 0xE6,
@@ -226,8 +226,8 @@
0x60, 0x63, 0x51, 0xB3, 0x52, 0xBC, 0x6D, 0x24, 0x0C, 0x6D, 0x38, 0x02, 0x20, 0x0E, 0x21, 0xF1,
0x51, 0x39, 0x2D, 0x4A, 0x45, 0x05, 0x45, 0xFA, 0x85, 0xA7, 0xCC, 0x00, 0xFE, 0x89, 0x8A, 0xD6,
0xD7, 0x34, 0x0D, 0x31, 0x6A, 0x94, 0xAE, 0x1F, 0xD8, 0x07, 0xF1, 0xDF, 0x80
- };
- std::vector<uint8_t> badSigInterestOldFormat = {
+ }};
+ const Block badSigInterestOldFormat{{
0x05, 0xFD, 0x01, 0x5B, 0x07, 0xC9, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x08, 0x69, 0x6E,
0x74, 0x65, 0x72, 0x65, 0x73, 0x74, 0x08, 0x05, 0x45, 0x63, 0x64, 0x73, 0x61, 0x02, 0x20, 0xDB,
0x6D, 0x5E, 0xA7, 0xBF, 0xAF, 0xEC, 0xA0, 0xC6, 0x20, 0x4E, 0xF2, 0x04, 0xF8, 0xFF, 0x39, 0x2A,
@@ -250,13 +250,13 @@
0x64, 0xAA, 0x60, 0x63, 0x51, 0xB3, 0x52, 0xBC, 0x6D, 0x24, 0x0C, 0x6D, 0x38, 0x02, 0x20, 0x0E,
0x21, 0xF1, 0x51, 0x39, 0x2D, 0x4A, 0x45, 0x05, 0x45, 0xFA, 0x85, 0xA7, 0xCC, 0x00, 0xFE, 0x89,
0x8A, 0xD6, 0xD7, 0x34, 0x0D, 0x31, 0x6A, 0x94, 0xAE, 0x1F, 0xD8, 0x07, 0xF1, 0xDF, 0x80
- };
+ }};
};
struct RsaDataset
{
const std::string name = "Rsa";
- std::vector<uint8_t> cert = {
+ const Block cert{{
0x06, 0xFD, 0x02, 0xED, 0x07, 0x48, 0x08, 0x08, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79,
0x08, 0x17, 0x54, 0x65, 0x73, 0x74, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69,
0x6F, 0x6E, 0x48, 0x65, 0x6C, 0x70, 0x65, 0x72, 0x73, 0x08, 0x03, 0x52, 0x53, 0x41, 0x08, 0x03,
@@ -305,8 +305,8 @@
0x3E, 0xFA, 0xE6, 0xB9, 0x8E, 0x08, 0x82, 0x50, 0xCA, 0xEE, 0x7F, 0x5D, 0x80, 0x65, 0xBA, 0x10,
0x1F, 0x24, 0xC1, 0x15, 0x78, 0xB7, 0x90, 0xE5, 0x3D, 0xDA, 0x0F, 0x0E, 0x03, 0x20, 0xC1, 0xEA,
0x85
- };
- std::vector<uint8_t> goodData = {
+ }};
+ const Block goodData{{
0x06, 0xFD, 0x01, 0x5B, 0x07, 0x11, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x04, 0x64, 0x61,
0x74, 0x61, 0x08, 0x03, 0x52, 0x73, 0x61, 0x14, 0x00, 0x15, 0x00, 0x16, 0x3E, 0x1B, 0x01, 0x01,
0x1C, 0x39, 0x07, 0x37, 0x08, 0x08, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x08, 0x17,
@@ -329,8 +329,8 @@
0x4F, 0xD9, 0xEB, 0xC1, 0x5D, 0x53, 0x15, 0xBF, 0x8C, 0x7C, 0x6B, 0x22, 0xB9, 0x24, 0x70, 0xAE,
0x63, 0x13, 0x96, 0x3B, 0x2A, 0xDA, 0x7F, 0x64, 0x0D, 0x9E, 0xA7, 0x90, 0x20, 0x2A, 0x2A, 0xAB,
0xA9, 0xA6, 0xC9, 0xB2, 0x37, 0x8E, 0xE3, 0x09, 0xFD, 0xA3, 0x68, 0x06, 0xCB, 0x96, 0x80
- };
- std::vector<uint8_t> badSigData = {
+ }};
+ const Block badSigData{{
0x06, 0xA2, 0x07, 0x11, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x04, 0x64, 0x61, 0x74, 0x61,
0x08, 0x03, 0x52, 0x73, 0x61, 0x14, 0x00, 0x15, 0x00, 0x16, 0x40, 0x1B, 0x01, 0x03, 0x1C, 0x3B,
0x07, 0x39, 0x08, 0x08, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x08, 0x17, 0x54, 0x65,
@@ -342,8 +342,8 @@
0x1E, 0x02, 0x21, 0x00, 0xA5, 0x62, 0xA5, 0x04, 0x60, 0xBC, 0x96, 0x54, 0x2C, 0x9E, 0x6F, 0xA8,
0x1B, 0xDB, 0xF9, 0xF0, 0x7E, 0xFF, 0xED, 0x92, 0x3A, 0x4B, 0xDE, 0x3D, 0x20, 0x02, 0x7B, 0xD7,
0x1C, 0xD0, 0xAA, 0xAB
- };
- std::vector<uint8_t> goodInterest = {
+ }};
+ const Block goodInterest{{
0x05, 0xFD, 0x01, 0x85, 0x07, 0x37, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x08, 0x69, 0x6E,
0x74, 0x65, 0x72, 0x65, 0x73, 0x74, 0x08, 0x03, 0x52, 0x73, 0x61, 0x02, 0x20, 0x08, 0x39, 0xEE,
0x12, 0xF1, 0x10, 0xB7, 0x8B, 0x49, 0xF2, 0xE2, 0x54, 0x23, 0xFF, 0x66, 0xB3, 0x0F, 0xC6, 0x91,
@@ -369,8 +369,8 @@
0xE3, 0x11, 0x85, 0xCC, 0x0E, 0xAF, 0x56, 0x6B, 0xE1, 0xAC, 0xB3, 0x20, 0xF2, 0x47, 0xFE, 0x95,
0xC8, 0x71, 0x99, 0xCC, 0x52, 0x8A, 0x6F, 0xF1, 0x01, 0xD6, 0xE9, 0x2E, 0x6C, 0x27, 0xC3, 0xED,
0xE3, 0xF2, 0xDD, 0x78, 0xB4, 0x7F, 0xFA, 0xD0, 0xC2
- };
- std::vector<uint8_t> badSigInterest = {
+ }};
+ const Block badSigInterest{{
0x05, 0xCC, 0x07, 0x37, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x08, 0x69, 0x6E, 0x74, 0x65,
0x72, 0x65, 0x73, 0x74, 0x08, 0x03, 0x52, 0x73, 0x61, 0x02, 0x20, 0x64, 0xE3, 0x6F, 0xD5, 0x73,
0x21, 0xBC, 0xAB, 0xDE, 0xDE, 0x0F, 0x99, 0xCB, 0x49, 0x7F, 0x46, 0xE7, 0xF0, 0x7A, 0xF1, 0x2C,
@@ -384,8 +384,8 @@
0x4A, 0xBF, 0xC0, 0x5B, 0xA8, 0x05, 0xA2, 0xC8, 0x61, 0xC4, 0x2E, 0x64, 0x02, 0x20, 0x1F, 0x5E,
0xF5, 0x8E, 0xC9, 0xDC, 0x9E, 0x15, 0x1C, 0xFA, 0x58, 0x5F, 0xDF, 0xAE, 0xA0, 0xFD, 0xDA, 0x34,
0x21, 0xE0, 0xA8, 0x2D, 0x32, 0x47, 0x9E, 0x44, 0x83, 0x79, 0x23, 0x5F, 0xBE, 0x16
- };
- std::vector<uint8_t> goodInterestOldFormat = {
+ }};
+ const Block goodInterestOldFormat{{
0x05, 0xFD, 0x01, 0x85, 0x07, 0x37, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x08, 0x69, 0x6E,
0x74, 0x65, 0x72, 0x65, 0x73, 0x74, 0x08, 0x03, 0x52, 0x73, 0x61, 0x02, 0x20, 0x08, 0x39, 0xEE,
0x12, 0xF1, 0x10, 0xB7, 0x8B, 0x49, 0xF2, 0xE2, 0x54, 0x23, 0xFF, 0x66, 0xB3, 0x0F, 0xC6, 0x91,
@@ -411,8 +411,8 @@
0xE3, 0x11, 0x85, 0xCC, 0x0E, 0xAF, 0x56, 0x6B, 0xE1, 0xAC, 0xB3, 0x20, 0xF2, 0x47, 0xFE, 0x95,
0xC8, 0x71, 0x99, 0xCC, 0x52, 0x8A, 0x6F, 0xF1, 0x01, 0xD6, 0xE9, 0x2E, 0x6C, 0x27, 0xC3, 0xED,
0xE3, 0xF2, 0xDD, 0x78, 0xB4, 0x7F, 0xFA, 0xD0, 0xC2
- };
- std::vector<uint8_t> badSigInterestOldFormat = {
+ }};
+ const Block badSigInterestOldFormat{{
0x05, 0xFD, 0x02, 0x15, 0x07, 0xC7, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x08, 0x69, 0x6E,
0x74, 0x65, 0x72, 0x65, 0x73, 0x74, 0x08, 0x03, 0x52, 0x73, 0x61, 0x02, 0x20, 0x08, 0x39, 0xEE,
0x12, 0xF1, 0x10, 0xB7, 0x8B, 0x49, 0xF2, 0xE2, 0x54, 0x23, 0xFF, 0x66, 0xB3, 0x0F, 0xC6, 0x91,
@@ -447,23 +447,22 @@
0xE3, 0x11, 0x85, 0xCC, 0x0E, 0xAF, 0x56, 0x6B, 0xE1, 0xAC, 0xB3, 0x20, 0xF2, 0x47, 0xFE, 0x95,
0xC8, 0x71, 0x99, 0xCC, 0x52, 0x8A, 0x6F, 0xF1, 0x01, 0xD6, 0xE9, 0x2E, 0x6C, 0x27, 0xC3, 0xED,
0xE3, 0xF2, 0xDD, 0x78, 0xB4, 0x7F, 0xFA, 0xD0, 0xC2
- };
+ }};
};
struct Sha256Dataset
{
const std::string name = "Sha256";
- std::vector<uint8_t> cert = {
-
- };
- std::vector<uint8_t> goodData = {
+ const Block cert{{
+ }};
+ const Block goodData{{
0x06, 0x41, 0x07, 0x14, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x04, 0x64, 0x61, 0x74, 0x61,
0x08, 0x06, 0x53, 0x68, 0x61, 0x32, 0x35, 0x36, 0x14, 0x00, 0x15, 0x00, 0x16, 0x03, 0x1B, 0x01,
0x00, 0x17, 0x20, 0xE2, 0xE2, 0x2F, 0x02, 0x70, 0xA7, 0xF7, 0x48, 0x70, 0x45, 0x29, 0x46, 0xBD,
0xD2, 0x62, 0x24, 0xA6, 0x1E, 0x1D, 0x75, 0x2A, 0x26, 0x98, 0x04, 0xAD, 0x9C, 0x47, 0x63, 0xF8,
0x98, 0x5A, 0x49
- };
- std::vector<uint8_t> badSigData = {
+ }};
+ const Block badSigData{{
0x06, 0xA6, 0x07, 0x14, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x04, 0x64, 0x61, 0x74, 0x61,
0x08, 0x06, 0x53, 0x68, 0x61, 0x32, 0x35, 0x36, 0x14, 0x00, 0x15, 0x00, 0x16, 0x40, 0x1B, 0x01,
0x03, 0x1C, 0x3B, 0x07, 0x39, 0x08, 0x08, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x08,
@@ -475,8 +474,8 @@
0x28, 0x19, 0x6C, 0x5C, 0xD6, 0x02, 0x21, 0x00, 0xF0, 0xD2, 0x23, 0xEA, 0xD9, 0x43, 0x6D, 0x8A,
0xD2, 0x02, 0x3F, 0xF1, 0x41, 0x12, 0xA6, 0xED, 0x87, 0xB3, 0xD5, 0x5A, 0x27, 0x5D, 0x4E, 0xEB,
0x13, 0x29, 0x01, 0xBC, 0x3C, 0xCC, 0x50, 0x61
- };
- std::vector<uint8_t> goodInterest = {
+ }};
+ const Block goodInterest{{
0x05, 0x6B, 0x07, 0x3A, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x08, 0x69, 0x6E, 0x74, 0x65,
0x72, 0x65, 0x73, 0x74, 0x08, 0x06, 0x53, 0x68, 0x61, 0x32, 0x35, 0x36, 0x02, 0x20, 0x8F, 0x03,
0x0B, 0x85, 0xA7, 0x05, 0xD8, 0x05, 0x31, 0x8E, 0x80, 0x81, 0xD3, 0xE2, 0xA8, 0x5E, 0x74, 0xD7,
@@ -484,8 +483,8 @@
0xF7, 0x2C, 0x8A, 0x4B, 0x24, 0x00, 0x2C, 0x03, 0x1B, 0x01, 0x00, 0x2E, 0x20, 0xEF, 0x45, 0x55,
0x75, 0xC8, 0x18, 0x5E, 0xE9, 0x2A, 0xAE, 0x52, 0x61, 0x0A, 0x94, 0x41, 0x03, 0x36, 0x4C, 0x13,
0x59, 0xD4, 0xC7, 0xA4, 0x3A, 0xA0, 0x40, 0x61, 0x44, 0x33, 0x93, 0x5E, 0x99
- };
- std::vector<uint8_t> badSigInterest = {
+ }};
+ const Block badSigInterest{{
0x05, 0xCE, 0x07, 0x3A, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x08, 0x69, 0x6E, 0x74, 0x65,
0x72, 0x65, 0x73, 0x74, 0x08, 0x06, 0x53, 0x68, 0x61, 0x32, 0x35, 0x36, 0x02, 0x20, 0x32, 0x3F,
0x2F, 0xA3, 0xDC, 0x15, 0x7E, 0x8C, 0xA9, 0x75, 0xF7, 0x66, 0xFF, 0xFD, 0x13, 0x42, 0x1B, 0xE1,
@@ -499,8 +498,8 @@
0x73, 0xB3, 0xA6, 0xD2, 0x99, 0x32, 0x26, 0xE2, 0x46, 0x3A, 0xE0, 0x69, 0xDF, 0xB2, 0x02, 0x20,
0x6A, 0x03, 0xCE, 0xB6, 0x85, 0x1E, 0x01, 0x5E, 0xF8, 0x48, 0xDE, 0x65, 0xB9, 0xE1, 0xEB, 0x9A,
0xF8, 0x47, 0x43, 0x5B, 0xBA, 0x63, 0xCB, 0xBA, 0xFB, 0x62, 0x1C, 0x38, 0xE8, 0x53, 0xF7, 0x29
- };
- std::vector<uint8_t> goodInterestOldFormat = {
+ }};
+ const Block goodInterestOldFormat{{
0x05, 0x6B, 0x07, 0x3A, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x08, 0x69, 0x6E, 0x74, 0x65,
0x72, 0x65, 0x73, 0x74, 0x08, 0x06, 0x53, 0x68, 0x61, 0x32, 0x35, 0x36, 0x02, 0x20, 0x8F, 0x03,
0x0B, 0x85, 0xA7, 0x05, 0xD8, 0x05, 0x31, 0x8E, 0x80, 0x81, 0xD3, 0xE2, 0xA8, 0x5E, 0x74, 0xD7,
@@ -508,8 +507,8 @@
0xF7, 0x2C, 0x8A, 0x4B, 0x24, 0x00, 0x2C, 0x03, 0x1B, 0x01, 0x00, 0x2E, 0x20, 0xEF, 0x45, 0x55,
0x75, 0xC8, 0x18, 0x5E, 0xE9, 0x2A, 0xAE, 0x52, 0x61, 0x0A, 0x94, 0x41, 0x03, 0x36, 0x4C, 0x13,
0x59, 0xD4, 0xC7, 0xA4, 0x3A, 0xA0, 0x40, 0x61, 0x44, 0x33, 0x93, 0x5E, 0x99
- };
- std::vector<uint8_t> badSigInterestOldFormat = {
+ }};
+ const Block badSigInterestOldFormat{{
0x05, 0xFA, 0x07, 0xC9, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x08, 0x69, 0x6E, 0x74, 0x65,
0x72, 0x65, 0x73, 0x74, 0x08, 0x06, 0x53, 0x68, 0x61, 0x32, 0x35, 0x36, 0x02, 0x20, 0x8F, 0x03,
0x0B, 0x85, 0xA7, 0x05, 0xD8, 0x05, 0x31, 0x8E, 0x80, 0x81, 0xD3, 0xE2, 0xA8, 0x5E, 0x74, 0xD7,
@@ -526,7 +525,7 @@
0x2C, 0x8A, 0x4B, 0x24, 0x00, 0x2C, 0x03, 0x1B, 0x01, 0x00, 0x2E, 0x20, 0xEF, 0x45, 0x55, 0x75,
0xC8, 0x18, 0x5E, 0xE9, 0x2A, 0xAE, 0x52, 0x61, 0x0A, 0x94, 0x41, 0x03, 0x36, 0x4C, 0x13, 0x59,
0xD4, 0xC7, 0xA4, 0x3A, 0xA0, 0x40, 0x61, 0x44, 0x33, 0x93, 0x5E, 0x99
- };
+ }};
};
// Note about the datasets:
@@ -547,18 +546,17 @@
BOOST_AUTO_TEST_CASE_TEMPLATE(VerifySignature, Dataset, SignatureDatasets)
{
const Dataset dataset;
- Certificate cert(Block(dataset.cert.data(), dataset.cert.size()));
- Buffer keyRaw = cert.getPublicKey();
+ Certificate cert(dataset.cert);
+ auto keyRaw = cert.getPublicKey();
transform::PublicKey key;
key.loadPkcs8(keyRaw);
- 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()));
- Interest badSigInterest(Block(dataset.badSigInterest.data(), dataset.badSigInterest.size()));
- Interest interestOldFormat(Block(dataset.goodInterestOldFormat.data(),
- dataset.goodInterestOldFormat.size()));
- Interest badSigInterestOldFormat(Block(dataset.badSigInterestOldFormat.data(),
- dataset.badSigInterestOldFormat.size()));
+
+ Data data(dataset.goodData);
+ Data badSigData(dataset.badSigData);
+ Interest interest(dataset.goodInterest);
+ Interest badSigInterest(dataset.badSigInterest);
+ Interest interestOldFormat(dataset.goodInterestOldFormat);
+ Interest badSigInterestOldFormat(dataset.badSigInterestOldFormat);
BOOST_CHECK(verifySignature(data, key));
BOOST_CHECK(verifySignature(data, keyRaw));
@@ -634,14 +632,12 @@
BOOST_AUTO_TEST_CASE_TEMPLATE(VerifyDigest, Dataset, DigestDatasets)
{
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()));
- Interest badSigInterest(Block(dataset.badSigInterest.data(), dataset.badSigInterest.size()));
- Interest interestOldFormat(Block(dataset.goodInterestOldFormat.data(),
- dataset.goodInterestOldFormat.size()));
- Interest badSigInterestOldFormat(Block(dataset.badSigInterestOldFormat.data(),
- dataset.badSigInterestOldFormat.size()));
+ Data data(dataset.goodData);
+ Data badSigData(dataset.badSigData);
+ Interest interest(dataset.goodInterest);
+ Interest badSigInterest(dataset.badSigInterest);
+ Interest interestOldFormat(dataset.goodInterestOldFormat);
+ Interest badSigInterestOldFormat(dataset.badSigInterestOldFormat);
BOOST_CHECK(verifySignature(data, nullopt));
BOOST_CHECK(verifySignature(interest, nullopt));
@@ -683,8 +679,8 @@
BOOST_AUTO_TEST_CASE(VerifyWithUnrecognizedElements) // Bug #4583
{
- Data data(Block(sha256DataUnrecognizedElements, sizeof(sha256DataUnrecognizedElements)));
- Interest interest(Block(sha256InterestUnrecognizedElements, sizeof(sha256InterestUnrecognizedElements)));
+ Data data(Block{sha256DataUnrecognizedElements});
+ Interest interest(Block{sha256InterestUnrecognizedElements});
BOOST_CHECK(verifySignature(data, nullopt));
BOOST_CHECK(verifySignature(interest, nullopt));