Avoid deprecated ndn-cxx functions

Change-Id: Idcef8a642affb276581397e869d19534ec776240
diff --git a/src/ca-module.cpp b/src/ca-module.cpp
index 73582a8..8b9ba5c 100644
--- a/src/ca-module.cpp
+++ b/src/ca-module.cpp
@@ -38,8 +38,8 @@
 namespace ndncert {
 namespace ca {
 
-static const time::seconds DEFAULT_DATA_FRESHNESS_PERIOD = 1_s;
-static const time::seconds REQUEST_VALIDITY_PERIOD_NOT_BEFORE_GRACE_PERIOD = 120_s;
+const time::seconds DEFAULT_DATA_FRESHNESS_PERIOD = 1_s;
+const time::seconds REQUEST_VALIDITY_PERIOD_NOT_BEFORE_GRACE_PERIOD = 120_s;
 
 NDN_LOG_INIT(ndncert.ca);
 
@@ -51,10 +51,13 @@
   // load the config and create storage
   m_config.load(configPath);
   m_storage = CaStorage::createCaStorage(storageType, m_config.caProfile.caPrefix, "");
-  ndn::random::generateSecureBytes(m_requestIdGenKey, 32);
-  if (m_config.nameAssignmentFuncs.size() == 0) {
+
+  ndn::random::generateSecureBytes(m_requestIdGenKey);
+
+  if (m_config.nameAssignmentFuncs.empty()) {
     m_config.nameAssignmentFuncs.push_back(NameAssignmentFunc::createNameAssignmentFunc("random"));
   }
+
   registerPrefix();
 }
 
@@ -75,11 +78,10 @@
   Name prefix = m_config.caProfile.caPrefix;
   prefix.append("CA");
 
-  auto prefixId = m_face.registerPrefix(
-    prefix,
+  auto prefixId = m_face.registerPrefix(prefix,
     [&] (const Name& name) {
       // register INFO RDR metadata prefix
-      ndn::name::Component metaDataComp(32, reinterpret_cast<const uint8_t*>("metadata"), std::strlen("metadata"));
+      const auto& metaDataComp = ndn::MetadataObject::getKeywordComponent();
       auto filterId = m_face.setInterestFilter(Name(name).append("INFO").append(metaDataComp),
                                                [this] (auto&&, const auto& i) { onCaProfileDiscovery(i); });
       m_interestFilterHandles.push_back(filterId);
@@ -147,8 +149,7 @@
   ndn::MetadataObject metadata;
   metadata.setVersionedName(m_profileData->getName().getPrefix(-1));
   Name discoveryInterestName(m_profileData->getName().getPrefix(-2));
-  ndn::name::Component metadataComponent(32, reinterpret_cast<const uint8_t*>("metadata"), std::strlen("metadata"));
-  discoveryInterestName.append(metadataComponent);
+  discoveryInterestName.append(ndn::MetadataObject::getKeywordComponent());
   m_face.put(metadata.makeData(discoveryInterestName, m_keyChain, signingByIdentity(m_config.caProfile.caPrefix)));
 }
 
@@ -180,11 +181,12 @@
     return;
   }
 
-  if (availableComponents.size() == 0 && redirectionNames.size() == 0) {
+  if (availableComponents.empty() && redirectionNames.empty()) {
     m_face.put(generateErrorDataPacket(request.getName(), ErrorCode::INVALID_PARAMETER,
                                        "Cannot generate available names from parameters provided."));
     return;
   }
+
   std::vector<Name> availableNames;
   for (const auto &component : availableComponents) {
     Name newIdentityName = m_config.caProfile.caPrefix;
@@ -205,7 +207,6 @@
 void
 CaModule::onNewRenewRevoke(const Interest& request, RequestType requestType)
 {
-
   //verify ca cert validity
   const auto& caCert = m_keyChain.getPib()
                                  .getIdentity(m_config.caProfile.caPrefix)
@@ -338,7 +339,7 @@
   requestState.cert = *clientCert;
   // generate salt for HKDF
   std::array<uint8_t, 32> salt;
-  ndn::random::generateSecureBytes(salt.data(), salt.size());
+  ndn::random::generateSecureBytes(salt);
   // hkdf
   std::array<uint8_t, 16> aesKey;
   hkdf(sharedSecret.data(), sharedSecret.size(), salt.data(), salt.size(),
@@ -353,6 +354,7 @@
                                        "Duplicate Request ID: The same request has been seen before."));
     return;
   }
+
   Data result;
   result.setName(request.getName());
   result.setFreshnessPeriod(DEFAULT_DATA_FRESHNESS_PERIOD);
@@ -377,6 +379,7 @@
                                        "No certificate request state can be found."));
     return;
   }
+
   // verify signature
   if (!ndn::security::verifySignature(request, requestState->cert)) {
     NDN_LOG_ERROR("Invalid Signature in the Interest packet.");
@@ -384,6 +387,7 @@
                                        "Invalid Signature in the Interest packet."));
     return;
   }
