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

156 :
157 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 159 of file msg_server_hello.cpp.

159 :
160 Server_Hello(std::move(data)) {
161 if(!m_data->version().is_pre_tls_13()) {
162 throw TLS_Exception(Alert::ProtocolVersion, "Expected server hello of (D)TLS 1.2 or lower");
163 }
164}
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 144 of file msg_server_hello.cpp.

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

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 136 of file msg_server_hello.cpp.

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

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 148 of file msg_server_hello.cpp.

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

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 128 of file msg_server_hello.cpp.

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

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 132 of file msg_server_hello.cpp.

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

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 170 of file msg_server_hello.cpp.

170 {
171 const uint64_t last8 = load_be<uint64_t>(m_data->random().data(), 3);
172 if(last8 == DOWNGRADE_TLS11) {
173 return Protocol_Version::TLS_V11;
174 }
175 if(last8 == DOWNGRADE_TLS12) {
176 return Protocol_Version::TLS_V12;
177 }
178
179 return std::nullopt;
180}
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 166 of file msg_server_hello.cpp.

166 {
167 return legacy_version();
168}
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 104 of file msg_server_hello.cpp.

104 {
105 std::vector<uint8_t> buf;
106 buf.reserve(1024); // working around GCC warning
107
108 buf.push_back(m_data->legacy_version().major_version());
109 buf.push_back(m_data->legacy_version().minor_version());
110 buf += m_data->random();
111
112 append_tls_length_value(buf, m_data->session_id().get(), 1);
113
114 buf.push_back(get_byte<0>(m_data->ciphersuite()));
115 buf.push_back(get_byte<1>(m_data->ciphersuite()));
116
117 buf.push_back(m_data->comp_method());
118
119 buf += m_data->extensions().serialize(Connection_Side::Server);
120
121 return buf;
122}
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 124 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: