Botan 3.10.0
Crypto and TLS for C&
Botan::TLS::Client_Hello_13 Class Referencefinal

#include <tls_messages.h>

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

Public Member Functions

std::vector< Signature_Schemecertificate_signature_schemes () const
const std::vector< uint16_t > & ciphersuites () const
 Client_Hello_13 (const Policy &policy, Callbacks &cb, RandomNumberGenerator &rng, std::string_view hostname, const std::vector< std::string > &next_protocols, std::optional< Session_with_Handle > &session, std::vector< ExternalPSK > psks)
const std::vector< uint8_t > & cookie () const
std::vector< uint8_t > cookie_input_data () const
std::set< Extension_Codeextension_types () const
const Extensionsextensions () const
std::optional< Protocol_Versionhighest_supported_version (const Policy &policy) 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
void retry (const Hello_Retry_Request &hrr, const Transcript_Hash_State &transcript_hash_state, Callbacks &cb, RandomNumberGenerator &rng)
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
void validate_updates (const Client_Hello_13 &new_ch)
virtual Handshake_Type wire_type () const

Static Public Member Functions

static std::variant< Client_Hello_13, Client_Hello_12parse (const std::vector< uint8_t > &buf)

Protected Member Functions

const std::vector< uint8_t > & compression_methods () const

Protected Attributes

std::unique_ptr< Client_Hello_Internal > m_data

Detailed Description

Definition at line 218 of file tls_messages.h.

Constructor & Destructor Documentation

◆ Client_Hello_13()

Botan::TLS::Client_Hello_13::Client_Hello_13 ( const Policy & policy,
Callbacks & cb,
RandomNumberGenerator & rng,
std::string_view hostname,
const std::vector< std::string > & next_protocols,
std::optional< Session_with_Handle > & session,
std::vector< ExternalPSK > psks )

Creates a client hello which might optionally use the passed-in session for resumption. In that case, this will "extract" the master secret from the passed-in session.

Definition at line 759 of file msg_client_hello.cpp.

