Update CaConfig and ClientCaItem. Add INFO packet encoding and decoding.

Change-Id: I2118bfee05640ddbf20643fa07bf4c91eb7ebd06
diff --git a/src/ca-config.cpp b/src/ca-config.cpp
index 3145839..c615e49 100644
--- a/src/ca-config.cpp
+++ b/src/ca-config.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2017-2019, Regents of the University of California.
+ * Copyright (c) 2017-2020, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -20,8 +20,12 @@
 
 #include "ca-config.hpp"
 #include "challenge-module.hpp"
-#include <ndn-cxx/util/io.hpp>
+
 #include <boost/filesystem.hpp>
+#include <ndn-cxx/util/io.hpp>
+#include <boost/property_tree/ptree.hpp>
+#include <boost/property_tree/json_parser.hpp>
+#include <boost/property_tree/info_parser.hpp>
 
 namespace ndn {
 namespace ndncert {
@@ -36,7 +40,6 @@
   catch (const std::exception& error) {
     BOOST_THROW_EXCEPTION(Error("Failed to parse configuration file " + fileName + ", " + error.what()));
   }
-
   if (configJson.begin() == configJson.end()) {
     BOOST_THROW_EXCEPTION(Error("Error processing configuration file: " + fileName + " no data"));
   }
@@ -46,30 +49,50 @@
 void
 CaConfig::parse(const JsonSection& configJson)
 {
-  // essential info
-  m_caName = Name(configJson.get("ca-prefix", ""));
-  if (m_caName.empty()) {
-    BOOST_THROW_EXCEPTION(Error("Cannot read ca-prefix from the config file"));
+  // CA prefix
+  m_caPrefix = Name(configJson.get(CONFIG_CA_PREFIX, ""));
+  if (m_caPrefix.empty()) {
+    BOOST_THROW_EXCEPTION(Error("Cannot parse ca-prefix from the config file"));
   }
-  m_freshnessPeriod = time::seconds(configJson.get("issuing-freshness", 720));
-  m_validityPeriod = time::days(configJson.get("max-validity-period", 360));
-
-  // optional info
-  m_probe = configJson.get("probe", "");
-  m_caInfo = configJson.get("ca-info", "");
-
+  // CA info
+  m_caInfo = configJson.get(CONFIG_CA_INFO, "");
+  // CA max validity period
+  m_maxValidityPeriod = time::seconds(configJson.get(CONFIG_MAX_VALIDITY_PERIOD, 3600));
+  // probe
+  m_probeParameterKeys.clear();
+  auto probeParameters = configJson.get_child_optional(CONFIG_PROBE_PARAMETERS);
+  if (probeParameters) {
+    parseProbeParameters(*probeParameters);
+  }
   // optional supported challenges
-  auto challengeList = configJson.get_child("supported-challenges");
-  m_supportedChallenges = parseChallengeList(challengeList);
+  m_supportedChallenges.clear();
+  auto challengeList = configJson.get_child_optional(CONFIG_SUPPORTED_CHALLENGES);
+  if (!challengeList) {
+    BOOST_THROW_EXCEPTION(Error("Cannot parse challenge list"));
+  }
+  parseChallengeList(*challengeList);
 }
 
-std::list<std::string>
-CaConfig::parseChallengeList(const JsonSection& section)
+void
+CaConfig::parseProbeParameters(const JsonSection& section)
 {
-  std::list<std::string> result;
   auto it = section.begin();
   for (; it != section.end(); it++) {
-    auto challengeType = it->second.get("type", "");
+    auto probeParameter = it->second.get(CONFIG_PROBE_PARAMETER, "");
+    if (probeParameter == "") {
+      BOOST_THROW_EXCEPTION(Error("Cannot read probe-parameter-key in probe-parameters from the config file"));
+    }
+    probeParameter = boost::algorithm::to_lower_copy(probeParameter);
+    m_probeParameterKeys.push_back(probeParameter);
+  }
+}
+
+void
+CaConfig::parseChallengeList(const JsonSection& section)
+{
+  auto it = section.begin();
+  for (; it != section.end(); it++) {
+    auto challengeType = it->second.get(CONFIG_CHALLENGE, "");
     if (challengeType == "") {
       BOOST_THROW_EXCEPTION(Error("Cannot read type in supported-challenges from the config file"));
     }
@@ -77,10 +100,12 @@
     if (!ChallengeModule::supportChallenge(challengeType)) {
       BOOST_THROW_EXCEPTION(Error("Does not support challenge read from the config file"));
     }
-    result.push_back(challengeType);
+    m_supportedChallenges.push_back(challengeType);
   }
-  return result;
+  if (m_supportedChallenges.size() == 0) {
+    BOOST_THROW_EXCEPTION(Error("At least one challenge should be identified under supported-challenges"));
+  }
 }
 
-} // namespace ndncert
-} // namespace ndn
+}  // namespace ndncert
+}  // namespace ndn
diff --git a/src/ca-config.hpp b/src/ca-config.hpp
index 091c327..5bf4f44 100644
--- a/src/ca-config.hpp
+++ b/src/ca-config.hpp
@@ -21,85 +21,159 @@
 #ifndef NDNCERT_CA_CONFIG_HPP
 #define NDNCERT_CA_CONFIG_HPP
 
+#include <ndn-cxx/security/v2/certificate.hpp>
+
 #include "certificate-request.hpp"
 #include "client-config.hpp"
+<<<<<<< HEAD
 #include <ndn-cxx/security/certificate.hpp>
+=======
+>>>>>>> Update CaConfig and ClientCaItem. Add INFO packet encoding and decoding.
 
 namespace ndn {
 namespace ndncert {
 
 /**
- * @brief The function should be able to convert a probe info string to an identity name
+ * @brief The name assignment function provided by the CA operator to generate available
+ * namecomponents.
+ * The function does not guarantee that all the returned names are available. Therefore the 
+ * CA should further check the availability of each returned name and remove unavailable results.
  *
- * The function should throw exceptions when there is an unexpected input.
+ * @p vector, input, a list of parameter key-value pair used for name assignment.
+ * @return a vector containing the possible namespaces derived from the parameters.
  */
-using ProbeHandler = function<std::string/*identity name*/ (const JsonSection& json/*requester input*/)>;
+using ProbeHandler = function<std::string /*identity name*/ (const JsonSection& json /*requester input*/)>;
+using NameAssignmentFunc = function<std::vector<std::string>(const std::vector<std::tuple<std::string, std::string>>)>;
 
 /**
- * @brief The function would be invoked whenever the certificate request status gets update
- *
+ * @brief The function would be invoked whenever the certificate request status is updated.
  * The callback is used to notice the CA application or CA command line tool. The callback is
  * fired whenever a request instance is created, challenge status is updated, and when certificate
  * is issued.
+ *
+ * @p CertificateRequest, input, the state of the certificate request whose status is updated.
  */
-using StatusUpdateCallback = function<void (const CertificateRequest&/*the latest request info*/)>;
+using StatusUpdateCallback = function<void(const CertificateRequest&)>;
 
 /**
- * @brief Represents a CA configuration instance
- *
+ * @brief CA's configuration on NDNCERT.
  * For CA configuration format, please refer to:
- *   https://github.com/named-data/ndncert/wiki/Ca-Configuration-Sample
+ *   https://github.com/named-data/ndncert/wiki/NDNCERT-Protocol-0.3#213-ca-profile
  *
- * @note Changes made to CaConfig won't be written back to the config
+ * The format of CA configuration in JSON
+ * {
+ *  "ca-prefix": "",
+ *  "ca-info": "",
+ *  "max-validity-period": "",
+ *  "probe-parameters":
+ *  [
+ *    {"probe-parameter-key": ""},
+ *    {"probe-parameter-key": ""}
+ *  ]
+ *  "supported-challenges":
+ *  [
+ *    {"challenge": ""},
+ *    {"challenge": ""}
+ *  ]
+ * }
  */
-class CaConfig
-{
+class CaConfig {
 public:
   /**
    * @brief Error that can be thrown from CaConfig
    */
-  class Error : public std::runtime_error
-  {
+  class Error : public std::runtime_error {
   public:
     using std::runtime_error::runtime_error;
   };
 
 public:
   /**
-   * @throw CaConfig::Error when config file does not exist
-   * @throw CaConfig::Error when the JSON text in the file cannot be parsed correctly
-   * @throw CaConfig::Error when the ca-prefix attribute in JSON text is empty
-   * @throw CaConfig::Error when the challenge is not specified or is not supported
+   * Load CA configuration from the file.
+   *
+   * @param fileName, the configuration file name.
+   * @throw CaConfig::Error when config file does not exist or the configuration
+   *        in the file cannot be parsed correctly.
+   * @throw CaConfig::Error when the ca-prefix attribute in JSON text is empty.
+   * @throw CaConfig::Error when the challenge is not specified or is not supported.
    */
   void
   load(const std::string& fileName);
 
+  /**
+   * Set the NameAssignmentFunction.
+   */
+  void
+  setNameAssignmentFunc(const NameAssignmentFunc& nameAssignmentFunc) {
+    m_nameAssignmentFunc = nameAssignmentFunc;
+  }
+
+  /**
+   * Set the StatusUpdateCallback.
+   */
+  void
+  setStatusUpdateCallback(const StatusUpdateCallback& statusUpdateCallback) {
+    m_statusUpdateCallback = statusUpdateCallback;
+  }
+
 private:
   void
   parse(const JsonSection& configJson);
 
-  std::list<std::string>
+  void
+  parseProbeParameters(const JsonSection& section);
+
+  void
   parseChallengeList(const JsonSection& configSection);
 
 public:
+  /**
+   * CA Name prefix (without /CA suffix).
+   */
+  Name m_caPrefix;
+  /**
+   * CA Information.
+   */
+  std::string m_caInfo;
+  /**
+   * A list of parameter-keys for PROBE.
+   */
+  std::list<std::string> m_probeParameterKeys;
+  /**
+   * Maximum allowed validity period of the certificate being requested.
+   * The value is in the unit of second.
+   */
+  time::seconds m_maxValidityPeriod;
+  /**
+   * A list of supported challenges.
+   */
+  std::list<std::string> m_supportedChallenges;
+  /**
+   * NameAssignmentFunc Callback function
+   */
+  NameAssignmentFunc m_nameAssignmentFunc;
+  /**
+   * StatusUpdate Callback function
+   */
+  StatusUpdateCallback m_statusUpdateCallback;
+
+  //====================old
+
   // basic info
   Name m_caName;
 
   // essential config
   time::seconds m_freshnessPeriod;
   time::days m_validityPeriod;
-  std::list<std::string> m_supportedChallenges;
 
   // optional parameters
   std::string m_probe;
-  std::string m_caInfo;
 
   // callbacks
   ProbeHandler m_probeHandler;
-  StatusUpdateCallback m_statusUpdateCallback;
 };
 
-} // namespace ndncert
-} // namespace ndn
+}  // namespace ndncert
+}  // namespace ndn
 
