blob: cb8cd5b48bbe8d64f3c0e61acf4f678b2cd8501a [file] [log] [blame]
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2017-2020, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
* ndncert is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* ndncert is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received copies of the GNU General Public License along with
* ndncert, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*
* See AUTHORS.md for complete list of ndncert authors and contributors.
*/
#ifndef NDNCERT_NDNCERT_COMMON_HPP
#define NDNCERT_NDNCERT_COMMON_HPP
#include "ndncert-config.hpp"
#ifdef HAVE_TESTS
#define VIRTUAL_WITH_TESTS virtual
#define PUBLIC_WITH_TESTS_ELSE_PROTECTED public
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE public
#define PROTECTED_WITH_TESTS_ELSE_PRIVATE protected
#else
#define VIRTUAL_WITH_TESTS
#define PUBLIC_WITH_TESTS_ELSE_PROTECTED protected
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE private
#define PROTECTED_WITH_TESTS_ELSE_PRIVATE private
#endif
#include <cstddef>
#include <cstdint>
#include <tuple>
#include <ndn-cxx/encoding/tlv.hpp>
#include <ndn-cxx/data.hpp>
#include <ndn-cxx/encoding/block.hpp>
#include <ndn-cxx/encoding/block-helpers.hpp>
#include <ndn-cxx/face.hpp>
#include <ndn-cxx/interest.hpp>
#include <ndn-cxx/link.hpp>
#include <ndn-cxx/lp/nack.hpp>
#include <ndn-cxx/name.hpp>
#include <ndn-cxx/security/key-chain.hpp>
#include <ndn-cxx/security/certificate.hpp>
#include <ndn-cxx/util/logger.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/assert.hpp>
#include <boost/noncopyable.hpp>
#include <boost/property_tree/info_parser.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/ptree.hpp>
namespace ndn {
namespace ndncert {
using boost::noncopyable;
typedef boost::property_tree::ptree JsonSection;
enum : uint32_t {
tlv_ca_prefix = 129,
tlv_ca_info = 131,
tlv_parameter_key = 133,
tlv_parameter_value = 135,
tlv_ca_certificate = 137,
tlv_max_validity_period = 139,
tlv_probe_response = 141,
tlv_max_suffix_length = 143,
tlv_ecdh_pub = 145,
tlv_cert_request = 147,
tlv_salt = 149,
tlv_request_id = 151,
tlv_challenge = 153,
tlv_status = 155,
tlv_initialization_vector = 157,
tlv_encrypted_payload = 159,
tlv_selected_challenge = 161,
tlv_challenge_status = 163,
tlv_remaining_tries = 165,
tlv_remaining_time = 167,
tlv_issued_cert_name = 169,
tlv_error_code = 171,
tlv_error_info = 173,
tlv_authentication_tag = 175,
tlv_cert_to_revoke = 177,
tlv_probe_redirect = 179
};
// NDNCERT error code
enum class ErrorCode : uint16_t {
NO_ERROR = 0,
BAD_INTEREST_FORMAT = 1,
BAD_PARAMETER_FORMAT = 2,
BAD_SIGNATURE = 3,
INVALID_PARAMETER = 4,
NAME_NOT_ALLOWED = 5,
BAD_VALIDITY_PERIOD = 6,
OUT_OF_TRIES = 7,
OUT_OF_TIME = 8,
NO_AVAILABLE_NAMES = 9
};
// Convert error code to string
std::string
errorCodeToString(ErrorCode code);
// NDNCERT request type
enum class RequestType : uint16_t {
NOTINITIALIZED = 0,
NEW = 1,
RENEW = 2,
REVOKE = 3
};
// Convert request type to string
std::string
requestTypeToString(RequestType type);
} // namespace ndncert
} // namespace ndn
#endif // NDNCERT_NDNCERT_COMMON_HPP