765 {
766 // RFC 8446 4.1.2
767 // In TLS 1.3, the client indicates its version preferences in the
768 // "supported_versions" extension (Section 4.2.1) and the
769 // legacy_version field MUST be set to 0x0303, which is the version
770 // number for TLS 1.2.
771 m_data->m_legacy_version = Protocol_Version::TLS_V12;
772 m_data->m_random = make_hello_random(rng, cb, policy);
773 m_data->m_suites = policy.ciphersuite_list(Protocol_Version::TLS_V13);
774
775 if(policy.allow_tls12()) {
776 // Note: DTLS 1.3 is NYI, hence dtls_12 is not checked
777 const auto legacy_suites = policy.ciphersuite_list(Protocol_Version::TLS_V12);
778 m_data->m_suites.insert(m_data->m_suites.end(), legacy_suites.cbegin(), legacy_suites.cend());
779 }
780
781 if(policy.tls_13_middlebox_compatibility_mode()) {
782 // RFC 8446 4.1.2
783 // In compatibility mode (see Appendix D.4), this field MUST be non-empty,
784 // so a client not offering a pre-TLS 1.3 session MUST generate a new
785 // 32-byte value.
786 //
787 // Note: we won't ever offer a TLS 1.2 session. In such a case we would
788 // have instantiated a TLS 1.2 client in the first place.
789 m_data->m_session_id = Session_ID(make_hello_random(rng, cb, policy));
790 }
791
792 // NOLINTBEGIN(*-owning-memory)
793 if(hostname_acceptable_for_sni(hostname)) {
794 m_data->extensions().add(new Server_Name_Indicator(hostname));
795 }
796
797 m_data->extensions().add(new Supported_Groups(policy.key_exchange_groups()));
798
799 m_data->extensions().add(new Key_Share(policy, cb, rng));
800
801 m_data->extensions().add(new Supported_Versions(Protocol_Version::TLS_V13, policy));
802
803 m_data->extensions().add(new Signature_Algorithms(policy.acceptable_signature_schemes()));
804 if(auto cert_signing_prefs = policy.acceptable_certificate_signature_schemes()) {
805 // RFC 8446 4.2.3
806 // Implementations which have the same policy in both cases MAY omit
807 // the "signature_algorithms_cert" extension.
808 m_data->extensions().add(new Signature_Algorithms_Cert(std::move(cert_signing_prefs.value())));
809 }
810
811 // TODO: Support for PSK-only mode without a key exchange.
812 // This should be configurable in TLS::Policy and should allow no PSK
813 // support at all (e.g. to disable support for session resumption).
814 m_data->extensions().add(new PSK_Key_Exchange_Modes({PSK_Key_Exchange_Mode::PSK_DHE_KE}));
815
816 if(policy.support_cert_status_message()) {
817 m_data->extensions().add(new Certificate_Status_Request({}, {}));
818 }
819
820 // We currently support "record_size_limit" for TLS 1.3 exclusively. Hence,
821 // when TLS 1.2 is advertised as a supported protocol, we must not offer this
822 // extension.
823 if(policy.record_size_limit().has_value() && !policy.allow_tls12()) {
824 m_data->extensions().add(new Record_Size_Limit(policy.record_size_limit().value()));
825 }
826
827 if(!next_protocols.empty()) {
828 m_data->extensions().add(new Application_Layer_Protocol_Notification(next_protocols));
829 }
830
831 // RFC 7250 4.1
832 // In order to indicate the support of raw public keys, clients include
833 // the client_certificate_type and/or the server_certificate_type
834 // extensions in an extended client hello message.
835 m_data->extensions().add(new Client_Certificate_Type(policy.accepted_client_certificate_types()));
836 m_data->extensions().add(new Server_Certificate_Type(policy.accepted_server_certificate_types()));
837
838 if(policy.allow_tls12()) {
839 m_data->extensions().add(new Renegotiation_Extension());
840 m_data->extensions().add(new Session_Ticket_Extension());
841
842 // EMS must always be used with TLS 1.2, regardless of the policy
843 m_data->extensions().add(new Extended_Master_Secret);
844
845 if(policy.negotiate_encrypt_then_mac()) {
846 m_data->extensions().add(new Encrypt_then_MAC);
847 }
848
849 if(m_data->extensions().has<Supported_Groups>() &&
850 !m_data->extensions().get<Supported_Groups>()->ec_groups().empty()) {
851 m_data->extensions().add(new Supported_Point_Formats(policy.use_ecc_point_compression()));
852 }
853 }
854
855 if(session.has_value() || !psks.empty()) {
856 m_data->extensions().add(new PSK(session, std::move(psks), cb));
857 }
858 // NOLINTEND(*-owning-memory)
859
860 cb.tls_modify_extensions(m_data->extensions(), Connection_Side::Client, type());
861
862 if(m_data->extensions().has<PSK>()) {
863 // RFC 8446 4.2.11
864 // The "pre_shared_key" extension MUST be the last extension in the
865 // ClientHello (this facilitates implementation [...]).
866 if(m_data->extensions().all().back()->type() != Extension_Code::PresharedKey) {
867 throw TLS_Exception(Alert::InternalError,
868 "Application modified extensions of Client Hello, PSK is not last anymore");
869 }
870 calculate_psk_binders({});
871 }
872}
std::unique_ptr< Client_Hello_Internal > m_data
std::vector< std::string > next_protocols() const
virtual Handshake_Type type() const =0
std::vector< uint8_t > make_hello_random(RandomNumberGenerator &rng, Callbacks &cb, const Policy &policy)
Strong< std::vector< uint8_t >, struct Session_ID_ > Session_ID
holds a TLS 1.2 session ID for stateful resumption
Definition tls_session.h:31

References Botan::TLS::Policy::acceptable_certificate_signature_schemes(), Botan::TLS::Policy::acceptable_signature_schemes(), Botan::TLS::Policy::accepted_client_certificate_types(), Botan::TLS::Policy::accepted_server_certificate_types(), Botan::TLS::Policy::allow_tls12(), Botan::TLS::Policy::ciphersuite_list(), Botan::TLS::Client, Botan::TLS::Supported_Groups::ec_groups(), Botan::TLS::Policy::key_exchange_groups(), Botan::TLS::Client_Hello::m_data, Botan::TLS::make_hello_random(), Botan::TLS::Policy::negotiate_encrypt_then_mac(), Botan::TLS::Client_Hello::next_protocols(), Botan::TLS::PresharedKey, Botan::TLS::PSK, Botan::TLS::PSK_DHE_KE, Botan::TLS::Policy::record_size_limit(), Botan::TLS::Policy::support_cert_status_message(), Botan::TLS::Policy::tls_13_middlebox_compatibility_mode(), Botan::TLS::Callbacks::tls_modify_extensions(), Botan::TLS::Client_Hello::type(), and Botan::TLS::Policy::use_ecc_point_compression().

Referenced by parse(), and validate_updates().

Member Function Documentation

◆ certificate_signature_schemes()

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

Definition at line 268 of file msg_client_hello.cpp.

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

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

