Zhiyi Zhang | f5246c4 | 2017-01-26 09:39:20 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
swa770 | 20643ac | 2020-03-26 02:24:45 -0700 | [diff] [blame] | 3 | * Copyright (c) 2017-2020, Regents of the University of California. |
Zhiyi Zhang | f5246c4 | 2017-01-26 09:39:20 -0800 | [diff] [blame] | 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_CA_MODULE_HPP |
| 22 | #define NDNCERT_CA_MODULE_HPP |
| 23 | |
Zhiyi Zhang | 9829da9 | 2020-09-30 16:19:34 -0700 | [diff] [blame] | 24 | #include "configuration.hpp" |
Zhiyi Zhang | 062be6d | 2020-10-14 17:13:43 -0700 | [diff] [blame] | 25 | #include "detail/crypto-helper.hpp" |
| 26 | #include "detail/ca-storage.hpp" |
Zhiyi Zhang | f5246c4 | 2017-01-26 09:39:20 -0800 | [diff] [blame] | 27 | |
| 28 | namespace ndn { |
| 29 | namespace ndncert { |
| 30 | |
| 31 | class CaModule : noncopyable |
| 32 | { |
| 33 | public: |
tylerliu | a7bea66 | 2020-10-08 18:51:02 -0700 | [diff] [blame] | 34 | CaModule(Face& face, security::KeyChain& keyChain, const std::string& configPath, |
Zhiyi Zhang | 91c846b | 2017-04-12 14:16:31 -0700 | [diff] [blame] | 35 | const std::string& storageType = "ca-storage-sqlite3"); |
Zhiyi Zhang | f5246c4 | 2017-01-26 09:39:20 -0800 | [diff] [blame] | 36 | |
| 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 Zhang | f6c5d27 | 2020-09-28 10:17:32 -0700 | [diff] [blame] | 51 | void |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 52 | setStatusUpdateCallback(const StatusUpdateCallback& onUpdateCallback); |
Zhiyi Zhang | 7420cf5 | 2017-12-18 18:59:21 +0800 | [diff] [blame] | 53 | |
Zhiyi Zhang | 696cd04 | 2020-10-07 21:27:36 -0700 | [diff] [blame] | 54 | Data |
| 55 | getCaProfileData(); |
Zhiyi Zhang | fc1678a | 2020-05-12 16:52:14 -0700 | [diff] [blame] | 56 | |
Zhiyi Zhang | 696cd04 | 2020-10-07 21:27:36 -0700 | [diff] [blame] | 57 | PUBLIC_WITH_TESTS_ELSE_PRIVATE: |
| 58 | void |
| 59 | onCaProfileDiscovery(const Interest& request); |
swa770 | 20643ac | 2020-03-26 02:24:45 -0700 | [diff] [blame] | 60 | |
| 61 | void |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 62 | onProbe(const Interest& request); |
Zhiyi Zhang | 1c0bd37 | 2017-12-18 18:32:55 +0800 | [diff] [blame] | 63 | |
| 64 | void |
Zhiyi Zhang | 01e91a3 | 2020-09-29 12:10:00 -0700 | [diff] [blame] | 65 | onNewRenewRevoke(const Interest& request, RequestType requestType); |
Zhiyi Zhang | f5246c4 | 2017-01-26 09:39:20 -0800 | [diff] [blame] | 66 | |
| 67 | void |
tylerliu | 4a00aad | 2020-09-26 02:03:17 -0700 | [diff] [blame] | 68 | onChallenge(const Interest& request); |
tylerliu | 182bc53 | 2020-09-25 01:54:45 -0700 | [diff] [blame] | 69 | |
| 70 | void |
Zhiyi Zhang | f5246c4 | 2017-01-26 09:39:20 -0800 | [diff] [blame] | 71 | onRegisterFailed(const std::string& reason); |
| 72 | |
tylerliu | 8704d03 | 2020-06-23 10:18:15 -0700 | [diff] [blame] | 73 | CaState |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 74 | getCertificateRequest(const Interest& request); |
Zhiyi Zhang | f5246c4 | 2017-01-26 09:39:20 -0800 | [diff] [blame] | 75 | |
tylerliu | a7bea66 | 2020-10-08 18:51:02 -0700 | [diff] [blame] | 76 | security::Certificate |
tylerliu | 8704d03 | 2020-06-23 10:18:15 -0700 | [diff] [blame] | 77 | issueCertificate(const CaState& requestState); |
Zhiyi Zhang | f5246c4 | 2017-01-26 09:39:20 -0800 | [diff] [blame] | 78 | |
Zhiyi Zhang | 1c0bd37 | 2017-12-18 18:32:55 +0800 | [diff] [blame] | 79 | void |
| 80 | registerPrefix(); |
| 81 | |
Zhiyi Zhang | aafc55e | 2020-09-28 17:54:48 -0700 | [diff] [blame] | 82 | Data |
| 83 | generateErrorDataPacket(const Name& name, ErrorCode error, const std::string& errorInfo); |
| 84 | |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 85 | PUBLIC_WITH_TESTS_ELSE_PRIVATE: |
Zhiyi Zhang | f5246c4 | 2017-01-26 09:39:20 -0800 | [diff] [blame] | 86 | Face& m_face; |
| 87 | CaConfig m_config; |
| 88 | unique_ptr<CaStorage> m_storage; |
tylerliu | a7bea66 | 2020-10-08 18:51:02 -0700 | [diff] [blame] | 89 | security::KeyChain& m_keyChain; |
Zhiyi Zhang | a2c39f7 | 2020-10-06 16:45:55 -0700 | [diff] [blame] | 90 | uint8_t m_requestIdGenKey[32]; |
Zhiyi Zhang | 696cd04 | 2020-10-07 21:27:36 -0700 | [diff] [blame] | 91 | std::unique_ptr<Data> m_profileData; |
Zhiyi Zhang | f5246c4 | 2017-01-26 09:39:20 -0800 | [diff] [blame] | 92 | |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 93 | std::list<RegisteredPrefixHandle> m_registeredPrefixHandles; |
| 94 | std::list<InterestFilterHandle> m_interestFilterHandles; |
Zhiyi Zhang | f5246c4 | 2017-01-26 09:39:20 -0800 | [diff] [blame] | 95 | }; |
| 96 | |
| 97 | } // namespace ndncert |
| 98 | } // namespace ndn |
| 99 | |
| 100 | #endif // NDNCERT_CA_MODULE_HPP |