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

#include <tls_messages.h>

Inheritance diagram for Botan::TLS::Client_Hello_12_Shim:
Botan::TLS::Client_Hello Botan::TLS::Handshake_Message Botan::TLS::Client_Hello_12

Public Member Functions

std::vector< Signature_Schemecertificate_signature_schemes () const
const std::vector< uint16_t > & ciphersuites () const
 Client_Hello_12_Shim (const std::vector< uint8_t > &buf)
const std::vector< uint8_t > & cookie () const
std::vector< uint8_t > cookie_input_data () const
std::set< Extension_Codeextension_types () const
const Extensionsextensions () const
Protocol_Version legacy_version () const
std::vector< std::string > next_protocols () const
bool offered_suite (uint16_t ciphersuite) const
const std::vector< uint8_t > & random () const
bool sent_signature_algorithms () const
std::vector< uint8_t > serialize () const override
const Session_IDsession_id () const
std::vector< Signature_Schemesignature_schemes () const
std::string sni_hostname () const
std::vector< uint16_t > srtp_profiles () const
std::vector< Group_Paramssupported_dh_groups () const
std::vector< Group_Paramssupported_ecc_curves () const
std::vector< Protocol_Versionsupported_versions () const
bool supports_alpn () const
Handshake_Type type () const override
std::string type_string () const
virtual Handshake_Type wire_type () const

Protected Member Functions

 Client_Hello ()
 Client_Hello (Client_Hello &&) noexcept
 Client_Hello (const Client_Hello &)=delete
 Client_Hello (std::unique_ptr< Client_Hello_Internal > data)
 Client_Hello_12_Shim (std::unique_ptr< Client_Hello_Internal > data)
const std::vector< uint8_t > & compression_methods () const

Protected Attributes

std::unique_ptr< Client_Hello_Internalm_data

Friends

class Client_Hello_13

Detailed Description

Basic implementation of Client_Hello from TLS 1.2. The full implementation is in Client_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 156 of file tls_messages.h.

Constructor & Destructor Documentation

◆ Client_Hello_12_Shim() [1/2]

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

Definition at line 271 of file msg_client_hello.cpp.

271 :
272 Client_Hello_12_Shim(std::make_unique<Client_Hello_Internal>(buf)) {}
Client_Hello_12_Shim(const std::vector< uint8_t > &buf)

References Client_Hello_12_Shim().

Referenced by Client_Hello_12_Shim(), and Client_Hello_13.

◆ Client_Hello_12_Shim() [2/2]

Botan::TLS::Client_Hello_12_Shim::Client_Hello_12_Shim ( std::unique_ptr< Client_Hello_Internal > data)
explicitprotected

Definition at line 268 of file msg_client_hello.cpp.

268 :
269 Client_Hello(std::move(data)) {}

References Client_Hello().

Member Function Documentation

◆ certificate_signature_schemes()

std::vector< Signature_Scheme > Botan::TLS::Client_Hello::certificate_signature_schemes ( ) const
inherited

Definition at line 202 of file msg_client_hello.cpp.

202 {
203 // RFC 8446 4.2.3
204 // If no "signature_algorithms_cert" extension is present, then the
205 // "signature_algorithms" extension also applies to signatures appearing
206 // in certificates.
207 if(const Signature_Algorithms_Cert* sigs = m_data->extensions().get<Signature_Algorithms_Cert>()) {
208 return sigs->supported_schemes();
209 } else {
210 return signature_schemes();
211 }
212}
std::vector< Signature_Scheme > signature_schemes() const
std::unique_ptr< Client_Hello_Internal > m_data

References m_data, and signature_schemes().

Referenced by Botan::TLS::Certificate_13::Certificate_13(), and ~Client_Hello().

◆ ciphersuites()

const std::vector< uint16_t > & Botan::TLS::Client_Hello::ciphersuites ( ) const
inherited

Definition at line 138 of file msg_client_hello.cpp.

138 {
139 return m_data->ciphersuites();
140}

References m_data.

Referenced by ~Client_Hello().

◆ Client_Hello() [1/4]

Definition at line 142 of file msg_client_hello.cpp.

109: m_data(std::make_unique<Client_Hello_Internal>()) {}

◆ Client_Hello() [2/4]

Botan::TLS::Client_Hello::Client_Hello ( Client_Hello && )
protecteddefaultnoexcept

◆ Client_Hello() [3/4]

Botan::TLS::Client_Hello::Client_Hello ( const Client_Hello & )
protecteddelete

◆ Client_Hello() [4/4]