+
   // decrypt the parameters
   ndn::Buffer paramTLVPayload;
   try {
@@ -398,14 +402,15 @@
                                        "Interest paramaters decryption failed."));
     return;
   }
-  if (paramTLVPayload.size() == 0) {
+  if (paramTLVPayload.empty()) {
     NDN_LOG_ERROR("No parameters are found after decryption.");
     m_storage->deleteRequest(requestState->requestId);
     m_face.put(generateErrorDataPacket(request.getName(), ErrorCode::INVALID_PARAMETER,
                                        "No parameters are found after decryption."));
     return;
   }
-  auto paramTLV = ndn::makeBinaryBlock(tlv::EncryptedPayload, paramTLVPayload.data(), paramTLVPayload.size());
+
+  auto paramTLV = ndn::makeBinaryBlock(tlv::EncryptedPayload, paramTLVPayload);
   paramTLV.parse();
 
   // load the corresponding challenge module
@@ -499,7 +504,7 @@
     return nullptr;
   }
   try {
-    NDN_LOG_TRACE("Request Id to query the database " << ndn::toHex(requestId.data(), requestId.size()));
+    NDN_LOG_TRACE("Request Id to query the database " << ndn::toHex(requestId));
     return std::make_unique<RequestState>(m_storage->getRequest(requestId));
   }
   catch (const std::exception& e) {
diff --git a/src/challenge/challenge-email.cpp b/src/challenge/challenge-email.cpp
index ea0345c..01bb7ba 100644
--- a/src/challenge/challenge-email.cpp
+++ b/src/challenge/challenge-email.cpp
@@ -51,16 +51,15 @@
     std::string emailAddress = readString(params.get(tlv::ParameterValue));
     auto lastComponentRequested = readString(request.cert.getIdentity().get(-1));
     if (lastComponentRequested != emailAddress) {
-      NDN_LOG_TRACE("Email and requested name do not match. Email " << emailAddress << " requested last component "
-                    << lastComponentRequested);
+      NDN_LOG_TRACE("Email and requested name do not match. Email " << emailAddress
+                    << " - requested last component " << lastComponentRequested);
     }
     std::string emailCode = generateSecretCode();
     JsonSection secretJson;
     secretJson.add(PARAMETER_KEY_CODE, emailCode);
     // send out the email
     sendEmail(emailAddress, emailCode, request);
-    NDN_LOG_TRACE("Secret for request " << ndn::toHex(request.requestId.data(), request.requestId.size())
-                  << " : " << emailCode);
+    NDN_LOG_TRACE("Secret for request " << ndn::toHex(request.requestId) << " : " << emailCode);
     return returnWithNewChallengeStatus(request, NEED_CODE, std::move(secretJson),
                                         m_maxAttemptTimes, m_secretLifetime);
   }
