Botan 3.6.1
Crypto and TLS for C&
|
#include <tls_client_impl_12.h>
Public Types | |
typedef std::function< void(Alert, const uint8_t[], size_t)> | alert_cb |
typedef std::function< void(const uint8_t[], size_t)> | data_cb |
typedef std::function< bool(const Session &)> | handshake_cb |
typedef std::function< void(const Handshake_Message &)> | handshake_msg_cb |
typedef std::function< void(const uint8_t[], size_t)> | output_fn |
Public Member Functions | |
std::string | application_protocol () const override |
Client_Impl_12 (const Channel_Impl::Downgrade_Information &downgrade_info) | |
Client_Impl_12 (const std::shared_ptr< Callbacks > &callbacks, const std::shared_ptr< Session_Manager > &session_manager, const std::shared_ptr< Credentials_Manager > &creds, const std::shared_ptr< const Policy > &policy, const std::shared_ptr< RandomNumberGenerator > &rng, Server_Information server_info=Server_Information(), bool datagram=false, const std::vector< std::string > &next_protocols={}, size_t reserved_io_buffer_size=TLS::Channel::IO_BUF_DEFAULT_SIZE) | |
void | close () |
bool | expects_downgrade () const |
std::optional< std::string > | external_psk_identity () const override |
std::unique_ptr< Downgrade_Information > | extract_downgrade_info () |
size_t | from_peer (std::span< const uint8_t > data) override |
bool | is_active () const override |
bool | is_closed () const override |
bool | is_closed_for_reading () const override |
bool | is_closed_for_writing () const override |
bool | is_downgrading () const |
bool | is_handshake_complete () const override |
SymmetricKey | key_material_export (std::string_view label, std::string_view context, size_t length) const override |
virtual bool | new_session_ticket_supported () const |
std::vector< X509_Certificate > | peer_cert_chain () const override |
std::shared_ptr< const Public_Key > | peer_raw_public_key () const override |
void | renegotiate (bool force_full_renegotiation=false) override |
bool | secure_renegotiation_supported () const override |
void | send_alert (const Alert &alert) override |
void | send_fatal_alert (Alert::Type type) |
virtual size_t | send_new_session_tickets (const size_t) |
void | send_warning_alert (Alert::Type type) |
bool | timeout_check () override |
void | to_peer (std::span< const uint8_t > data) override |
void | update_traffic_keys (bool request_peer_update=false) override |
Protected Attributes | |
std::unique_ptr< Downgrade_Information > | m_downgrade_info |
SSL/TLS Client 1.2 implementation
Definition at line 24 of file tls_client_impl_12.h.
|
inherited |
Definition at line 44 of file tls_channel_impl_12.h.
|
inherited |
Definition at line 43 of file tls_channel_impl_12.h.
|
inherited |
Definition at line 45 of file tls_channel_impl_12.h.
|
inherited |
Definition at line 46 of file tls_channel_impl_12.h.
|
inherited |
Definition at line 42 of file tls_channel_impl_12.h.
|
explicit |
Set up a new TLS client session
callbacks | contains a set of callback function references required by the TLS client. |
session_manager | manages session state |
creds | manages application/user credentials |
policy | specifies other connection policy information |
rng | a random number generator |
server_info | is identifying information about the TLS server |
datagram | specifies whether to use TLS 1.2 or DTLS 1.2 |
next_protocols | specifies protocols to advertise with ALPN |
reserved_io_buffer_size | This many bytes of memory will be preallocated for the read and write buffers. Smaller values just mean reallocations and copies are more likely. |
Definition at line 84 of file tls_client_impl_12.cpp.
References BOTAN_ASSERT_NONNULL, and Botan::TLS::Channel_Impl_12::create_handshake_state().
|
explicit |
Definition at line 102 of file tls_client_impl_12.cpp.
References BOTAN_ASSERT_NOMSG, Botan::TLS::Handshake_State::client_hello(), Botan::TLS::Channel_Impl::Downgrade_Information::client_hello_message, Botan::TLS::Channel_Impl_12::create_handshake_state(), Botan::TLS::Handshake_State::hash(), Botan::TLS::Channel_Impl::Downgrade_Information::next_protocols, Botan::TLS::Channel_Impl_12::secure_renegotiation_check(), Botan::TLS::ServerHello, Botan::TLS::Handshake_State::set_expected_next(), Botan::TLS::Channel_Impl::Downgrade_Information::tls12_session, and Botan::TLS::Handshake_Hash::update().
|
protectedinherited |
Definition at line 252 of file tls_channel_impl_12.cpp.
References Botan::TLS::Channel_Impl_12::callbacks(), Botan::TLS::Connection_Sequence_Numbers::current_write_epoch(), Botan::map_remove_if(), and Botan::TLS::Callbacks::tls_session_activated().
|
inlineoverridevirtual |
Implements Botan::TLS::Channel_Impl.
Definition at line 65 of file tls_client_impl_12.h.
|
inlineprotectedinherited |
Definition at line 190 of file tls_channel_impl_12.h.
Referenced by Botan::TLS::Channel_Impl_12::activate_session().
|
protectedinherited |
Definition at line 187 of file tls_channel_impl_12.cpp.
References BOTAN_ASSERT, Botan::TLS::Client, Botan::TLS::Connection_Sequence_Numbers::current_read_epoch(), Botan::TLS::Connection_Sequence_Numbers::new_read_cipher_state(), and Botan::TLS::Server.
|
protectedinherited |
Definition at line 214 of file tls_channel_impl_12.cpp.
References BOTAN_ASSERT, Botan::TLS::Connection_Sequence_Numbers::current_write_epoch(), and Botan::TLS::Connection_Sequence_Numbers::new_write_cipher_state().
|
inlineinherited |
Send a close notification alert
Definition at line 80 of file tls_channel_impl.h.
References Botan::TLS::Channel_Impl::send_warning_alert().
|
protectedinherited |
Definition at line 112 of file tls_channel_impl_12.cpp.
References Botan::TLS::Protocol_Version::is_datagram_protocol(), Botan::TLS::Channel_Impl_12::new_handshake_state(), Botan::TLS::Channel_Impl_12::policy(), and Botan::TLS::Protocol_Version::to_string().
Referenced by Client_Impl_12(), Client_Impl_12(), and Botan::TLS::Channel_Impl_12::renegotiate().
|
inlineinherited |
Definition at line 278 of file tls_channel_impl.h.
References Botan::TLS::Channel_Impl::m_downgrade_info.
Referenced by Botan::TLS::Client_Impl_13::Client_Impl_13(), and Botan::TLS::Channel_Impl_13::from_peer().
|
overridevirtualinherited |
Implements Botan::TLS::Channel_Impl.
Definition at line 103 of file tls_channel_impl_12.cpp.
|
inlineinherited |
Definition at line 276 of file tls_channel_impl.h.
References Botan::TLS::Channel_Impl::m_downgrade_info.
|
overridevirtualinherited |
Inject TLS traffic received from counterparty
Implements Botan::TLS::Channel_Impl.
Definition at line 269 of file tls_channel_impl_12.cpp.
References Botan::TLS::Alert, Botan::TLS::Policy::allow_dtls_epoch0_restart(), Botan::TLS::ApplicationData, BOTAN_ASSERT, BOTAN_ASSERT_IMPLICATION, Botan::TLS::ChangeCipherSpec, Botan::TLS::ClientHello, Botan::TLS::Record_Header::epoch(), Botan::TLS::Handshake, Botan::TLS::Invalid, Botan::TLS::Protocol_Version::major_version(), Botan::TLS::MAX_PLAINTEXT_SIZE, Botan::TLS::Record_Header::needed(), Botan::TLS::Channel_Impl_12::policy(), Botan::TLS::read_record(), Botan::TLS::Channel_Impl::send_fatal_alert(), Botan::TLS::Record_Header::sequence(), Botan::TLS::Record_Header::type(), Botan::TLS::TLS_Exception::type(), and Botan::TLS::Record_Header::version().
|
protectedinherited |
|
overridevirtualinherited |
Implements Botan::TLS::Channel_Impl.
Definition at line 244 of file tls_channel_impl_12.cpp.
References Botan::TLS::Channel_Impl_12::is_closed(), and Botan::TLS::Channel_Impl_12::is_handshake_complete().
Referenced by Botan::TLS::Channel_Impl_12::to_peer().
|
overridevirtualinherited |
Implements Botan::TLS::Channel_Impl.
Definition at line 248 of file tls_channel_impl_12.cpp.
Referenced by Botan::TLS::Channel_Impl_12::is_active(), Botan::TLS::Channel_Impl_12::is_closed_for_reading(), Botan::TLS::Channel_Impl_12::is_closed_for_writing(), and Botan::TLS::Channel_Impl_12::send_alert().
|
inlineoverridevirtualinherited |
Implements Botan::TLS::Channel_Impl.
Definition at line 101 of file tls_channel_impl_12.h.
References Botan::TLS::Channel_Impl_12::is_closed().
|
inlineoverridevirtualinherited |
Implements Botan::TLS::Channel_Impl.
Definition at line 103 of file tls_channel_impl_12.h.
References Botan::TLS::Channel_Impl_12::is_closed().
|
inlineinherited |
Indicates whether a downgrade to TLS 1.2 or lower is in progress
Definition at line 271 of file tls_channel_impl.h.
References Botan::TLS::Channel_Impl::m_downgrade_info.
Referenced by Botan::TLS::Channel_Impl_13::from_peer(), Botan::TLS::Channel_Impl_13::key_material_export(), and Botan::TLS::Channel_Impl_13::update_traffic_keys().
|
overridevirtualinherited |
Implements Botan::TLS::Channel_Impl.
Definition at line 240 of file tls_channel_impl_12.cpp.
Referenced by Botan::TLS::Channel_Impl_12::is_active().
|
overridevirtualinherited |
Key material export (RFC 5705)
label | a disambiguating label string |
context | a per-association context value |
length | the length of the desired key in bytes |
Implements Botan::TLS::Channel_Impl.
Definition at line 623 of file tls_channel_impl_12.cpp.
References Botan::get_byte(), and Botan::to_byte_vector().
|
protectedpure virtualinherited |
Referenced by Botan::TLS::Channel_Impl_12::create_handshake_state().
|
inlinevirtualinherited |
Reimplemented in Botan::TLS::Server_Impl_13.
Definition at line 144 of file tls_channel_impl.h.
|
overridevirtualinherited |
Implements Botan::TLS::Channel_Impl.
Definition at line 96 of file tls_channel_impl_12.cpp.
References Botan::TLS::Channel_Impl_12::get_peer_cert_chain().
|
inlineoverridevirtualinherited |
Note: Raw public key for authentication (RFC7250) is currently not implemented for TLS 1.2.
Implements Botan::TLS::Channel_Impl.
Definition at line 116 of file tls_channel_impl_12.h.
|
inlineprotectedinherited |
Definition at line 188 of file tls_channel_impl_12.h.
Referenced by Botan::TLS::Channel_Impl_12::create_handshake_state(), Botan::TLS::Channel_Impl_12::from_peer(), and Botan::TLS::Channel_Impl_12::renegotiate().
|
inlineprotectedinherited |
Definition at line 231 of file tls_channel_impl.h.
References BOTAN_STATE_CHECK, and Botan::TLS::Channel_Impl::m_downgrade_info.
Referenced by Botan::TLS::Client_Impl_13::Client_Impl_13().
|
inlineprotectedinherited |
Definition at line 226 of file tls_channel_impl.h.
References BOTAN_STATE_CHECK, and Botan::TLS::Channel_Impl::m_downgrade_info.
Referenced by Botan::TLS::Channel_Impl_13::from_peer().
|
overridevirtualinherited |
Attempt to renegotiate the session
force_full_renegotiation | if true, require a full renegotiation, otherwise allow session resumption |
Implements Botan::TLS::Channel_Impl.
Definition at line 167 of file tls_channel_impl_12.cpp.
References Botan::TLS::Policy::allow_resumption_for_renegotiation(), Botan::TLS::Channel_Impl_12::create_handshake_state(), Botan::TLS::Channel_Impl_12::initiate_handshake(), and Botan::TLS::Channel_Impl_12::policy().
|
inlineprotectedinherited |
Implementations use this to signal that the peer indicated a protocol version downgrade. After calling request_downgrade()
no further state changes must be perfomed by the implementation. Particularly, no further handshake messages must be emitted. Instead, they must yield control flow back to the underlying Channel implementation to perform the protocol version downgrade.
Definition at line 252 of file tls_channel_impl.h.
References BOTAN_STATE_CHECK, and Botan::TLS::Channel_Impl::m_downgrade_info.
Referenced by Botan::TLS::Channel_Impl::request_downgrade_for_resumption().
|
inlineprotectedinherited |
Definition at line 257 of file tls_channel_impl.h.
References BOTAN_ASSERT_NOMSG, BOTAN_STATE_CHECK, Botan::TLS::Protocol_Version::is_pre_tls_13(), Botan::TLS::Channel_Impl::m_downgrade_info, Botan::TLS::Channel_Impl::request_downgrade(), Botan::TLS::Session_with_Handle::session, and Botan::TLS::Session_Base::version().
Referenced by Botan::TLS::Client_Impl_13::Client_Impl_13().
|
protectedinherited |
Definition at line 58 of file tls_channel_impl_12.cpp.
References BOTAN_ASSERT_NOMSG.
|
inlineprotectedinherited |
Definition at line 184 of file tls_channel_impl_12.h.
|
protectedinherited |
Definition at line 552 of file tls_channel_impl_12.cpp.
References Botan::TLS::Client_Hello_12::renegotiation_info(), Botan::TLS::Client_Hello_12::secure_renegotiation(), and Botan::TLS::Channel_Impl_12::secure_renegotiation_data_for_client_hello().
Referenced by Client_Impl_12().
|
protectedinherited |
Definition at line 572 of file tls_channel_impl_12.cpp.
References Botan::TLS::Server_Hello_12::renegotiation_info(), Botan::TLS::Server_Hello_12::secure_renegotiation(), and Botan::TLS::Channel_Impl_12::secure_renegotiation_data_for_server_hello().
|
protectedinherited |
Definition at line 592 of file tls_channel_impl_12.cpp.
Referenced by Botan::TLS::Channel_Impl_12::secure_renegotiation_check().
|
protectedinherited |
Definition at line 599 of file tls_channel_impl_12.cpp.
Referenced by Botan::TLS::Channel_Impl_12::secure_renegotiation_check().
|
overridevirtualinherited |
Implements Botan::TLS::Channel_Impl.
Definition at line 609 of file tls_channel_impl_12.cpp.
|
overridevirtualinherited |
Send a TLS alert message. If the alert is fatal, the internal state (keys, etc) will be reset.
alert | the Alert to send |
Implements Botan::TLS::Channel_Impl.
Definition at line 524 of file tls_channel_impl_12.cpp.
References Botan::TLS::Alert, Botan::TLS::Channel_Impl_12::is_closed(), Botan::TLS::Alert::is_fatal(), Botan::TLS::Alert::is_valid(), Botan::TLS::Session_Manager::remove(), Botan::TLS::Alert::serialize(), Botan::TLS::Channel_Impl_12::session_manager(), and Botan::TLS::Alert::type().
|
inlineinherited |
Send a fatal alert
Definition at line 75 of file tls_channel_impl.h.
References Botan::TLS::Alert, and Botan::TLS::Channel_Impl::send_alert().
Referenced by Botan::TLS::Channel_Impl_12::from_peer(), and Botan::TLS::Channel_Impl_13::from_peer().
|
inlinevirtualinherited |
Send tickets
new session tickets to the peer. This is only supported on TLS 1.3 servers.
If the server's Session_Manager does not accept the generated Session objects, the server implementation won't be able to send new tickets. Additionally, anything but TLS 1.3 servers will return 0 (because they don't support sending such session tickets).
Reimplemented in Botan::TLS::Server_Impl_13.
Definition at line 157 of file tls_channel_impl.h.
|
inlineinherited |
Send a warning alert
Definition at line 70 of file tls_channel_impl.h.
References Botan::TLS::Alert, and Botan::TLS::Channel_Impl::send_alert().
Referenced by Botan::TLS::Channel_Impl::close().
|
inlineprotectedinherited |
Definition at line 186 of file tls_channel_impl_12.h.
Referenced by Botan::TLS::Channel_Impl_12::send_alert().
|
inlineprotectedinherited |
Definition at line 239 of file tls_channel_impl.h.
References BOTAN_STATE_CHECK, and Botan::TLS::Channel_Impl::m_downgrade_info.
|
overridevirtualinherited |
Perform a handshake timeout check. This does nothing unless this is a DTLS channel with a pending handshake state, in which case we check for timeout and potentially retransmit handshake packets.
Implements Botan::TLS::Channel_Impl.
Definition at line 158 of file tls_channel_impl_12.cpp.
|
overridevirtualinherited |
Inject plaintext intended for counterparty Throws an exception if is_active() is false
Implements Botan::TLS::Channel_Impl.
Definition at line 516 of file tls_channel_impl_12.cpp.
References Botan::TLS::ApplicationData, and Botan::TLS::Channel_Impl_12::is_active().
|
overridevirtualinherited |
Attempt to update the session's traffic key material Note that this is possible with a TLS 1.3 channel, only.
request_peer_update | if true, require a reciprocal key update |
Implements Botan::TLS::Channel_Impl.
Definition at line 183 of file tls_channel_impl_12.cpp.
|
protectedinherited |
Definition at line 224 of file tls_channel_impl.h.
Referenced by Botan::TLS::Channel_Impl_13::expect_downgrade(), Botan::TLS::Channel_Impl::expects_downgrade(), Botan::TLS::Channel_Impl::extract_downgrade_info(), Botan::TLS::Channel_Impl_13::from_peer(), Botan::TLS::Channel_Impl::is_downgrading(), Botan::TLS::Channel_Impl::preserve_client_hello(), Botan::TLS::Channel_Impl::preserve_peer_transcript(), Botan::TLS::Channel_Impl::request_downgrade(), Botan::TLS::Channel_Impl::request_downgrade_for_resumption(), and Botan::TLS::Channel_Impl::set_io_buffer_size().