Botan::TLS::Client_Hello::Client_Hello ( std::unique_ptr< Client_Hello_Internal > data)
explicitprotected

Definition at line 143 of file msg_client_hello.cpp.

114 : m_data(std::move(data)) {
116}
#define BOTAN_ASSERT_NONNULL(ptr)
Definition assert.h:114

References Botan::TLS::Client_Hello::m_data.

◆ compression_methods()

const std::vector< uint8_t > & Botan::TLS::Client_Hello::compression_methods ( ) const
protectedinherited

Definition at line 134 of file msg_client_hello.cpp.

134 {
135 return m_data->comp_methods();
136}

References m_data.

Referenced by ~Client_Hello().

◆ cookie()

const std::vector< uint8_t > & Botan::TLS::Client_Hello::cookie ( ) const
inherited

Definition at line 264 of file msg_client_hello.cpp.

264 {
265 return m_data->hello_cookie();
266}

References m_data.

Referenced by ~Client_Hello().

◆ cookie_input_data()

std::vector< uint8_t > Botan::TLS::Client_Hello::cookie_input_data ( ) const
inherited

Definition at line 181 of file msg_client_hello.cpp.

181 {
182 BOTAN_STATE_CHECK(!m_data->hello_cookie_input_bits().empty());
183
184 return m_data->hello_cookie_input_bits();
185}
#define BOTAN_STATE_CHECK(expr)
Definition assert.h:49

References BOTAN_STATE_CHECK, and m_data.

Referenced by ~Client_Hello().

◆ extension_types()

std::set< Extension_Code > Botan::TLS::Client_Hello::extension_types ( ) const
inherited

Definition at line 142 of file msg_client_hello.cpp.

142 {
143 return m_data->extensions().extension_types();
144}

Referenced by Botan::TLS::Server_Hello_12::Server_Hello_12(), Botan::TLS::Client_Hello_13::validate_updates(), and ~Client_Hello().

◆ extensions()

◆ legacy_version()

Protocol_Version Botan::TLS::Client_Hello::legacy_version ( ) const
inherited

Return the version indicated in the ClientHello. This may differ from the version indicated in the supported_versions extension.

See RFC 8446 4.1.2: TLS 1.3, the client indicates its version preferences in the "supported_versions" extension (Section 4.2.1) and the legacy_version field MUST be set to 0x0303, which is the version number for TLS 1.2.

Definition at line 122 of file msg_client_hello.cpp.

122 {
123 return m_data->legacy_version();
124}

References m_data.

Referenced by ~Client_Hello().

◆ next_protocols()

std::vector< std::string > Botan::TLS::Client_Hello::next_protocols ( ) const
inherited

Definition at line 250 of file msg_client_hello.cpp.

250 {
251 if(auto* alpn = m_data->extensions().get<Application_Layer_Protocol_Notification>()) {
252 return alpn->protocols();
253 }
254 return {};
255}

References m_data.

Referenced by Botan::TLS::Client_Hello_12::Client_Hello_12(), Botan::TLS::Client_Hello_12::Client_Hello_12(), Botan::TLS::Client_Hello_13::Client_Hello_13(), and ~Client_Hello().

◆ offered_suite()

bool Botan::TLS::Client_Hello::offered_suite ( uint16_t ciphersuite) const
inherited

Definition at line 190 of file msg_client_hello.cpp.

190 {
191 return std::find(m_data->ciphersuites().cbegin(), m_data->ciphersuites().cend(), ciphersuite) !=
192 m_data->ciphersuites().cend();
193}

References m_data.

Referenced by ~Client_Hello().

◆ random()

const std::vector< uint8_t > & Botan::TLS::Client_Hello::random ( ) const
inherited

Definition at line 126 of file msg_client_hello.cpp.

126 {
127 return m_data->random();
128}

References m_data.

Referenced by ~Client_Hello().

◆ sent_signature_algorithms()

bool Botan::TLS::Client_Hello::sent_signature_algorithms ( ) const
inherited

Definition at line 246 of file msg_client_hello.cpp.

246 {
247 return m_data->extensions().has<Signature_Algorithms>();
248}

References m_data.

Referenced by ~Client_Hello().

◆ serialize()

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

Implements Botan::TLS::Handshake_Message.

Definition at line 153 of file msg_client_hello.cpp.

