Botan 3.14.1
Crypto and TLS for C&
Botan::TLS::Server_Hello_Internal Class Referencefinal

#include <tls_messages_internal.h>

Public Member Functions

uint16_t ciphersuite () const
uint8_t comp_method () const
Extensions & extensions ()
const Extensions & extensions () const
bool is_hello_retry_request () const
Protocol_Version legacy_version () const
const std::vector< uint8_t > & random () const
 Server_Hello_Internal (Protocol_Version lv, Session_ID sid, std::vector< uint8_t > r, const uint16_t cs, const uint8_t cm, bool is_hrr=false)
 Server_Hello_Internal (std::span< const uint8_t > buf)
const Session_ID & session_id () const
Protocol_Version version () const

Detailed Description

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

Definition at line 150 of file tls_messages_internal.h.

Constructor & Destructor Documentation

◆ Server_Hello_Internal() [1/2]

Botan::TLS::Server_Hello_Internal::Server_Hello_Internal ( std::span< const uint8_t > buf)
explicit

Deserialize a Server Hello message

Definition at line 51 of file msg_server_hello.cpp.

51 {
52 if(buf.size() < 38) {
53 throw Decoding_Error("Server_Hello: Packet corrupted");
54 }
55
56 TLS_Data_Reader reader("ServerHello", buf);
57
58 const uint8_t major_version = reader.get_byte();
59 const uint8_t minor_version = reader.get_byte();
60
61 m_legacy_version = Protocol_Version(major_version, minor_version);
62
63 // RFC 8446 4.1.3
64 // Upon receiving a message with type server_hello, implementations MUST
65 // first examine the Random value and, if it matches this value, process
66 // it as described in Section 4.1.4 [Hello Retry Request]).
67 m_random = reader.get_fixed<uint8_t>(32);
68 m_is_hello_retry_request = CT::is_equal<uint8_t>(m_random, HELLO_RETRY_REQUEST_MARKER).as_bool();
69
70 m_session_id = Session_ID(reader.get_range<uint8_t>(1, 0, 32));
71 m_ciphersuite = reader.get_uint16_t();
72 m_comp_method = reader.get_byte();
73
74 // Note that this code path might parse a TLS 1.2 (or older) server hello message that
75 // is nevertheless marked as being a 'hello retry request' (potentially maliciously).
76 // Extension parsing will however not be affected by the associated flag.
77 // Only after parsing the extensions will the upstream code be able to decide
78 // whether we're dealing with TLS 1.3 or older.
79 m_extensions.deserialize(reader,
82}
constexpr CT::Mask< T > is_equal(const T x[], const T y[], size_t len)
Definition ct_utils.h:803
Strong< std::vector< uint8_t >, struct Session_ID_ > Session_ID
holds a TLS 1.2 session ID for stateful resumption
constexpr std::array< uint8_t, 32 > HELLO_RETRY_REQUEST_MARKER
Definition tls_magic.h:138

References Botan::TLS::TLS_Data_Reader::get_byte(), Botan::TLS::TLS_Data_Reader::get_fixed(), Botan::TLS::TLS_Data_Reader::get_range(), Botan::TLS::TLS_Data_Reader::get_uint16_t(), Botan::TLS::HELLO_RETRY_REQUEST_MARKER, Botan::TLS::HelloRetryRequest, Botan::CT::is_equal(), Botan::TLS::Server, and Botan::TLS::ServerHello.

◆ Server_Hello_Internal() [2/2]

Botan::TLS::Server_Hello_Internal::Server_Hello_Internal ( Protocol_Version lv,
Session_ID sid,
std::vector< uint8_t > r,
const uint16_t cs,
const uint8_t cm,
bool is_hrr = false )
inline

Definition at line 157 of file tls_messages_internal.h.

162 :
163 m_legacy_version(lv),
164 m_session_id(std::move(sid)),
165 m_random(std::move(r)),
166 m_is_hello_retry_request(is_hrr),
167 m_ciphersuite(cs),
168 m_comp_method(cm) {}

Member Function Documentation

◆ ciphersuite()

uint16_t Botan::TLS::Server_Hello_Internal::ciphersuite ( ) const
inline

Definition at line 178 of file tls_messages_internal.h.

178{ return m_ciphersuite; }

◆ comp_method()

uint8_t Botan::TLS::Server_Hello_Internal::comp_method ( ) const
inline

Definition at line 180 of file tls_messages_internal.h.

180{ return m_comp_method; }

◆ extensions() [1/2]

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

Definition at line 186 of file tls_messages_internal.h.

186{ return m_extensions; }

◆ extensions() [2/2]

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

Definition at line 184 of file tls_messages_internal.h.

184{ return m_extensions; }

Referenced by version().

◆ is_hello_retry_request()

bool Botan::TLS::Server_Hello_Internal::is_hello_retry_request ( ) const
inline

Definition at line 182 of file tls_messages_internal.h.

182{ return m_is_hello_retry_request; }

◆ legacy_version()

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

Definition at line 172 of file tls_messages_internal.h.

172{ return m_legacy_version; }

◆ random()

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

Definition at line 176 of file tls_messages_internal.h.

176{ return m_random; }

◆ session_id()

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

Definition at line 174 of file tls_messages_internal.h.

174{ return m_session_id; }

◆ version()

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

Definition at line 84 of file msg_server_hello.cpp.

84 {
85 // RFC 8446 4.2.1
86 // A server which negotiates a version of TLS prior to TLS 1.3 MUST set
87 // ServerHello.version and MUST NOT send the "supported_versions"
88 // extension. A server which negotiates TLS 1.3 MUST respond by sending
89 // a "supported_versions" extension containing the selected version
90 // value (0x0304).
91 //
92 // Note: Here we just take a message parsing decision, further validation of
93 // the extension's contents is done later.
94 return (extensions().has<Supported_Versions>()) ? Protocol_Version::TLS_V13 : m_legacy_version;
95}
const Extensions & extensions() const

References extensions().


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