-#endif // NDNCERT_CA_CONFIG_HPP
+#endif  // NDNCERT_CA_CONFIG_HPP
diff --git a/src/certificate-request.hpp b/src/certificate-request.hpp
index c8de2ee..d44316c 100644
--- a/src/certificate-request.hpp
+++ b/src/certificate-request.hpp
@@ -22,7 +22,14 @@
 #define NDNCERT_CERTIFICATE_REQUEST_HPP
 
 #include "ndncert-common.hpp"
+<<<<<<< HEAD
 #include <ndn-cxx/security/certificate.hpp>
+=======
+#include <ndn-cxx/security/v2/certificate.hpp>
+#include <boost/property_tree/info_parser.hpp>
+#include <boost/property_tree/json_parser.hpp>
+#include <boost/property_tree/ptree.hpp>
+>>>>>>> Update CaConfig and ClientCaItem. Add INFO packet encoding and decoding.
 
 namespace ndn {
 namespace ndncert {
diff --git a/src/client-config.cpp b/src/client-config.cpp
index 1cd2618..589cd49 100644
--- a/src/client-config.cpp
+++ b/src/client-config.cpp
@@ -19,6 +19,7 @@
  */
 
 #include "client-config.hpp"
+
 #include <ndn-cxx/util/io.hpp>
 #include <fstream>
 
@@ -103,8 +104,8 @@
 void
 ClientConfig::removeCaItem(const Name& caName)
 {
-  m_caItems.remove_if([&] (const ClientCaItem& item) {return item.m_caName == caName;});
+  m_caItems.remove_if([&](const ClientCaItem& item) { return item.m_caName == caName; });
 }
 
-} // namespace ndncert
-} // namespace ndn
+}  // namespace ndncert
+}  // namespace ndn
diff --git a/src/client-config.hpp b/src/client-config.hpp
index 03a01f2..0195c48 100644
--- a/src/client-config.hpp
+++ b/src/client-config.hpp
@@ -22,7 +22,12 @@
 #define NDNCERT_CLIENT_CONFIG_HPP
 
 #include "certificate-request.hpp"
