Avoid deprecated ndn-cxx functions
Change-Id: Ib148262999a691760821a2ce1c05a5e6332e7e34
diff --git a/examples/consumer.cpp b/examples/consumer.cpp
index ae79848..359f17b 100644
--- a/examples/consumer.cpp
+++ b/examples/consumer.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2018, Regents of the University of California
+/*
+ * Copyright (c) 2014-2022, Regents of the University of California
*
* NAC library is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -35,9 +35,8 @@
{
public:
Consumer()
- : m_face(nullptr, m_keyChain)
- , m_validator(m_face)
- , m_decryptor(m_keyChain.getPib().getDefaultIdentity().getDefaultKey(), m_validator, m_keyChain, m_face)
+ : m_decryptor(m_keyChain.getPib().getDefaultIdentity().getDefaultKey(),
+ m_validator, m_keyChain, m_face)
{
m_validator.load(R"CONF(
trust-anchor
@@ -51,58 +50,57 @@
run()
{
Interest interest(Name("/example/testApp/randomData"));
- interest.setInterestLifetime(2_s); // 2 seconds
interest.setMustBeFresh(true);
+ interest.setInterestLifetime(3_s); // 3 seconds
+ std::cout << "Sending Interest " << interest << std::endl;
m_face.expressInterest(interest,
- bind(&Consumer::onData, this, _1, _2),
- bind(&Consumer::onNack, this, _1, _2),
- bind(&Consumer::onTimeout, this, _1));
+ std::bind(&Consumer::onData, this, _1, _2),
+ std::bind(&Consumer::onNack, this, _1, _2),
+ std::bind(&Consumer::onTimeout, this, _1));
- std::cout << "Sending " << interest << std::endl;
-
- // processEvents will block until the requested data received or timeout occurs
+ // processEvents will block until the requested data is received or a timeout occurs
m_face.processEvents();
}
private:
void
- onData(const Interest& interest, const Data& data)
+ onData(const Interest&, const Data& data)
{
m_validator.validate(data,
[=] (const Data& data) {
m_decryptor.decrypt(data.getContent().blockFromValue(),
- [=] (ConstBufferPtr content) {
+ [] (const ConstBufferPtr& content) {
std::cout << "Decrypted content: "
<< std::string(reinterpret_cast<const char*>(content->data()), content->size())
<< std::endl;
},
- [=] (const ErrorCode&, const std::string& error) {
+ [] (const ErrorCode&, const std::string& error) {
std::cerr << "Cannot decrypt data: " << error << std::endl;
});
},
- [=] (const Data& data, const ValidationError& error) {
+ [] (const Data&, const ValidationError& error) {
std::cerr << "Cannot validate retrieved data: " << error << std::endl;
});
}
void
- onNack(const Interest& interest, const lp::Nack& nack)
+ onNack(const Interest& interest, const lp::Nack& nack) const
{
- std::cout << "received Nack with reason " << nack.getReason()
+ std::cout << "Received Nack with reason " << nack.getReason()
<< " for interest " << interest << std::endl;
}
void
- onTimeout(const Interest& interest)
+ onTimeout(const Interest& interest) const
{
- std::cout << "Timeout " << interest << std::endl;
+ std::cout << "Timeout for " << interest << std::endl;
}
private:
KeyChain m_keyChain;
- Face m_face;
- ValidatorConfig m_validator;
+ Face m_face{nullptr, m_keyChain};
+ ValidatorConfig m_validator{m_face};
Decryptor m_decryptor;
};
@@ -113,12 +111,13 @@
int
main(int argc, char** argv)
{
- ndn::nac::examples::Consumer consumer;
try {
+ ndn::nac::examples::Consumer consumer;
consumer.run();
+ return 0;
}
catch (const std::exception& e) {
std::cerr << "ERROR: " << e.what() << std::endl;
+ return 1;
}
- return 0;
}
diff --git a/examples/producer.cpp b/examples/producer.cpp
index a1f3422..9c9d95b 100644
--- a/examples/producer.cpp
+++ b/examples/producer.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California
+ * Copyright (c) 2014-2022, Regents of the University of California
*
* NAC library is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -37,15 +37,12 @@
{
public:
Producer()
- : m_face(nullptr, m_keyChain)
- , m_validator(m_face)
- , m_accessManager(m_keyChain.createIdentity("/nac/example", RsaKeyParams()), "test",
+ : m_accessManager(m_keyChain.createIdentity("/nac/example", RsaKeyParams()), "test",
m_keyChain, m_face)
, m_encryptor("/nac/example/NAC/test",
"/nac/example/CK", signingWithSha256(),
- [] (auto...) {
- std::cerr << "Failed to publish CK";
- }, m_validator, m_keyChain, m_face)\
+ [] (auto&&...) { std::cerr << "Failed to publish CK"; },
+ m_validator, m_keyChain, m_face)
{
m_validator.load(R"CONF(
trust-anchor
@@ -58,19 +55,19 @@
void
run()
{
- // give access to default identity. If consumer uses the same default identity, he will be able to decrypt
+ // Give access to default identity. If consumer uses the same default identity, it will be able to decrypt
m_accessManager.addMember(m_keyChain.getPib().getDefaultIdentity().getDefaultKey().getDefaultCertificate());
m_face.setInterestFilter("/example/testApp",
- bind(&Producer::onInterest, this, _1, _2),
- RegisterPrefixSuccessCallback(),
- bind(&Producer::onRegisterFailed, this, _1, _2));
+ std::bind(&Producer::onInterest, this, _1, _2),
+ nullptr, // RegisterPrefixSuccessCallback is optional
+ std::bind(&Producer::onRegisterFailed, this, _1, _2));
m_face.processEvents();
}
private:
void
- onInterest(const InterestFilter& filter, const Interest& interest)
+ onInterest(const InterestFilter&, const Interest& interest)
{
std::cout << "<< I: " << interest << std::endl;
@@ -80,14 +77,13 @@
.append("testApp") // add "testApp" component to Interest name
.appendVersion(); // add "version" component (current UNIX timestamp in milliseconds)
- static const std::string content = "HELLO KITTY";
-
// Create Data packet
- shared_ptr<Data> data = make_shared<Data>();
+ auto data = std::make_shared<Data>();
data->setName(dataName);
data->setFreshnessPeriod(10_s); // 10 seconds
- auto blob = m_encryptor.encrypt(reinterpret_cast<const uint8_t*>(content.data()), content.size());
+ static const std::string content = "HELLO KITTY";
+ auto blob = m_encryptor.encrypt({reinterpret_cast<const uint8_t*>(content.data()), content.size()});
data->setContent(blob.wireEncode());
// Sign Data packet with default identity
@@ -104,16 +100,15 @@
void
onRegisterFailed(const Name& prefix, const std::string& reason)
{
- std::cerr << "ERROR: Failed to register prefix \""
- << prefix << "\" in local hub's daemon (" << reason << ")"
- << std::endl;
+ std::cerr << "ERROR: Failed to register prefix '" << prefix
+ << "' with the local forwarder (" << reason << ")" << std::endl;
m_face.shutdown();
}
private:
KeyChain m_keyChain;
- Face m_face;
- ValidatorConfig m_validator;
+ Face m_face{nullptr, m_keyChain};
+ ValidatorConfig m_validator{m_face};
AccessManager m_accessManager;
Encryptor m_encryptor;
};
@@ -125,12 +120,13 @@
int
main(int argc, char** argv)
{
- ndn::nac::examples::Producer producer;
try {
+ ndn::nac::examples::Producer producer;
producer.run();
+ return 0;
}
catch (const std::exception& e) {
std::cerr << "ERROR: " << e.what() << std::endl;
+ return 1;
}
- return 0;
}
diff --git a/src/access-manager.cpp b/src/access-manager.cpp
index a759f2d..3602c98 100644
--- a/src/access-manager.cpp
+++ b/src/access-manager.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California
+ * Copyright (c) 2014-2022, Regents of the University of California
*
* NAC library is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -87,7 +87,7 @@
const size_t secretLength = 32;
uint8_t secret[secretLength + 1];
- random::generateSecureBytes(secret, secretLength);
+ random::generateSecureBytes({secret, secretLength});
// because of stupid bug in ndn-cxx, remove all \0 in generated secret, replace with 1
for (size_t i = 0; i < secretLength; ++i) {
if (secret[i] == 0) {
@@ -100,11 +100,11 @@
reinterpret_cast<const char*>(secret), secretLength);
PublicKey memberKey;
- memberKey.loadPkcs8(memberCert.getPublicKey().data(), memberCert.getPublicKey().size());
+ memberKey.loadPkcs8(memberCert.getPublicKey());
EncryptedContent content;
content.setPayload(kdkData->wireEncode());
- content.setPayloadKey(memberKey.encrypt(secret, secretLength));
+ content.setPayloadKey(memberKey.encrypt({secret, secretLength}));
auto kdk = make_shared<Data>(kdkName);
kdk->setContent(content.wireEncode());
diff --git a/src/decryptor.cpp b/src/decryptor.cpp
index 1630080..74290c8 100644
--- a/src/decryptor.cpp
+++ b/src/decryptor.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California
+ * Copyright (c) 2014-2022, Regents of the University of California
*
* NAC library is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -109,7 +109,7 @@
.setCanBePrefix(true),
[=] (const Interest& ckInterest, const Data& ckData) {
ck->second.pendingInterest = nullopt;
- // @TODO verify if the key is legit
+ // TODO: verify that the key is legit
Name kdkPrefix, kdkIdentity, kdkKeyName;
std::tie(kdkPrefix, kdkIdentity, kdkKeyName) =
extractKdkInfoFromCkName(ckData.getName(), ckInterest.getName(), onFailure);
@@ -165,12 +165,10 @@
NDN_LOG_DEBUG("Fetching KDK " << kdkName);
- ck->second.pendingInterest = m_face.expressInterest(Interest(kdkName)
- .setMustBeFresh(true)
- .setCanBePrefix(false),
+ ck->second.pendingInterest = m_face.expressInterest(Interest(kdkName).setMustBeFresh(true),
[=] (const Interest&, const Data& kdkData) {
ck->second.pendingInterest = nullopt;
- // @TODO verify if the key is legit
+ // TODO: verify that the key is legit
bool isOk = decryptAndImportKdk(kdkData, onFailure);
if (!isOk)
@@ -205,8 +203,7 @@
EncryptedContent content(kdkData.getContent().blockFromValue());
SafeBag safeBag(content.getPayload().blockFromValue());
- auto secret = m_keyChain.getTpm().decrypt(content.getPayloadKey().value(),
- content.getPayloadKey().value_size(),
+ auto secret = m_keyChain.getTpm().decrypt(content.getPayloadKey().value_bytes(),
m_credentialsKey.getName());
if (secret == nullptr) {
onFailure(ErrorCode::TpmKeyNotFound,
@@ -233,8 +230,7 @@
EncryptedContent content(ckData.getContent().blockFromValue());
- auto ckBits = m_internalKeyChain.getTpm().decrypt(content.getPayload().value(), content.getPayload().value_size(),
- kdkKeyName);
+ auto ckBits = m_internalKeyChain.getTpm().decrypt(content.getPayload().value_bytes(), kdkKeyName);
if (ckBits == nullptr) {
onFailure(ErrorCode::TpmKeyNotFound, "Could not decrypt secret, " + kdkKeyName.toUri() + " not found in TPM");
return;
@@ -259,11 +255,10 @@
}
OBufferStream os;
- security::transform::bufferSource(content.getPayload().value(), content.getPayload().value_size())
+ security::transform::bufferSource(content.getPayload().value_bytes())
>> security::transform::blockCipher(BlockCipherAlgorithm::AES_CBC,
CipherOperator::DECRYPT,
- ckBits.data(), ckBits.size(),
- content.getIv().value(), content.getIv().value_size())
+ ckBits, content.getIv().value_bytes())
>> security::transform::streamSink(os);
onSuccess(os.buf());
diff --git a/src/encrypted-content.cpp b/src/encrypted-content.cpp
index 4bc3d44..beaeda5 100644
--- a/src/encrypted-content.cpp
+++ b/src/encrypted-content.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California
+ * Copyright (c) 2014-2022, Regents of the University of California
*
* NAC library is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -26,7 +26,6 @@
namespace ndn {
namespace nac {
-BOOST_CONCEPT_ASSERT((boost::EqualityComparable<EncryptedContent>));
BOOST_CONCEPT_ASSERT((WireEncodable<EncryptedContent>));
BOOST_CONCEPT_ASSERT((WireDecodable<EncryptedContent>));
static_assert(std::is_base_of<ndn::tlv::Error, EncryptedContent::Error>::value,
@@ -42,7 +41,7 @@
{
m_wire.reset();
if (payload.type() != tlv::EncryptedPayload) {
- m_payload = Block(tlv::EncryptedPayload, std::move(payload));
+ m_payload = Block(tlv::EncryptedPayload, payload);
}
else {
m_payload = std::move(payload);
@@ -63,7 +62,7 @@
{
m_wire.reset();
if (iv.type() != tlv::InitializationVector) {
- m_iv = Block(tlv::InitializationVector, std::move(iv));
+ m_iv = Block(tlv::InitializationVector, iv);
}
else {
m_iv = std::move(iv);
@@ -75,7 +74,7 @@
EncryptedContent::setIv(ConstBufferPtr iv)
{
m_wire.reset();
- m_iv = Block(tlv::InitializationVector, iv);
+ m_iv = Block(tlv::InitializationVector, std::move(iv));
return *this;
}
@@ -83,7 +82,7 @@
EncryptedContent::unsetIv()
{
m_wire.reset();
- m_iv = Block();
+ m_iv = {};
return *this;
}
@@ -92,7 +91,7 @@
{
m_wire.reset();
if (key.type() != tlv::EncryptedPayloadKey) {
- m_payloadKey = Block(tlv::EncryptedPayloadKey, std::move(key));
+ m_payloadKey = Block(tlv::EncryptedPayloadKey, key);
}
else {
m_payloadKey = std::move(key);
@@ -112,7 +111,7 @@
EncryptedContent::unsetPayloadKey()
{
m_wire.reset();
- m_payloadKey = Block();
+ m_payloadKey = {};
return *this;
}
@@ -128,37 +127,37 @@
EncryptedContent::unsetKeyLocator()
{
m_wire.reset();
- m_keyLocator = Name();
+ m_keyLocator = {};
return *this;
}
template<encoding::Tag TAG>
size_t
-EncryptedContent::wireEncode(EncodingImpl<TAG>& block) const
+EncryptedContent::wireEncode(EncodingImpl<TAG>& encoder) const
{
size_t totalLength = 0;
if (hasKeyLocator()) {
- totalLength += m_keyLocator.wireEncode(block);
+ totalLength += m_keyLocator.wireEncode(encoder);
}
if (hasPayloadKey()) {
- totalLength += block.prependBlock(m_payloadKey);
+ totalLength += prependBlock(encoder, m_payloadKey);
}
if (hasIv()) {
- totalLength += block.prependBlock(m_iv);
+ totalLength += prependBlock(encoder, m_iv);
}
if (m_payload.isValid()) {
- totalLength += block.prependBlock(m_payload);
+ totalLength += prependBlock(encoder, m_payload);
}
else {
NDN_THROW(Error("Required EncryptedPayload is not set on EncryptedContent"));
}
- totalLength += block.prependVarNumber(totalLength);
- totalLength += block.prependVarNumber(tlv::EncryptedContent);
+ totalLength += encoder.prependVarNumber(totalLength);
+ totalLength += encoder.prependVarNumber(tlv::EncryptedContent);
return totalLength;
}
@@ -221,11 +220,5 @@
}
}
-bool
-EncryptedContent::operator==(const EncryptedContent& rhs) const
-{
- return wireEncode() == rhs.wireEncode();
-}
-
} // namespace nac
} // namespace ndn
diff --git a/src/encrypted-content.hpp b/src/encrypted-content.hpp
index 0f014c7..5ba0ab1 100644
--- a/src/encrypted-content.hpp
+++ b/src/encrypted-content.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California
+ * Copyright (c) 2014-2022, Regents of the University of California
*
* NAC library is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -139,16 +139,6 @@
void
wireDecode(const Block& wire);
-public:
- bool
- operator==(const EncryptedContent& rhs) const;
-
- bool
- operator!=(const EncryptedContent& rhs) const
- {
- return !(*this == rhs);
- }
-
private:
Block m_iv;
Block m_payload;
diff --git a/src/encryptor.cpp b/src/encryptor.cpp
index 5059eba..b35a744 100644
--- a/src/encryptor.cpp
+++ b/src/encryptor.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California
+ * Copyright (c) 2014-2022, Regents of the University of California
*
* NAC library is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -100,7 +100,7 @@
.append(CK)
.appendVersion(); // version = ID of CK
NDN_LOG_DEBUG("Generating new CK: " << m_ckName);
- random::generateSecureBytes(m_ckBits.data(), m_ckBits.size());
+ random::generateSecureBytes(m_ckBits);
// one implication: if CK updated before KEK fetched, KDK for the old CK will not be published
if (!m_kek) {
@@ -112,17 +112,17 @@
}
EncryptedContent
-Encryptor::encrypt(const uint8_t* data, size_t size)
+Encryptor::encrypt(span<const uint8_t> data)
{
// Generate IV
auto iv = make_shared<Buffer>(AES_IV_SIZE);
- random::generateSecureBytes(iv->data(), iv->size());
+ random::generateSecureBytes(*iv);
OBufferStream os;
- security::transform::bufferSource(data, size)
+ security::transform::bufferSource(data)
>> security::transform::blockCipher(BlockCipherAlgorithm::AES_CBC,
CipherOperator::ENCRYPT,
- m_ckBits.data(), m_ckBits.size(), iv->data(), iv->size())
+ m_ckBits, *iv)
>> security::transform::streamSink(os);
EncryptedContent content;
@@ -185,10 +185,10 @@
{
try {
PublicKey kek;
- kek.loadPkcs8(m_kek->getContent().value(), m_kek->getContent().value_size());
+ kek.loadPkcs8(m_kek->getContent().value_bytes());
EncryptedContent content;
- content.setPayload(kek.encrypt(m_ckBits.data(), m_ckBits.size()));
+ content.setPayload(kek.encrypt(m_ckBits));
auto ckData = make_shared<Data>(Name(m_ckName).append(ENCRYPTED_BY).append(m_kek->getName()));
ckData->setContent(content.wireEncode());
diff --git a/src/encryptor.hpp b/src/encryptor.hpp
index 9656674..1b177eb 100644
--- a/src/encryptor.hpp
+++ b/src/encryptor.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2019, Regents of the University of California
+ * Copyright (c) 2014-2022, Regents of the University of California
*
* NAC library is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -56,7 +56,7 @@
~Encryptor();
/**
- * Synchronously encrypt supplied data
+ * @brief Synchronously encrypt supplied data
*
* If KEK has not been fetched already, this method will trigger async fetching of it.
* After KEK successfully fetched, CK data will be automatically published.
@@ -72,7 +72,7 @@
* @return Encrypted content
*/
EncryptedContent
- encrypt(const uint8_t* data, size_t size);
+ encrypt(span<const uint8_t> data);
/**
* @brief Create a new content key and publish the corresponding CK data
@@ -84,8 +84,8 @@
regenerateCk();
public: // accessor interface for published data packets
-
- /** @return{ number of packets stored in in-memory storage }
+ /**
+ * @return number of packets stored in in-memory storage
*/
size_t
size() const
@@ -93,10 +93,10 @@
return m_ims.size();
}
- /** @brief Returns begin iterator of the in-memory storage ordered by
- * name with digest
+ /**
+ * @brief Returns begin iterator of the in-memory storage ordered by name with digest
*
- * @return{ const_iterator pointing to the beginning of m_cache }
+ * @return const_iterator pointing to the beginning of m_cache
*/
InMemoryStorage::const_iterator
begin() const
@@ -104,10 +104,10 @@
return m_ims.begin();
}
- /** @brief Returns end iterator of the in-memory storage ordered by
- * name with digest
+ /**
+ * @brief Returns end iterator of the in-memory storage ordered by name with digest
*
- * @return{ const_iterator pointing to the end of m_cache }
+ * @return const_iterator pointing to the end of m_cache
*/
InMemoryStorage::const_iterator
end() const
diff --git a/tests/key-chain-fixture.cpp b/tests/key-chain-fixture.cpp
index 29a75b8..b416524 100644
--- a/tests/key-chain-fixture.cpp
+++ b/tests/key-chain-fixture.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California
+ * Copyright (c) 2014-2022, Regents of the University of California
*
* NAC library is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -55,7 +55,7 @@
cert.setFreshnessPeriod(1_h);
// set content
- cert.setContent(key.getPublicKey().data(), key.getPublicKey().size());
+ cert.setContent(key.getPublicKey());
// set signature info
ndn::SignatureInfo info;
diff --git a/tests/unit/access-manager.t.cpp b/tests/unit/access-manager.t.cpp
index d15249f..dbbae40 100644
--- a/tests/unit/access-manager.t.cpp
+++ b/tests/unit/access-manager.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California
+ * Copyright (c) 2014-2022, Regents of the University of California
*
* NAC library is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -111,7 +111,7 @@
std::cerr << "const Block nacIdentity = \"";
auto block = m_keyChain.exportSafeBag(nacIdentity.getDefaultKey().getDefaultCertificate(),
"password", strlen("password"))->wireEncode();
- printHex(std::cerr, block.wire(), block.size(), true);
+ printHex(std::cerr, block, true);
std::cerr << "\"_block;\n\n";
std::cerr << "const std::vector<Block> userIdentities = {\n";
@@ -119,7 +119,7 @@
std::cerr << " \"";
block = m_keyChain.exportSafeBag(userId.getDefaultKey().getDefaultCertificate(),
"password", strlen("password"))->wireEncode();
- printHex(std::cerr, block.wire(), block.size(), true);
+ printHex(std::cerr, block, true);
std::cerr << "\"_block,\n";
}
std::cerr << "};\n\n";
@@ -127,7 +127,7 @@
std::cerr << "const std::vector<Block> managerPackets = {\n";
for (const auto& data : manager) {
std::cerr << " \"";
- printHex(std::cerr, data.wireEncode().wire(), data.wireEncode().size(), true);
+ printHex(std::cerr, data.wireEncode(), true);
std::cerr << "\"_block,\n";
}
std::cerr << "};\n\n";
diff --git a/tests/unit/encryptor.t.cpp b/tests/unit/encryptor.t.cpp
index 9439fcc..d9bafba 100644
--- a/tests/unit/encryptor.t.cpp
+++ b/tests/unit/encryptor.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California
+ * Copyright (c) 2014-2022, Regents of the University of California
*
* NAC library is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -103,8 +103,8 @@
encryptor.regenerateCk();
BOOST_CHECK_EQUAL(encryptor.m_isKekRetrievalInProgress, true);
- std::string plaintext = "Data to encrypt";
- auto block = encryptor.encrypt(reinterpret_cast<const uint8_t*>(plaintext.data()), plaintext.size());
+ const std::string plaintext = "Data to encrypt";
+ auto block = encryptor.encrypt({reinterpret_cast<const uint8_t*>(plaintext.data()), plaintext.size()});
EncryptedContent content(block);
auto ckPrefix = content.getKeyLocator();
@@ -147,8 +147,8 @@
size_t nErrors = 0;
onFailure.connect([&] (auto&&...) { ++nErrors; });
- std::string plaintext = "Data to encrypt";
- auto block = encryptor.encrypt(reinterpret_cast<const uint8_t*>(plaintext.data()), plaintext.size());
+ const std::string plaintext = "Data to encrypt";
+ auto block = encryptor.encrypt({reinterpret_cast<const uint8_t*>(plaintext.data()), plaintext.size()});
advanceClocks(1_ms, 10);
// check that KEK interests has been sent
@@ -204,8 +204,8 @@
std::cerr << "const std::vector<Block> encryptedBlobs = {\n";
for (size_t i = 0; i < 3; ++i) {
std::cerr << " \"";
- auto block = encryptor.encrypt(reinterpret_cast<const uint8_t*>(plaintext.data()), plaintext.size());
- printHex(std::cerr, block.wireEncode().wire(), block.wireEncode().size(), true);
+ auto block = encryptor.encrypt({reinterpret_cast<const uint8_t*>(plaintext.data()), plaintext.size()});
+ printHex(std::cerr, block.wireEncode(), true);
std::cerr << "\"_block,\n";
encryptor.regenerateCk();
@@ -216,7 +216,7 @@
std::cerr << "const std::vector<Block> encryptorPackets = {\n";
for (const auto& data : encryptor) {
std::cerr << " \"";
- printHex(std::cerr, data.wireEncode().wire(), data.wireEncode().size(), true);
+ printHex(std::cerr, data.wireEncode(), true);
std::cerr << "\"_block,\n";
}
std::cerr << "};\n\n";
diff --git a/wscript b/wscript
index b2b21f9..b3e2e4d 100644
--- a/wscript
+++ b/wscript
@@ -5,7 +5,6 @@
VERSION = '0.1.0'
APPNAME = 'ndn-nac'
-PACKAGE_BUGREPORT = 'https://redmine.named-data.net/projects/nac'
GIT_TAG_PREFIX = 'nac-'
def options(opt):
@@ -31,8 +30,9 @@
conf.find_program('dot', var='DOT', mandatory=False)
- conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'], uselib_store='NDN_CXX',
- pkg_config_path=os.environ.get('PKG_CONFIG_PATH', '%s/pkgconfig' % conf.env.LIBDIR))
+ pkg_config_path = os.environ.get('PKG_CONFIG_PATH', f'{conf.env.LIBDIR}/pkgconfig')
+ conf.check_cfg(package='libndn-cxx', args=['libndn-cxx >= 0.8.0', '--cflags', '--libs'],
+ uselib_store='NDN_CXX', pkg_config_path=pkg_config_path)
boost_libs = ['system', 'program_options']
if conf.env.WITH_TESTS: