Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Zhiyi Zhang | ad9e04f | 2020-03-27 12:04:31 -0700 | [diff] [blame] | 3 | * Copyright (c) 2017-2020, Regents of the University of California. |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -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 | |
Zhiyi Zhang | b6fab0f | 2017-09-21 16:26:27 -0700 | [diff] [blame] | 21 | #ifndef NDNCERT_NDNCERT_COMMON_HPP |
| 22 | #define NDNCERT_NDNCERT_COMMON_HPP |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 23 | |
| 24 | #include "ndncert-config.hpp" |
| 25 | |
Zhiyi Zhang | daf2fd7 | 2017-01-19 11:31:35 -0800 | [diff] [blame] | 26 | #ifdef HAVE_TESTS |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 27 | #define VIRTUAL_WITH_TESTS virtual |
| 28 | #define PUBLIC_WITH_TESTS_ELSE_PROTECTED public |
| 29 | #define PUBLIC_WITH_TESTS_ELSE_PRIVATE public |
| 30 | #define PROTECTED_WITH_TESTS_ELSE_PRIVATE protected |
| 31 | #else |
| 32 | #define VIRTUAL_WITH_TESTS |
| 33 | #define PUBLIC_WITH_TESTS_ELSE_PROTECTED protected |
| 34 | #define PUBLIC_WITH_TESTS_ELSE_PRIVATE private |
| 35 | #define PROTECTED_WITH_TESTS_ELSE_PRIVATE private |
| 36 | #endif |
| 37 | |
Zhiyi Zhang | 48f2378 | 2020-09-28 12:11:24 -0700 | [diff] [blame] | 38 | #include <cstddef> |
| 39 | #include <cstdint> |
Zhiyi Zhang | e537dd5 | 2020-10-01 18:02:24 -0700 | [diff] [blame] | 40 | #include <tuple> |
| 41 | #include <ndn-cxx/encoding/tlv.hpp> |
Zhiyi Zhang | 48f2378 | 2020-09-28 12:11:24 -0700 | [diff] [blame] | 42 | #include <ndn-cxx/data.hpp> |
| 43 | #include <ndn-cxx/encoding/block.hpp> |
Zhiyi Zhang | 97bedb8 | 2020-10-10 11:11:35 -0700 | [diff] [blame] | 44 | #include <ndn-cxx/encoding/block-helpers.hpp> |
Zhiyi Zhang | 48f2378 | 2020-09-28 12:11:24 -0700 | [diff] [blame] | 45 | #include <ndn-cxx/face.hpp> |
| 46 | #include <ndn-cxx/interest.hpp> |
| 47 | #include <ndn-cxx/link.hpp> |
| 48 | #include <ndn-cxx/lp/nack.hpp> |
| 49 | #include <ndn-cxx/name.hpp> |
| 50 | #include <ndn-cxx/security/key-chain.hpp> |
tylerliu | a7bea66 | 2020-10-08 18:51:02 -0700 | [diff] [blame] | 51 | #include <ndn-cxx/security/certificate.hpp> |
Zhiyi Zhang | 523f0c2 | 2020-09-29 14:19:20 -0700 | [diff] [blame] | 52 | #include <ndn-cxx/util/logger.hpp> |
Zhiyi Zhang | c87d52b | 2020-09-28 22:07:18 -0700 | [diff] [blame] | 53 | #include <boost/algorithm/string.hpp> |
| 54 | #include <boost/assert.hpp> |
| 55 | #include <boost/noncopyable.hpp> |
Zhiyi Zhang | a749f44 | 2020-09-29 17:19:51 -0700 | [diff] [blame] | 56 | #include <boost/property_tree/info_parser.hpp> |
| 57 | #include <boost/property_tree/json_parser.hpp> |
| 58 | #include <boost/property_tree/ptree.hpp> |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 59 | |
| 60 | namespace ndn { |
tylerliu | 50d679e | 2020-10-14 14:08:39 -0700 | [diff] [blame^] | 61 | namespace tlv { |
| 62 | enum : uint32_t { |
| 63 | CaPrefix = 129, |
| 64 | CaInfo = 131, |
| 65 | ParameterKey = 133, |
| 66 | ParameterValue = 135, |
| 67 | CaCertificate = 137, |
| 68 | MaxValidityPeriod = 139, |
| 69 | ProbeResponse = 141, |
| 70 | MaxSuffixLength = 143, |
| 71 | EcdhPub = 145, |
| 72 | CertRequest = 147, |
| 73 | Salt = 149, |
| 74 | RequestId = 151, |
| 75 | Challenge = 153, |
| 76 | Status = 155, |
| 77 | InitializationVector = 157, |
| 78 | EncryptedPayload = 159, |
| 79 | SelectedChallenge = 161, |
| 80 | ChallengeStatus = 163, |
| 81 | RemainingTries = 165, |
| 82 | RemainingTime = 167, |
| 83 | IssuedCertName = 169, |
| 84 | ErrorCode = 171, |
| 85 | ErrorInfo = 173, |
| 86 | AuthenticationTag = 175, |
| 87 | CertToRevoke = 177, |
| 88 | ProbeRedirect = 179 |
| 89 | }; |
| 90 | } // namespace tlv |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 91 | namespace ndncert { |
| 92 | |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 93 | using boost::noncopyable; |
Zhiyi Zhang | 5981223 | 2020-10-12 13:11:35 -0700 | [diff] [blame] | 94 | typedef boost::property_tree::ptree JsonSection; |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 95 | |
Zhiyi Zhang | 4b11809 | 2020-10-10 10:28:38 -0700 | [diff] [blame] | 96 | // NDNCERT error code |
Zhiyi Zhang | aafc55e | 2020-09-28 17:54:48 -0700 | [diff] [blame] | 97 | enum class ErrorCode : uint16_t { |
Zhiyi Zhang | 4604983 | 2020-09-28 17:08:12 -0700 | [diff] [blame] | 98 | NO_ERROR = 0, |
Zhiyi Zhang | 48f2378 | 2020-09-28 12:11:24 -0700 | [diff] [blame] | 99 | BAD_INTEREST_FORMAT = 1, |
| 100 | BAD_PARAMETER_FORMAT = 2, |
| 101 | BAD_SIGNATURE = 3, |
| 102 | INVALID_PARAMETER = 4, |
| 103 | NAME_NOT_ALLOWED = 5, |
| 104 | BAD_VALIDITY_PERIOD = 6, |
| 105 | OUT_OF_TRIES = 7, |
| 106 | OUT_OF_TIME = 8, |
| 107 | NO_AVAILABLE_NAMES = 9 |
Zhiyi Zhang | af7c290 | 2019-03-14 22:13:21 -0700 | [diff] [blame] | 108 | }; |
| 109 | |
Zhiyi Zhang | 4b11809 | 2020-10-10 10:28:38 -0700 | [diff] [blame] | 110 | // Convert error code to string |
| 111 | std::string |
| 112 | errorCodeToString(ErrorCode code); |
| 113 | |
| 114 | // NDNCERT request type |
Zhiyi Zhang | c87d52b | 2020-09-28 22:07:18 -0700 | [diff] [blame] | 115 | enum class RequestType : uint16_t { |
| 116 | NOTINITIALIZED = 0, |
| 117 | NEW = 1, |
| 118 | RENEW = 2, |
| 119 | REVOKE = 3 |
| 120 | }; |
| 121 | |
Zhiyi Zhang | 4b11809 | 2020-10-10 10:28:38 -0700 | [diff] [blame] | 122 | // Convert request type to string |
Zhiyi Zhang | a749f44 | 2020-09-29 17:19:51 -0700 | [diff] [blame] | 123 | std::string |
Zhiyi Zhang | 4b11809 | 2020-10-10 10:28:38 -0700 | [diff] [blame] | 124 | requestTypeToString(RequestType type); |
Zhiyi Zhang | a749f44 | 2020-09-29 17:19:51 -0700 | [diff] [blame] | 125 | |
Zhiyi Zhang | e4891b7 | 2020-10-10 15:11:57 -0700 | [diff] [blame] | 126 | } // namespace ndncert |
| 127 | } // namespace ndn |
Zhiyi Zhang | 8617a79 | 2017-01-17 16:45:56 -0800 | [diff] [blame] | 128 | |
Zhiyi Zhang | e4891b7 | 2020-10-10 15:11:57 -0700 | [diff] [blame] | 129 | #endif // NDNCERT_NDNCERT_COMMON_HPP |