Botan 3.12.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 48 of file msg_server_hello.cpp.

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

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

References extensions().


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