Botan
1.11.15
|
#include <tls_version.h>
Public Types | |
enum | Version_Code { TLS_V10 = 0x0301, TLS_V11 = 0x0302, TLS_V12 = 0x0303, DTLS_V10 = 0xFEFF, DTLS_V12 = 0xFEFD } |
Public Member Functions | |
bool | is_datagram_protocol () const |
bool | known_version () const |
byte | major_version () const |
byte | minor_version () const |
bool | operator!= (const Protocol_Version &other) const |
bool | operator== (const Protocol_Version &other) const |
bool | operator> (const Protocol_Version &other) const |
bool | operator>= (const Protocol_Version &other) const |
Protocol_Version () | |
Protocol_Version (Version_Code named_version) | |
Protocol_Version (byte major, byte minor) | |
bool | supports_aead_modes () const |
bool | supports_ciphersuite_specific_prf () const |
bool | supports_explicit_cbc_ivs () const |
bool | supports_negotiable_signature_algorithms () const |
std::string | to_string () const |
bool | valid () const |
Static Public Member Functions | |
static Protocol_Version | latest_dtls_version () |
static Protocol_Version | latest_tls_version () |
TLS Protocol Version
Definition at line 21 of file tls_version.h.
Botan::TLS::Protocol_Version::Protocol_Version | ( | ) | [inline] |
Definition at line 43 of file tls_version.h.
: m_version(0) {}
Botan::TLS::Protocol_Version::Protocol_Version | ( | Version_Code | named_version | ) | [inline] |
named_version | a specific named version of the protocol |
Definition at line 48 of file tls_version.h.
: m_version(static_cast<u16bit>(named_version)) {}
Botan::TLS::Protocol_Version::Protocol_Version | ( | byte | major, |
byte | minor | ||
) | [inline] |
major | the major version |
minor | the minor version |
Definition at line 55 of file tls_version.h.
: m_version((static_cast<u16bit>(major) << 8) | minor) {}
bool Botan::TLS::Protocol_Version::is_datagram_protocol | ( | ) | const |
Definition at line 34 of file tls_version.cpp.
References major_version().
Referenced by Botan::TLS::Policy::acceptable_protocol_version(), Botan::TLS::Strict_Policy::acceptable_protocol_version(), Botan::TLS::Policy::ciphersuite_list(), Botan::TLS::Client_Hello::Client_Hello(), Botan::TLS::Channel::create_handshake_state(), operator>(), Botan::TLS::Channel::received_data(), Botan::TLS::Policy::send_fallback_scsv(), Botan::TLS::Server_Hello::Server_Hello(), Botan::TLS::Client_Hello::update_hello_cookie(), and Botan::TLS::write_record().
{ return major_version() == 254; }
bool Botan::TLS::Protocol_Version::known_version | ( | ) | const |
Definition at line 52 of file tls_version.cpp.
References DTLS_V10, DTLS_V12, TLS_V10, TLS_V11, and TLS_V12.
{ return (m_version == Protocol_Version::TLS_V10 || m_version == Protocol_Version::TLS_V11 || m_version == Protocol_Version::TLS_V12 || m_version == Protocol_Version::DTLS_V10 || m_version == Protocol_Version::DTLS_V12); }
static Protocol_Version Botan::TLS::Protocol_Version::latest_dtls_version | ( | ) | [inline, static] |
Definition at line 38 of file tls_version.h.
Referenced by Botan::TLS::Policy::latest_supported_version().
{ return Protocol_Version(DTLS_V12); }
static Protocol_Version Botan::TLS::Protocol_Version::latest_tls_version | ( | ) | [inline, static] |
Definition at line 33 of file tls_version.h.
Referenced by Botan::TLS::Policy::latest_supported_version().
{ return Protocol_Version(TLS_V12); }
byte Botan::TLS::Protocol_Version::major_version | ( | ) | const [inline] |
Definition at line 71 of file tls_version.h.
References Botan::get_byte().
Referenced by Botan::TLS::Client_Key_Exchange::Client_Key_Exchange(), Botan::TLS::Session::DER_encode(), Botan::TLS::Connection_Cipher_State::format_ad(), is_datagram_protocol(), Botan::TLS::Hello_Verify_Request::serialize(), to_string(), and Botan::TLS::write_record().
{ return get_byte(0, m_version); }
byte Botan::TLS::Protocol_Version::minor_version | ( | ) | const [inline] |
Definition at line 76 of file tls_version.h.
References Botan::get_byte().
Referenced by Botan::TLS::Client_Key_Exchange::Client_Key_Exchange(), Botan::TLS::Session::DER_encode(), Botan::TLS::Connection_Cipher_State::format_ad(), Botan::TLS::Hello_Verify_Request::serialize(), to_string(), and Botan::TLS::write_record().
{ return get_byte(1, m_version); }
bool Botan::TLS::Protocol_Version::operator!= | ( | const Protocol_Version & | other | ) | const [inline] |
Definition at line 116 of file tls_version.h.
{
return (m_version != other.m_version);
}
bool Botan::TLS::Protocol_Version::operator== | ( | const Protocol_Version & | other | ) | const [inline] |
Definition at line 108 of file tls_version.h.
{
return (m_version == other.m_version);
}
bool Botan::TLS::Protocol_Version::operator> | ( | const Protocol_Version & | other | ) | const |
Definition at line 39 of file tls_version.cpp.
References is_datagram_protocol(), Botan::TLS::Alert::PROTOCOL_VERSION, and to_string().
{ if(this->is_datagram_protocol() != other.is_datagram_protocol()) throw TLS_Exception(Alert::PROTOCOL_VERSION, "Version comparing " + to_string() + " with " + other.to_string()); if(this->is_datagram_protocol()) return m_version < other.m_version; // goes backwards return m_version > other.m_version; }
bool Botan::TLS::Protocol_Version::operator>= | ( | const Protocol_Version & | other | ) | const [inline] |
Definition at line 129 of file tls_version.h.
{ return (*this == other || *this > other); }
bool Botan::TLS::Protocol_Version::supports_aead_modes | ( | ) | const |
Definition at line 81 of file tls_version.cpp.
References DTLS_V12, and TLS_V12.
Referenced by Botan::TLS::Policy::ciphersuite_list().
{ return (m_version == Protocol_Version::TLS_V12 || m_version == Protocol_Version::DTLS_V12); }
Definition at line 75 of file tls_version.cpp.
References DTLS_V12, and TLS_V12.
Referenced by Botan::TLS::Handshake_Hash::final().
{ return (m_version == Protocol_Version::TLS_V12 || m_version == Protocol_Version::DTLS_V12); }
bool Botan::TLS::Protocol_Version::supports_explicit_cbc_ivs | ( | ) | const |
Definition at line 67 of file tls_version.cpp.
References DTLS_V10, DTLS_V12, TLS_V11, and TLS_V12.
Referenced by Botan::TLS::Connection_Cipher_State::Connection_Cipher_State().
{ return (m_version == Protocol_Version::TLS_V11 || m_version == Protocol_Version::TLS_V12 || m_version == Protocol_Version::DTLS_V10 || m_version == Protocol_Version::DTLS_V12); }
Definition at line 61 of file tls_version.cpp.
References DTLS_V12, and TLS_V12.
Referenced by Botan::TLS::Certificate_Verify::Certificate_Verify(), Botan::TLS::Client_Hello::Client_Hello(), and Botan::TLS::Server_Key_Exchange::Server_Key_Exchange().
{ return (m_version == Protocol_Version::TLS_V12 || m_version == Protocol_Version::DTLS_V12); }
std::string Botan::TLS::Protocol_Version::to_string | ( | ) | const |
Definition at line 16 of file tls_version.cpp.
References major_version(), and minor_version().
Referenced by Botan::TLS::Channel::create_handshake_state(), and operator>().
{ const byte maj = major_version(); const byte min = minor_version(); if(maj == 3 && min == 0) return "SSL v3"; if(maj == 3 && min >= 1) // TLS v1.x return "TLS v1." + std::to_string(min-1); if(maj == 254) // DTLS 1.x return "DTLS v1." + std::to_string(255 - min); // Some very new or very old protocol (or bogus data) return "Unknown " + std::to_string(maj) + "." + std::to_string(min); }
bool Botan::TLS::Protocol_Version::valid | ( | ) | const [inline] |
Definition at line 61 of file tls_version.h.
{ return (m_version != 0); }