Botan 3.6.1
Crypto and TLS for C&
|
#include <tls_extensions.h>
Public Member Functions | |
void | calculate_binders (const Transcript_Hash_State &truncated_transcript_hash) |
bool | empty () const override |
void | filter (const Ciphersuite &cipher) |
virtual bool | is_implemented () const |
PSK (std::optional< Session_with_Handle > &session_to_resume, std::vector< ExternalPSK > psks, Callbacks &callbacks) | |
PSK (TLS_Data_Reader &reader, uint16_t extension_size, Handshake_Type message_type) | |
std::unique_ptr< PSK > | select_offered_psk (std::string_view host, const Ciphersuite &cipher, Session_Manager &session_mgr, Credentials_Manager &credentials_mgr, Callbacks &callbacks, const Policy &policy) |
std::vector< uint8_t > | serialize (Connection_Side side) const override |
std::pair< std::optional< std::string >, std::unique_ptr< Cipher_State > > | take_selected_psk_info (const PSK &server_psk, const Ciphersuite &cipher) |
std::variant< Session, ExternalPSK > | take_session_to_resume_or_psk () |
Extension_Code | type () const override |
bool | validate_binder (const PSK &server_psk, const std::vector< uint8_t > &binder) const |
~PSK () override | |
Static Public Member Functions | |
static Extension_Code | static_type () |
Pre-Shared Key extension from RFC 8446 4.2.11
Definition at line 661 of file tls_extensions.h.
Botan::TLS::PSK::PSK | ( | TLS_Data_Reader & | reader, |
uint16_t | extension_size, | ||
Handshake_Type | message_type ) |
Definition at line 142 of file tls_extensions_psk.cpp.
References Botan::TLS::ClientHello, Botan::TLS::TLS_Data_Reader::get_tls_length_value(), Botan::TLS::TLS_Data_Reader::get_uint16_t(), Botan::TLS::TLS_Data_Reader::get_uint32_t(), Botan::TLS::TLS_Data_Reader::has_remaining(), Botan::TLS::TLS_Data_Reader::read_so_far(), and Botan::TLS::ServerHello.
Botan::TLS::PSK::PSK | ( | std::optional< Session_with_Handle > & | session_to_resume, |
std::vector< ExternalPSK > | psks, | ||
Callbacks & | callbacks ) |
Creates a PSK extension with a TLS 1.3 session object containing a master_secret. Note that it will extract that secret from the session, and won't create a copy of it.
session_to_resume | the session to be resumed; note that the master secret will be taken away from the session object. |
psks | a list of non-resumption PSKs that should be offered to the server |
callbacks | the application's callbacks |
Definition at line 195 of file tls_extensions_psk.cpp.
References Botan::TLS::Callbacks::tls_current_timestamp().
|
overridedefault |
void Botan::TLS::PSK::calculate_binders | ( | const Transcript_Hash_State & | truncated_transcript_hash | ) |
Definition at line 413 of file tls_extensions_psk.cpp.
References BOTAN_ASSERT_NOMSG, Botan::TLS::Transcript_Hash_State::clone(), and Botan::TLS::Transcript_Hash_State::set_algorithm().
|
overridevirtual |
Implements Botan::TLS::Extension.
Definition at line 217 of file tls_extensions_psk.cpp.
References BOTAN_ASSERT_NOMSG, and empty().
Referenced by empty().
void Botan::TLS::PSK::filter | ( | const Ciphersuite & | cipher | ) |
Remove PSK identities from the list in m_psk
that are not compatible with the passed in cipher
suite. This is useful to react to Hello Retry Requests. See RFC 8446 4.1.4.
Definition at line 349 of file tls_extensions_psk.cpp.
References BOTAN_STATE_CHECK.
|
inlinevirtualinherited |
Reimplemented in Botan::TLS::Unknown_Extension.
Definition at line 116 of file tls_extensions.h.
std::unique_ptr< PSK > Botan::TLS::PSK::select_offered_psk | ( | std::string_view | host, |
const Ciphersuite & | cipher, | ||
Session_Manager & | session_mgr, | ||
Credentials_Manager & | credentials_mgr, | ||
Callbacks & | callbacks, | ||
const Policy & | policy ) |
Selects one of the offered PSKs that is compatible with cipher
.
PSK | extension object that can be added to the Server Hello response |
std::nullptr | if no PSK offered by the client is convenient |
Definition at line 270 of file tls_extensions_psk.cpp.
References BOTAN_STATE_CHECK, Botan::TLS::Session_Manager::choose_from_offered_tickets(), Botan::Credentials_Manager::choose_preshared_key(), Botan::TLS::Ciphersuite::prf_algo(), Botan::TLS::PSK, and Botan::TLS::Server.
|
overridevirtual |
Implements Botan::TLS::Extension.
Definition at line 374 of file tls_extensions_psk.cpp.
References Botan::TLS::append_tls_length_value(), BOTAN_STATE_CHECK, Botan::TLS::Client, Botan::get_byte(), and Botan::TLS::Server.
|
inlinestatic |
Definition at line 663 of file tls_extensions.h.
std::pair< std::optional< std::string >, std::unique_ptr< Cipher_State > > Botan::TLS::PSK::take_selected_psk_info | ( | const PSK & | server_psk, |
const Ciphersuite & | cipher ) |
Returns the PSK identity (in case of an externally provided PSK) and the cipher state representing the PSK selected by the server. Note that this destructs the list of offered PSKs and its cipher states and must therefore not be called more than once.
Definition at line 226 of file tls_extensions_psk.cpp.
References BOTAN_ASSERT_NONNULL, and BOTAN_STATE_CHECK.
std::variant< Session, ExternalPSK > Botan::TLS::PSK::take_session_to_resume_or_psk | ( | ) |
Pulls the preshared key or the Session to resume from a PSK extension in Server Hello.
Definition at line 360 of file tls_extensions_psk.cpp.
References BOTAN_STATE_CHECK, and Botan::TLS::InternalError.
|
inlineoverridevirtual |
Implements Botan::TLS::Extension.
Definition at line 665 of file tls_extensions.h.
bool Botan::TLS::PSK::validate_binder | ( | const PSK & | server_psk, |
const std::vector< uint8_t > & | binder ) const |
Definition at line 423 of file tls_extensions_psk.cpp.
References BOTAN_STATE_CHECK.