Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | 0dc0201 | 2021-11-23 22:55:03 -0500 | [diff] [blame] | 2 | /* |
Tianyuan Yu | 6077555 | 2022-03-07 17:10:10 -0800 | [diff] [blame^] | 3 | * Copyright (c) 2017-2022, Regents of the University of California. |
Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 4 | * |
| 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 | |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 21 | #ifndef NDNCERT_REQUESTER_REQUEST_HPP |
| 22 | #define NDNCERT_REQUESTER_REQUEST_HPP |
Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 23 | |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 24 | #include "detail/ca-request-state.hpp" |
| 25 | #include "detail/crypto-helpers.hpp" |
| 26 | #include "detail/profile-storage.hpp" |
Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 27 | |
Davide Pesavento | 0dc0201 | 2021-11-23 22:55:03 -0500 | [diff] [blame] | 28 | #include <ndn-cxx/security/key-chain.hpp> |
| 29 | |
Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 30 | namespace ndncert { |
Zhiyi Zhang | 3002e6b | 2020-10-29 18:54:07 -0700 | [diff] [blame] | 31 | namespace requester { |
Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 32 | |
Davide Pesavento | 0dc0201 | 2021-11-23 22:55:03 -0500 | [diff] [blame] | 33 | class Request : boost::noncopyable |
Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 34 | { |
| 35 | public: |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 36 | /** |
Zhiyi Zhang | 6d9eda6 | 2020-10-16 17:37:02 -0700 | [diff] [blame] | 37 | * @brief Generates a CA profile discovery Interest following RDR protocol. |
| 38 | * |
| 39 | * @param caName The name prefix of the CA. |
Zhiyi Zhang | fbcab84 | 2020-10-07 15:17:13 -0700 | [diff] [blame] | 40 | * @return A shared pointer to an Interest ready to be sent. |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 41 | */ |
Davide Pesavento | 0dc0201 | 2021-11-23 22:55:03 -0500 | [diff] [blame] | 42 | static std::shared_ptr<Interest> |
Zhiyi Zhang | fbcab84 | 2020-10-07 15:17:13 -0700 | [diff] [blame] | 43 | genCaProfileDiscoveryInterest(const Name& caName); |
Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 44 | |
| 45 | /** |
Zhiyi Zhang | 6d9eda6 | 2020-10-16 17:37:02 -0700 | [diff] [blame] | 46 | * @brief Generates a CA profile fetching Interest following RDR protocol. |
| 47 | * |
| 48 | * @param reply The Data packet replied from discovery Interest. |
Zhiyi Zhang | fbcab84 | 2020-10-07 15:17:13 -0700 | [diff] [blame] | 49 | * @return A shared pointer to an Interest ready to be sent. |
| 50 | */ |
Davide Pesavento | 0dc0201 | 2021-11-23 22:55:03 -0500 | [diff] [blame] | 51 | static std::shared_ptr<Interest> |
Zhiyi Zhang | fbcab84 | 2020-10-07 15:17:13 -0700 | [diff] [blame] | 52 | genCaProfileInterestFromDiscoveryResponse(const Data& reply); |
| 53 | |
| 54 | /** |
Zhiyi Zhang | 6d9eda6 | 2020-10-16 17:37:02 -0700 | [diff] [blame] | 55 | * @brief Decodes the CA profile from the replied CA profile Data packet. |
| 56 | * |
Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 57 | * Will first verify the signature of the packet using the key provided inside the profile. |
Zhiyi Zhang | a16b758 | 2020-10-29 18:59:46 -0700 | [diff] [blame] | 58 | * The application should be cautious whether to add CaProfile into the ProfileStorage. |
Zhiyi Zhang | 6d9eda6 | 2020-10-16 17:37:02 -0700 | [diff] [blame] | 59 | * |
| 60 | * @param reply The Data packet replied from CA profile fetching Interest. |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 61 | * @return the CaProfile if decoding is successful |
| 62 | * @throw std::runtime_error if the decoding fails or receiving an error packet. |
Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 63 | */ |
Zhiyi Zhang | 997669a | 2020-10-28 21:15:40 -0700 | [diff] [blame] | 64 | static optional<CaProfile> |
Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 65 | onCaProfileResponse(const Data& reply); |
| 66 | |
Zhiyi Zhang | fbcab84 | 2020-10-07 15:17:13 -0700 | [diff] [blame] | 67 | /** |
Zhiyi Zhang | 6d9eda6 | 2020-10-16 17:37:02 -0700 | [diff] [blame] | 68 | * @brief Decodes the CA profile from the replied CA profile Data packet after the redirection. |
| 69 | * |
Zhiyi Zhang | fbcab84 | 2020-10-07 15:17:13 -0700 | [diff] [blame] | 70 | * Will first verify the signature of the packet using the key provided inside the profile and |
| 71 | * verify the certificate's digest matches the one obtained from the original CA. |
Zhiyi Zhang | a16b758 | 2020-10-29 18:59:46 -0700 | [diff] [blame] | 72 | * The application should be cautious whether to add CaProfile into the ProfileStorage. |
Zhiyi Zhang | 6d9eda6 | 2020-10-16 17:37:02 -0700 | [diff] [blame] | 73 | * |
| 74 | * @param reply The Data packet replied from CA profile fetching Interest. |
| 75 | * @param caCertFullName The full name obtained from original CA's probe response. |
Zhiyi Zhang | fbcab84 | 2020-10-07 15:17:13 -0700 | [diff] [blame] | 76 | * @return the CaProfile if decoding is successful |
| 77 | * @throw std::runtime_error if the decoding fails or receiving an error packet. |
| 78 | */ |
Zhiyi Zhang | 997669a | 2020-10-28 21:15:40 -0700 | [diff] [blame] | 79 | static optional<CaProfile> |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 80 | onCaProfileResponseAfterRedirection(const Data& reply, const Name& caCertFullName); |
| 81 | |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 82 | /** |
Zhiyi Zhang | 6d9eda6 | 2020-10-16 17:37:02 -0700 | [diff] [blame] | 83 | * @brief Generates a PROBE interest to the CA (for suggested name assignments). |
| 84 | * |
| 85 | * @param ca The CA that interest is send to |
| 86 | * @param probeInfo The requester information to carry to the CA |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 87 | * @return A shared pointer of to the encoded interest, ready to be sent. |
| 88 | */ |
Davide Pesavento | 0dc0201 | 2021-11-23 22:55:03 -0500 | [diff] [blame] | 89 | static std::shared_ptr<Interest> |
tylerliu | 4022633 | 2020-11-11 15:37:16 -0800 | [diff] [blame] | 90 | genProbeInterest(const CaProfile& ca, std::multimap<std::string, std::string>&& probeInfo); |
Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 91 | |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 92 | /** |
Zhiyi Zhang | 6d9eda6 | 2020-10-16 17:37:02 -0700 | [diff] [blame] | 93 | * @brief Decodes the replied data for PROBE process from the CA. |
| 94 | * |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 95 | * Will first verify the signature of the packet using the key provided inside the profile. |
Zhiyi Zhang | 6d9eda6 | 2020-10-16 17:37:02 -0700 | [diff] [blame] | 96 | * |
| 97 | * @param reply The replied data packet |
| 98 | * @param ca the profile of the CA that replies the packet |
| 99 | * @param identityNames The vector to load the decoded identity names from the data. |
| 100 | * @param otherCas The vector to load the decoded redirection CA prefixes from the data. |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 101 | * @throw std::runtime_error if the decoding fails or receiving an error packet. |
| 102 | */ |
Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 103 | static void |
| 104 | onProbeResponse(const Data& reply, const CaProfile& ca, |
tylerliu | b47dad7 | 2020-10-08 21:36:55 -0700 | [diff] [blame] | 105 | std::vector<std::pair<Name, int>>& identityNames, std::vector<Name>& otherCas); |
Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 106 | |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 107 | explicit |
Davide Pesavento | 0dc0201 | 2021-11-23 22:55:03 -0500 | [diff] [blame] | 108 | Request(ndn::KeyChain& keyChain, const CaProfile& profile, RequestType requestType); |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 109 | |
Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 110 | // NEW/REVOKE/RENEW related helpers |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 111 | /** |
Zhiyi Zhang | 6d9eda6 | 2020-10-16 17:37:02 -0700 | [diff] [blame] | 112 | * @brief Generates a NEW interest to the CA. |
| 113 | * |
| 114 | * @param state The current requester state for this request. Will be modified in the function. |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 115 | * @param newIdentityName The identity name to be requested. |
Zhiyi Zhang | 6d9eda6 | 2020-10-16 17:37:02 -0700 | [diff] [blame] | 116 | * @param notBefore The expected notBefore field for the certificate (starting time) |
| 117 | * @param notAfter The expected notAfter field for the certificate (expiration time) |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 118 | * @return The shared pointer to the encoded interest. |
| 119 | */ |
Davide Pesavento | 0dc0201 | 2021-11-23 22:55:03 -0500 | [diff] [blame] | 120 | std::shared_ptr<Interest> |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 121 | genNewInterest(const Name& newIdentityName, |
Zhiyi Zhang | c5d93a9 | 2020-10-14 17:07:35 -0700 | [diff] [blame] | 122 | const time::system_clock::TimePoint& notBefore, |
| 123 | const time::system_clock::TimePoint& notAfter); |
Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 124 | |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 125 | /** |
Zhiyi Zhang | 6d9eda6 | 2020-10-16 17:37:02 -0700 | [diff] [blame] | 126 | * @brief Generates a REVOKE interest to the CA. |
| 127 | * |
| 128 | * @param state The current requester state for this request. Will be modified in the function. |
| 129 | * @param certificate The certificate to the revoked. |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 130 | * @return The shared pointer to the encoded interest. |
| 131 | */ |
Davide Pesavento | 0dc0201 | 2021-11-23 22:55:03 -0500 | [diff] [blame] | 132 | std::shared_ptr<Interest> |
| 133 | genRevokeInterest(const Certificate& certificate); |
Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 134 | |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 135 | /** |
Zhiyi Zhang | 6d9eda6 | 2020-10-16 17:37:02 -0700 | [diff] [blame] | 136 | * @brief Decodes the replied data of NEW, RENEW, or REVOKE interest from the CA. |
| 137 | * |
| 138 | * @param state The current requester state for the request. Will be updated in the function. |
| 139 | * @param reply The replied data from the network |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 140 | * @return the list of challenge accepted by the CA, for CHALLENGE step. |
| 141 | * @throw std::runtime_error if the decoding fails or receiving an error packet. |
| 142 | */ |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 143 | std::list<std::string> |
| 144 | onNewRenewRevokeResponse(const Data& reply); |
Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 145 | |
| 146 | // CHALLENGE helpers |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 147 | /** |
Zhiyi Zhang | 6d9eda6 | 2020-10-16 17:37:02 -0700 | [diff] [blame] | 148 | * @brief Generates the required parameter for the selected challenge for the request |
| 149 | * |
| 150 | * @param state, The requester state of the request.Will be updated in the function. |
| 151 | * @param challengeSelected, The selected challenge for the request. |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 152 | * Can use state.m_challengeType to continue. |
| 153 | * @return The requirement list for the current stage of the challenge, in name, prompt mapping. |
Zhiyi Zhang | c5d93a9 | 2020-10-14 17:07:35 -0700 | [diff] [blame] | 154 | * @throw std::runtime_error if the challenge is not supported. |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 155 | */ |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 156 | std::multimap<std::string, std::string> |
| 157 | selectOrContinueChallenge(const std::string& challengeSelected); |
Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 158 | |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 159 | /** |
Zhiyi Zhang | 6d9eda6 | 2020-10-16 17:37:02 -0700 | [diff] [blame] | 160 | * @brief Generates the CHALLENGE interest for the request. |
| 161 | * |
| 162 | * @param state, The requester state of the request. |
| 163 | * @param parameters, The requirement list, in name, value mapping. |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 164 | * @return The shared pointer to the encoded interest |
Zhiyi Zhang | c5d93a9 | 2020-10-14 17:07:35 -0700 | [diff] [blame] | 165 | * @throw std::runtime_error if the challenge is not selected or is not supported. |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 166 | */ |
Davide Pesavento | 0dc0201 | 2021-11-23 22:55:03 -0500 | [diff] [blame] | 167 | std::shared_ptr<Interest> |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 168 | genChallengeInterest(std::multimap<std::string, std::string>&& parameters); |
Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 169 | |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 170 | /** |
Zhiyi Zhang | 6d9eda6 | 2020-10-16 17:37:02 -0700 | [diff] [blame] | 171 | * @brief Decodes the responded data from the CHALLENGE interest. |
| 172 | * |
| 173 | * @param state, the corresponding requester state of the request. Will be modified. |
| 174 | * @param reply, the response data. |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 175 | * @throw std::runtime_error if the decoding fails or receiving an error packet. |
| 176 | */ |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 177 | void |
| 178 | onChallengeResponse(const Data& reply); |
Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 179 | |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 180 | /** |
Zhiyi Zhang | 6d9eda6 | 2020-10-16 17:37:02 -0700 | [diff] [blame] | 181 | * @brief Generate the interest to fetch the issued certificate |
| 182 | * |
| 183 | * @param state, the state of the request. |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 184 | * @return The shared pointer to the encoded interest |
| 185 | */ |
Davide Pesavento | 0dc0201 | 2021-11-23 22:55:03 -0500 | [diff] [blame] | 186 | std::shared_ptr<Interest> |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 187 | genCertFetchInterest() const; |
Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 188 | |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 189 | /** |
Zhiyi Zhang | 6d9eda6 | 2020-10-16 17:37:02 -0700 | [diff] [blame] | 190 | * @brief Decoded and installs the response certificate from the certificate fetch. |
| 191 | * |
| 192 | * @param reply, the data replied from the certificate fetch interest. |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 193 | * @return The shared pointer to the certificate being fetched. |
| 194 | */ |
Davide Pesavento | 0dc0201 | 2021-11-23 22:55:03 -0500 | [diff] [blame] | 195 | static std::shared_ptr<Certificate> |
Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 196 | onCertFetchResponse(const Data& reply); |
| 197 | |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 198 | /** |
Zhiyi Zhang | 6d9eda6 | 2020-10-16 17:37:02 -0700 | [diff] [blame] | 199 | * @brief End the current request session and performs cleanup if necessary. |
| 200 | * |
| 201 | * @param state, the requester state for the request. |
tylerliu | df6e5cc | 2020-10-05 18:52:13 -0700 | [diff] [blame] | 202 | */ |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 203 | void |
| 204 | endSession(); |
Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 205 | |
| 206 | private: |
| 207 | static void |
| 208 | processIfError(const Data& data); |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 209 | |
| 210 | public: |
| 211 | /** |
| 212 | * @brief The CA profile for this request. |
| 213 | */ |
Zhiyi Zhang | 6499edd | 2021-02-17 22:37:21 -0800 | [diff] [blame] | 214 | CaProfile m_caProfile; |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 215 | /** |
| 216 | * @brief The type of request. Either NEW, RENEW, or REVOKE. |
| 217 | */ |
Zhiyi Zhang | 6499edd | 2021-02-17 22:37:21 -0800 | [diff] [blame] | 218 | RequestType m_type; |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 219 | /** |
| 220 | * @brief The identity name for the requesting certificate. |
| 221 | */ |
Zhiyi Zhang | 6499edd | 2021-02-17 22:37:21 -0800 | [diff] [blame] | 222 | Name m_identityName; |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 223 | /** |
| 224 | * @brief The CA-generated request ID for the request. |
| 225 | */ |
Zhiyi Zhang | 6499edd | 2021-02-17 22:37:21 -0800 | [diff] [blame] | 226 | RequestId m_requestId; |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 227 | /** |
| 228 | * @brief The current status of the request. |
| 229 | */ |
Zhiyi Zhang | 6499edd | 2021-02-17 22:37:21 -0800 | [diff] [blame] | 230 | Status m_status = Status::BEFORE_CHALLENGE; |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 231 | /** |
| 232 | * @brief The type of challenge chosen. |
| 233 | */ |
Zhiyi Zhang | 6499edd | 2021-02-17 22:37:21 -0800 | [diff] [blame] | 234 | std::string m_challengeType; |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 235 | /** |
| 236 | * @brief The status of the current challenge. |
| 237 | */ |
Zhiyi Zhang | 6499edd | 2021-02-17 22:37:21 -0800 | [diff] [blame] | 238 | std::string m_challengeStatus; |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 239 | /** |
| 240 | * @brief The remaining number of tries left for the challenge |
| 241 | */ |
Zhiyi Zhang | 6499edd | 2021-02-17 22:37:21 -0800 | [diff] [blame] | 242 | int m_remainingTries = 0; |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 243 | /** |
| 244 | * @brief The time this challenge will remain fresh |
| 245 | */ |
Zhiyi Zhang | 6499edd | 2021-02-17 22:37:21 -0800 | [diff] [blame] | 246 | time::system_clock::TimePoint m_freshBefore; |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 247 | /** |
| 248 | * @brief the name of the certificate being issued. |
| 249 | */ |
Zhiyi Zhang | 6499edd | 2021-02-17 22:37:21 -0800 | [diff] [blame] | 250 | Name m_issuedCertName; |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 251 | /** |
Tianyuan Yu | 6077555 | 2022-03-07 17:10:10 -0800 | [diff] [blame^] | 252 | * @brief The optional forwarding hint. |
| 253 | */ |
| 254 | Name m_forwardingHint; |
| 255 | /** |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 256 | * @brief ecdh state. |
| 257 | */ |
Zhiyi Zhang | 6499edd | 2021-02-17 22:37:21 -0800 | [diff] [blame] | 258 | ECDHState m_ecdh; |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 259 | /** |
| 260 | * @brief AES key derived from the ecdh shared secret. |
| 261 | */ |
Zhiyi Zhang | 6499edd | 2021-02-17 22:37:21 -0800 | [diff] [blame] | 262 | std::array<uint8_t, 16> m_aesKey = {}; |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 263 | /** |
| 264 | * @brief The last Initialization Vector used by the AES encryption. |
| 265 | */ |
Zhiyi Zhang | 6499edd | 2021-02-17 22:37:21 -0800 | [diff] [blame] | 266 | std::vector<uint8_t> m_encryptionIv; |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 267 | /** |
| 268 | * @brief The last Initialization Vector used by the other side's AES encryption. |
| 269 | */ |
Zhiyi Zhang | 6499edd | 2021-02-17 22:37:21 -0800 | [diff] [blame] | 270 | std::vector<uint8_t> m_decryptionIv; |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 271 | /** |
| 272 | * @brief Store Nonce for signature |
| 273 | */ |
Zhiyi Zhang | 6499edd | 2021-02-17 22:37:21 -0800 | [diff] [blame] | 274 | std::array<uint8_t, 16> m_nonce = {}; |
Zhiyi Zhang | 3f1c7cf | 2021-02-17 14:08:14 -0800 | [diff] [blame] | 275 | |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 276 | private: |
| 277 | /** |
| 278 | * @brief The local keychain to generate and install identities, keys and certificates |
| 279 | */ |
Davide Pesavento | 0dc0201 | 2021-11-23 22:55:03 -0500 | [diff] [blame] | 280 | ndn::KeyChain& m_keyChain; |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 281 | /** |
| 282 | * @brief State about how identity/key is generated. |
| 283 | */ |
| 284 | bool m_isNewlyCreatedIdentity = false; |
| 285 | bool m_isNewlyCreatedKey = false; |
| 286 | /** |
| 287 | * @brief The keypair for the request. |
| 288 | */ |
Davide Pesavento | 0dc0201 | 2021-11-23 22:55:03 -0500 | [diff] [blame] | 289 | ndn::security::Key m_keyPair; |
Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 290 | }; |
| 291 | |
Zhiyi Zhang | 3002e6b | 2020-10-29 18:54:07 -0700 | [diff] [blame] | 292 | } // namespace requester |
Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 293 | } // namespace ndncert |
Zhiyi Zhang | 1d3dcd2 | 2020-10-01 22:25:43 -0700 | [diff] [blame] | 294 | |
tylerliu | 4140fe8 | 2021-01-27 15:45:44 -0800 | [diff] [blame] | 295 | #endif // NDNCERT_REQUESTER_REQUEST_HPP |