blob: 09c0b9c7428754c2371fcc421433afdbe40ba788 [file] [log] [blame]
Zhiyi Zhangf5246c42017-01-26 09:39:20 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesaventoe5b43692021-11-15 22:05:03 -05002/*
Davide Pesavento9510c912024-02-25 17:50:05 -05003 * Copyright (c) 2017-2024, Regents of the University of California.
Zhiyi Zhangf5246c42017-01-26 09:39:20 -08004 *
5 * This file is part of ndncert, a certificate management system based on NDN.
6 *
7 * ndncert is free software: you can redistribute it and/or modify it under the terms
8 * of the GNU General Public License as published by the Free Software Foundation, either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * ndncert is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License along with
16 * ndncert, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * See AUTHORS.md for complete list of ndncert authors and contributors.
19 */
20
21#include "ca-module.hpp"
Zhiyi Zhangdc25ddf2020-10-20 14:28:55 -070022#include "detail/crypto-helpers.hpp"
Zhiyi Zhang84e11842020-11-19 20:03:23 -080023#include "challenge/challenge-module.hpp"
Zhiyi Zhangc2c4ed22020-10-14 17:16:28 -070024#include "name-assignment/assignment-func.hpp"
Zhiyi Zhang062be6d2020-10-14 17:13:43 -070025#include "detail/challenge-encoder.hpp"
26#include "detail/error-encoder.hpp"
27#include "detail/info-encoder.hpp"
Zhiyi Zhang7cca76a2021-02-17 14:57:42 -080028#include "detail/request-encoder.hpp"
Zhiyi Zhang062be6d2020-10-14 17:13:43 -070029#include "detail/probe-encoder.hpp"
Davide Pesaventoe5b43692021-11-15 22:05:03 -050030
Zhiyi Zhang01e91a32020-09-29 12:10:00 -070031#include <ndn-cxx/metadata-object.hpp>
32#include <ndn-cxx/security/signing-helpers.hpp>
33#include <ndn-cxx/security/verification-helpers.hpp>
34#include <ndn-cxx/util/io.hpp>
Davide Pesavento9510c912024-02-25 17:50:05 -050035#include <ndn-cxx/util/logger.hpp>
Zhiyi Zhang01e91a32020-09-29 12:10:00 -070036#include <ndn-cxx/util/random.hpp>
Zhiyi Zhang8683ec92020-10-07 18:18:35 -070037#include <ndn-cxx/util/string-helper.hpp>
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080038
Davide Pesavento0d1d11c2022-04-11 22:11:34 -040039namespace ndncert::ca {
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080040
Davide Pesavento6f1a2ab2022-03-17 03:57:21 -040041const time::seconds DEFAULT_DATA_FRESHNESS_PERIOD = 1_s;
42const time::seconds REQUEST_VALIDITY_PERIOD_NOT_BEFORE_GRACE_PERIOD = 120_s;
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070043
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -070044NDN_LOG_INIT(ndncert.ca);
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080045
Davide Pesavento0dc02012021-11-23 22:55:03 -050046CaModule::CaModule(ndn::Face& face, ndn::KeyChain& keyChain,
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080047 const std::string& configPath, const std::string& storageType)
Zhiyi Zhang1b101b32021-02-17 14:36:03 -080048 : m_face(face)
49 , m_keyChain(keyChain)
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080050{
Zhiyi Zhanga63b7372017-05-17 14:14:34 -070051 // load the config and create storage
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080052 m_config.load(configPath);
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080053 m_storage = CaStorage::createCaStorage(storageType, m_config.caProfile.caPrefix, "");
Davide Pesavento6f1a2ab2022-03-17 03:57:21 -040054
55 ndn::random::generateSecureBytes(m_requestIdGenKey);
56
57 if (m_config.nameAssignmentFuncs.empty()) {
tylerliuf2e6bb52020-12-13 13:23:05 -080058 m_config.nameAssignmentFuncs.push_back(NameAssignmentFunc::createNameAssignmentFunc("random"));
Zhiyi Zhang8683ec92020-10-07 18:18:35 -070059 }
Davide Pesavento6f1a2ab2022-03-17 03:57:21 -040060
Zhiyi Zhang1c0bd372017-12-18 18:32:55 +080061 registerPrefix();
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080062}
63
64CaModule::~CaModule()
65{
Zhiyi Zhangc87d52b2020-09-28 22:07:18 -070066 for (auto& handle : m_interestFilterHandles) {
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070067 handle.cancel();
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080068 }
Zhiyi Zhangc87d52b2020-09-28 22:07:18 -070069 for (auto& handle : m_registeredPrefixHandles) {
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070070 handle.unregister();
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080071 }
72}
73
74void
Zhiyi Zhang1c0bd372017-12-18 18:32:55 +080075CaModule::registerPrefix()
76{
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070077 // register prefixes
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080078 Name prefix = m_config.caProfile.caPrefix;
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070079 prefix.append("CA");
Zhiyi Zhang1c0bd372017-12-18 18:32:55 +080080
Davide Pesavento6f1a2ab2022-03-17 03:57:21 -040081 auto prefixId = m_face.registerPrefix(prefix,
Davide Pesaventoe5b43692021-11-15 22:05:03 -050082 [&] (const Name& name) {
Zhiyi Zhang1b101b32021-02-17 14:36:03 -080083 // register INFO RDR metadata prefix
Davide Pesavento6f1a2ab2022-03-17 03:57:21 -040084 const auto& metaDataComp = ndn::MetadataObject::getKeywordComponent();
Zhiyi Zhang1b101b32021-02-17 14:36:03 -080085 auto filterId = m_face.setInterestFilter(Name(name).append("INFO").append(metaDataComp),
Davide Pesaventoe5b43692021-11-15 22:05:03 -050086 [this] (auto&&, const auto& i) { onCaProfileDiscovery(i); });
Zhiyi Zhang1b101b32021-02-17 14:36:03 -080087 m_interestFilterHandles.push_back(filterId);
Zhiyi Zhang696cd042020-10-07 21:27:36 -070088
Zhiyi Zhang1b101b32021-02-17 14:36:03 -080089 // register PROBE prefix
90 filterId = m_face.setInterestFilter(Name(name).append("PROBE"),
Davide Pesaventoe5b43692021-11-15 22:05:03 -050091 [this] (auto&&, const auto& i) { onProbe(i); });
Zhiyi Zhang1b101b32021-02-17 14:36:03 -080092 m_interestFilterHandles.push_back(filterId);
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070093
Zhiyi Zhang1b101b32021-02-17 14:36:03 -080094 // register NEW prefix
95 filterId = m_face.setInterestFilter(Name(name).append("NEW"),
Davide Pesaventoe5b43692021-11-15 22:05:03 -050096 [this] (auto&&, const auto& i) { onNewRenewRevoke(i, RequestType::NEW); });
Zhiyi Zhang1b101b32021-02-17 14:36:03 -080097 m_interestFilterHandles.push_back(filterId);
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070098
Zhiyi Zhang1b101b32021-02-17 14:36:03 -080099 // register SELECT prefix
100 filterId = m_face.setInterestFilter(Name(name).append("CHALLENGE"),
Davide Pesaventoe5b43692021-11-15 22:05:03 -0500101 [this] (auto&&, const auto& i) { onChallenge(i); });
Zhiyi Zhang1b101b32021-02-17 14:36:03 -0800102 m_interestFilterHandles.push_back(filterId);
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700103
Zhiyi Zhang1b101b32021-02-17 14:36:03 -0800104 // register REVOKE prefix
105 filterId = m_face.setInterestFilter(Name(name).append("REVOKE"),
Davide Pesaventoe5b43692021-11-15 22:05:03 -0500106 [this] (auto&&, const auto& i) { onNewRenewRevoke(i, RequestType::REVOKE); });
Zhiyi Zhang1b101b32021-02-17 14:36:03 -0800107 m_interestFilterHandles.push_back(filterId);
Davide Pesaventoe5b43692021-11-15 22:05:03 -0500108
Zhiyi Zhang1b101b32021-02-17 14:36:03 -0800109 NDN_LOG_TRACE("Prefix " << name << " got registered");
110 },
Davide Pesaventoe5b43692021-11-15 22:05:03 -0500111 [this] (auto&&, const auto& reason) { onRegisterFailed(reason); });
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700112 m_registeredPrefixHandles.push_back(prefixId);
Zhiyi Zhang1c0bd372017-12-18 18:32:55 +0800113}
114
Zhiyi Zhangf6c5d272020-09-28 10:17:32 -0700115void
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700116CaModule::setStatusUpdateCallback(const StatusUpdateCallback& onUpdateCallback)
Zhiyi Zhang7420cf52017-12-18 18:59:21 +0800117{
tylerliu1f480be2020-11-10 13:02:53 -0800118 m_statusUpdateCallback = onUpdateCallback;
Zhiyi Zhang7420cf52017-12-18 18:59:21 +0800119}
120
Zhiyi Zhang696cd042020-10-07 21:27:36 -0700121Data
122CaModule::getCaProfileData()
swa77020643ac2020-03-26 02:24:45 -0700123{
Zhiyi Zhangcd57da82020-10-08 20:35:40 -0700124 if (m_profileData == nullptr) {
Davide Pesavento6a625d82023-02-24 03:38:06 -0500125 auto key = m_keyChain.getPib().getIdentity(m_config.caProfile.caPrefix).getDefaultKey();
126 Block contentTLV = infotlv::encodeDataContent(m_config.caProfile, key.getDefaultCertificate());
swa77020643ac2020-03-26 02:24:45 -0700127
Zhiyi Zhang615b6b72021-01-11 14:25:32 -0800128 Name infoPacketName(m_config.caProfile.caPrefix);
Davide Pesavento0dc02012021-11-23 22:55:03 -0500129 auto segmentComp = ndn::name::Component::fromSegment(0);
Zhiyi Zhang615b6b72021-01-11 14:25:32 -0800130 infoPacketName.append("CA").append("INFO").appendVersion().append(segmentComp);
Zhiyi Zhangcd57da82020-10-08 20:35:40 -0700131 m_profileData = std::make_unique<Data>(infoPacketName);
Zhiyi Zhang615b6b72021-01-11 14:25:32 -0800132 m_profileData->setFinalBlock(segmentComp);
Zhiyi Zhangcd57da82020-10-08 20:35:40 -0700133 m_profileData->setContent(contentTLV);
134 m_profileData->setFreshnessPeriod(DEFAULT_DATA_FRESHNESS_PERIOD);
Zhiyi Zhang1b101b32021-02-17 14:36:03 -0800135 m_keyChain.sign(*m_profileData, signingByIdentity(m_config.caProfile.caPrefix));
Zhiyi Zhangcd57da82020-10-08 20:35:40 -0700136 }
Zhiyi Zhang696cd042020-10-07 21:27:36 -0700137 return *m_profileData;
138}
139
140void
Davide Pesavento0dc02012021-11-23 22:55:03 -0500141CaModule::onCaProfileDiscovery(const Interest&)
Zhiyi Zhang696cd042020-10-07 21:27:36 -0700142{
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700143 NDN_LOG_TRACE("Received CA Profile MetaData discovery Interest");
Zhiyi Zhang696cd042020-10-07 21:27:36 -0700144 if (m_profileData == nullptr) {
145 m_profileData = std::make_unique<Data>(getCaProfileData());
146 }
Davide Pesavento0dc02012021-11-23 22:55:03 -0500147 ndn::MetadataObject metadata;
Zhiyi Zhang696cd042020-10-07 21:27:36 -0700148 metadata.setVersionedName(m_profileData->getName().getPrefix(-1));
149 Name discoveryInterestName(m_profileData->getName().getPrefix(-2));
Davide Pesavento6f1a2ab2022-03-17 03:57:21 -0400150 discoveryInterestName.append(ndn::MetadataObject::getKeywordComponent());
Zhiyi Zhang1b101b32021-02-17 14:36:03 -0800151 m_face.put(metadata.makeData(discoveryInterestName, m_keyChain, signingByIdentity(m_config.caProfile.caPrefix)));
Zhiyi Zhangfc1678a2020-05-12 16:52:14 -0700152}
swa77020643ac2020-03-26 02:24:45 -0700153
Zhiyi Zhangfc1678a2020-05-12 16:52:14 -0700154void
Davide Pesavento6a625d82023-02-24 03:38:06 -0500155CaModule::onProbe(const Interest& request)
156{
swa77020643ac2020-03-26 02:24:45 -0700157 // PROBE Naming Convention: /<CA-Prefix>/CA/PROBE/[ParametersSha256DigestComponent]
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700158 NDN_LOG_TRACE("Received PROBE request");
Zhiyi Zhang1c0bd372017-12-18 18:32:55 +0800159
Zhiyi Zhang3e8ca252020-09-30 17:18:38 -0700160 // process PROBE requests: collect probe parameters
Tianyuan Yu13aac732022-03-03 20:59:54 -0800161 std::vector<ndn::Name> redirectionNames;
Davide Pesavento0dc02012021-11-23 22:55:03 -0500162 std::vector<ndn::PartialName> availableComponents;
Tianyuan Yu13aac732022-03-03 20:59:54 -0800163 try {
164 auto parameters = probetlv::decodeApplicationParameters(request.getApplicationParameters());
165
Davide Pesavento6a625d82023-02-24 03:38:06 -0500166 // collect redirections
Tianyuan Yu13aac732022-03-03 20:59:54 -0800167 for (auto &item : m_config.redirection) {
168 if (item.second->isRedirecting(parameters)) {
169 redirectionNames.push_back(item.first->getFullName());
170 }
171 }
172
Davide Pesavento6a625d82023-02-24 03:38:06 -0500173 // collect name assignments
Tianyuan Yu13aac732022-03-03 20:59:54 -0800174 for (auto &item : m_config.nameAssignmentFuncs) {
175 auto names = item->assignName(parameters);
176 availableComponents.insert(availableComponents.end(), names.begin(), names.end());
177 }
Davide Pesavento6a625d82023-02-24 03:38:06 -0500178 }
179 catch (const std::exception& e) {
Tianyuan Yu13aac732022-03-03 20:59:54 -0800180 NDN_LOG_ERROR("[CaModule::onProbe]Error in decoding TLV: " << e.what());
181 return;
Zhiyi Zhangcd57da82020-10-08 20:35:40 -0700182 }
Tianyuan Yu13aac732022-03-03 20:59:54 -0800183
Davide Pesavento6f1a2ab2022-03-17 03:57:21 -0400184 if (availableComponents.empty() && redirectionNames.empty()) {
Zhiyi Zhang8683ec92020-10-07 18:18:35 -0700185 m_face.put(generateErrorDataPacket(request.getName(), ErrorCode::INVALID_PARAMETER,
Zhiyi Zhangcb8acf22020-10-07 19:35:16 -0700186 "Cannot generate available names from parameters provided."));
Zhiyi Zhang8683ec92020-10-07 18:18:35 -0700187 return;
Zhiyi Zhang3e8ca252020-09-30 17:18:38 -0700188 }
Davide Pesavento6f1a2ab2022-03-17 03:57:21 -0400189
Tianyuan Yu13aac732022-03-03 20:59:54 -0800190 std::vector<Name> availableNames;
191 for (const auto &component : availableComponents) {
Zhiyi Zhang44c6a352020-12-14 10:57:17 -0800192 Name newIdentityName = m_config.caProfile.caPrefix;
Zhiyi Zhang3e8ca252020-09-30 17:18:38 -0700193 newIdentityName.append(component);
194 availableNames.push_back(newIdentityName);
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700195 }
Suyong Won44d0cce2020-05-10 04:07:43 -0700196
Zhiyi Zhang3e8ca252020-09-30 17:18:38 -0700197 Data result;
198 result.setName(request.getName());
Davide Pesavento6a625d82023-02-24 03:38:06 -0500199 result.setContent(probetlv::encodeDataContent(availableNames, m_config.caProfile.maxSuffixLength,
200 redirectionNames));
Zhiyi Zhang3e8ca252020-09-30 17:18:38 -0700201 result.setFreshnessPeriod(DEFAULT_DATA_FRESHNESS_PERIOD);
Zhiyi Zhang1b101b32021-02-17 14:36:03 -0800202 m_keyChain.sign(result, signingByIdentity(m_config.caProfile.caPrefix));
Zhiyi Zhang3e8ca252020-09-30 17:18:38 -0700203 m_face.put(result);
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700204 NDN_LOG_TRACE("Handle PROBE: send out the PROBE response");
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800205}
206
207void
Zhiyi Zhang01e91a32020-09-29 12:10:00 -0700208CaModule::onNewRenewRevoke(const Interest& request, RequestType requestType)
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800209{
Davide Pesavento6a625d82023-02-24 03:38:06 -0500210 // verify ca cert validity
211 auto caCert = m_keyChain.getPib()
212 .getIdentity(m_config.caProfile.caPrefix)
213 .getDefaultKey()
214 .getDefaultCertificate();
tylerliuf62cfeb2021-01-28 11:01:33 -0800215 if (!caCert.isValid()) {
216 NDN_LOG_ERROR("Server certificate invalid/expired");
217 m_face.put(generateErrorDataPacket(request.getName(), ErrorCode::BAD_VALIDITY_PERIOD,
218 "Server certificate invalid/expired"));
219 return;
220 }
221
Zhiyi Zhangaafc55e2020-09-28 17:54:48 -0700222 // NEW Naming Convention: /<CA-prefix>/CA/NEW/[SignedInterestParameters_Digest]
Zhiyi Zhangaafc55e2020-09-28 17:54:48 -0700223 // REVOKE Naming Convention: /<CA-prefix>/CA/REVOKE/[SignedInterestParameters_Digest]
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700224 // get ECDH pub key and cert request
Suyong Won19fba4d2020-05-09 13:39:46 -0700225 const auto& parameterTLV = request.getApplicationParameters();
Zhiyi Zhang1b101b32021-02-17 14:36:03 -0800226 std::vector <uint8_t> ecdhPub;
Davide Pesavento0dc02012021-11-23 22:55:03 -0500227 std::shared_ptr<Certificate> clientCert;
tylerliu0790bdb2020-10-02 00:50:51 -0700228 try {
Zhiyi Zhangf22ae242020-11-17 10:51:15 -0800229 requesttlv::decodeApplicationParameters(parameterTLV, requestType, ecdhPub, clientCert);
Zhiyi Zhangcd57da82020-10-08 20:35:40 -0700230 }
231 catch (const std::exception& e) {
tylerliu0790bdb2020-10-02 00:50:51 -0700232 if (!parameterTLV.hasValue()) {
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700233 NDN_LOG_ERROR("Empty TLV obtained from the Interest parameter.");
tylerliu0790bdb2020-10-02 00:50:51 -0700234 m_face.put(generateErrorDataPacket(request.getName(), ErrorCode::INVALID_PARAMETER,
235 "Empty TLV obtained from the Interest parameter."));
236 return;
237 }
Suyong Won7968f7a2020-05-12 01:01:25 -0700238
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700239 NDN_LOG_ERROR("Unrecognized self-signed certificate: " << e.what());
Zhiyi Zhang01e91a32020-09-29 12:10:00 -0700240 m_face.put(generateErrorDataPacket(request.getName(), ErrorCode::INVALID_PARAMETER,
tylerliu0790bdb2020-10-02 00:50:51 -0700241 "Unrecognized self-signed certificate."));
Zhiyi Zhang547c8512019-06-18 23:46:14 -0700242 return;
243 }
Suyong Won19fba4d2020-05-09 13:39:46 -0700244
Zhiyi Zhangbed854c2020-10-20 18:25:35 -0700245 if (ecdhPub.empty()) {
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700246 NDN_LOG_ERROR("Empty ECDH PUB obtained from the Interest parameter.");
Zhiyi Zhang01e91a32020-09-29 12:10:00 -0700247 m_face.put(generateErrorDataPacket(request.getName(), ErrorCode::INVALID_PARAMETER,
248 "Empty ECDH PUB obtained from the Interest parameter."));
Zhiyi Zhangbc2d4122019-09-10 12:10:54 -0700249 return;
250 }
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700251
252 // get server's ECDH pub key
tylerliu8e170d62020-09-30 01:31:53 -0700253 ECDHState ecdh;
Zhiyi Zhang1b101b32021-02-17 14:36:03 -0800254 std::vector <uint8_t> sharedSecret;
Zhiyi Zhangbc2d4122019-09-10 12:10:54 -0700255 try {
Zhiyi Zhangbed854c2020-10-20 18:25:35 -0700256 sharedSecret = ecdh.deriveSecret(ecdhPub);
Zhiyi Zhangbc2d4122019-09-10 12:10:54 -0700257 }
258 catch (const std::exception& e) {
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700259 NDN_LOG_ERROR("Cannot derive a shared secret using the provided ECDH key: " << e.what());
Zhiyi Zhang01e91a32020-09-29 12:10:00 -0700260 m_face.put(generateErrorDataPacket(request.getName(), ErrorCode::INVALID_PARAMETER,
261 "Cannot derive a shared secret using the provided ECDH key."));
Zhiyi Zhangbc2d4122019-09-10 12:10:54 -0700262 return;
263 }
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700264
tylerliud9239f52020-09-30 17:25:16 -0700265 // verify identity name
Zhiyi Zhang1b101b32021-02-17 14:36:03 -0800266 if (!m_config.caProfile.caPrefix.isPrefixOf(clientCert->getIdentity())
Davide Pesavento0dc02012021-11-23 22:55:03 -0500267 || !Certificate::isValidName(clientCert->getName())
Zhiyi Zhang44c6a352020-12-14 10:57:17 -0800268 || clientCert->getIdentity().size() <= m_config.caProfile.caPrefix.size()) {
Zhiyi Zhang1b101b32021-02-17 14:36:03 -0800269 NDN_LOG_ERROR("An invalid certificate name is being requested " << clientCert->getName());
270 m_face.put(generateErrorDataPacket(request.getName(), ErrorCode::NAME_NOT_ALLOWED,
271 "An invalid certificate name is being requested."));
272 return;
tylerliud9239f52020-09-30 17:25:16 -0700273 }
Zhiyi Zhang1b101b32021-02-17 14:36:03 -0800274 if (m_config.caProfile.maxSuffixLength) {
275 if (clientCert->getIdentity().size() > m_config.caProfile.caPrefix.size() + *m_config.caProfile.maxSuffixLength) {
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700276 NDN_LOG_ERROR("An invalid certificate name is being requested " << clientCert->getName());
tylerliud9239f52020-09-30 17:25:16 -0700277 m_face.put(generateErrorDataPacket(request.getName(), ErrorCode::NAME_NOT_ALLOWED,
278 "An invalid certificate name is being requested."));
279 return;
280 }
281 }
282
Zhiyi Zhangc87d52b2020-09-28 22:07:18 -0700283 if (requestType == RequestType::NEW) {
tylerliu4a00aad2020-09-26 02:03:17 -0700284 // check the validity period
Davide Pesavento0d1d11c2022-04-11 22:11:34 -0400285 auto [notBefore, notAfter] = clientCert->getValidityPeriod().getPeriod();
tylerliu4a00aad2020-09-26 02:03:17 -0700286 auto currentTime = time::system_clock::now();
Davide Pesavento0d1d11c2022-04-11 22:11:34 -0400287 if (notBefore < currentTime - REQUEST_VALIDITY_PERIOD_NOT_BEFORE_GRACE_PERIOD ||
288 notAfter > currentTime + m_config.caProfile.maxValidityPeriod ||
289 notAfter <= notBefore) {
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700290 NDN_LOG_ERROR("An invalid validity period is being requested.");
Zhiyi Zhang01e91a32020-09-29 12:10:00 -0700291 m_face.put(generateErrorDataPacket(request.getName(), ErrorCode::BAD_VALIDITY_PERIOD,
292 "An invalid validity period is being requested."));
tylerliu4a00aad2020-09-26 02:03:17 -0700293 return;
294 }
tylerliud9239f52020-09-30 17:25:16 -0700295
Zhiyi Zhang9829da92020-09-30 16:19:34 -0700296 // verify signature
Davide Pesavento0dc02012021-11-23 22:55:03 -0500297 if (!ndn::security::verifySignature(*clientCert, *clientCert)) {
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700298 NDN_LOG_ERROR("Invalid signature in the self-signed certificate.");
Zhiyi Zhang01e91a32020-09-29 12:10:00 -0700299 m_face.put(generateErrorDataPacket(request.getName(), ErrorCode::BAD_SIGNATURE,
300 "Invalid signature in the self-signed certificate."));
tylerliu4a00aad2020-09-26 02:03:17 -0700301 return;
302 }
Davide Pesavento0dc02012021-11-23 22:55:03 -0500303 if (!ndn::security::verifySignature(request, *clientCert)) {
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700304 NDN_LOG_ERROR("Invalid signature in the Interest packet.");
Zhiyi Zhang01e91a32020-09-29 12:10:00 -0700305 m_face.put(generateErrorDataPacket(request.getName(), ErrorCode::BAD_SIGNATURE,
306 "Invalid signature in the Interest packet."));
tylerliu4a00aad2020-09-26 02:03:17 -0700307 return;
308 }
Zhiyi Zhangaafc55e2020-09-28 17:54:48 -0700309 }
Zhiyi Zhangc87d52b2020-09-28 22:07:18 -0700310 else if (requestType == RequestType::REVOKE) {
tylerliud9239f52020-09-30 17:25:16 -0700311 //verify cert is from this CA
Davide Pesavento0dc02012021-11-23 22:55:03 -0500312 if (!ndn::security::verifySignature(*clientCert, caCert)) {
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700313 NDN_LOG_ERROR("Invalid signature in the certificate to revoke.");
Zhiyi Zhang01e91a32020-09-29 12:10:00 -0700314 m_face.put(generateErrorDataPacket(request.getName(), ErrorCode::BAD_SIGNATURE,
315 "Invalid signature in the certificate to revoke."));
tylerliu4a00aad2020-09-26 02:03:17 -0700316 return;
317 }
Zhiyi Zhang693c1272017-05-20 22:58:55 -0700318 }
319
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700320 // create new request instance
Zhiyi Zhanga2c39f72020-10-06 16:45:55 -0700321 uint8_t requestIdData[32];
322 Block certNameTlv = clientCert->getName().wireEncode();
Zhiyi Zhangf12ee302020-10-14 17:46:44 -0700323 try {
Davide Pesaventof48e1632023-04-24 22:00:26 -0400324 hmacSha256(certNameTlv.data(), certNameTlv.size(), m_requestIdGenKey, 32, requestIdData);
Zhiyi Zhangf12ee302020-10-14 17:46:44 -0700325 }
326 catch (const std::runtime_error& e) {
Davide Pesaventof48e1632023-04-24 22:00:26 -0400327 NDN_LOG_ERROR("Error computing the request ID: " << e.what());
Zhiyi Zhangf12ee302020-10-14 17:46:44 -0700328 m_face.put(generateErrorDataPacket(request.getName(), ErrorCode::INVALID_PARAMETER,
329 "Error computing the request ID."));
330 return;
331 }
Zhiyi Zhangc9ada1b2020-10-29 19:13:15 -0700332 RequestId id;
Zhiyi Zhang8fdb36b2020-10-18 11:58:51 -0700333 std::memcpy(id.data(), requestIdData, id.size());
Zhiyi Zhang1f5e86e2020-12-04 15:07:57 -0800334 // initialize request state
335 RequestState requestState;
Zhiyi Zhang44c6a352020-12-14 10:57:17 -0800336 requestState.caPrefix = m_config.caProfile.caPrefix;
Zhiyi Zhang1f5e86e2020-12-04 15:07:57 -0800337 requestState.requestId = id;
338 requestState.requestType = requestType;
339 requestState.cert = *clientCert;
Zhiyi Zhang6499edd2021-02-17 22:37:21 -0800340 // generate salt for HKDF
341 std::array<uint8_t, 32> salt;
Davide Pesavento6f1a2ab2022-03-17 03:57:21 -0400342 ndn::random::generateSecureBytes(salt);
Zhiyi Zhang6499edd2021-02-17 22:37:21 -0800343 // hkdf
344 std::array<uint8_t, 16> aesKey;
345 hkdf(sharedSecret.data(), sharedSecret.size(), salt.data(), salt.size(),
346 aesKey.data(), aesKey.size(), id.data(), id.size());
Zhiyi Zhang1f5e86e2020-12-04 15:07:57 -0800347 requestState.encryptionKey = aesKey;
Zhiyi Zhang21d52b52020-10-05 18:29:15 -0700348 try {
349 m_storage->addRequest(requestState);
350 }
Davide Pesavento0dc02012021-11-23 22:55:03 -0500351 catch (const std::runtime_error&) {
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700352 NDN_LOG_ERROR("Duplicate Request ID: The same request has been seen before.");
Zhiyi Zhanga2c39f72020-10-06 16:45:55 -0700353 m_face.put(generateErrorDataPacket(request.getName(), ErrorCode::INVALID_PARAMETER,
Zhiyi Zhangf12ee302020-10-14 17:46:44 -0700354 "Duplicate Request ID: The same request has been seen before."));
Zhiyi Zhanga2c39f72020-10-06 16:45:55 -0700355 return;
Zhiyi Zhang21d52b52020-10-05 18:29:15 -0700356 }
Davide Pesavento6f1a2ab2022-03-17 03:57:21 -0400357
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800358 Data result;
359 result.setName(request.getName());
Zhiyi Zhang42e1cf32019-06-22 17:11:42 -0700360 result.setFreshnessPeriod(DEFAULT_DATA_FRESHNESS_PERIOD);
Zhiyi Zhang1b101b32021-02-17 14:36:03 -0800361 result.setContent(requesttlv::encodeDataContent(ecdh.getSelfPubKey(),
362 salt, requestState.requestId,
Zhiyi Zhang44c6a352020-12-14 10:57:17 -0800363 m_config.caProfile.supportedChallenges));
Zhiyi Zhang1b101b32021-02-17 14:36:03 -0800364 m_keyChain.sign(result, signingByIdentity(m_config.caProfile.caPrefix));
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800365 m_face.put(result);
tylerliu1f480be2020-11-10 13:02:53 -0800366 if (m_statusUpdateCallback) {
367 m_statusUpdateCallback(requestState);
Zhiyi Zhang7420cf52017-12-18 18:59:21 +0800368 }
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800369}
370
371void
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700372CaModule::onChallenge(const Interest& request)
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800373{
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700374 // get certificate request state
Zhiyi Zhang8fdb36b2020-10-18 11:58:51 -0700375 auto requestState = getCertificateRequest(request);
Zhiyi Zhang84207c52020-10-28 21:45:44 -0700376 if (requestState == nullptr) {
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700377 NDN_LOG_ERROR("No certificate request state can be found.");
Zhiyi Zhangaafc55e2020-09-28 17:54:48 -0700378 m_face.put(generateErrorDataPacket(request.getName(), ErrorCode::INVALID_PARAMETER,
Zhiyi Zhang01e91a32020-09-29 12:10:00 -0700379 "No certificate request state can be found."));
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800380 return;
381 }
Davide Pesavento6f1a2ab2022-03-17 03:57:21 -0400382
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700383 // verify signature
Davide Pesavento0dc02012021-11-23 22:55:03 -0500384 if (!ndn::security::verifySignature(request, requestState->cert)) {
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700385 NDN_LOG_ERROR("Invalid Signature in the Interest packet.");
Zhiyi Zhang01e91a32020-09-29 12:10:00 -0700386 m_face.put(generateErrorDataPacket(request.getName(), ErrorCode::BAD_SIGNATURE,
387 "Invalid Signature in the Interest packet."));
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800388 return;
389 }
Davide Pesavento6f1a2ab2022-03-17 03:57:21 -0400390
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700391 // decrypt the parameters
Davide Pesavento0dc02012021-11-23 22:55:03 -0500392 ndn::Buffer paramTLVPayload;
Zhiyi Zhangbc2d4122019-09-10 12:10:54 -0700393 try {
Zhiyi Zhang3b9a5032021-02-18 11:15:09 -0800394 paramTLVPayload = decodeBlockWithAesGcm128(request.getApplicationParameters(), requestState->encryptionKey.data(),
395 requestState->requestId.data(), requestState->requestId.size(),
396 requestState->decryptionIv, requestState->encryptionIv);
Zhiyi Zhangbc2d4122019-09-10 12:10:54 -0700397 }
398 catch (const std::exception& e) {
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700399 NDN_LOG_ERROR("Interest paramaters decryption failed: " << e.what());
tylerliu7b9185c2020-11-24 12:15:18 -0800400 m_storage->deleteRequest(requestState->requestId);
Zhiyi Zhangaafc55e2020-09-28 17:54:48 -0700401 m_face.put(generateErrorDataPacket(request.getName(), ErrorCode::INVALID_PARAMETER,
Zhiyi Zhang01e91a32020-09-29 12:10:00 -0700402 "Interest paramaters decryption failed."));
Zhiyi Zhangbc2d4122019-09-10 12:10:54 -0700403 return;
404 }
Davide Pesavento6f1a2ab2022-03-17 03:57:21 -0400405 if (paramTLVPayload.empty()) {
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700406 NDN_LOG_ERROR("No parameters are found after decryption.");
tylerliu7b9185c2020-11-24 12:15:18 -0800407 m_storage->deleteRequest(requestState->requestId);
Zhiyi Zhangaafc55e2020-09-28 17:54:48 -0700408 m_face.put(generateErrorDataPacket(request.getName(), ErrorCode::INVALID_PARAMETER,
Zhiyi Zhang01e91a32020-09-29 12:10:00 -0700409 "No parameters are found after decryption."));
Zhiyi Zhang42e1cf32019-06-22 17:11:42 -0700410 return;
411 }
Davide Pesavento6f1a2ab2022-03-17 03:57:21 -0400412
413 auto paramTLV = ndn::makeBinaryBlock(tlv::EncryptedPayload, paramTLVPayload);
Suyong Won44d0cce2020-05-10 04:07:43 -0700414 paramTLV.parse();
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800415
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700416 // load the corresponding challenge module
tylerliu50d679e2020-10-14 14:08:39 -0700417 std::string challengeType = readString(paramTLV.get(tlv::SelectedChallenge));
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800418 auto challenge = ChallengeModule::createChallengeModule(challengeType);
419 if (challenge == nullptr) {
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700420 NDN_LOG_TRACE("Unrecognized challenge type: " << challengeType);
tylerliu7b9185c2020-11-24 12:15:18 -0800421 m_storage->deleteRequest(requestState->requestId);
Zhiyi Zhang1b101b32021-02-17 14:36:03 -0800422 m_face.put(
423 generateErrorDataPacket(request.getName(), ErrorCode::INVALID_PARAMETER, "Unrecognized challenge type."));
Zhiyi Zhangaafc55e2020-09-28 17:54:48 -0700424 return;
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800425 }
Suyong Won19fba4d2020-05-09 13:39:46 -0700426
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700427 NDN_LOG_TRACE("CHALLENGE module to be load: " << challengeType);
Zhiyi Zhang8fdb36b2020-10-18 11:58:51 -0700428 auto errorInfo = challenge->handleChallengeRequest(paramTLV, *requestState);
Zhiyi Zhangaafc55e2020-09-28 17:54:48 -0700429 if (std::get<0>(errorInfo) != ErrorCode::NO_ERROR) {
tylerliu7b9185c2020-11-24 12:15:18 -0800430 m_storage->deleteRequest(requestState->requestId);
Zhiyi Zhangaafc55e2020-09-28 17:54:48 -0700431 m_face.put(generateErrorDataPacket(request.getName(), std::get<0>(errorInfo), std::get<1>(errorInfo)));
432 return;
433 }
Suyong Won19fba4d2020-05-09 13:39:46 -0700434
Zhiyi Zhangaafc55e2020-09-28 17:54:48 -0700435 Block payload;
tylerliu7b9185c2020-11-24 12:15:18 -0800436 if (requestState->status == Status::PENDING) {
Zhiyi Zhangaafc55e2020-09-28 17:54:48 -0700437 // if challenge succeeded
tylerliud82cc5c2020-12-21 23:58:39 -0800438 if (requestState->requestType == RequestType::NEW || requestState->requestType == RequestType::RENEW) {
Zhiyi Zhang8fdb36b2020-10-18 11:58:51 -0700439 auto issuedCert = issueCertificate(*requestState);
tylerliu7b9185c2020-11-24 12:15:18 -0800440 requestState->cert = issuedCert;
441 requestState->status = Status::SUCCESS;
442 m_storage->deleteRequest(requestState->requestId);
Zhiyi Zhangaafc55e2020-09-28 17:54:48 -0700443
Tianyuan Yu42bc63e2024-10-18 10:18:38 -0700444 payload = challengetlv::encodeDataContent(*requestState, issuedCert.getName(),
445 m_config.caProfile.forwardingHint);
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700446 NDN_LOG_TRACE("Challenge succeeded. Certificate has been issued: " << issuedCert.getName());
Zhiyi Zhang1c0bd372017-12-18 18:32:55 +0800447 }
tylerliu7b9185c2020-11-24 12:15:18 -0800448 else if (requestState->requestType == RequestType::REVOKE) {
449 requestState->status = Status::SUCCESS;
450 m_storage->deleteRequest(requestState->requestId);
Zhiyi Zhangf9d94eb2020-12-21 15:39:38 -0800451 // TODO: where is the code to revoke?
Zhiyi Zhangf22ae242020-11-17 10:51:15 -0800452 payload = challengetlv::encodeDataContent(*requestState);
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700453 NDN_LOG_TRACE("Challenge succeeded. Certificate has been revoked");
Zhiyi Zhangaafc55e2020-09-28 17:54:48 -0700454 }
455 }
456 else {
Zhiyi Zhangf22ae242020-11-17 10:51:15 -0800457 payload = challengetlv::encodeDataContent(*requestState);
Zhiyi Zhangc1e98152020-12-21 16:15:39 -0800458 m_storage->updateRequest(*requestState);
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700459 NDN_LOG_TRACE("No failure no success. Challenge moves on");
Zhiyi Zhang1c0bd372017-12-18 18:32:55 +0800460 }
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700461
462 Data result;
463 result.setName(request.getName());
Zhiyi Zhang42e1cf32019-06-22 17:11:42 -0700464 result.setFreshnessPeriod(DEFAULT_DATA_FRESHNESS_PERIOD);
Zhiyi Zhang4c259db2020-10-30 09:36:01 -0700465 result.setContent(payload);
Zhiyi Zhang1b101b32021-02-17 14:36:03 -0800466 m_keyChain.sign(result, signingByIdentity(m_config.caProfile.caPrefix));
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700467 m_face.put(result);
tylerliu1f480be2020-11-10 13:02:53 -0800468 if (m_statusUpdateCallback) {
469 m_statusUpdateCallback(*requestState);
Zhiyi Zhang1c0bd372017-12-18 18:32:55 +0800470 }
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700471}
472
Davide Pesavento0dc02012021-11-23 22:55:03 -0500473Certificate
Zhiyi Zhang32d4b4e2020-10-28 22:10:49 -0700474CaModule::issueCertificate(const RequestState& requestState)
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800475{
Davide Pesavento0d1d11c2022-04-11 22:11:34 -0400476 auto period = requestState.cert.getValidityPeriod();
Davide Pesavento0dc02012021-11-23 22:55:03 -0500477 Certificate newCert;
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700478
tylerliu7b9185c2020-11-24 12:15:18 -0800479 Name certName = requestState.cert.getKeyName();
Tianyuan Yu13aac732022-03-03 20:59:54 -0800480 certName.append("NDNCERT").appendVersion();
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800481 newCert.setName(certName);
tylerliu7b9185c2020-11-24 12:15:18 -0800482 newCert.setContent(requestState.cert.getContent());
Tianyuan Yue78fd4d2022-05-25 13:18:06 -0700483 newCert.setFreshnessPeriod(1_h);
tylerliu7b9185c2020-11-24 12:15:18 -0800484 NDN_LOG_TRACE("cert request content " << requestState.cert);
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800485 SignatureInfo signatureInfo;
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800486 signatureInfo.setValidityPeriod(period);
Davide Pesavento0dc02012021-11-23 22:55:03 -0500487 ndn::security::SigningInfo signingInfo(ndn::security::SigningInfo::SIGNER_TYPE_ID,
488 m_config.caProfile.caPrefix, signatureInfo);
Tianyuan Yue78fd4d2022-05-25 13:18:06 -0700489 // Note: we should use KeyChain::makeCertificate() in future.
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800490 m_keyChain.sign(newCert, signingInfo);
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700491 NDN_LOG_TRACE("new cert got signed" << newCert);
Zhiyi Zhang343cdfb2018-01-17 12:04:28 -0800492 return newCert;
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800493}
494
Zhiyi Zhang1b101b32021-02-17 14:36:03 -0800495std::unique_ptr <RequestState>
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700496CaModule::getCertificateRequest(const Interest& request)
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800497{
Zhiyi Zhangc9ada1b2020-10-29 19:13:15 -0700498 RequestId requestId;
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800499 try {
Zhiyi Zhang44c6a352020-12-14 10:57:17 -0800500 auto& component = request.getName().at(m_config.caProfile.caPrefix.size() + 2);
Zhiyi Zhang8fdb36b2020-10-18 11:58:51 -0700501 std::memcpy(requestId.data(), component.value(), component.value_size());
Zhiyi Zhang42e1cf32019-06-22 17:11:42 -0700502 }
503 catch (const std::exception& e) {
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700504 NDN_LOG_ERROR("Cannot read the request ID out from the request: " << e.what());
Zhiyi Zhang8fdb36b2020-10-18 11:58:51 -0700505 return nullptr;
Zhiyi Zhang42e1cf32019-06-22 17:11:42 -0700506 }
507 try {
Davide Pesavento6f1a2ab2022-03-17 03:57:21 -0400508 NDN_LOG_TRACE("Request Id to query the database " << ndn::toHex(requestId));
Zhiyi Zhang32d4b4e2020-10-28 22:10:49 -0700509 return std::make_unique<RequestState>(m_storage->getRequest(requestId));
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800510 }
511 catch (const std::exception& e) {
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700512 NDN_LOG_ERROR("Cannot get certificate request record from the storage: " << e.what());
Zhiyi Zhang8fdb36b2020-10-18 11:58:51 -0700513 return nullptr;
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800514 }
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800515}
516
517void
518CaModule::onRegisterFailed(const std::string& reason)
519{
Zhiyi Zhangd61b4a82020-10-10 15:18:43 -0700520 NDN_LOG_ERROR("Failed to register prefix in local hub's daemon, REASON: " << reason);
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800521}
522
Zhiyi Zhangaafc55e2020-09-28 17:54:48 -0700523Data
524CaModule::generateErrorDataPacket(const Name& name, ErrorCode error, const std::string& errorInfo)
525{
526 Data result;
527 result.setName(name);
528 result.setFreshnessPeriod(DEFAULT_DATA_FRESHNESS_PERIOD);
Zhiyi Zhangf22ae242020-11-17 10:51:15 -0800529 result.setContent(errortlv::encodeDataContent(error, errorInfo));
Zhiyi Zhang1b101b32021-02-17 14:36:03 -0800530 m_keyChain.sign(result, signingByIdentity(m_config.caProfile.caPrefix));
Zhiyi Zhangaafc55e2020-09-28 17:54:48 -0700531 return result;
532}
533
Davide Pesavento0d1d11c2022-04-11 22:11:34 -0400534} // namespace ndncert::ca