Avoid deprecated ndn-cxx functions

Change-Id: I039306cf97a85ee28969651198823a5878b28ed3
diff --git a/src/ca-module.cpp b/src/ca-module.cpp
index 842ab39..12fff93 100644
--- a/src/ca-module.cpp
+++ b/src/ca-module.cpp
@@ -320,10 +320,10 @@
   uint8_t requestIdData[32];
   Block certNameTlv = clientCert->getName().wireEncode();
   try {
-    hmacSha256(certNameTlv.wire(), certNameTlv.size(), m_requestIdGenKey, 32, requestIdData);
+    hmacSha256(certNameTlv.data(), certNameTlv.size(), m_requestIdGenKey, 32, requestIdData);
   }
   catch (const std::runtime_error& e) {
-    NDN_LOG_ERROR("Error computing the request ID: " << std::string(e.what()));
+    NDN_LOG_ERROR("Error computing the request ID: " << e.what());
     m_face.put(generateErrorDataPacket(request.getName(), ErrorCode::INVALID_PARAMETER,
                                        "Error computing the request ID."));
     return;
diff --git a/src/challenge/challenge-possession.cpp b/src/challenge/challenge-possession.cpp
index 81a0bb6..20b0127 100644
--- a/src/challenge/challenge-possession.cpp
+++ b/src/challenge/challenge-possession.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017-2022, Regents of the University of California.
+ * Copyright (c) 2017-2023, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -38,7 +38,7 @@
 const std::string ChallengePossession::NEED_PROOF = "need-proof";
 
 ChallengePossession::ChallengePossession(const std::string& configPath)
-    : ChallengeModule("Possession", 1, time::seconds(60))
+  : ChallengeModule("Possession", 1, time::seconds(60))
 {
   if (configPath.empty()) {
     m_configFile = std::string(NDNCERT_SYSCONFDIR) + "/ndncert/challenge-credential.conf";
@@ -112,7 +112,6 @@
   // verify the credential and the self-signed cert
   if (request.status == Status::BEFORE_CHALLENGE) {
     NDN_LOG_TRACE("Challenge Interest arrives. Check certificate and init the challenge");
-    using ndn::toHex;
 
     // check the certificate
     if (!credential.hasContent() || signatureLen != 0) {
@@ -133,10 +132,9 @@
     std::array<uint8_t, 16> secretCode{};
     ndn::random::generateSecureBytes(secretCode);
     JsonSection secretJson;
-    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));
+    secretJson.add(PARAMETER_KEY_NONCE, ndn::toHex(secretCode));
+    secretJson.add(PARAMETER_KEY_CREDENTIAL_CERT, ndn::toHex(credential.wireEncode()));
+    NDN_LOG_TRACE("Secret for request " << ndn::toHex(request.requestId) << " : " << ndn::toHex(secretCode));
     return returnWithNewChallengeStatus(request, NEED_PROOF, std::move(secretJson), m_maxAttemptTimes, m_secretLifetime);
   }
   else if (request.challengeState && request.challengeState->challengeStatus == NEED_PROOF) {
@@ -210,9 +208,7 @@
     for (const auto& item : params) {
       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, sigTlvStr.data(), sigTlvStr.size());
-        request.push_back(valueBlock);
+        request.push_back(ndn::makeStringBlock(tlv::ParameterValue, std::get<1>(item)));
       }
       else {
         NDN_THROW(std::runtime_error("Wrong parameter provided."));
@@ -239,7 +235,7 @@
 
   for (auto& [key, val] : params) {
     if (key == PARAMETER_KEY_CREDENTIAL_CERT) {
-      val = std::string(reinterpret_cast<const char*>(issuedCertTlv.wire()), issuedCertTlv.size());
+      val = std::string(reinterpret_cast<const char*>(issuedCertTlv.data()), issuedCertTlv.size());
     }
     else if (key == PARAMETER_KEY_PROOF) {
       val = std::string(signature->get<char>(), signature->size());
diff --git a/tools/ndncert-ca-server.cpp b/tools/ndncert-ca-server.cpp
index a8af693..144f416 100644
--- a/tools/ndncert-ca-server.cpp
+++ b/tools/ndncert-ca-server.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2022, Regents of the University of California.
+ * Copyright (c) 2017-2023, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -39,24 +39,24 @@
 static ndn::KeyChain keyChain;
 static std::string repoHost = "localhost";
 static std::string repoPort = "7376";
-const size_t MAX_CACHED_CERT_NUM = 100;
+constexpr size_t MAX_CACHED_CERT_NUM = 100;
 
 static bool
 writeDataToRepo(const Data& data)
 {
   boost::asio::ip::tcp::iostream requestStream;
 #if BOOST_VERSION >= 106600
-    requestStream.expires_after(std::chrono::seconds(3));
+  requestStream.expires_after(std::chrono::seconds(5));
 #else
-    requestStream.expires_from_now(boost::posix_time::seconds(3));
-#endif //BOOST_VERSION >= 106600
+  requestStream.expires_from_now(boost::posix_time::seconds(5));
+#endif // BOOST_VERSION >= 106600
   requestStream.connect(repoHost, repoPort);
   if (!requestStream) {
     std::cerr << "ERROR: Cannot publish the certificate to repo-ng"
               << " (" << requestStream.error().message() << ")" << std::endl;
     return false;
   }
-  requestStream.write(reinterpret_cast<const char*>(data.wireEncode().wire()),
+  requestStream.write(reinterpret_cast<const char*>(data.wireEncode().data()),
                       data.wireEncode().size());
   return true;
 }