Botan 3.3.0
Crypto and TLS for C&
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Botan::TLS::Client_Hello Class Reference

#include <tls_messages.h>

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

Public Member Functions

std::vector< Signature_Schemecertificate_signature_schemes () const
 
const std::vector< uint16_t > & ciphersuites () const
 
 Client_Hello (Client_Hello &&) noexcept
 
 Client_Hello (const Client_Hello &)=delete
 
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
 
Client_Hellooperator= (Client_Hello &&) noexcept
 
Client_Hellooperator= (const Client_Hello &)=delete
 
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
 
 ~Client_Hello () override
 

Protected Member Functions

 Client_Hello ()
 
 Client_Hello (std::unique_ptr< Client_Hello_Internal > data)
 
const std::vector< uint8_t > & compression_methods () const
 

Protected Attributes

std::unique_ptr< Client_Hello_Internal > m_data
 

Detailed Description

Client Hello Message

Definition at line 76 of file tls_messages.h.

Constructor & Destructor Documentation

◆ Client_Hello() [1/4]

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

◆ Client_Hello() [2/4]

Botan::TLS::Client_Hello::Client_Hello ( Client_Hello && )
defaultnoexcept

◆ ~Client_Hello()

Botan::TLS::Client_Hello::~Client_Hello ( )
overridedefault

◆ Client_Hello() [3/4]

Botan::TLS::Client_Hello::Client_Hello ( )
protected

Definition at line 174 of file msg_client_hello.cpp.

174: m_data(std::make_unique<Client_Hello_Internal>()) {}
std::unique_ptr< Client_Hello_Internal > m_data

◆ Client_Hello() [4/4]

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

Definition at line 179 of file msg_client_hello.cpp.

179 : m_data(std::move(data)) {
181}
#define BOTAN_ASSERT_NONNULL(ptr)
Definition assert.h:86

References BOTAN_ASSERT_NONNULL, and m_data.

Member Function Documentation

◆ certificate_signature_schemes()

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

Definition at line 273 of file msg_client_hello.cpp.

273 {
274 // RFC 8446 4.2.3
275 // If no "signature_algorithms_cert" extension is present, then the
276 // "signature_algorithms" extension also applies to signatures appearing
277 // in certificates.
278 if(Signature_Algorithms_Cert* sigs = m_data->extensions().get<Signature_Algorithms_Cert>()) {
279 return sigs->supported_schemes();
280 } else {
281 return signature_schemes();
282 }
283}
std::vector< Signature_Scheme > signature_schemes() const

References m_data, and signature_schemes().

Referenced by Botan::TLS::Certificate_13::Certificate_13().

◆ ciphersuites()

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

Definition at line 203 of file msg_client_hello.cpp.

203 {
204 return m_data->ciphersuites();
205}

References m_data.

◆ compression_methods()

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

Definition at line 199 of file msg_client_hello.cpp.

199 {
200 return m_data->comp_methods();
201}

References m_data.

◆ cookie()

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

Definition at line 390 of file msg_client_hello.cpp.

390 {
391 return m_data->hello_cookie();
392}

References m_data.

◆ cookie_input_data()

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

Definition at line 252 of file msg_client_hello.cpp.

252 {
253 BOTAN_STATE_CHECK(!m_data->hello_cookie_input_bits().empty());
254
255 return m_data->hello_cookie_input_bits();
256}
#define BOTAN_STATE_CHECK(expr)
Definition assert.h:41

References BOTAN_STATE_CHECK, and m_data.

◆ extension_types()

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

Definition at line 207 of file msg_client_hello.cpp.

207 {
208 return m_data->extensions().extension_types();
209}

References m_data.

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

◆ extensions()

const Extensions & Botan::TLS::Client_Hello::extensions ( ) const

◆ legacy_version()

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

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 187 of file msg_client_hello.cpp.

187 {
188 return m_data->legacy_version();
189}

References m_data.

◆ next_protocols()

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

Definition at line 376 of file msg_client_hello.cpp.

376 {
377 if(auto alpn = m_data->extensions().get<Application_Layer_Protocol_Notification>()) {
378 return alpn->protocols();
379 }
380 return {};
381}

References m_data.

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

◆ offered_suite()

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

Definition at line 261 of file msg_client_hello.cpp.

261 {
262 return std::find(m_data->ciphersuites().cbegin(), m_data->ciphersuites().cend(), ciphersuite) !=
263 m_data->ciphersuites().cend();
264}

References m_data.

Referenced by Botan::TLS::Client_Hello_12::Client_Hello_12().

