Botan 3.11.0
Crypto and TLS for C&
Botan::TLS::Client_Hello_Internal Class Reference

#include <tls_messages_internal.h>

Public Member Functions

const std::vector< uint16_t > & ciphersuites () const
 Client_Hello_Internal ()
 Client_Hello_Internal (const std::vector< uint8_t > &buf)
const std::vector< uint8_t > & comp_methods () const
Extensionsextensions ()
const Extensionsextensions () const
const std::vector< uint8_t > & hello_cookie () const
const std::vector< uint8_t > & hello_cookie_input_bits () const
Protocol_Version legacy_version () const
const std::vector< uint8_t > & random () const
const Session_IDsession_id () const
Protocol_Version version () const

Public Attributes

std::vector< uint8_t > m_comp_methods
std::vector< uint8_t > m_cookie_input_bits
Extensions m_extensions
std::vector< uint8_t > m_hello_cookie
Protocol_Version m_legacy_version
std::vector< uint8_t > m_random
Session_ID m_session_id
std::vector< uint16_t > m_suites

Detailed Description

Version-agnostic internal client hello data container that allows parsing Client_Hello messages without prior knowledge of the contained protocol version.

Definition at line 57 of file tls_messages_internal.h.

Constructor & Destructor Documentation

◆ Client_Hello_Internal() [1/2]

Botan::TLS::Client_Hello_Internal::Client_Hello_Internal ( )
inline

Definition at line 59 of file tls_messages_internal.h.

59: m_comp_methods({0}) {}

References m_comp_methods.

◆ Client_Hello_Internal() [2/2]

Botan::TLS::Client_Hello_Internal::Client_Hello_Internal ( const std::vector< uint8_t > & buf)
explicit

Definition at line 46 of file msg_client_hello.cpp.

46 {
47 if(buf.size() < 41) {
48 throw Decoding_Error("Client_Hello: Packet corrupted");
49 }
50
51 TLS_Data_Reader reader("ClientHello", buf);
52
53 const uint8_t major_version = reader.get_byte();
54 const uint8_t minor_version = reader.get_byte();
55
56 m_legacy_version = Protocol_Version(major_version, minor_version);
57 m_random = reader.get_fixed<uint8_t>(32);
58 m_session_id = Session_ID(reader.get_range<uint8_t>(1, 0, 32));
59
60 if(m_legacy_version.is_datagram_protocol()) {
61 auto sha256 = HashFunction::create_or_throw("SHA-256");
62 sha256->update(reader.get_data_read_so_far());
63
64 m_hello_cookie = reader.get_range<uint8_t>(1, 0, 255);
65
66 sha256->update(reader.get_remaining());
67 m_cookie_input_bits = sha256->final_stdvec();
68 }
69
70 m_suites = reader.get_range_vector<uint16_t>(2, 1, 32767);
71 m_comp_methods = reader.get_range_vector<uint8_t>(1, 1, 255);
72
74}
static std::unique_ptr< HashFunction > create_or_throw(std::string_view algo_spec, std::string_view provider="")
Definition hash.cpp:308
Strong< std::vector< uint8_t >, struct Session_ID_ > Session_ID
holds a TLS 1.2 session ID for stateful resumption

References Botan::TLS::Client, Botan::TLS::ClientHello, Botan::HashFunction::create_or_throw(), Botan::TLS::TLS_Data_Reader::get_byte(), Botan::TLS::TLS_Data_Reader::get_data_read_so_far(), Botan::TLS::TLS_Data_Reader::get_fixed(), Botan::TLS::TLS_Data_Reader::get_range(), Botan::TLS::TLS_Data_Reader::get_range_vector(), Botan::TLS::TLS_Data_Reader::get_remaining(), m_comp_methods, m_cookie_input_bits, m_extensions, m_hello_cookie, m_legacy_version, m_random, m_session_id, and m_suites.

Member Function Documentation

◆ ciphersuites()

const std::vector< uint16_t > & Botan::TLS::Client_Hello_Internal::ciphersuites ( ) const
inline

Definition at line 80 of file tls_messages_internal.h.

80{ return m_suites; }

References m_suites.

◆ comp_methods()

const std::vector< uint8_t > & Botan::TLS::Client_Hello_Internal::comp_methods ( ) const
inline

Definition at line 82 of file tls_messages_internal.h.

82{ return m_comp_methods; }

References m_comp_methods.

◆ extensions() [1/2]

Extensions & Botan::TLS::Client_Hello_Internal::extensions ( )
inline

Definition at line 90 of file tls_messages_internal.h.

90{ return m_extensions; }

References m_extensions.

◆ extensions() [2/2]

const Extensions & Botan::TLS::Client_Hello_Internal::extensions ( ) const
inline

Definition at line 88 of file tls_messages_internal.h.

88{ return m_extensions; }

References m_extensions.

Referenced by version().

◆ hello_cookie()

const std::vector< uint8_t > & Botan::TLS::Client_Hello_Internal::hello_cookie ( ) const
inline

Definition at line 84 of file tls_messages_internal.h.

84{ return m_hello_cookie; }

References m_hello_cookie.

◆ hello_cookie_input_bits()

const std::vector< uint8_t > & Botan::TLS::Client_Hello_Internal::hello_cookie_input_bits ( ) const
inline

Definition at line 86 of file tls_messages_internal.h.

86{ return m_cookie_input_bits; }

References m_cookie_input_bits.

◆ legacy_version()

Protocol_Version Botan::TLS::Client_Hello_Internal::legacy_version ( ) const
inline

Definition at line 74 of file tls_messages_internal.h.

74{ return m_legacy_version; }

References m_legacy_version.

◆ random()

const std::vector< uint8_t > & Botan::TLS::Client_Hello_Internal::random ( ) const
inline

Definition at line 78 of file tls_messages_internal.h.

78{ return m_random; }

References m_random.

◆ session_id()

const Session_ID & Botan::TLS::Client_Hello_Internal::session_id ( ) const
inline

Definition at line 76 of file tls_messages_internal.h.

76{ return m_session_id; }

References m_session_id.

◆ version()

Protocol_Version Botan::TLS::Client_Hello_Internal::version ( ) const

This distinguishes between a TLS 1.3 compliant Client Hello (containing the "supported_version" extension) and legacy Client Hello messages.

Returns
TLS 1.3 if the Client Hello contains "supported_versions", or the content of the "legacy_version" version field if it indicates (D)TLS 1.2 or older, or (D)TLS 1.2 if the "legacy_version" was some other odd value.

Definition at line 76 of file msg_client_hello.cpp.

76 {
77 // RFC 8446 4.2.1
78 // If [the "supported_versions"] extension is not present, servers
79 // which are compliant with this specification and which also support
80 // TLS 1.2 MUST negotiate TLS 1.2 or prior as specified in [RFC5246],
81 // even if ClientHello.legacy_version is 0x0304 or later.
82 //
83 // RFC 8446 4.2.1
84 // Servers MUST be prepared to receive ClientHellos that include
85 // [the supported_versions] extension but do not include 0x0304 in
86 // the list of versions.
87 //
88 // RFC 8446 4.1.2
89 // TLS 1.3 ClientHellos are identified as having a legacy_version of
90 // 0x0303 and a supported_versions extension present with 0x0304 as
91 // the highest version indicated therein.
92 if(!extensions().has<Supported_Versions>() ||
93 !extensions().get<Supported_Versions>()->supports(Protocol_Version::TLS_V13)) {
94 // The exact legacy_version is ignored we just inspect it to
95 // distinguish TLS and DTLS.
96 return (m_legacy_version.is_datagram_protocol()) ? Protocol_Version::DTLS_V12 : Protocol_Version::TLS_V12;
97 }
98
99 // Note: The Client_Hello_13 class will make sure that legacy_version
100 // is exactly 0x0303 (aka ossified TLS 1.2)
101 return Protocol_Version::TLS_V13;
102}
const Extensions & extensions() const

References extensions(), and m_legacy_version.

Member Data Documentation

◆ m_comp_methods

std::vector<uint8_t> Botan::TLS::Client_Hello_Internal::m_comp_methods

◆ m_cookie_input_bits

std::vector<uint8_t> Botan::TLS::Client_Hello_Internal::m_cookie_input_bits

Definition at line 102 of file tls_messages_internal.h.

Referenced by Client_Hello_Internal(), and hello_cookie_input_bits().

◆ m_extensions

Extensions Botan::TLS::Client_Hello_Internal::m_extensions

Definition at line 98 of file tls_messages_internal.h.

Referenced by Client_Hello_Internal(), extensions(), and extensions().

◆ m_hello_cookie

std::vector<uint8_t> Botan::TLS::Client_Hello_Internal::m_hello_cookie

Definition at line 101 of file tls_messages_internal.h.

Referenced by Client_Hello_Internal(), and hello_cookie().

◆ m_legacy_version

Protocol_Version Botan::TLS::Client_Hello_Internal::m_legacy_version

Definition at line 93 of file tls_messages_internal.h.

Referenced by Client_Hello_Internal(), legacy_version(), and version().

◆ m_random

std::vector<uint8_t> Botan::TLS::Client_Hello_Internal::m_random

Definition at line 95 of file tls_messages_internal.h.

Referenced by Client_Hello_Internal(), and random().

◆ m_session_id

Session_ID Botan::TLS::Client_Hello_Internal::m_session_id

Definition at line 94 of file tls_messages_internal.h.

Referenced by Client_Hello_Internal(), and session_id().

◆ m_suites

std::vector<uint16_t> Botan::TLS::Client_Hello_Internal::m_suites

Definition at line 96 of file tls_messages_internal.h.

Referenced by ciphersuites(), and Client_Hello_Internal().


The documentation for this class was generated from the following files: