9#include <botan/tls_policy.h>
11#include <botan/exceptn.h>
12#include <botan/internal/parsing.h>
75 const auto cert_types =
get_str(
"accepted_client_certificate_types");
80 const auto cert_types =
get_str(
"accepted_server_certificate_types");
97 const auto limit =
get_len(
"record_size_limit", 0);
101 return (limit > 0) ? std::make_optional(
static_cast<uint16_t
>(limit)) : std::nullopt;
109 std::string group_str =
get_str(
"key_exchange_groups");
111 if(group_str.empty()) {
116 if(group_str.empty()) {
124 std::string group_str =
get_str(
"key_exchange_groups_to_offer",
"notset");
126 if(group_str.empty() || group_str ==
"notset") {
131 if(group_str ==
"none") {
195 std::vector<uint16_t> r;
196 for(
const auto& p :
get_list(
"srtp_profiles", std::vector<std::string>())) {
215 std::istringstream iss{std::string(s)};
222 const std::string v =
get_str(key);
232 std::vector<Group_Params> groups;
233 for(
const auto& group_name :
split_on(group_str,
' ')) {
236#if !defined(BOTAN_HAS_X25519)
237 if(group_id == Group_Params::X25519)
240#if !defined(BOTAN_HAS_X448)
241 if(group_id == Group_Params::X448)
245 if(group_id == Group_Params::NONE) {
248 unsigned long ll_id = std::stoul(group_name, &consumed, 0);
249 if(consumed != group_name.size()) {
253 const uint16_t
id =
static_cast<uint16_t
>(ll_id);
265 if(group_id != Group_Params::NONE) {
266 groups.push_back(group_id);
274 std::vector<Certificate_Type> cert_types;
275 for(
const std::string& cert_type_name :
split_on(cert_type_names,
' ')) {
283 const std::string v =
get_str(key);
293 using rep_t = std::chrono::seconds::rep;
294 constexpr rep_t max_seconds = std::chrono::seconds::max().count();
295 constexpr auto max_sizet = std::numeric_limits<size_t>::max();
296 using ull =
unsigned long long;
302 const rep_t positive_default = std::max(def.count(), rep_t(0));
304 const size_t positive_capped_default =
static_cast<size_t>(std::min<ull>(positive_default, max_sizet));
306 const rep_t result =
static_cast<rep_t
>(std::min<ull>(
get_len(key, positive_capped_default), max_seconds));
308 return std::chrono::seconds(result);
312 const std::string v =
get_str(key);
318 if(v ==
"true" || v ==
"True") {
320 }
else if(v ==
"false" || v ==
"False") {
328 auto i = m_kv.find(key);
329 if(i == m_kv.end()) {
337 auto i = m_kv.find(key);
339 if(overwrite ==
false && i != m_kv.end()) {
343 m_kv.insert(i, std::make_pair(key, val));
#define BOTAN_ARG_CHECK(expr, msg)
static std::optional< Group_Params > from_string(std::string_view group_name)
virtual bool include_time_in_hello_random() const
virtual size_t dtls_maximum_timeout() const
virtual size_t minimum_ecdh_group_size() const
virtual size_t dtls_default_mtu() const
virtual bool allow_tls12() const
virtual bool reuse_session_tickets() const
virtual std::vector< Certificate_Type > accepted_server_certificate_types() const
virtual std::vector< Certificate_Type > accepted_client_certificate_types() const
virtual bool require_client_certificate_authentication() const
virtual std::vector< Group_Params > key_exchange_groups() const
virtual size_t new_session_tickets_upon_handshake_success() const
virtual std::vector< Group_Params > key_exchange_groups_to_offer() const
virtual size_t minimum_rsa_bits() const
virtual bool tls_13_middlebox_compatibility_mode() const
virtual bool allow_client_initiated_renegotiation() const
virtual bool allow_ssl_key_log_file() const
virtual bool require_cert_revocation_info() const
virtual bool negotiate_encrypt_then_mac() const
virtual bool server_uses_own_ciphersuite_preferences() const
virtual bool support_cert_status_message() const
virtual std::vector< std::string > allowed_macs() const
virtual bool hide_unknown_users() const
virtual bool hash_hello_random() const
virtual bool allow_tls13() const
virtual std::vector< std::string > allowed_key_exchange_methods() const
virtual size_t dtls_initial_timeout() const
virtual size_t maximum_session_tickets_per_client_hello() const
virtual bool use_ecc_point_compression() const
virtual bool allow_dtls12() const
virtual size_t minimum_dh_group_size() const
virtual bool allow_insecure_renegotiation() const
virtual std::vector< std::string > allowed_ciphers() const
virtual std::chrono::seconds session_ticket_lifetime() const
virtual size_t minimum_signature_strength() const
virtual std::vector< std::string > allowed_signature_methods() const
virtual size_t minimum_ecdsa_group_size() const
virtual std::vector< std::string > allowed_signature_hashes() const
virtual bool allow_server_initiated_renegotiation() const
size_t dtls_initial_timeout() const override
bool allow_dtls12() const override
bool server_uses_own_ciphersuite_preferences() const override
bool hash_hello_random() const override
std::chrono::seconds session_ticket_lifetime() const override
std::optional< uint16_t > record_size_limit() const override
bool allow_ssl_key_log_file() const override
bool include_time_in_hello_random() const override
bool allow_client_initiated_renegotiation() const override
std::string get_str(const std::string &key, const std::string &def="") const
bool support_cert_status_message() const override
std::vector< std::string > allowed_signature_methods() const override
std::vector< Group_Params > key_exchange_groups() const override
bool require_cert_revocation_info() const override
std::vector< std::string > allowed_key_exchange_methods() const override
size_t minimum_ecdsa_group_size() const override
bool set_value(const std::string &key, std::string_view val, bool overwrite)
bool allow_tls13() const override
size_t maximum_session_tickets_per_client_hello() const override
std::vector< Certificate_Type > accepted_server_certificate_types() const override
std::vector< Group_Params > key_exchange_groups_to_offer() const override
std::chrono::seconds get_duration(const std::string &key, std::chrono::seconds def) const
size_t new_session_tickets_upon_handshake_success() const override
std::vector< std::string > allowed_signature_hashes() const override
std::vector< uint16_t > srtp_profiles() const override
bool hide_unknown_users() const override
std::vector< std::string > allowed_ciphers() const override
Text_Policy(std::string_view s)
size_t minimum_ecdh_group_size() const override
void set(const std::string &key, const std::string &value)
bool allow_server_initiated_renegotiation() const override
bool get_bool(const std::string &key, bool def) const
size_t minimum_signature_strength() const override
std::vector< Certificate_Type > accepted_client_certificate_types() const override
bool negotiate_encrypt_then_mac() const override
bool require_client_certificate_authentication() const override
bool tls_13_middlebox_compatibility_mode() const override
size_t dtls_maximum_timeout() const override
bool reuse_session_tickets() const override
size_t get_len(const std::string &key, size_t def) const
bool allow_insecure_renegotiation() const override
bool allow_tls12() const override
bool use_ecc_point_compression() const override
std::vector< Certificate_Type > read_cert_type_list(const std::string &cert_type_str) const
size_t dtls_default_mtu() const override
std::vector< Group_Params > read_group_list(std::string_view group_str) const
size_t minimum_rsa_bits() const override
std::vector< std::string > allowed_macs() const override
size_t minimum_dh_group_size() const override
std::vector< std::string > get_list(const std::string &key, const std::vector< std::string > &def) const
Certificate_Type certificate_type_from_string(const std::string &type_str)
uint32_t to_u32bit(std::string_view str_view)
uint16_t to_uint16(std::string_view str)
std::map< std::string, std::string > read_cfg(std::istream &is)
std::vector< std::string > split_on(std::string_view str, char delim)