Botan
1.11.15
|
#include <tls_policy.h>
Public Member Functions | |
virtual bool | acceptable_ciphersuite (const Ciphersuite &suite) const |
virtual bool | acceptable_protocol_version (Protocol_Version version) const |
bool | allow_insecure_renegotiation () const override |
bool | allow_server_initiated_renegotiation () const override |
std::vector< std::string > | allowed_ciphers () const override |
std::vector< std::string > | allowed_ecc_curves () const override |
std::vector< std::string > | allowed_key_exchange_methods () const override |
std::vector< std::string > | allowed_macs () const override |
std::vector< std::string > | allowed_signature_hashes () const override |
std::vector< std::string > | allowed_signature_methods () const override |
virtual std::string | choose_curve (const std::vector< std::string > &curve_names) const |
virtual std::vector< u16bit > | ciphersuite_list (Protocol_Version version, bool have_srp) const |
virtual std::vector< byte > | compression () const |
std::string | dh_group () const override |
bool | hide_unknown_users () const override |
bool | include_time_in_hello_random () const override |
virtual Protocol_Version | latest_supported_version (bool datagram) const |
size_t | minimum_dh_group_size () const override |
bool | negotiate_heartbeat_support () const override |
virtual void | print (std::ostream &o) const |
virtual bool | send_fallback_scsv (Protocol_Version version) const |
bool | server_uses_own_ciphersuite_preferences () const override |
u32bit | session_ticket_lifetime () const override |
std::vector< u16bit > | srtp_profiles () const override |
Text_Policy (std::istream &in) |
Definition at line 243 of file tls_policy.h.
Botan::TLS::Text_Policy::Text_Policy | ( | std::istream & | in | ) | [inline] |
bool Botan::TLS::Policy::acceptable_ciphersuite | ( | const Ciphersuite & | suite | ) | const [virtual, inherited] |
Allows policy to reject any ciphersuites which are undesirable for whatever reason without having to reimplement ciphersuite_list
Definition at line 166 of file tls_policy.cpp.
Referenced by Botan::TLS::Policy::ciphersuite_list().
{ return true; }
bool Botan::TLS::Policy::acceptable_protocol_version | ( | Protocol_Version | version | ) | const [virtual, inherited] |
Reimplemented in Botan::TLS::Strict_Policy, Botan::TLS::Datagram_Policy, and Botan::TLS::NSA_Suite_B_128.
Definition at line 150 of file tls_policy.cpp.
References Botan::TLS::Protocol_Version::DTLS_V12, Botan::TLS::Protocol_Version::is_datagram_protocol(), and Botan::TLS::Protocol_Version::TLS_V10.
Referenced by Botan::TLS::Client_Hello::Client_Hello().
{ if(version.is_datagram_protocol()) return (version >= Protocol_Version::DTLS_V12); else return (version >= Protocol_Version::TLS_V10); }
bool Botan::TLS::Text_Policy::allow_insecure_renegotiation | ( | ) | const [inline, override, virtual] |
Allow renegotiation even if the counterparty doesn't support the secure renegotiation extension.
Reimplemented from Botan::TLS::Policy.
Definition at line 268 of file tls_policy.h.
References Botan::TLS::Policy::allow_insecure_renegotiation().
{ return get_bool("allow_insecure_renegotiation", Policy::allow_insecure_renegotiation()); }
bool Botan::TLS::Text_Policy::allow_server_initiated_renegotiation | ( | ) | const [inline, override, virtual] |
Allow servers to initiate a new handshake
Reimplemented from Botan::TLS::Policy.
Definition at line 274 of file tls_policy.h.
References Botan::TLS::Policy::allow_server_initiated_renegotiation().
{ return get_bool("allow_server_initiated_renegotiation", Policy::allow_server_initiated_renegotiation()); }
std::vector<std::string> Botan::TLS::Text_Policy::allowed_ciphers | ( | ) | const [inline, override, virtual] |
Returns a list of ciphers we are willing to negotiate, in order of preference.
Reimplemented from Botan::TLS::Policy.
Definition at line 247 of file tls_policy.h.
References Botan::TLS::Policy::allowed_ciphers().
{ return get_list("ciphers", Policy::allowed_ciphers()); }
std::vector<std::string> Botan::TLS::Text_Policy::allowed_ecc_curves | ( | ) | const [inline, override, virtual] |
Return list of ECC curves we are willing to use in order of preference
Reimplemented from Botan::TLS::Policy.
Definition at line 262 of file tls_policy.h.
References Botan::TLS::Policy::allowed_ecc_curves().
{ return get_list("ecc_curves", Policy::allowed_ecc_curves()); }
std::vector<std::string> Botan::TLS::Text_Policy::allowed_key_exchange_methods | ( | ) | const [inline, override, virtual] |
Returns a list of key exchange algorithms we are willing to use, in order of preference. Allowed values: DH, empty string (representing RSA using server certificate key)
Reimplemented from Botan::TLS::Policy.
Definition at line 256 of file tls_policy.h.
References Botan::TLS::Policy::allowed_key_exchange_methods().
{ return get_list("key_exchange_methods", Policy::allowed_key_exchange_methods()); }
std::vector<std::string> Botan::TLS::Text_Policy::allowed_macs | ( | ) | const [inline, override, virtual] |
Returns a list of MAC algorithms we are willing to use.
Reimplemented from Botan::TLS::Policy.
Definition at line 253 of file tls_policy.h.
References Botan::TLS::Policy::allowed_macs().
{ return get_list("macs", Policy::allowed_macs()); }
std::vector<std::string> Botan::TLS::Text_Policy::allowed_signature_hashes | ( | ) | const [inline, override, virtual] |
Returns a list of hash algorithms we are willing to use for signatures, in order of preference.
Reimplemented from Botan::TLS::Policy.
Definition at line 250 of file tls_policy.h.
References Botan::TLS::Policy::allowed_signature_hashes().
{ return get_list("signature_hashes", Policy::allowed_signature_hashes()); }
std::vector<std::string> Botan::TLS::Text_Policy::allowed_signature_methods | ( | ) | const [inline, override, virtual] |
Returns a list of signature algorithms we are willing to use, in order of preference. Allowed values RSA and DSA.
Reimplemented from Botan::TLS::Policy.
Definition at line 259 of file tls_policy.h.
References Botan::TLS::Policy::allowed_signature_methods().
{ return get_list("signature_methods", Policy::allowed_signature_methods()); }
std::string Botan::TLS::Policy::choose_curve | ( | const std::vector< std::string > & | curve_names | ) | const [virtual, inherited] |
Choose an elliptic curve to use
Definition at line 111 of file tls_policy.cpp.
References Botan::TLS::Policy::allowed_ecc_curves(), and Botan::value_exists().
Referenced by Botan::TLS::Server_Key_Exchange::Server_Key_Exchange().
{ const std::vector<std::string> our_curves = allowed_ecc_curves(); for(size_t i = 0; i != our_curves.size(); ++i) if(value_exists(curve_names, our_curves[i])) return our_curves[i]; return ""; // no shared curve }
std::vector< u16bit > Botan::TLS::Policy::ciphersuite_list | ( | Protocol_Version | version, |
bool | have_srp | ||
) | const [virtual, inherited] |
Return allowed ciphersuites, in order of preference
Definition at line 256 of file tls_policy.cpp.
References Botan::TLS::Policy::acceptable_ciphersuite(), Botan::TLS::Ciphersuite::all_known_ciphersuites(), Botan::TLS::Policy::allowed_ciphers(), Botan::TLS::Policy::allowed_key_exchange_methods(), Botan::TLS::Policy::allowed_macs(), Botan::TLS::Policy::allowed_signature_methods(), Botan::TLS::Protocol_Version::is_datagram_protocol(), order, Botan::TLS::Protocol_Version::supports_aead_modes(), and Botan::value_exists().
{ const std::vector<std::string> ciphers = allowed_ciphers(); const std::vector<std::string> macs = allowed_macs(); const std::vector<std::string> kex = allowed_key_exchange_methods(); const std::vector<std::string> sigs = allowed_signature_methods(); Ciphersuite_Preference_Ordering order(ciphers, macs, kex, sigs); std::set<Ciphersuite, Ciphersuite_Preference_Ordering> ciphersuites(order); for(auto&& suite : Ciphersuite::all_known_ciphersuites()) { if(!acceptable_ciphersuite(suite)) continue; if(!have_srp && suite.kex_algo() == "SRP_SHA") continue; if(version.is_datagram_protocol() && suite.cipher_algo() == "RC4") continue; if(!version.supports_aead_modes() && suite.mac_algo() == "AEAD") continue; if(!value_exists(kex, suite.kex_algo())) continue; // unsupported key exchange if(!value_exists(ciphers, suite.cipher_algo())) continue; // unsupported cipher if(!value_exists(macs, suite.mac_algo())) continue; // unsupported MAC algo if(!value_exists(sigs, suite.sig_algo())) { // allow if it's an empty sig algo and we want to use PSK if(suite.sig_algo() != "" || !suite.psk_ciphersuite()) continue; } // OK, allow it: ciphersuites.insert(suite); } if(ciphersuites.empty()) throw std::logic_error("Policy does not allow any available cipher suite"); std::vector<u16bit> ciphersuite_codes; for(auto i : ciphersuites) ciphersuite_codes.push_back(i.ciphersuite_code()); return ciphersuite_codes; }
std::vector< byte > Botan::TLS::Policy::compression | ( | ) | const [virtual, inherited] |
Returns a list of compression algorithms we are willing to use, in order of preference. Allowed values any value of Compression_Method.
Definition at line 135 of file tls_policy.cpp.
References Botan::TLS::NO_COMPRESSION.
{ return std::vector<byte>{ NO_COMPRESSION }; }
std::string Botan::TLS::Text_Policy::dh_group | ( | ) | const [inline, override, virtual] |
Reimplemented from Botan::TLS::Policy.
Definition at line 280 of file tls_policy.h.
References Botan::TLS::Policy::dh_group().
{ return get_str("dh_group", Policy::dh_group()); }
bool Botan::TLS::Text_Policy::hide_unknown_users | ( | ) | const [inline, override, virtual] |
If this function returns false, unknown SRP/PSK identifiers will be rejected with an unknown_psk_identifier alert as soon as the non-existence is identified. Otherwise, a false identifier value will be used and the protocol allowed to proceed, causing the handshake to eventually fail without revealing that the username does not exist on this system.
Reimplemented from Botan::TLS::Policy.
Definition at line 286 of file tls_policy.h.
References Botan::TLS::Policy::hide_unknown_users().
{ return get_bool("hide_unknown_users", Policy::hide_unknown_users()); }
bool Botan::TLS::Text_Policy::include_time_in_hello_random | ( | ) | const [inline, override, virtual] |
The protocol dictates that the first 32 bits of the random field are the current time in seconds. However this allows client fingerprinting attacks. Set to false to disable, in which case random bytes will be used instead.
Reimplemented from Botan::TLS::Policy.
Definition at line 271 of file tls_policy.h.
References Botan::TLS::Policy::include_time_in_hello_random().
{ return get_bool("include_time_in_hello_random", Policy::include_time_in_hello_random()); }
Protocol_Version Botan::TLS::Policy::latest_supported_version | ( | bool | datagram | ) | const [virtual, inherited] |
Returns the more recent protocol version we are willing to use, for either TLS or DTLS depending on datagram param. Shouldn't ever need to override this unless you want to allow a user to disable use of TLS v1.2 (which is *not recommended*)
Definition at line 158 of file tls_policy.cpp.
References Botan::TLS::Protocol_Version::latest_dtls_version(), and Botan::TLS::Protocol_Version::latest_tls_version().
Referenced by Botan::TLS::Policy::send_fallback_scsv().
{ if(datagram) return Protocol_Version::latest_dtls_version(); else return Protocol_Version::latest_tls_version(); }
size_t Botan::TLS::Text_Policy::minimum_dh_group_size | ( | ) | const [inline, override, virtual] |
Return the minimum DH group size we're willing to use
Reimplemented from Botan::TLS::Policy.
Definition at line 283 of file tls_policy.h.
References Botan::TLS::Policy::minimum_dh_group_size().
{ return get_len("minimum_dh_group_size", Policy::minimum_dh_group_size()); }
bool Botan::TLS::Text_Policy::negotiate_heartbeat_support | ( | ) | const [inline, override, virtual] |
Attempt to negotiate the use of the heartbeat extension
Reimplemented from Botan::TLS::Policy.
Definition at line 265 of file tls_policy.h.
References Botan::TLS::Policy::negotiate_heartbeat_support().
{ return get_bool("negotiate_heartbeat_support", Policy::negotiate_heartbeat_support()); }
void Botan::TLS::Policy::print | ( | std::ostream & | o | ) | const [virtual, inherited] |
Definition at line 335 of file tls_policy.cpp.
References Botan::TLS::Policy::allow_insecure_renegotiation(), Botan::TLS::Policy::allow_server_initiated_renegotiation(), Botan::TLS::Policy::allowed_ciphers(), Botan::TLS::Policy::allowed_ecc_curves(), Botan::TLS::Policy::allowed_key_exchange_methods(), Botan::TLS::Policy::allowed_macs(), Botan::TLS::Policy::allowed_signature_hashes(), Botan::TLS::Policy::allowed_signature_methods(), Botan::TLS::Policy::dh_group(), Botan::TLS::Policy::hide_unknown_users(), Botan::TLS::Policy::include_time_in_hello_random(), Botan::TLS::Policy::minimum_dh_group_size(), Botan::TLS::Policy::negotiate_heartbeat_support(), Botan::TLS::Policy::server_uses_own_ciphersuite_preferences(), and Botan::TLS::Policy::session_ticket_lifetime().
{ print_vec(o, "ciphers", allowed_ciphers()); print_vec(o, "macs", allowed_macs()); print_vec(o, "signature_hashes", allowed_signature_hashes()); print_vec(o, "signature_methods", allowed_signature_methods()); print_vec(o, "key_exchange_methods", allowed_key_exchange_methods()); print_vec(o, "ecc_curves", allowed_ecc_curves()); print_bool(o, "negotiate_heartbeat_support", negotiate_heartbeat_support()); print_bool(o, "allow_insecure_renegotiation", allow_insecure_renegotiation()); print_bool(o, "include_time_in_hello_random", include_time_in_hello_random()); print_bool(o, "allow_server_initiated_renegotiation", allow_server_initiated_renegotiation()); print_bool(o, "hide_unknown_users", hide_unknown_users()); print_bool(o, "server_uses_own_ciphersuite_preferences", server_uses_own_ciphersuite_preferences()); o << "session_ticket_lifetime = " << session_ticket_lifetime() << '\n'; o << "dh_group = " << dh_group() << '\n'; o << "minimum_dh_group_size = " << minimum_dh_group_size() << '\n'; }
bool Botan::TLS::Policy::send_fallback_scsv | ( | Protocol_Version | version | ) | const [virtual, inherited] |
When offering this version, should we send a fallback SCSV? Default returns true iff version is not the latest version the policy allows, exists to allow override in case of interop problems.
Definition at line 145 of file tls_policy.cpp.
References Botan::TLS::Protocol_Version::is_datagram_protocol(), and Botan::TLS::Policy::latest_supported_version().
Referenced by Botan::TLS::Client_Hello::Client_Hello().
{ return version != latest_supported_version(version.is_datagram_protocol()); }
bool Botan::TLS::Text_Policy::server_uses_own_ciphersuite_preferences | ( | ) | const [inline, override, virtual] |
Reimplemented from Botan::TLS::Policy.
Definition at line 277 of file tls_policy.h.
References Botan::TLS::Policy::server_uses_own_ciphersuite_preferences().
{ return get_bool("server_uses_own_ciphersuite_preferences", Policy::server_uses_own_ciphersuite_preferences()); }
u32bit Botan::TLS::Text_Policy::session_ticket_lifetime | ( | ) | const [inline, override, virtual] |
Return the allowed lifetime of a session ticket. If 0, session tickets do not expire until the session ticket key rolls over. Expired session tickets cannot be used to resume a session.
Reimplemented from Botan::TLS::Policy.
Definition at line 289 of file tls_policy.h.
References Botan::TLS::Policy::session_ticket_lifetime().
{ return get_len("session_ticket_lifetime", Policy::session_ticket_lifetime()); }
std::vector<u16bit> Botan::TLS::Text_Policy::srtp_profiles | ( | ) | const [inline, override, virtual] |
If this returns a non-empty vector, and DTLS is negotiated, then we will also attempt to negotiate the SRTP extension from RFC 5764 using the returned values as the profile ids.
Reimplemented from Botan::TLS::Policy.
Definition at line 292 of file tls_policy.h.
References Botan::to_u32bit().
{ std::vector<u16bit> r; for(auto&& p : get_list("srtp_profiles", std::vector<std::string>())) { r.push_back(to_u32bit(p)); } return r; }