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