+<<<<<<< HEAD
 #include <ndn-cxx/security/certificate.hpp>
+=======
+
+#include <ndn-cxx/security/v2/certificate.hpp>
+>>>>>>> Update CaConfig and ClientCaItem. Add INFO packet encoding and decoding.
 
 namespace ndn {
 namespace ndncert {
@@ -30,19 +35,37 @@
 /**
  * @brief The configuration for a trusted CA from a requester's perspective
  */
-class ClientCaItem
-{
+class ClientCaItem {
 public:
+  /**
+   * CA Name prefix (without /CA suffix).
+   */
+  Name m_caPrefix;
+  /**
+   * CA Information.
+   */
+  std::string m_caInfo;
+  /**
+   * A list of parameter-keys for PROBE.
+   */
+  std::list<std::string> m_probeParameterKeys;
+  /**
+   * Maximum allowed validity period of the certificate being requested.
+   * The value is in the unit of second.
+   */
+  time::seconds m_maxValidityPeriod;
+  /**
+   * CA's certificate.
+   */
+  security::v2::Certificate m_anchor;
+
+  //=======old
+
   // The identity name of the CA. Extracted from config field "ca-prefix"
   Name m_caName;
 
-  // A brief introduction to the CA. Extracted from config field "ca-info"
-  std::string m_caInfo;
   // An instruction for requesters to use _PROBE. Extracted from config field "probe"
-  std::string m_probe; // "email::uid::name"
-
-  // CA's certificate
-  security::v2::Certificate m_anchor;
+  std::string m_probe;  // "email::uid::name"
 };
 
 /**
@@ -51,11 +74,9 @@
  * For Client configuration format, please refer to:
  *   https://github.com/named-data/ndncert/wiki/Client-Configuration-Sample
  */
-class ClientConfig
-{
+class ClientConfig {
 public:
-  class Error : public std::runtime_error
-  {
+  class Error : public std::runtime_error {
   public:
     using std::runtime_error::runtime_error;
   };
@@ -90,7 +111,7 @@
   std::string m_localNdncertAnchor;
 };
 
-} // namespace ndncert
-} // namespace ndn
+}  // namespace ndncert
+}  // namespace ndn
 
-#endif // NDNCERT_CLIENT_CONFIG_HPP
+#endif  // NDNCERT_CLIENT_CONFIG_HPP
diff --git a/src/ndncert-common.hpp b/src/ndncert-common.hpp
index d1fb8cf..b9ca5fb 100644
--- a/src/ndncert-common.hpp
+++ b/src/ndncert-common.hpp
@@ -37,14 +37,6 @@
 
 #include <cstddef>
 #include <cstdint>
-#include <functional>
-#include <list>
-#include <map>
-#include <memory>
-#include <set>
-#include <string>
-#include <unordered_map>
-#include <utility>
 
 #include <ndn-cxx/interest.hpp>
 #include <ndn-cxx/data.hpp>
@@ -53,17 +45,12 @@
 #include <ndn-cxx/link.hpp>
 #include <ndn-cxx/encoding/block.hpp>
 #include <ndn-cxx/lp/nack.hpp>
-#include <ndn-cxx/util/backports.hpp>
-#include <ndn-cxx/util/signal.hpp>
 #include <ndn-cxx/security/key-chain.hpp>
 #include <ndn-cxx/security/certificate.hpp>
 
 #include <boost/algorithm/string.hpp>
 #include <boost/assert.hpp>
 #include <boost/noncopyable.hpp>
-#include <boost/property_tree/ptree.hpp>
-#include <boost/property_tree/json_parser.hpp>
-#include <boost/property_tree/info_parser.hpp>
 #include <boost/throw_exception.hpp>
 
 namespace ndn {
@@ -87,6 +74,41 @@
 using ndn::time::system_clock;
 using ndn::time::toUnixTimestamp;
 
+enum : uint32_t {
+  tlv_ca_prefix = 129,
+  tlv_ca_info = 131,
+  tlv_parameter_key = 133,
+  tlv_parameter_value = 135,
+  tlv_ca_certificate = 137,
+  tlv_max_validity_period = 139,
+  tlv_probe_response = 141,
+  tlv_allow_longer_name = 143,
+  tlv_ecdh_pub = 145,
+  tlv_cert_request = 147,
+  tlv_salt = 149,
+  tlv_request_id = 151,
+  tlv_challenge = 153,
+  tlv_status = 155,
+  tlv_initialization_vector = 157,
+  tlv_encrypted_payload = 159,
+  tlv_selected_challenge = 161,
+  tlv_challenge_status = 163,
+  tlv_remaining_tries = 165,
+  tlv_remaining_time = 167,
+  tlv_issued_cert_name = 169,
+  tlv_error_code = 171,
+  tlv_error_info = 173
+};
+
+// Parse CA Configuration file
+const std::string CONFIG_CA_PREFIX = "ca-prefix";
+const std::string CONFIG_CA_INFO = "ca-info";
+const std::string CONFIG_MAX_VALIDITY_PERIOD = "max-validity-period";
+const std::string CONFIG_PROBE_PARAMETERS = "probe-parameters";
+const std::string CONFIG_PROBE_PARAMETER = "probe-parameter-key";
+const std::string CONFIG_SUPPORTED_CHALLENGES = "supported-challenges";
+const std::string CONFIG_CHALLENGE = "challenge";
+
 // JSON format for Certificate Issuer (CA)
 const std::string JSON_CA_NAME = "name";
 const std::string JSON_CA_CONFIG = "ca-config";
diff --git a/src/protocol-detail/info.cpp b/src/protocol-detail/info.cpp
new file mode 100644
index 0000000..93bd7b7
--- /dev/null
+++ b/src/protocol-detail/info.cpp
@@ -0,0 +1,72 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2017-2020, Regents of the University of California.
+ *
+ * This file is part of ndncert, a certificate management system based on NDN.
+ *
+ * ndncert is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ndncert is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License along with
+ * ndncert, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndncert authors and contributors.
+ */
+
+#include "info.hpp"
+
+namespace ndn {
+namespace ndncert {
+
+Block
+INFO::encodeContentFromCAConfig(const CaConfig& caConfig, const security::v2::Certificate& certificate)
+{
+  auto content = makeEmptyBlock(tlv::Content);
+  content.push_back(makeNestedBlock(tlv_ca_prefix, caConfig.m_caPrefix));
+  content.push_back(makeStringBlock(tlv_ca_info, caConfig.m_caInfo));
+  for (const auto& key : caConfig.m_probeParameterKeys) {
+    content.push_back(makeStringBlock(tlv_parameter_key, key));
+  }
+  content.push_back(makeNonNegativeIntegerBlock(tlv_max_validity_period, caConfig.m_maxValidityPeriod.count()));
+  content.push_back(makeNestedBlock(tlv_ca_certificate, certificate));
+  content.parse();
+  return content;
+}
+
+ClientCaItem
+INFO::decodeClientConfigFromContent(const Block& block)
+{
+  ClientCaItem result;
+  block.parse();
+  for (auto const& item : block.elements()) {
+    if (item.type() == tlv_ca_prefix) {
+      item.parse();
+      result.m_caPrefix.wireDecode(item.get(tlv::Name));
+    }
+    else if (item.type() == tlv_ca_info) {
+      result.m_caInfo = readString(item);
+    }
+    else if (item.type() == tlv_parameter_key) {
+      result.m_probeParameterKeys.push_back(readString(item));
+    }
+    else if (item.type() == tlv_max_validity_period) {
+      result.m_maxValidityPeriod = time::seconds(readNonNegativeInteger(item));
+    }
+    else if (item.type() == tlv_ca_certificate) {
+      item.parse();
+      result.m_anchor.wireDecode(item.get(tlv::Data));
+    }
+    else {
+      continue;
+    }
+  }
+  return result;
+}
+
+}  // namespace ndncert
+}  // namespace ndn
\ No newline at end of file
diff --git a/src/protocol-detail/info.hpp b/src/protocol-detail/info.hpp
new file mode 100644
index 0000000..89a907b
--- /dev/null
+++ b/src/protocol-detail/info.hpp
@@ -0,0 +1,42 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2017-2020, Regents of the University of California.
+ *
+ * This file is part of ndncert, a certificate management system based on NDN.
+ *
+ * ndncert is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ndncert is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License along with
+ * ndncert, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndncert authors and contributors.
+ */
+
+#ifndef NDNCERT_PROTOCOL_DETAIL_HPP
+#define NDNCERT_PROTOCOL_DETAIL_HPP
+
+#include "../ca-config.hpp"
+#include "../client-config.hpp"
+
+namespace ndn {
+namespace ndncert {
+
+class INFO {
+public:
+  static Block
+  encodeContentFromCAConfig(const CaConfig& caConfig, const security::v2::Certificate& certificate);
+
+  static ClientCaItem
+  decodeClientConfigFromContent(const Block& block);
+};
+
+}  // namespace ndncert
+}  // namespace ndn
+
+#endif // NDNCERT_PROTOCOL_DETAIL_HPP
\ No newline at end of file
diff --git a/tests/unit-tests/ca-config.t.cpp b/tests/unit-tests/ca-config.t.cpp
index 5b47505..0de626b 100644
--- a/tests/unit-tests/ca-config.t.cpp
+++ b/tests/unit-tests/ca-config.t.cpp
@@ -19,7 +19,7 @@
  */
 
 #include "ca-config.hpp"
-
+#include "protocol-detail/info.hpp"
 #include "identity-management-fixture.hpp"
 
 #include <ndn-cxx/security/transform/base64-encode.hpp>
@@ -36,11 +36,13 @@
 {
   CaConfig config;
   config.load("tests/unit-tests/ca.conf.test");
-  BOOST_CHECK_EQUAL(config.m_caName, "/ndn");
-  BOOST_CHECK_EQUAL(config.m_freshnessPeriod, time::seconds(720));
-  BOOST_CHECK_EQUAL(config.m_validityPeriod, time::days(360));
-  BOOST_CHECK_EQUAL(config.m_probe, "");
+  BOOST_CHECK_EQUAL(config.m_caPrefix, "/ndn");
   BOOST_CHECK_EQUAL(config.m_caInfo, "ndn testbed ca");
+  BOOST_CHECK_EQUAL(config.m_maxValidityPeriod, time::seconds(86400));
+  BOOST_CHECK_EQUAL(config.m_probeParameterKeys.size(), 1);
+  BOOST_CHECK_EQUAL(config.m_probeParameterKeys.front(), "full name");
+  BOOST_CHECK_EQUAL(config.m_supportedChallenges.size(), 1);
+  BOOST_CHECK_EQUAL(config.m_supportedChallenges.front(), "pin");
 }
 
 BOOST_AUTO_TEST_CASE(ReadNonexistConfigFile)
@@ -61,6 +63,23 @@
   BOOST_CHECK_THROW(config.load("tests/unit-tests/ca.conf.test3"), CaConfig::Error);
 }
 
+BOOST_AUTO_TEST_CASE(InfoContentEncodingDecoding)
+{
+  CaConfig config;
+  config.load("tests/unit-tests/ca.conf.test");
+
+  const auto& identity = addIdentity("/test");
+  const auto& cert = identity.getDefaultKey().getDefaultCertificate();
+  auto encoded = INFO::encodeContentFromCAConfig(config, cert);
+  auto decoded = INFO::decodeClientConfigFromContent(encoded);
+  BOOST_CHECK_EQUAL(config.m_caPrefix, decoded.m_caPrefix);
+  BOOST_CHECK_EQUAL(config.m_caInfo, decoded.m_caInfo);
+  BOOST_CHECK_EQUAL(config.m_maxValidityPeriod, decoded.m_maxValidityPeriod);
+  BOOST_CHECK_EQUAL(config.m_probeParameterKeys.size(), decoded.m_probeParameterKeys.size());
+  BOOST_CHECK_EQUAL(config.m_probeParameterKeys.front(), decoded.m_probeParameterKeys.front());
+  BOOST_CHECK_EQUAL(cert.wireEncode(), decoded.m_anchor.wireEncode());
+}
+
 BOOST_AUTO_TEST_SUITE_END() // TestCaConfig
 
 } // namespace tests