198 {
199 return m_data->ciphersuites();
200}

References m_data.

Referenced by ~Client_Hello().

◆ compression_methods()

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

Definition at line 194 of file msg_client_hello.cpp.

194 {
195 return m_data->comp_methods();
196}

References m_data.

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

◆ cookie()

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

Definition at line 385 of file msg_client_hello.cpp.

385 {
386 return m_data->hello_cookie();
387}

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

247 {
248 BOTAN_STATE_CHECK(!m_data->hello_cookie_input_bits().empty());
249
250 return m_data->hello_cookie_input_bits();
251}
#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 202 of file msg_client_hello.cpp.

202 {
203 return m_data->extensions().extension_types();
204}

References m_data.

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

◆ extensions()

◆ highest_supported_version()

std::optional< Protocol_Version > Botan::TLS::Client_Hello_13::highest_supported_version ( const Policy & policy) const

Select the highest protocol version from the list of versions supported by the client. If no such version can be determined this returns std::nullopt.

Definition at line 1052 of file msg_client_hello.cpp.

1052 {
1053 // RFC 8446 4.2.1
1054 // The "supported_versions" extension is used by the client to indicate
1055 // which versions of TLS it supports and by the server to indicate which
1056 // version it is using. The extension contains a list of supported
1057 // versions in preference order, with the most preferred version first.
1058 auto* const supvers = m_data->extensions().get<Supported_Versions>();
1059 BOTAN_ASSERT_NONNULL(supvers);
1060
1061 std::optional<Protocol_Version> result;
1062
1063 for(const auto& v : supvers->versions()) {
1064 // RFC 8446 4.2.1
1065 // Servers MUST only select a version of TLS present in that extension
1066 // and MUST ignore any unknown versions that are present in that
1067 // extension.
1068 if(!v.known_version() || !policy.acceptable_protocol_version(v)) {
1069 continue;
1070 }
1071
1072 result = (result.has_value()) ? std::optional(std::max(result.value(), v)) : std::optional(v);
1073 }
1074
1075 return result;
1076}
#define BOTAN_ASSERT_NONNULL(ptr)
Definition assert.h:114

References Botan::TLS::Policy::acceptable_protocol_version(), BOTAN_ASSERT_NONNULL, and Botan::TLS::Client_Hello::m_data.

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

182 {
183 return m_data->legacy_version();
184}

References m_data.

Referenced by ~Client_Hello().

◆ next_protocols()

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

Definition at line 371 of file msg_client_hello.cpp.

371 {
372 if(auto* alpn = m_data->extensions().get<Application_Layer_Protocol_Notification>()) {
373 return alpn->protocols();
374 }
375 return {};
376}

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

256 {
257 return std::find(m_data->ciphersuites().cbegin(), m_data->ciphersuites().cend(), ciphersuite) !=
258 m_data->ciphersuites().cend();
259}

References m_data.

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

◆ parse()

std::variant< Client_Hello_13, Client_Hello_12 > Botan::TLS::Client_Hello_13::parse ( const std::vector< uint8_t > & buf)
static

Definition at line 874 of file msg_client_hello.cpp.

874 {
875 auto data = std::make_unique<Client_Hello_Internal>(buf);
876 const auto version = data->version();
877
878 if(version.is_pre_tls_13()) {
879 return Client_Hello_12(std::move(data));
880 } else {
881 return Client_Hello_13(std::move(data));
882 }
883}
Client_Hello_13(const Policy &policy, Callbacks &cb, RandomNumberGenerator &rng, std::string_view hostname, const std::vector< std::string > &next_protocols, std::optional< Session_with_Handle > &session, std::vector< ExternalPSK > psks)

References Client_Hello_13().

◆ random()

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

Definition at line 186 of file msg_client_hello.cpp.

186 {
187 return m_data->random();
188}

References m_data.

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

◆ retry()

void Botan::TLS::Client_Hello_13::retry ( const Hello_Retry_Request & hrr,
const Transcript_Hash_State & transcript_hash_state,
Callbacks & cb,
RandomNumberGenerator & rng )

Definition at line 885 of file msg_client_hello.cpp.

