util: backport C++20 std::span and use it in various APIs
Implementation taken from span-lite by Martin Moene,
commit 337af6e23f6d3264136c16565546244da23159ba
Change-Id: Icfd0ba6841cbf6ef7870c31c881df940da9faf7e
diff --git a/tools/ndnsec/cert-gen.cpp b/tools/ndnsec/cert-gen.cpp
index 8772062..51ad678 100644
--- a/tools/ndnsec/cert-gen.cpp
+++ b/tools/ndnsec/cert-gen.cpp
@@ -127,9 +127,9 @@
auto certRequest = loadFromFile<security::Certificate>(requestFile);
// validate that the content is a public key
- Buffer keyContent = certRequest.getPublicKey();
+ auto keyContent = certRequest.getPublicKey();
security::transform::PublicKey pubKey;
- pubKey.loadPkcs8(keyContent.data(), keyContent.size());
+ pubKey.loadPkcs8(keyContent);
Name certName = certRequest.getKeyName();
certName
@@ -161,7 +161,7 @@
{
using namespace security::transform;
const auto& wire = cert.wireEncode();
- bufferSource(wire.wire(), wire.size()) >> base64Encode(true) >> streamSink(std::cout);
+ bufferSource(make_span(wire.wire(), wire.size())) >> base64Encode(true) >> streamSink(std::cout);
}
return 0;