blob: a6f10286b68ad06702b20b754c81c083cb3fb91f [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 Zhang34f03f02020-10-29 18:34:42 -070024#include "detail/ca-request-state.hpp"
Zhiyi Zhangdc25ddf2020-10-20 14:28:55 -070025#include "detail/crypto-helpers.hpp"
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070026#include "configuration.hpp"
27
28namespace ndn {
29namespace ndncert {
Zhiyi Zhang3002e6b2020-10-29 18:54:07 -070030namespace requester {
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070031
32struct RequesterState {
33 explicit
34 RequesterState(security::KeyChain& keyChain, const CaProfile& caItem, RequestType requestType);
35
36 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070037 * @brief The CA profile for this request.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070038 */
39 CaProfile m_caItem;
40 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070041 * @brief The local keychain to generate and install identities, keys and certificates
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070042 */
43 security::KeyChain& m_keyChain;
44 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070045 * @brief The type of request. Either NEW, RENEW, or REVOKE.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070046 */
47 RequestType m_type;
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070048 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070049 * @brief The identity name for the requesting certificate.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070050 */
51 Name m_identityName;
52 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070053 * @brief The keypair for the request.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070054 */
55 security::Key m_keyPair;
56 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070057 * @brief The CA-generated request ID for the request.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070058 */
Zhiyi Zhang8fdb36b2020-10-18 11:58:51 -070059 RequestID m_requestId;
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070060 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070061 * @brief The current status of the request.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070062 */
63 Status m_status = Status::NOT_STARTED;
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070064 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070065 * @brief The type of challenge chosen.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070066 */
67 std::string m_challengeType;
68 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070069 * @brief The status of the current challenge.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070070 */
71 std::string m_challengeStatus;
72 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070073 * @brief The remaining number of tries left for the challenge
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070074 */
75 int m_remainingTries = 0;
76 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070077 * @brief The time this challenge will remain fresh
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070078 */
79 time::system_clock::TimePoint m_freshBefore;
80 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070081 * @brief the name of the certificate being issued.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070082 */
83 Name m_issuedCertName;
84 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070085 * @brief ecdh state.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070086 */
87 ECDHState m_ecdh;
88 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070089 * @brief AES key derived from the ecdh shared secret.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070090 */
91 uint8_t m_aesKey[16] = {0};
92 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070093 * @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 Zhangf2306f72020-10-09 11:26:05 -070098 */
99 bool m_isNewlyCreatedIdentity = false;
100 bool m_isNewlyCreatedKey = false;
101};
102
Zhiyi Zhang3002e6b2020-10-29 18:54:07 -0700103} // namespace requester
Zhiyi Zhange4891b72020-10-10 15:11:57 -0700104} // namespace ndncert
105} // namespace ndn
Zhiyi Zhangf2306f72020-10-09 11:26:05 -0700106
Zhiyi Zhange4891b72020-10-10 15:11:57 -0700107#endif // NDNCERT_REQUESTER_STATE_HPP