888 {
889 BOTAN_STATE_CHECK(m_data->extensions().has<Supported_Groups>());
890 BOTAN_STATE_CHECK(m_data->extensions().has<Key_Share>());
891
892 auto* hrr_ks = hrr.extensions().get<Key_Share>();
893 const auto& supported_groups = m_data->extensions().get<Supported_Groups>()->groups();
894
895 if(hrr.extensions().has<Key_Share>()) {
896 m_data->extensions().get<Key_Share>()->retry_offer(*hrr_ks, supported_groups, cb, rng);
897 }
898
899 // RFC 8446 4.2.2
900 // When sending the new ClientHello, the client MUST copy
901 // the contents of the extension received in the HelloRetryRequest into
902 // a "cookie" extension in the new ClientHello.
903 //
904 // RFC 8446 4.2.2
905 // Clients MUST NOT use cookies in their initial ClientHello in subsequent
906 // connections.
907 if(hrr.extensions().has<Cookie>()) {
908 BOTAN_STATE_CHECK(!m_data->extensions().has<Cookie>());
909 m_data->extensions().add(new Cookie(hrr.extensions().get<Cookie>()->get_cookie())); // NOLINT(*-owning-memory)
910 }
911
912 // Note: the consumer of the TLS implementation won't be able to distinguish
913 // invocations to this callback due to the first Client_Hello or the
914 // retried Client_Hello after receiving a Hello_Retry_Request. We assume
915 // that the user keeps and detects this state themselves.
916 cb.tls_modify_extensions(m_data->extensions(), Connection_Side::Client, type());
917
918 auto* psk = m_data->extensions().get<PSK>();
919 if(psk != nullptr) {
920 // Cipher suite should always be a known suite as this is checked upstream
921 const auto cipher = Ciphersuite::by_id(hrr.ciphersuite());
922 BOTAN_ASSERT_NOMSG(cipher.has_value());
923
924 // RFC 8446 4.1.4
925 // In [...] its updated ClientHello, the client SHOULD NOT offer
926 // any pre-shared keys associated with a hash other than that of the
927 // selected cipher suite.
928 psk->filter(cipher.value());
929
930 // RFC 8446 4.2.11.2
931 // If the server responds with a HelloRetryRequest and the client
932 // then sends ClientHello2, its binder will be computed over: [...].
933 calculate_psk_binders(transcript_hash_state.clone());
934 }
935}
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:75
static std::optional< Ciphersuite > by_id(uint16_t suite)

References BOTAN_ASSERT_NOMSG, BOTAN_STATE_CHECK, Botan::TLS::Ciphersuite::by_id(), Botan::TLS::Server_Hello::ciphersuite(), Botan::TLS::Client, Botan::TLS::Transcript_Hash_State::clone(), Botan::TLS::Cookie, Botan::TLS::Server_Hello::extensions(), Botan::TLS::Extensions::get(), Botan::TLS::Cookie::get_cookie(), Botan::TLS::Extensions::has(), Botan::TLS::Client_Hello::m_data, Botan::TLS::Callbacks::tls_modify_extensions(), and Botan::TLS::Client_Hello::type().

◆ sent_signature_algorithms()

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

Definition at line 367 of file msg_client_hello.cpp.

367 {
368 return m_data->extensions().has<Signature_Algorithms>();
369}

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

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

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

190 {
191 return m_data->session_id();
192}

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

261 {
262 if(Signature_Algorithms* sigs = m_data->extensions().get<Signature_Algorithms>()) {
263 return sigs->supported_schemes();
264 }
265 return {};
266}

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

301 {
302 if(Server_Name_Indicator* sni = m_data->extensions().get<Server_Name_Indicator>()) {
303 return sni->host_name();
304 }
305 return "";
306}

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

378 {
379 if(SRTP_Protection_Profiles* srtp = m_data->extensions().get<SRTP_Protection_Profiles>()) {
380 return srtp->profiles();
381 }
382 return {};
383}

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

287 {
288 if(Supported_Groups* groups = m_data->extensions().get<Supported_Groups>()) {
289 return groups->dh_groups();
290 }
291 return std::vector<Group_Params>();
292}

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

280 {
281 if(Supported_Groups* groups = m_data->extensions().get<Supported_Groups>()) {
282 return groups->ec_groups();
283 }
284 return {};
285}

References m_data.

Referenced by ~Client_Hello().

◆ supported_versions()

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

Definition at line 319 of file msg_client_hello.cpp.

319 {
320 if(Supported_Versions* versions = m_data->extensions().get<Supported_Versions>()) {
321 return versions->versions();
322 }
323 return {};
324}

References m_data.

Referenced by ~Client_Hello().

◆ supports_alpn()

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

Definition at line 351 of file msg_client_hello.cpp.

351 {
352 return m_data->extensions().has<Application_Layer_Protocol_Notification>();
353}

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 18 of file tls_handshake_state.cpp.

18 {
20}
const char * handshake_type_to_string(Handshake_Type type)

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

