blob: 73f67371d583ab7ea514584b1939c74a86f688c2 [file] [log] [blame]
Zhiyi Zhangf2306f72020-10-09 11:26:05 -07001/* -*- 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 Zhang062be6d2020-10-14 17:13:43 -070024#include "detail/ndncert-common.hpp"
25#include "detail/crypto-helper.hpp"
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070026#include "configuration.hpp"
27
28namespace ndn {
29namespace ndncert {
30
31struct RequesterState {
32 explicit
33 RequesterState(security::KeyChain& keyChain, const CaProfile& caItem, RequestType requestType);
34
35 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070036 * @brief The CA profile for this request.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070037 */
38 CaProfile m_caItem;
39 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070040 * @brief The local keychain to generate and install identities, keys and certificates
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070041 */
42 security::KeyChain& m_keyChain;
43 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070044 * @brief The type of request. Either NEW, RENEW, or REVOKE.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070045 */
46 RequestType m_type;
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070047 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070048 * @brief The identity name for the requesting certificate.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070049 */
50 Name m_identityName;
51 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070052 * @brief The keypair for the request.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070053 */
54 security::Key m_keyPair;
55 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070056 * @brief The CA-generated request ID for the request.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070057 */
58 std::string m_requestId;
59 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070060 * @brief The current status of the request.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070061 */
62 Status m_status = Status::NOT_STARTED;
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070063 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070064 * @brief The type of challenge chosen.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070065 */
66 std::string m_challengeType;
67 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070068 * @brief The status of the current challenge.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070069 */
70 std::string m_challengeStatus;
71 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070072 * @brief The remaining number of tries left for the challenge
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070073 */
74 int m_remainingTries = 0;
75 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070076 * @brief The time this challenge will remain fresh
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070077 */
78 time::system_clock::TimePoint m_freshBefore;
79 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070080 * @brief the name of the certificate being issued.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070081 */
82 Name m_issuedCertName;
83 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070084 * @brief ecdh state.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070085 */
86 ECDHState m_ecdh;
87 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070088 * @brief AES key derived from the ecdh shared secret.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070089 */
90 uint8_t m_aesKey[16] = {0};
91 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070092 * @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 Zhangf2306f72020-10-09 11:26:05 -070097 */
98 bool m_isNewlyCreatedIdentity = false;
99 bool m_isNewlyCreatedKey = false;
100};
101
Zhiyi Zhange4891b72020-10-10 15:11:57 -0700102} // namespace ndncert
103} // namespace ndn
Zhiyi Zhangf2306f72020-10-09 11:26:05 -0700104
Zhiyi Zhange4891b72020-10-10 15:11:57 -0700105#endif // NDNCERT_REQUESTER_STATE_HPP