blob: b86dac79b51f8c5c09a74174adc2f73a5839e58e [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
tylerliubb630362020-11-10 11:31:35 -080021#ifndef NDNCERT_REQUESTER_REQUEST_STATE_HPP
22#define NDNCERT_REQUESTER_REQUEST_STATE_HPP
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070023
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 Zhang3f20f952020-11-19 19:26:43 -080026#include "detail/profile-storage.hpp"
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070027
28namespace ndn {
29namespace ndncert {
Zhiyi Zhang3002e6b2020-10-29 18:54:07 -070030namespace requester {
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070031
tylerliubb630362020-11-10 11:31:35 -080032struct RequestState {
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070033 explicit
tylerliuf2e6bb52020-12-13 13:23:05 -080034 RequestState(security::KeyChain& keyChain, const CaProfile& profile, RequestType requestType);
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070035
36 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070037 * @brief The CA profile for this request.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070038 */
tylerliuf2e6bb52020-12-13 13:23:05 -080039 CaProfile caProfile;
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070040 /**
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 */
tylerliuf2e6bb52020-12-13 13:23:05 -080043 security::KeyChain& keyChain;
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070044 /**
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 */
tylerliuf2e6bb52020-12-13 13:23:05 -080047 RequestType 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 */
tylerliuf2e6bb52020-12-13 13:23:05 -080051 Name identityName;
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070052 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070053 * @brief The keypair for the request.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070054 */
tylerliuf2e6bb52020-12-13 13:23:05 -080055 security::Key keyPair;
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070056 /**
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 */
tylerliuf2e6bb52020-12-13 13:23:05 -080059 RequestId 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 */
tylerliuf2e6bb52020-12-13 13:23:05 -080063 Status status = Status::BEFORE_CHALLENGE;
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 */
tylerliuf2e6bb52020-12-13 13:23:05 -080067 std::string challengeType;
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070068 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070069 * @brief The status of the current challenge.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070070 */
tylerliuf2e6bb52020-12-13 13:23:05 -080071 std::string challengeStatus;
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070072 /**
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 */
tylerliuf2e6bb52020-12-13 13:23:05 -080075 int remainingTries = 0;
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070076 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070077 * @brief The time this challenge will remain fresh
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070078 */
tylerliuf2e6bb52020-12-13 13:23:05 -080079 time::system_clock::TimePoint freshBefore;
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070080 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070081 * @brief the name of the certificate being issued.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070082 */
tylerliuf2e6bb52020-12-13 13:23:05 -080083 Name issuedCertName;
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070084 /**
Zhiyi Zhang222810b2020-10-16 21:50:35 -070085 * @brief ecdh state.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070086 */
tylerliuf2e6bb52020-12-13 13:23:05 -080087 ECDHState ecdh;
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070088 /**
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 */
tylerliuf2e6bb52020-12-13 13:23:05 -080091 std::array<uint8_t, 16> aesKey = {};
Zhiyi Zhangf2306f72020-10-09 11:26:05 -070092 /**
Zhiyi Zhang4f1c0102020-12-21 15:08:09 -080093 * @brief The last Initialization Vector used by the AES encryption.
Zhiyi Zhang222810b2020-10-16 21:50:35 -070094 */
Zhiyi Zhang4f1c0102020-12-21 15:08:09 -080095 std::vector<uint8_t> encryptionIv;
96 /**
97 * @brief The last Initialization Vector used by the other side's AES encryption.
98 */
99 std::vector<uint8_t> decryptionIv;
Zhiyi Zhang222810b2020-10-16 21:50:35 -0700100 /**
101 * @brief State about how identity/key is generated.
Zhiyi Zhangf2306f72020-10-09 11:26:05 -0700102 */
tylerliuf2e6bb52020-12-13 13:23:05 -0800103 bool isNewlyCreatedIdentity = false;
104 bool isNewlyCreatedKey = false;
tylerliuf51e3162020-12-20 19:22:59 -0800105 /**
106 * @brief Store Nonce for signature
107 */
108 std::array<uint8_t, 16> nonce = {};
Zhiyi Zhangf2306f72020-10-09 11:26:05 -0700109};
110
Zhiyi Zhang3002e6b2020-10-29 18:54:07 -0700111} // namespace requester
Zhiyi Zhange4891b72020-10-10 15:11:57 -0700112} // namespace ndncert
113} // namespace ndn
Zhiyi Zhangf2306f72020-10-09 11:26:05 -0700114
tylerliubb630362020-11-10 11:31:35 -0800115#endif // NDNCERT_REQUESTER_REQUEST_STATE_HPP