◆ validate_updates()

void Botan::TLS::Client_Hello_13::validate_updates ( const Client_Hello_13 & new_ch)

This validates that a Client Hello received after sending a Hello Retry Request was updated in accordance with RFC 8446 4.1.2. If issues are found, this method throws accordingly.

Definition at line 937 of file msg_client_hello.cpp.

937 {
938 // RFC 8446 4.1.2
939 // The client will also send a ClientHello when the server has responded
940 // to its ClientHello with a HelloRetryRequest. In that case, the client
941 // MUST send the same ClientHello without modification, except as follows:
942
943 if(m_data->session_id() != new_ch.m_data->session_id() || m_data->random() != new_ch.m_data->random() ||
944 m_data->ciphersuites() != new_ch.m_data->ciphersuites() ||
945 m_data->comp_methods() != new_ch.m_data->comp_methods()) {
946 throw TLS_Exception(Alert::IllegalParameter, "Client Hello core values changed after Hello Retry Request");
947 }
948
949 const auto oldexts = extension_types();
950 const auto newexts = new_ch.extension_types();
951
952 // Check that extension omissions are justified
953 for(const auto oldext : oldexts) {
954 if(!newexts.contains(oldext)) {
955 auto* const ext = extensions().get(oldext);
956
957 // We don't make any assumptions about unimplemented extensions.
958 if(!ext->is_implemented()) {
959 continue;
960 }
961
962 // RFC 8446 4.1.2
963 // Removing the "early_data" extension (Section 4.2.10) if one was
964 // present. Early data is not permitted after a HelloRetryRequest.
965 if(oldext == EarlyDataIndication::static_type()) {
966 continue;
967 }
968
969 // RFC 8446 4.1.2
970 // Optionally adding, removing, or changing the length of the
971 // "padding" extension.
972 //
973 // TODO: implement the Padding extension
974 // if(oldext == Padding::static_type())
975 // continue;
976
977 throw TLS_Exception(Alert::IllegalParameter, "Extension removed in updated Client Hello");
978 }
979 }
980
981 // Check that extension additions are justified
982 for(const auto newext : newexts) {
983 if(!oldexts.contains(newext)) {
984 auto* const ext = new_ch.extensions().get(newext);
985
986 // We don't make any assumptions about unimplemented extensions.
987 if(!ext->is_implemented()) {
988 continue;
989 }
990
991 // RFC 8446 4.1.2
992 // Including a "cookie" extension if one was provided in the
993 // HelloRetryRequest.
994 if(newext == Cookie::static_type()) {
995 continue;
996 }
997
998 // RFC 8446 4.1.2
999 // Optionally adding, removing, or changing the length of the
1000 // "padding" extension.
1001 //
1002 // TODO: implement the Padding extension
1003 // if(newext == Padding::static_type())
1004 // continue;
1005
1006 throw TLS_Exception(Alert::UnsupportedExtension, "Added an extension in updated Client Hello");
1007 }
1008 }
1009
1010 // RFC 8446 4.1.2
1011 // Removing the "early_data" extension (Section 4.2.10) if one was
1012 // present. Early data is not permitted after a HelloRetryRequest.
1013 if(new_ch.extensions().has<EarlyDataIndication>()) {
1014 throw TLS_Exception(Alert::IllegalParameter, "Updated Client Hello indicates early data");
1015 }
1016
1017 // TODO: Contents of extensions are not checked for update compatibility, see:
1018 //
1019 // RFC 8446 4.1.2
1020 // If a "key_share" extension was supplied in the HelloRetryRequest,
1021 // replacing the list of shares with a list containing a single
1022 // KeyShareEntry from the indicated group.
1023 //
1024 // Updating the "pre_shared_key" extension if present by recomputing
1025 // the "obfuscated_ticket_age" and binder values and (optionally)
1026 // removing any PSKs which are incompatible with the server's
1027 // indicated cipher suite.
1028 //
1029 // Optionally adding, removing, or changing the length of the
1030 // "padding" extension.
1031}
const Extensions & extensions() const
std::set< Extension_Code > extension_types() const
static Extension_Code static_type()
static Extension_Code static_type()

References Client_Hello_13(), Botan::TLS::Client_Hello::extension_types(), Botan::TLS::Client_Hello::extensions(), Botan::TLS::Extensions::get(), Botan::TLS::Extensions::has(), Botan::TLS::Client_Hello::m_data, Botan::TLS::Cookie::static_type(), and Botan::TLS::EarlyDataIndication::static_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().

Member Data Documentation

◆ m_data


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