◆ operator=() [1/2]

Client_Hello & Botan::TLS::Client_Hello::operator= ( Client_Hello && )
defaultnoexcept

◆ operator=() [2/2]

Client_Hello & Botan::TLS::Client_Hello::operator= ( const Client_Hello & )
delete

◆ random()

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

Definition at line 191 of file msg_client_hello.cpp.

191 {
192 return m_data->random();
193}

References m_data.

◆ sent_signature_algorithms()

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

Definition at line 372 of file msg_client_hello.cpp.

372 {
373 return m_data->extensions().has<Signature_Algorithms>();
374}

References m_data.

◆ serialize()

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

Implements Botan::TLS::Handshake_Message.

Definition at line 224 of file msg_client_hello.cpp.

224 {
225 std::vector<uint8_t> buf;
226 buf.reserve(1024); // working around GCC warning
227
228 buf.push_back(m_data->legacy_version().major_version());
229 buf.push_back(m_data->legacy_version().minor_version());
230 buf += m_data->random();
231
232 append_tls_length_value(buf, m_data->session_id().get(), 1);
233
234 if(m_data->legacy_version().is_datagram_protocol()) {
235 append_tls_length_value(buf, m_data->hello_cookie(), 1);
236 }
237
238 append_tls_length_value(buf, m_data->ciphersuites(), 2);
239 append_tls_length_value(buf, m_data->comp_methods(), 1);
240
241 /*
242 * May not want to send extensions at all in some cases. If so,
243 * should include SCSV value (if reneg info is empty, if not we are
244 * renegotiating with a modern server)
245 */
246
247 buf += m_data->extensions().serialize(Connection_Side::Client);
248
249 return buf;
250}
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:180

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

◆ session_id()

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

Definition at line 195 of file msg_client_hello.cpp.

195 {
196 return m_data->session_id();
197}

References m_data.

Referenced by Botan::TLS::Client_Hello_12::session_handle().

◆ signature_schemes()

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

Definition at line 266 of file msg_client_hello.cpp.

266 {
267 if(Signature_Algorithms* sigs = m_data->extensions().get<Signature_Algorithms>()) {
268 return sigs->supported_schemes();
269 }
270 return {};
271}

References m_data.

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

◆ sni_hostname()

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

Definition at line 306 of file msg_client_hello.cpp.

306 {
307 if(Server_Name_Indicator* sni = m_data->extensions().get<Server_Name_Indicator>()) {
308 return sni->host_name();
309 }
310 return "";
311}

References m_data.

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

◆ srtp_profiles()

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

Definition at line 383 of file msg_client_hello.cpp.

383 {
384 if(SRTP_Protection_Profiles* srtp = m_data->extensions().get<SRTP_Protection_Profiles>()) {
385 return srtp->profiles();
386 }
387 return {};
388}

References m_data.

Referenced by Botan::TLS::Server_Hello_12::Server_Hello_12().

◆ supported_dh_groups()

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

Definition at line 292 of file msg_client_hello.cpp.

292 {
293 if(Supported_Groups* groups = m_data->extensions().get<Supported_Groups>()) {
294 return groups->dh_groups();
295 }
296 return std::vector<Group_Params>();
297}

References m_data.

◆ supported_ecc_curves()

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

Definition at line 285 of file msg_client_hello.cpp.

285 {
286 if(Supported_Groups* groups = m_data->extensions().get<Supported_Groups>()) {
287 return groups->ec_groups();
288 }
289 return {};
290}

References m_data.

◆ supported_versions()

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

Definition at line 324 of file msg_client_hello.cpp.

324 {
325 if(Supported_Versions* versions = m_data->extensions().get<Supported_Versions>()) {
326 return versions->versions();
327 }
328 return {};
329}

References m_data.

◆ supports_alpn()

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

Definition at line 356 of file msg_client_hello.cpp.

356 {
357 return m_data->extensions().has<Application_Layer_Protocol_Notification>();
358}

References m_data.

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

◆ type()

Handshake_Type Botan::TLS::Client_Hello::type ( ) const
overridevirtual

◆ type_string()

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

Definition at line 19 of file tls_handshake_state.cpp.

19 {
21}
virtual Handshake_Type type() const =0
const char * handshake_type_to_string(Handshake_Type type)

References Botan::TLS::handshake_type_to_string(), and Botan::TLS::Handshake_Message::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 }

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

Member Data Documentation

◆ m_data

std::unique_ptr<Client_Hello_Internal> Botan::TLS::Client_Hello::m_data
protected

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