blob: b1bb3a30b0d373474f5ff7db82bfedd74d4854a7 [file] [log] [blame]
Zhiyi Zhangf5246c42017-01-26 09:39:20 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
swa77020643ac2020-03-26 02:24:45 -07003 * Copyright (c) 2017-2020, Regents of the University of California.
Zhiyi Zhangf5246c42017-01-26 09:39:20 -08004 *
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_CA_MODULE_HPP
22#define NDNCERT_CA_MODULE_HPP
23
Zhiyi Zhang9829da92020-09-30 16:19:34 -070024#include "configuration.hpp"
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070025#include "crypto-support/crypto-helper.hpp"
Zhiyi Zhangdbd9d432020-10-07 15:56:27 -070026#include "ca-storage/ca-storage.hpp"
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080027
28namespace ndn {
29namespace ndncert {
30
31class CaModule : noncopyable
32{
33public:
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080034 CaModule(Face& face, security::v2::KeyChain& keyChain, const std::string& configPath,
Zhiyi Zhang91c846b2017-04-12 14:16:31 -070035 const std::string& storageType = "ca-storage-sqlite3");
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080036
37 ~CaModule();
38
39 CaConfig&
40 getCaConf()
41 {
42 return m_config;
43 }
44
45 const unique_ptr<CaStorage>&
46 getCaStorage()
47 {
48 return m_storage;
49 }
50
Zhiyi Zhangf6c5d272020-09-28 10:17:32 -070051 void
52 setNameAssignmentFunction(const NameAssignmentFunc& handler);
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080053
Zhiyi Zhang01e91a32020-09-29 12:10:00 -070054 void
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070055 setStatusUpdateCallback(const StatusUpdateCallback& onUpdateCallback);
Zhiyi Zhang7420cf52017-12-18 18:59:21 +080056
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080057PUBLIC_WITH_TESTS_ELSE_PRIVATE:
Zhiyi Zhangfc1678a2020-05-12 16:52:14 -070058 shared_ptr<Data>
Zhiyi Zhangf61404d2020-10-07 15:41:07 -070059 generateCaProfileMetaData();
Zhiyi Zhangfc1678a2020-05-12 16:52:14 -070060
61 shared_ptr<Data>
Zhiyi Zhangf61404d2020-10-07 15:41:07 -070062 generateCaProfileData();
swa77020643ac2020-03-26 02:24:45 -070063
64 void
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070065 onProbe(const Interest& request);
Zhiyi Zhang1c0bd372017-12-18 18:32:55 +080066
67 void
Zhiyi Zhang01e91a32020-09-29 12:10:00 -070068 onNewRenewRevoke(const Interest& request, RequestType requestType);
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080069
70 void
tylerliu4a00aad2020-09-26 02:03:17 -070071 onChallenge(const Interest& request);
tylerliu182bc532020-09-25 01:54:45 -070072
73 void
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080074 onRegisterFailed(const std::string& reason);
75
tylerliu8704d032020-06-23 10:18:15 -070076 CaState
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070077 getCertificateRequest(const Interest& request);
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080078
Zhiyi Zhang343cdfb2018-01-17 12:04:28 -080079 security::v2::Certificate
tylerliu8704d032020-06-23 10:18:15 -070080 issueCertificate(const CaState& requestState);
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080081
Zhiyi Zhang1c0bd372017-12-18 18:32:55 +080082 void
83 registerPrefix();
84
Zhiyi Zhangaafc55e2020-09-28 17:54:48 -070085 Data
86 generateErrorDataPacket(const Name& name, ErrorCode error, const std::string& errorInfo);
87
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070088PUBLIC_WITH_TESTS_ELSE_PRIVATE:
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080089 Face& m_face;
90 CaConfig m_config;
91 unique_ptr<CaStorage> m_storage;
92 security::v2::KeyChain& m_keyChain;
Zhiyi Zhanga2c39f72020-10-06 16:45:55 -070093 uint8_t m_requestIdGenKey[32];
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080094
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070095 std::list<RegisteredPrefixHandle> m_registeredPrefixHandles;
96 std::list<InterestFilterHandle> m_interestFilterHandles;
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080097};
98
99} // namespace ndncert
100} // namespace ndn
101
102#endif // NDNCERT_CA_MODULE_HPP