@@ -104,7 +103,7 @@
 ChallengeEmail::getRequestedParameterList(Status status, const std::string& challengeStatus)
 {
   std::multimap<std::string, std::string> result;
-  if (status == Status::BEFORE_CHALLENGE && challengeStatus == "") {
+  if (status == Status::BEFORE_CHALLENGE && challengeStatus.empty()) {
     result.emplace(PARAMETER_KEY_EMAIL, "Please input your email address");
   }
   else if (status == Status::CHALLENGE && challengeStatus == NEED_CODE) {
diff --git a/src/challenge/challenge-pin.cpp b/src/challenge/challenge-pin.cpp
index 6e42969..46f65fd 100644
--- a/src/challenge/challenge-pin.cpp
+++ b/src/challenge/challenge-pin.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2021, Regents of the University of California.
+ * Copyright (c) 2017-2022, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -48,7 +48,7 @@
     std::string secretCode = generateSecretCode();
     JsonSection secretJson;
     secretJson.add(PARAMETER_KEY_CODE, secretCode);
-    NDN_LOG_TRACE("Secret for request " << ndn::toHex(request.requestId.data(), request.requestId.size())
+    NDN_LOG_TRACE("Secret for request " << ndn::toHex(request.requestId)
                   << " : " << secretCode);
     return returnWithNewChallengeStatus(request, NEED_CODE, std::move(secretJson), m_maxAttemptTimes,
                                         m_secretLifetime);
diff --git a/src/challenge/challenge-possession.cpp b/src/challenge/challenge-possession.cpp
index a7f0f77..d4c8185 100644
--- a/src/challenge/challenge-possession.cpp
+++ b/src/challenge/challenge-possession.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017-2021, Regents of the University of California.
+ * Copyright (c) 2017-2022, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -119,9 +119,8 @@
     if (credential.hasContent() && signatureLen == 0) {
       Name signingKeyName = credential.getSignatureInfo().getKeyLocator().getName();
       ndn::security::transform::PublicKey key;
-      const auto& pubKeyBuffer = credential.getPublicKey();
-      key.loadPkcs8(pubKeyBuffer.data(), pubKeyBuffer.size());
-      for (auto anchor : m_trustAnchors) {
+      key.loadPkcs8(credential.getPublicKey());
+      for (const auto& anchor : m_trustAnchors) {
         if (anchor.getKeyName() == signingKeyName) {
           if (ndn::security::verifySignature(credential, anchor)) {
             checkOK = true;
@@ -138,13 +137,12 @@
 
     // for the first time, init the challenge
     std::array<uint8_t, 16> secretCode{};
-    ndn::random::generateSecureBytes(secretCode.data(), 16);
+    ndn::random::generateSecureBytes(secretCode);
     JsonSection secretJson;
-    secretJson.add(PARAMETER_KEY_NONCE, toHex(secretCode.data(), 16));
-    auto credential_block = credential.wireEncode();
-    secretJson.add(PARAMETER_KEY_CREDENTIAL_CERT, toHex(credential_block.wire(), credential_block.size()));
-    NDN_LOG_TRACE("Secret for request " << toHex(request.requestId.data(), request.requestId.size())
-                  << " : " << toHex(secretCode.data(), 16));
+    secretJson.add(PARAMETER_KEY_NONCE, toHex(secretCode));
+    const auto& credBlock = credential.wireEncode();
+    secretJson.add(PARAMETER_KEY_CREDENTIAL_CERT, toHex({credBlock.wire(), credBlock.size()}));
+    NDN_LOG_TRACE("Secret for request " << toHex(request.requestId) << " : " << toHex(secretCode));
     return returnWithNewChallengeStatus(request, NEED_PROOF, std::move(secretJson), m_maxAttemptTimes, m_secretLifetime);
   }
   else if (request.challengeState && request.challengeState->challengeStatus == NEED_PROOF) {
@@ -158,9 +156,8 @@
 
     //check the proof
     ndn::security::transform::PublicKey key;
-    const auto& pubKeyBuffer = credential.getPublicKey();
-    key.loadPkcs8(pubKeyBuffer.data(), pubKeyBuffer.size());
-    if (ndn::security::verifySignature({{secretCode.data(), secretCode.size()}}, signature, signatureLen, key)) {
+    key.loadPkcs8(credential.getPublicKey());
+    if (ndn::security::verifySignature({secretCode}, {signature, signatureLen}, key)) {
       return returnWithSuccess(request);
     }
     return returnWithError(request, ErrorCode::INVALID_PARAMETER,
@@ -203,7 +200,8 @@
         request.push_back(ndn::makeStringBlock(tlv::ParameterKey, PARAMETER_KEY_CREDENTIAL_CERT));
         Block valueBlock(tlv::ParameterValue);
         auto& certTlvStr = std::get<1>(item);
-        valueBlock.push_back(Block(reinterpret_cast<const uint8_t*>(certTlvStr.data()), certTlvStr.size()));
+        valueBlock.push_back(Block(ndn::make_span(reinterpret_cast<const uint8_t*>(certTlvStr.data()),
+                                                  certTlvStr.size())));
         request.push_back(valueBlock);
       }
       else {
@@ -219,9 +217,7 @@
       if (std::get<0>(item) == PARAMETER_KEY_PROOF) {
         request.push_back(ndn::makeStringBlock(tlv::ParameterKey, PARAMETER_KEY_PROOF));
         auto& sigTlvStr = std::get<1>(item);
-        auto valueBlock = ndn::makeBinaryBlock(tlv::ParameterValue,
-                                               reinterpret_cast<const uint8_t*>(sigTlvStr.data()),
-                                               sigTlvStr.size());
+        auto valueBlock = ndn::makeBinaryBlock(tlv::ParameterValue, sigTlvStr.data(), sigTlvStr.size());
         request.push_back(valueBlock);
       }
       else {
@@ -244,8 +240,8 @@
   auto keyName = ndn::security::extractKeyNameFromCertName(issuedCertName);
   auto id = keyChain.getPib().getIdentity(ndn::security::extractIdentityFromCertName(issuedCertName));
   auto issuedCert = id.getKey(keyName).getCertificate(issuedCertName);
-  auto issuedCertTlv = issuedCert.wireEncode();
-  auto signature = keyChain.getTpm().sign({{nonce.data(), nonce.size()}}, keyName, ndn::DigestAlgorithm::SHA256);
+  const auto& issuedCertTlv = issuedCert.wireEncode();
+  auto signature = keyChain.getTpm().sign({nonce}, keyName, ndn::DigestAlgorithm::SHA256);
 
   for (auto& item : params) {
     if (item.first == PARAMETER_KEY_CREDENTIAL_CERT) {
diff --git a/src/detail/ca-memory.cpp b/src/detail/ca-memory.cpp
index eae67cc..b3c5efd 100644
--- a/src/detail/ca-memory.cpp
+++ b/src/detail/ca-memory.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2021, Regents of the University of California.
+ * Copyright (c) 2017-2022, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -36,8 +36,7 @@
 {
   auto search = m_requests.find(requestId);
   if (search == m_requests.end()) {
-    NDN_THROW(std::runtime_error("Request " + ndn::toHex(requestId.data(), requestId.size()) +
-                                 " does not exists"));
+    NDN_THROW(std::runtime_error("Request " + ndn::toHex(requestId) + " does not exists"));
   }
   return search->second;
 }
@@ -50,8 +49,7 @@
     m_requests.insert(std::make_pair(request.requestId, request));
   }
   else {
-    NDN_THROW(std::runtime_error("Request " + ndn::toHex(request.requestId.data(), request.requestId.size()) +
-                                 " already exists"));
+    NDN_THROW(std::runtime_error("Request " + ndn::toHex(request.requestId) + " already exists"));
   }
 }
 
diff --git a/src/detail/ca-request-state.cpp b/src/detail/ca-request-state.cpp
index 68d189a..63ac317 100644
--- a/src/detail/ca-request-state.cpp
+++ b/src/detail/ca-request-state.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2021, Regents of the University of California.
+ * Copyright (c) 2017-2022, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -71,7 +71,7 @@
 operator<<(std::ostream& os, const RequestState& request)
 {
   os << "Request's CA name: " << request.caPrefix << "\n";
-  os << "Request's request ID: " << ndn::toHex(request.requestId.data(), request.requestId.size()) << "\n";
+  os << "Request's request ID: " << ndn::toHex(request.requestId) << "\n";
   os << "Request's status: " << statusToString(request.status) << "\n";
   os << "Request's challenge type: " << request.challengeType << "\n";
   if (request.challengeState) {
diff --git a/src/detail/ca-sqlite.cpp b/src/detail/ca-sqlite.cpp
index 45cd84d..0632edc 100644
--- a/src/detail/ca-sqlite.cpp
+++ b/src/detail/ca-sqlite.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2021, Regents of the University of California.
+ * Copyright (c) 2017-2022, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -157,8 +157,7 @@
     return state;
   }
   else {
-    NDN_THROW(std::runtime_error("Request " + ndn::toHex(requestId.data(), requestId.size()) +
-                                 " cannot be fetched from database"));
+    NDN_THROW(std::runtime_error("Request " + ndn::toHex(requestId) + " cannot be fetched from database"));
   }
 }
 
@@ -188,8 +187,8 @@
     statement.bind(11, request.challengeState->remainingTime.count());
   }
   if (statement.step() != SQLITE_DONE) {
-    NDN_THROW(std::runtime_error("Request " + ndn::toHex(request.requestId.data(), request.requestId.size()) +
-                                 " cannot be added to database"));
+    NDN_THROW(std::runtime_error("Request " + ndn::toHex(request.requestId) +
+                                 " cannot be added to the database"));
   }
 }
 
diff --git a/src/detail/challenge-encoder.cpp b/src/detail/challenge-encoder.cpp
index c2bdd68..1a7a83d 100644
--- a/src/detail/challenge-encoder.cpp
+++ b/src/detail/challenge-encoder.cpp
@@ -36,7 +36,7 @@
     if (request.challengeState->challengeStatus == "need-proof") {
       response.push_back(ndn::makeStringBlock(tlv::ParameterKey, "nonce"));
       auto nonce = ndn::fromHex(request.challengeState->secrets.get("nonce", ""));
-      response.push_back(ndn::makeBinaryBlock(tlv::ParameterValue, nonce->data(), 16));
+      response.push_back(ndn::makeBinaryBlock(tlv::ParameterValue, *nonce));
     }
   }
   if (!issuedCertName.empty()) {
@@ -57,7 +57,7 @@
   auto result = decodeBlockWithAesGcm128(contentBlock, state.m_aesKey.data(),
                                          state.m_requestId.data(), state.m_requestId.size(),
                                          state.m_decryptionIv, state.m_encryptionIv);
-  auto data = ndn::makeBinaryBlock(tlv::EncryptedPayload, result.data(), result.size());
+  auto data = ndn::makeBinaryBlock(tlv::EncryptedPayload, result);
   data.parse();
 
   int numStatus = 0;
diff --git a/src/detail/crypto-helpers.cpp b/src/detail/crypto-helpers.cpp
index d0c2e55..16e56a5 100644
--- a/src/detail/crypto-helpers.cpp
+++ b/src/detail/crypto-helpers.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2021, Regents of the University of California.
+ * Copyright (c) 2017-2022, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -416,17 +416,20 @@
   // The spec of AES encrypted payload TLV used in NDNCERT:
   //   https://github.com/named-data/ndncert/wiki/NDNCERT-Protocol-0.3#242-aes-gcm-encryption
   ndn::Buffer encryptedPayload(payloadSize);
-  uint8_t tag[16];
   if (encryptionIv.empty()) {
     encryptionIv.resize(12, 0);
-    ndn::random::generateSecureBytes(encryptionIv.data(), 8);
+    ndn::random::generateSecureBytes(ndn::make_span(encryptionIv).first(8));
   }
+
+  uint8_t tag[16];
   size_t encryptedPayloadLen = aesGcm128Encrypt(payload, payloadSize, associatedData, associatedDataSize,
                                                 key, encryptionIv.data(), encryptedPayload.data(), tag);
+
   Block content(tlvType);
-  content.push_back(ndn::makeBinaryBlock(tlv::InitializationVector, encryptionIv.data(), encryptionIv.size()));
-  content.push_back(ndn::makeBinaryBlock(tlv::AuthenticationTag, tag, 16));
-  content.push_back(ndn::makeBinaryBlock(tlv::EncryptedPayload, encryptedPayload.data(), encryptedPayloadLen));
+  content.push_back(ndn::makeBinaryBlock(tlv::InitializationVector, encryptionIv));
+  content.push_back(ndn::makeBinaryBlock(tlv::AuthenticationTag, tag));
+  content.push_back(ndn::makeBinaryBlock(tlv::EncryptedPayload,
+                                         ndn::make_span(encryptedPayload).first(encryptedPayloadLen)));
   content.encode();
   // update IV's counter
   updateIv(encryptionIv, payloadSize);
diff --git a/src/detail/request-encoder.cpp b/src/detail/request-encoder.cpp
index fde2d86..1187243 100644
--- a/src/detail/request-encoder.cpp
+++ b/src/detail/request-encoder.cpp
@@ -31,9 +31,8 @@
                                         const std::vector<uint8_t>& ecdhPub,
                                         const Certificate& certRequest)
 {
-  Block
-  request(ndn::tlv::ApplicationParameters);
-  request.push_back(ndn::makeBinaryBlock(tlv::EcdhPub, ecdhPub.data(), ecdhPub.size()));
+  Block request(ndn::tlv::ApplicationParameters);
+  request.push_back(ndn::makeBinaryBlock(tlv::EcdhPub, ecdhPub));
   if (requestType == RequestType::NEW || requestType == RequestType::RENEW) {
     request.push_back(makeNestedBlock(tlv::CertRequest, certRequest));
   }
@@ -83,14 +82,15 @@
 }
 
 Block
-requesttlv::encodeDataContent(const std::vector <uint8_t>& ecdhKey, const std::array<uint8_t, 32>& salt,
+requesttlv::encodeDataContent(const std::vector<uint8_t>& ecdhKey,
+                              const std::array<uint8_t, 32>& salt,
                               const RequestId& requestId,
-                              const std::vector <std::string>& challenges)
+                              const std::vector<std::string>& challenges)
 {
   Block response(ndn::tlv::Content);
-  response.push_back(ndn::makeBinaryBlock(tlv::EcdhPub, ecdhKey.data(), ecdhKey.size()));
-  response.push_back(ndn::makeBinaryBlock(tlv::Salt, salt.data(), salt.size()));
-  response.push_back(ndn::makeBinaryBlock(tlv::RequestId, requestId.data(), requestId.size()));
+  response.push_back(ndn::makeBinaryBlock(tlv::EcdhPub, ecdhKey));
+  response.push_back(ndn::makeBinaryBlock(tlv::Salt, salt));
+  response.push_back(ndn::makeBinaryBlock(tlv::RequestId, requestId));
   for (const auto& entry: challenges) {
     response.push_back(ndn::makeStringBlock(tlv::Challenge, entry));
   }
diff --git a/src/requester-request.cpp b/src/requester-request.cpp
index 60442c1..4e6d654 100644
--- a/src/requester-request.cpp
+++ b/src/requester-request.cpp
@@ -140,7 +140,7 @@
   Certificate certRequest;
   certRequest.setName(Name(keyName).append("cert-request").appendVersion());
   certRequest.setContentType(ndn::tlv::ContentType_Key);
-  certRequest.setContent(m_keyPair.getPublicKey().data(), m_keyPair.getPublicKey().size());
+  certRequest.setContent(m_keyPair.getPublicKey());
   SignatureInfo signatureInfo;
   signatureInfo.setValidityPeriod(ndn::security::ValidityPeriod(notBefore, notAfter));
   m_keyChain.sign(certRequest, signingByKey(keyName).setSignatureInfo(signatureInfo));
@@ -213,7 +213,7 @@
 std::shared_ptr<Interest>
 Request::genChallengeInterest(std::multimap<std::string, std::string>&& parameters)
 {
-  if (m_challengeType == "") {
+  if (m_challengeType.empty()) {
     NDN_THROW(std::runtime_error("The challenge has not been selected."));
   }
   auto challenge = ChallengeModule::createChallengeModule(m_challengeType);
@@ -223,7 +223,7 @@
   auto challengeParams = challenge->genChallengeRequestTLV(m_status, m_challengeStatus, std::move(parameters));
 
   Name interestName = m_caProfile.caPrefix;
-  interestName.append("CA").append("CHALLENGE").append(m_requestId.data(), m_requestId.size());
+  interestName.append("CA").append("CHALLENGE").append(Name::Component(m_requestId));
   auto interest = std::make_shared<Interest>(interestName);
   interest->setMustBeFresh(true);
 
diff --git a/tests/identity-management-fixture.cpp b/tests/identity-management-fixture.cpp
index c4a4590..254da23 100644
--- a/tests/identity-management-fixture.cpp
+++ b/tests/identity-management-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).
  *
@@ -115,7 +115,7 @@
   certificate.setFreshnessPeriod(1_h);
 
   // set content
-  certificate.setContent(key.getPublicKey().data(), key.getPublicKey().size());
+  certificate.setContent(key.getPublicKey());
 
   // set signature-info
   SignatureInfo info;
diff --git a/tests/unit-tests/ca-module.t.cpp b/tests/unit-tests/ca-module.t.cpp
index 73a722f..3d76678 100644
--- a/tests/unit-tests/ca-module.t.cpp
+++ b/tests/unit-tests/ca-module.t.cpp
@@ -302,7 +302,7 @@
   Certificate cert;
   cert.setName(Name(key.getName()).append("self-sign").appendVersion());
   cert.setContentType(ndn::tlv::ContentType_Key);
-  cert.setContent(key.getPublicKey().data(), key.getPublicKey().size());
+  cert.setContent(key.getPublicKey());
   SignatureInfo signatureInfo;
   signatureInfo.setValidityPeriod(ndn::security::ValidityPeriod(time::system_clock::now() - time::days(1),
                                                                 time::system_clock::now() - time::seconds(1)));
@@ -497,7 +497,7 @@
   clientCert.setName(Name(clientKey.getName()).append("cert-request").appendVersion());
   clientCert.setContentType(ndn::tlv::ContentType_Key);
   clientCert.setFreshnessPeriod(time::hours(24));
-  clientCert.setContent(clientKey.getPublicKey().data(), clientKey.getPublicKey().size());
+  clientCert.setContent(clientKey.getPublicKey());
   SignatureInfo signatureInfo;
   signatureInfo.setValidityPeriod(ndn::security::ValidityPeriod(time::system_clock::now(),
                                                                 time::system_clock::now() + time::hours(10)));
@@ -568,7 +568,7 @@
   clientCert.setName(Name(clientKey.getName()).append("NDNCERT").append("1473283247810732701"));
   clientCert.setContentType(ndn::tlv::ContentType_Key);
   clientCert.setFreshnessPeriod(time::hours(24));
-  clientCert.setContent(clientKey.getPublicKey().data(), clientKey.getPublicKey().size());
+  clientCert.setContent(clientKey.getPublicKey());
   SignatureInfo signatureInfo;
   signatureInfo.setValidityPeriod(ndn::security::ValidityPeriod(time::system_clock::now(),
                                                                 time::system_clock::now() + time::hours(10)));
diff --git a/tests/unit-tests/challenge-possession.t.cpp b/tests/unit-tests/challenge-possession.t.cpp
index 2c76c3d..0a25577 100644
--- a/tests/unit-tests/challenge-possession.t.cpp
+++ b/tests/unit-tests/challenge-possession.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2021, Regents of the University of California.
+ * Copyright (c) 2017-2022, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -66,7 +66,7 @@
   auto credentialName = Name(keyB.getName()).append("Credential").appendVersion();
   Certificate credential;
   credential.setName(credentialName);
-  credential.setContent(keyB.getPublicKey().data(), keyB.getPublicKey().size());
+  credential.setContent(keyB.getPublicKey());
   SignatureInfo signatureInfo;
   signatureInfo.setValidityPeriod(ndn::security::ValidityPeriod(time::system_clock::now(),
                                                                 time::system_clock::now() + time::minutes(1)));
@@ -119,7 +119,7 @@
   auto credentialName = Name(keyB.getName()).append("Credential").appendVersion();
   Certificate credential;
   credential.setName(credentialName);
-  credential.setContent(keyB.getPublicKey().data(), keyB.getPublicKey().size());
+  credential.setContent(keyB.getPublicKey());
   SignatureInfo signatureInfo;
   signatureInfo.setValidityPeriod(ndn::security::ValidityPeriod(time::system_clock::now(),
                                                                 time::system_clock::now() + time::minutes(1)));
diff --git a/wscript b/wscript
index 1c430b1..a3b2c88 100644
--- a/wscript
+++ b/wscript
@@ -3,7 +3,7 @@
 from waflib import Utils
 import os
 
-VERSION = '0.1.0'
+VERSION = '0.1'
 APPNAME = 'ndncert'
 GIT_TAG_PREFIX = 'ndncert-'
 
@@ -23,8 +23,9 @@
 
     conf.env.WITH_TESTS = conf.options.with_tests
 
-    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)
 
     conf.check_sqlite3()
     conf.check_openssl(lib='crypto', atleast_version='1.1.1')