diff --git a/tests/unit-tests/ca.conf.test b/tests/unit-tests/ca.conf.test
index 8acd23c..f742a2b 100644
--- a/tests/unit-tests/ca.conf.test
+++ b/tests/unit-tests/ca.conf.test
@@ -1,10 +1,13 @@
 {
   "ca-prefix": "/ndn",
-  "issuing-freshness": "720",
-  "validity-period": "360",
+  "max-validity-period": "86400",
   "ca-info": "ndn testbed ca",
+  "probe-parameters":
+  [
+      { "probe-parameter-key": "full name" }
+  ],
   "supported-challenges":
   [
-      { "type": "PIN" }
+      { "challenge": "PIN" }
   ]
 }
\ No newline at end of file
diff --git a/tests/unit-tests/ca.conf.test2 b/tests/unit-tests/ca.conf.test2
index 17f058b..22cd83c 100644
--- a/tests/unit-tests/ca.conf.test2
+++ b/tests/unit-tests/ca.conf.test2
@@ -1,9 +1,8 @@
 {
-  "issuing-freshness": "720",
-  "validity-period": "360",
   "ca-info": "ndn testbed ca",
+  "max-validity-period": "86400",
   "supported-challenges":
   [
-      { "type": "PIN" }
+      { "challenge": "PIN" }
   ]
 }
\ No newline at end of file
diff --git a/tests/unit-tests/ca.conf.test3 b/tests/unit-tests/ca.conf.test3
index f12eabb..b330134 100644
--- a/tests/unit-tests/ca.conf.test3
+++ b/tests/unit-tests/ca.conf.test3
@@ -1,10 +1,9 @@
 {
   "ca-prefix": "/ndn",
-  "issuing-freshness": "720",
-  "validity-period": "360",
   "ca-info": "ndn testbed ca",
+  "max-validity-period": "86400",
   "supported-challenges":
   [
-      { "type": "PINN" }
+      { "challenge": "ABC" }
   ]
 }
\ No newline at end of file