153 {
154 std::vector<uint8_t> buf;
155 buf.reserve(1024); // working around GCC warning
156
157 buf.push_back(m_data->legacy_version().major_version());
158 buf.push_back(m_data->legacy_version().minor_version());
159 buf += m_data->random();
160
161 append_tls_length_value(buf, m_data->session_id().get(), 1);
162
163 if(m_data->legacy_version().is_datagram_protocol()) {
164 append_tls_length_value(buf, m_data->hello_cookie(), 1);
165 }
166
167 append_tls_length_value(buf, m_data->ciphersuites(), 2);
168 append_tls_length_value(buf, m_data->comp_methods(), 1);
169
170 /*
171 * May not want to send extensions at all in some cases. If so,
172 * should include SCSV value (if reneg info is empty, if not we are
173 * renegotiating with a modern server)
174 */
175
176 buf += m_data->extensions().serialize(Connection_Side::Client);
177
178 return buf;
179}
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

References Botan::TLS::append_tls_length_value(), Botan::TLS::Client, and m_data.

Referenced by ~Client_Hello().

◆ session_id()

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

Definition at line 130 of file msg_client_hello.cpp.

130 {
131 return m_data->session_id();
132}

References m_data.

Referenced by Botan::TLS::Client_Hello_12::session_handle(), and ~Client_Hello().

◆ signature_schemes()

std::vector< Signature_Scheme > Botan::TLS::Client_Hello::signature_schemes ( ) const
inherited

Definition at line 195 of file msg_client_hello.cpp.

195 {
196 if(const Signature_Algorithms* sigs = m_data->extensions().get<Signature_Algorithms>()) {
197 return sigs->supported_schemes();
198 }
199 return {};
200}

References m_data.

Referenced by Botan::TLS::Certificate_13::Certificate_13(), certificate_signature_schemes(), Botan::TLS::Handshake_State::choose_sig_format(), and ~Client_Hello().

◆ sni_hostname()

std::string Botan::TLS::Client_Hello::sni_hostname ( ) const
inherited

Definition at line 228 of file msg_client_hello.cpp.

228 {
229 if(const Server_Name_Indicator* sni = m_data->extensions().get<Server_Name_Indicator>()) {
230 return sni->host_name();
231 }
232 return "";
233}

References m_data.

Referenced by Botan::TLS::Certificate_13::Certificate_13(), Botan::TLS::Certificate_Request_13::maybe_create(), and ~Client_Hello().

◆ srtp_profiles()

std::vector< uint16_t > Botan::TLS::Client_Hello::srtp_profiles ( ) const
inherited

Definition at line 257 of file msg_client_hello.cpp.

257 {
258 if(const SRTP_Protection_Profiles* srtp = m_data->extensions().get<SRTP_Protection_Profiles>()) {
259 return srtp->profiles();
260 }
261 return {};
262}

References m_data.

Referenced by ~Client_Hello().

◆ supported_dh_groups()

std::vector< Group_Params > Botan::TLS::Client_Hello::supported_dh_groups ( ) const
inherited

Definition at line 221 of file msg_client_hello.cpp.

221 {
222 if(const Supported_Groups* groups = m_data->extensions().get<Supported_Groups>()) {
223 return groups->dh_groups();
224 }
225 return std::vector<Group_Params>();
226}

References m_data.

Referenced by ~Client_Hello().

◆ supported_ecc_curves()

std::vector< Group_Params > Botan::TLS::Client_Hello::supported_ecc_curves ( ) const
inherited

Definition at line 214 of file msg_client_hello.cpp.

214 {
215 if(const Supported_Groups* groups = m_data->extensions().get<Supported_Groups>()) {
216 return groups->ec_groups();
217 }
218 return {};
219}

References m_data.

Referenced by ~Client_Hello().

◆ supported_versions()

std::vector< Protocol_Version > Botan::TLS::Client_Hello::supported_versions ( ) const
inherited

Definition at line 235 of file msg_client_hello.cpp.

235 {
236 if(const Supported_Versions* versions = m_data->extensions().get<Supported_Versions>()) {
237 return versions->versions();
238 }
239 return {};
240}

References m_data.

Referenced by ~Client_Hello().

◆ supports_alpn()

bool Botan::TLS::Client_Hello::supports_alpn ( ) const
inherited

Definition at line 242 of file msg_client_hello.cpp.

242 {
243 return m_data->extensions().has<Application_Layer_Protocol_Notification>();
244}

References m_data.

Referenced by Botan::TLS::Server_Hello_12::Server_Hello_12(), Botan::TLS::Server_Hello_12::Server_Hello_12(), and ~Client_Hello().

◆ type()

◆ 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().

◆ Client_Hello_13

friend class Client_Hello_13
friend

Definition at line 163 of file tls_messages.h.

References Client_Hello_12_Shim(), and Client_Hello_13.

Referenced by Client_Hello_13.

Member Data Documentation

◆ m_data


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