Botan 3.11.0
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
Extensionsextensions ()
const Extensionsextensions () const
bool is_hello_retry_request () const
Protocol_Version legacy_version () const
const std::vector< uint8_t > & random () const
 Server_Hello_Internal (const std::vector< uint8_t > &buf)
 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)
const Session_IDsession_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 110 of file tls_messages_internal.h.

Constructor & Destructor Documentation

◆ Server_Hello_Internal() [1/2]

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

Deserialize a Server Hello message

Definition at line 49 of file msg_server_hello.cpp.

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

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 117 of file tls_messages_internal.h.

122 :
123 m_legacy_version(lv),
124 m_session_id(std::move(sid)),
125 m_random(std::move(r)),
126 m_is_hello_retry_request(is_hrr),
127 m_ciphersuite(cs),
128 m_comp_method(cm) {}

Member Function Documentation

◆ ciphersuite()

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

Definition at line 138 of file tls_messages_internal.h.

138{ return m_ciphersuite; }

◆ comp_method()

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

Definition at line 140 of file tls_messages_internal.h.

140{ return m_comp_method; }

◆ extensions() [1/2]

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

Definition at line 146 of file tls_messages_internal.h.

146{ return m_extensions; }

◆ extensions() [2/2]

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

Definition at line 144 of file tls_messages_internal.h.

144{ 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 142 of file tls_messages_internal.h.

142{ return m_is_hello_retry_request; }

◆ legacy_version()

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

Definition at line 132 of file tls_messages_internal.h.

132{ return m_legacy_version; }

◆ random()

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

Definition at line 136 of file tls_messages_internal.h.

136{ return m_random; }

◆ session_id()

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

Definition at line 134 of file tls_messages_internal.h.

134{ return m_session_id; }

◆ version()

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

Definition at line 82 of file msg_server_hello.cpp.

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

References extensions().


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