Zhiyi Zhang | f2306f7 | 2020-10-09 11:26:05 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2017-2020, Regents of the University of California. |
| 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 | |
| 21 | #ifndef NDNCERT_REQUESTER_STATE_HPP |
| 22 | #define NDNCERT_REQUESTER_STATE_HPP |
| 23 | |
Zhiyi Zhang | 062be6d | 2020-10-14 17:13:43 -0700 | [diff] [blame] | 24 | #include "detail/ndncert-common.hpp" |
| 25 | #include "detail/crypto-helper.hpp" |
Zhiyi Zhang | f2306f7 | 2020-10-09 11:26:05 -0700 | [diff] [blame] | 26 | #include "configuration.hpp" |
| 27 | |
| 28 | namespace ndn { |
| 29 | namespace ndncert { |
| 30 | |
| 31 | struct RequesterState { |
| 32 | explicit |
| 33 | RequesterState(security::KeyChain& keyChain, const CaProfile& caItem, RequestType requestType); |
| 34 | |
| 35 | /** |
Zhiyi Zhang | 222810b | 2020-10-16 21:50:35 -0700 | [diff] [blame^] | 36 | * @brief The CA profile for this request. |
Zhiyi Zhang | f2306f7 | 2020-10-09 11:26:05 -0700 | [diff] [blame] | 37 | */ |
| 38 | CaProfile m_caItem; |
| 39 | /** |
Zhiyi Zhang | 222810b | 2020-10-16 21:50:35 -0700 | [diff] [blame^] | 40 | * @brief The local keychain to generate and install identities, keys and certificates |
Zhiyi Zhang | f2306f7 | 2020-10-09 11:26:05 -0700 | [diff] [blame] | 41 | */ |
| 42 | security::KeyChain& m_keyChain; |
| 43 | /** |
Zhiyi Zhang | 222810b | 2020-10-16 21:50:35 -0700 | [diff] [blame^] | 44 | * @brief The type of request. Either NEW, RENEW, or REVOKE. |
Zhiyi Zhang | f2306f7 | 2020-10-09 11:26:05 -0700 | [diff] [blame] | 45 | */ |
| 46 | RequestType m_type; |
Zhiyi Zhang | f2306f7 | 2020-10-09 11:26:05 -0700 | [diff] [blame] | 47 | /** |
Zhiyi Zhang | 222810b | 2020-10-16 21:50:35 -0700 | [diff] [blame^] | 48 | * @brief The identity name for the requesting certificate. |
Zhiyi Zhang | f2306f7 | 2020-10-09 11:26:05 -0700 | [diff] [blame] | 49 | */ |
| 50 | Name m_identityName; |
| 51 | /** |
Zhiyi Zhang | 222810b | 2020-10-16 21:50:35 -0700 | [diff] [blame^] | 52 | * @brief The keypair for the request. |
Zhiyi Zhang | f2306f7 | 2020-10-09 11:26:05 -0700 | [diff] [blame] | 53 | */ |
| 54 | security::Key m_keyPair; |
| 55 | /** |
Zhiyi Zhang | 222810b | 2020-10-16 21:50:35 -0700 | [diff] [blame^] | 56 | * @brief The CA-generated request ID for the request. |
Zhiyi Zhang | f2306f7 | 2020-10-09 11:26:05 -0700 | [diff] [blame] | 57 | */ |
| 58 | std::string m_requestId; |
| 59 | /** |
Zhiyi Zhang | 222810b | 2020-10-16 21:50:35 -0700 | [diff] [blame^] | 60 | * @brief The current status of the request. |
Zhiyi Zhang | f2306f7 | 2020-10-09 11:26:05 -0700 | [diff] [blame] | 61 | */ |
| 62 | Status m_status = Status::NOT_STARTED; |
Zhiyi Zhang | f2306f7 | 2020-10-09 11:26:05 -0700 | [diff] [blame] | 63 | /** |
Zhiyi Zhang | 222810b | 2020-10-16 21:50:35 -0700 | [diff] [blame^] | 64 | * @brief The type of challenge chosen. |
Zhiyi Zhang | f2306f7 | 2020-10-09 11:26:05 -0700 | [diff] [blame] | 65 | */ |
| 66 | std::string m_challengeType; |
| 67 | /** |
Zhiyi Zhang | 222810b | 2020-10-16 21:50:35 -0700 | [diff] [blame^] | 68 | * @brief The status of the current challenge. |
Zhiyi Zhang | f2306f7 | 2020-10-09 11:26:05 -0700 | [diff] [blame] | 69 | */ |
| 70 | std::string m_challengeStatus; |
| 71 | /** |
Zhiyi Zhang | 222810b | 2020-10-16 21:50:35 -0700 | [diff] [blame^] | 72 | * @brief The remaining number of tries left for the challenge |
Zhiyi Zhang | f2306f7 | 2020-10-09 11:26:05 -0700 | [diff] [blame] | 73 | */ |
| 74 | int m_remainingTries = 0; |
| 75 | /** |
Zhiyi Zhang | 222810b | 2020-10-16 21:50:35 -0700 | [diff] [blame^] | 76 | * @brief The time this challenge will remain fresh |
Zhiyi Zhang | f2306f7 | 2020-10-09 11:26:05 -0700 | [diff] [blame] | 77 | */ |
| 78 | time::system_clock::TimePoint m_freshBefore; |
| 79 | /** |
Zhiyi Zhang | 222810b | 2020-10-16 21:50:35 -0700 | [diff] [blame^] | 80 | * @brief the name of the certificate being issued. |
Zhiyi Zhang | f2306f7 | 2020-10-09 11:26:05 -0700 | [diff] [blame] | 81 | */ |
| 82 | Name m_issuedCertName; |
| 83 | /** |
Zhiyi Zhang | 222810b | 2020-10-16 21:50:35 -0700 | [diff] [blame^] | 84 | * @brief ecdh state. |
Zhiyi Zhang | f2306f7 | 2020-10-09 11:26:05 -0700 | [diff] [blame] | 85 | */ |
| 86 | ECDHState m_ecdh; |
| 87 | /** |
Zhiyi Zhang | 222810b | 2020-10-16 21:50:35 -0700 | [diff] [blame^] | 88 | * @brief AES key derived from the ecdh shared secret. |
Zhiyi Zhang | f2306f7 | 2020-10-09 11:26:05 -0700 | [diff] [blame] | 89 | */ |
| 90 | uint8_t m_aesKey[16] = {0}; |
| 91 | /** |
Zhiyi Zhang | 222810b | 2020-10-16 21:50:35 -0700 | [diff] [blame^] | 92 | * @brief The counter of AES blocks that have been encrypted. |
| 93 | */ |
| 94 | uint32_t m_aesBlockCounter = 0; |
| 95 | /** |
| 96 | * @brief State about how identity/key is generated. |
Zhiyi Zhang | f2306f7 | 2020-10-09 11:26:05 -0700 | [diff] [blame] | 97 | */ |
| 98 | bool m_isNewlyCreatedIdentity = false; |
| 99 | bool m_isNewlyCreatedKey = false; |
| 100 | }; |
| 101 | |
Zhiyi Zhang | e4891b7 | 2020-10-10 15:11:57 -0700 | [diff] [blame] | 102 | } // namespace ndncert |
| 103 | } // namespace ndn |
Zhiyi Zhang | f2306f7 | 2020-10-09 11:26:05 -0700 | [diff] [blame] | 104 | |
Zhiyi Zhang | e4891b7 | 2020-10-10 15:11:57 -0700 | [diff] [blame] | 105 | #endif // NDNCERT_REQUESTER_STATE_HPP |