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

#include <tls_messages.h>

Inheritance diagram for Botan::TLS::Server_Hello_12_Shim:
Botan::TLS::Server_Hello Botan::TLS::Handshake_Message Botan::TLS::Server_Hello_12

Public Member Functions

uint16_t ciphersuite () const
const Extensionsextensions () const
std::optional< Protocol_Versionrandom_signals_downgrade () const
Protocol_Version selected_version () const final
std::vector< uint8_t > serialize () const override
 Server_Hello_12_Shim (const std::vector< uint8_t > &buf)
const Session_IDsession_id () const
Handshake_Type type () const override
std::string type_string () const
virtual Handshake_Type wire_type () const

Protected Member Functions

uint8_t compression_method () const
std::set< Extension_Codeextension_types () const
Protocol_Version legacy_version () const
const std::vector< uint8_t > & random () const
 Server_Hello_12_Shim (std::unique_ptr< Server_Hello_Internal > data)

Protected Attributes

std::unique_ptr< Server_Hello_Internalm_data

Friends

class Server_Hello_13

Detailed Description

Basic implementation of Server_Hello from TLS 1.2. The full implementation is in Server_Hello_12 in the tls12 module. This is meant to be used by the TLS 1.3 implementation to parse, validate and understand a downgrade request.

Definition at line 210 of file tls_messages.h.

Constructor & Destructor Documentation

◆ Server_Hello_12_Shim() [1/2]

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

Definition at line 157 of file msg_server_hello.cpp.

157 :
158 Server_Hello_12_Shim(std::make_unique<Server_Hello_Internal>(buf)) {}
Server_Hello_12_Shim(const std::vector< uint8_t > &buf)

References Server_Hello_12_Shim().

Referenced by Server_Hello_12_Shim(), and Server_Hello_13.

◆ Server_Hello_12_Shim() [2/2]

Botan::TLS::Server_Hello_12_Shim::Server_Hello_12_Shim ( std::unique_ptr< Server_Hello_Internal > data)
explicitprotected

Definition at line 160 of file msg_server_hello.cpp.

160 :
161 Server_Hello(std::move(data)) {
162 if(!m_data->version().is_pre_tls_13()) {
163 throw TLS_Exception(Alert::ProtocolVersion, "Expected server hello of (D)TLS 1.2 or lower");
164 }
165}
Server_Hello(const Server_Hello &)=delete
std::unique_ptr< Server_Hello_Internal > m_data

References Botan::TLS::Server_Hello::m_data, and Botan::TLS::Server_Hello::Server_Hello().

Member Function Documentation

◆ ciphersuite()

uint16_t Botan::TLS::Server_Hello::ciphersuite ( ) const
inherited

Definition at line 145 of file msg_server_hello.cpp.

145 {
146 return m_data->ciphersuite();
147}

References m_data.

Referenced by Botan::TLS::Client_Hello_13::retry(), Botan::TLS::Server_Hello_12::Server_Hello_12(), and ~Server_Hello().

◆ compression_method()

uint8_t Botan::TLS::Server_Hello::compression_method ( ) const
protectedinherited

Definition at line 137 of file msg_server_hello.cpp.

137 {
138 return m_data->comp_method();
139}

References m_data.

Referenced by Botan::TLS::Server_Hello_13::basic_validation(), and selected_version().

◆ extension_types()

std::set< Extension_Code > Botan::TLS::Server_Hello::extension_types ( ) const
protectedinherited

Definition at line 149 of file msg_server_hello.cpp.

149 {
150 return m_data->extensions().extension_types();
151}

References m_data.

Referenced by selected_version().

◆ extensions()

const Extensions & Botan::TLS::Server_Hello::extensions ( ) const
inherited

◆ legacy_version()

Protocol_Version Botan::TLS::Server_Hello::legacy_version ( ) const
protectedinherited

Definition at line 129 of file msg_server_hello.cpp.

129 {
130 return m_data->legacy_version();
131}

References m_data.

Referenced by Botan::TLS::Server_Hello_13::basic_validation(), selected_version(), and Botan::TLS::Server_Hello_12_Shim::selected_version().

◆ random()

const std::vector< uint8_t > & Botan::TLS::Server_Hello::random ( ) const
protectedinherited

Definition at line 133 of file msg_server_hello.cpp.

133 {
134 return m_data->random();
135}

References m_data.

Referenced by selected_version().

◆ random_signals_downgrade()

