|
Botan 3.14.1
Crypto and TLS for C&
|
#include <tls_channel_io.h>
Public Types | |
| using | ReceiveEvent |
Public Member Functions | |
| Channel_IO (Channel_IO &&)=delete | |
| Channel_IO (const Channel_IO &)=delete | |
| void | notify_closed_for_reading () |
| void | notify_shutdown () |
| Channel_IO & | operator= (Channel_IO &&)=delete |
| Channel_IO & | operator= (const Channel_IO &)=delete |
| void | set_cipher_state (std::weak_ptr< Cipher_State > cipher_state) |
| void | set_record_size_limits (uint16_t out, uint16_t in) |
| void | set_selected_certificate_type (Certificate_Type cert_type) |
| virtual | ~Channel_IO ()=default |
Ingestion of incoming data | |
| void | copy_data (std::span< const uint8_t > data) |
| ReceiveEvent | next_pending_event (std::optional< Transcript_Hash_State > &transcript_hash, bool handshake_complete) |
Emission of outgoing data | |
| void | send (std::vector< Flight::Message > flight) |
| Sends a flight of handshake messages to the peer. | |
| void | send (std::span< const uint8_t > payload) |
| Sends application data to the peer. | |
| void | send (const Alert &alert, bool handle_compat_mode) |
| Sends an alert to the peer. | |
Traffic key updates (RFC 8446 4.6.3) | |
| void | handle_key_update (const Key_Update &key_update) |
| void | update_traffic_keys (bool request_peer_update) |
Static Public Member Functions | |
| static std::shared_ptr< Channel_IO > | create (Connection_Side side, TLS_Flavor flavor, std::shared_ptr< const Policy > policy, std::shared_ptr< Callbacks > callbacks) |
Protected Member Functions | |
| Callbacks & | callbacks () |
| const Callbacks & | callbacks () const |
| Channel_IO (Connection_Side side, std::shared_ptr< const Policy > policy, std::shared_ptr< Callbacks > callbacks) | |
| std::shared_ptr< Cipher_State > | cipher_state () |
| std::shared_ptr< const Cipher_State > | cipher_state () const |
| virtual const Handshake_Layer & | handshake_layer () const =0 |
| virtual Handshake_Layer & | handshake_layer ()=0 |
| std::optional< ReceiveEvent > | next_pending_handshake_message (std::optional< Transcript_Hash_State > &transcript_hash, bool handshake_complete) |
| const Policy & | policy () const |
| virtual void | process (const Handshake_Record &record)=0 |
| virtual const Record_Layer & | record_layer () const =0 |
| virtual Record_Layer & | record_layer ()=0 |
| virtual void | send_data (Record_Type record_type, std::span< const uint8_t > payload, Cipher_State *cipher_state)=0 |
| void | send_dummy_change_cipher_spec () |
| Sends a dummy ChangeCipherSpec record to the peer. | |
| virtual void | send_flight (std::vector< Flight::Message > flight)=0 |
Channel_IO owns the record layer and handshake layer of a (D)TLS 1.3 channel and handles all wire-format I/O: incoming bytes are ingested via copy_data() and surfaced as a stream of events via next_pending_event(); outgoing handshake flights, application data and alerts are emitted via the send() overloads.
Definition at line 30 of file tls_channel_io.h.
Definition at line 32 of file tls_channel_io.h.
|
inlineprotected |
Definition at line 45 of file tls_channel_io.h.
References callbacks(), and policy().
Referenced by Channel_IO(), Channel_IO(), operator=(), and operator=().
|
delete |
References Channel_IO().
|
delete |
References Channel_IO().
|
virtualdefault |
|
inlineprotected |
Definition at line 151 of file tls_channel_io.h.
|
inlineprotected |
Definition at line 149 of file tls_channel_io.h.
Referenced by Channel_IO(), create(), handle_key_update(), and update_traffic_keys().
|
protected |
Definition at line 335 of file tls_channel_io.cpp.
|
protected |
Definition at line 331 of file tls_channel_io.cpp.
Referenced by handle_key_update(), handshake_layer(), next_pending_event(), send(), send(), send_data(), set_cipher_state(), and update_traffic_keys().
| void Botan::TLS::Channel_IO::copy_data | ( | std::span< const uint8_t > | data | ) |
Ingests incoming data from the network and processes it into a stream of events.
Definition at line 87 of file tls_channel_io.cpp.
References Botan::TLS::Record_Layer::copy_data(), and record_layer().
Referenced by ~Channel_IO().
|
static |
Definition at line 468 of file tls_channel_io.cpp.
References callbacks(), Botan::TLS::DTLS, and policy().
| void Botan::TLS::Channel_IO::handle_key_update | ( | const Key_Update & | key_update | ) |
Processes a KeyUpdate message received from the peer: updates the read keys, and schedules a reciprocal KeyUpdate if the peer requested one.
Definition at line 223 of file tls_channel_io.cpp.
References BOTAN_ASSERT_NONNULL, callbacks(), cipher_state(), Botan::TLS::Key_Update::expects_reciprocation(), policy(), and Botan::TLS::Callbacks::tls_current_monotonic_clock_ms().
Referenced by ~Channel_IO().
|
protectedpure virtual |
References cipher_state().
|
protectedpure virtual |
Referenced by next_pending_event(), next_pending_handshake_message(), and set_selected_certificate_type().
| Channel_IO::ReceiveEvent Botan::TLS::Channel_IO::next_pending_event | ( | std::optional< Transcript_Hash_State > & | transcript_hash, |
| bool | handshake_complete ) |
Retrieves the next pending event from the processed incoming data. If no more events are available, this will return a BytesNeeded event indicating how many more bytes are needed to continue processing.
Definition at line 98 of file tls_channel_io.cpp.
References cipher_state(), handshake_layer(), next_pending_handshake_message(), Botan::TLS::Record_Layer::next_record(), process(), and record_layer().
Referenced by ~Channel_IO().
|
protected |
Definition at line 24 of file tls_channel_io.cpp.
References BOTAN_ASSERT_NOMSG, handshake_layer(), Botan::holds_any_of(), policy(), and record_layer().
Referenced by next_pending_event().
| void Botan::TLS::Channel_IO::notify_closed_for_reading | ( | ) |
Notifies that the channel is closed for reading (close_notify received). The IO can discard any read-side state; no further data will be processed.
Definition at line 314 of file tls_channel_io.cpp.
References Botan::TLS::Record_Layer::clear_read_buffer(), and record_layer().
Referenced by notify_shutdown(), and ~Channel_IO().
| void Botan::TLS::Channel_IO::notify_shutdown | ( | ) |
Notifies that the channel was shut down in both directions. The IO discards any read-side state; no further data will be processed.
Definition at line 319 of file tls_channel_io.cpp.
References notify_closed_for_reading().
Referenced by ~Channel_IO().
|
delete |
References Channel_IO().
|
delete |
References Channel_IO().
|
inlineprotected |
Definition at line 147 of file tls_channel_io.h.
Referenced by Channel_IO(), create(), handle_key_update(), and next_pending_handshake_message().
|
protectedpure virtual |
Referenced by next_pending_event().
|
protectedpure virtual |
|
protectedpure virtual |
| void Botan::TLS::Channel_IO::send | ( | const Alert & | alert, |
| bool | handle_compat_mode ) |
Sends an alert to the peer.
Definition at line 279 of file tls_channel_io.cpp.
References Botan::TLS::Alert, cipher_state(), Botan::TLS::Client, send_data(), send_dummy_change_cipher_spec(), and Botan::TLS::Alert::serialize().
| void Botan::TLS::Channel_IO::send | ( | std::span< const uint8_t > | payload | ) |
Sends application data to the peer.
Definition at line 144 of file tls_channel_io.cpp.
References Botan::TLS::ApplicationData, BOTAN_ASSERT_NONNULL, cipher_state(), send_data(), and update_traffic_keys().
| void Botan::TLS::Channel_IO::send | ( | std::vector< Flight::Message > | flight | ) |
Sends a flight of handshake messages to the peer.
Definition at line 140 of file tls_channel_io.cpp.
References send_flight().
Referenced by ~Channel_IO().
|
protectedpure virtual |
References cipher_state().
Referenced by send(), send(), and send_dummy_change_cipher_spec().
|
protected |
Sends a dummy ChangeCipherSpec record to the peer.
Definition at line 302 of file tls_channel_io.cpp.
References Botan::TLS::ChangeCipherSpec, and send_data().
Referenced by send().
|
protectedpure virtual |
Referenced by send(), and update_traffic_keys().
|
inline |
Definition at line 118 of file tls_channel_io.h.
References cipher_state().
| void Botan::TLS::Channel_IO::set_record_size_limits | ( | uint16_t | out, |
| uint16_t | in ) |
Definition at line 323 of file tls_channel_io.cpp.
References record_layer(), and Botan::TLS::Record_Layer::set_record_size_limits().
| void Botan::TLS::Channel_IO::set_selected_certificate_type | ( | Certificate_Type | cert_type | ) |
Definition at line 327 of file tls_channel_io.cpp.
References handshake_layer(), and Botan::TLS::Handshake_Layer::set_selected_certificate_type().
| void Botan::TLS::Channel_IO::update_traffic_keys | ( | bool | request_peer_update | ) |
Sends a KeyUpdate message to the peer and updates the write keys.
| request_peer_update | whether to request a reciprocal KeyUpdate |
Definition at line 265 of file tls_channel_io.cpp.
References BOTAN_ASSERT_NONNULL, callbacks(), cipher_state(), and send_flight().
Referenced by send(), and ~Channel_IO().