std::optional< Protocol_Version > Botan::TLS::Server_Hello_12_Shim::random_signals_downgrade ( ) const

Return desired downgrade version indicated by hello random, if any.

Definition at line 171 of file msg_server_hello.cpp.

171 {
172 const uint64_t last8 = load_be<uint64_t>(m_data->random().data(), 3);
173 if(last8 == DOWNGRADE_TLS11) {
174 return Protocol_Version::TLS_V11;
175 }
176 if(last8 == DOWNGRADE_TLS12) {
177 return Protocol_Version::TLS_V12;
178 }
179
180 return std::nullopt;
181}
constexpr uint64_t DOWNGRADE_TLS12
Definition tls_magic.h:118
constexpr uint64_t DOWNGRADE_TLS11
Definition tls_magic.h:107
constexpr auto load_be(ParamTs &&... params)
Definition loadstor.h:504

References Botan::TLS::DOWNGRADE_TLS11, Botan::TLS::DOWNGRADE_TLS12, Botan::load_be(), and Botan::TLS::Server_Hello::m_data.

Referenced by Server_Hello_13.

◆ selected_version()

Protocol_Version Botan::TLS::Server_Hello_12_Shim::selected_version ( ) const
finalvirtual
Returns
the selected version as indicated in the legacy_version field

Implements Botan::TLS::Server_Hello.

Definition at line 167 of file msg_server_hello.cpp.

167 {
168 return legacy_version();
169}
Protocol_Version legacy_version() const

References Botan::TLS::Server_Hello::legacy_version().

Referenced by Server_Hello_13.

◆ serialize()

std::vector< uint8_t > Botan::TLS::Server_Hello::serialize ( ) const
overridevirtualinherited
Returns
DER representation of this message

Implements Botan::TLS::Handshake_Message.

Definition at line 105 of file msg_server_hello.cpp.

105 {
106 std::vector<uint8_t> buf;
107 buf.reserve(1024); // working around GCC warning
108
109 buf.push_back(m_data->legacy_version().major_version());
110 buf.push_back(m_data->legacy_version().minor_version());
111 buf += m_data->random();
112
113 append_tls_length_value(buf, m_data->session_id().get(), 1);
114
115 buf.push_back(get_byte<0>(m_data->ciphersuite()));
116 buf.push_back(get_byte<1>(m_data->ciphersuite()));
117
118 buf.push_back(m_data->comp_method());
119
120 buf += m_data->extensions().serialize(Connection_Side::Server);
121
122 return buf;
123}
void append_tls_length_value(std::vector< uint8_t, Alloc > &buf, const T *vals, size_t vals_size, size_t tag_size)
Definition tls_reader.h:177
constexpr uint8_t get_byte(T input)
Definition loadstor.h:79

References Botan::TLS::append_tls_length_value(), Botan::get_byte(), m_data, serialize(), Botan::TLS::Server, and Server_Hello().

Referenced by serialize(), and ~Server_Hello().

◆ session_id()

const Session_ID & Botan::TLS::Server_Hello::session_id ( ) const
inherited

◆ type()

Handshake_Type Botan::TLS::Server_Hello::type ( ) const
overridevirtualinherited
Returns
the message type

Implements Botan::TLS::Handshake_Message.

Definition at line 125 of file msg_server_hello.cpp.

References Botan::TLS::ServerHello.

Referenced by ~Server_Hello().

◆ type_string()

std::string Botan::TLS::Handshake_Message::type_string ( ) const
inherited
Returns
string representation of this message type

Definition at line 21 of file tls_handshake_state.cpp.

21 {
23}
virtual Handshake_Type type() const =0
const char * handshake_type_to_string(Handshake_Type type)
Definition tls_magic.cpp:15

References Botan::TLS::handshake_type_to_string(), and type().

◆ wire_type()

virtual Handshake_Type Botan::TLS::Handshake_Message::wire_type ( ) const
inlinevirtualinherited
Returns
the wire representation of the message's type

Reimplemented in Botan::TLS::Hello_Retry_Request.

Definition at line 39 of file tls_handshake_msg.h.

39 {
40 // Usually equal to the Handshake_Type enum value,
41 // with the exception of TLS 1.3 Hello Retry Request.
42 return type();
43 }

References type().

Referenced by Botan::TLS::Stream_Handshake_IO::send().

◆ Server_Hello_13

friend class Server_Hello_13
friend

Member Data Documentation

◆ m_data


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