Botan 3.14.1
Crypto and TLS for C&
Botan::TLS::Channel_Impl_13 Class Referenceabstract

#include <tls_channel_impl_13.h>

Inheritance diagram for Botan::TLS::Channel_Impl_13:
Botan::TLS::Channel_Impl Botan::TLS::Client_Impl_13 Botan::TLS::Server_Impl_13

Public Member Functions

virtual std::string application_protocol () const =0
 Channel_Impl_13 (Channel_Impl_13 &&other)=delete
 Channel_Impl_13 (const Channel_Impl_13 &other)=delete
 Channel_Impl_13 (const std::shared_ptr< Callbacks > &callbacks, const std::shared_ptr< Session_Manager > &session_manager, const std::shared_ptr< Credentials_Manager > &credentials_manager, const std::shared_ptr< RandomNumberGenerator > &rng, const std::shared_ptr< const Policy > &policy, bool is_server)
void close ()
virtual std::optional< std::string > external_psk_identity () const =0
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
virtual bool is_handshake_complete () const =0
SymmetricKey key_material_export (std::string_view label, std::string_view context, size_t length) const override
virtual bool new_session_ticket_supported () const
virtual std::optional< std::chrono::milliseconds > next_retransmission_timeout () const
Channel_Impl_13 & operator= (Channel_Impl_13 &&other)=delete
Channel_Impl_13 & operator= (const Channel_Impl_13 &other)=delete
virtual std::vector< X509_Certificate > peer_cert_chain () const =0
virtual std::shared_ptr< const Public_Key > peer_raw_public_key () const =0
void renegotiate (bool) 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
 ~Channel_Impl_13 () override

Protected Member Functions

Callbacks & callbacks () const
virtual bool compat_mode_ccs_requested () const =0
Credentials_Manager & credentials_manager ()
bool expects_downgrade () const
void handle (const Key_Update &key_update)
bool is_downgrading () const
virtual void maybe_log_secret (std::string_view label, std::span< const uint8_t > secret) const =0
void note_useless_record (const Policy &policy)
const Policy & policy () const
virtual void process_dummy_change_cipher_spec ()=0
virtual void process_handshake_msg (Handshake_Message_13 msg)=0
virtual void process_post_handshake_msg (Post_Handshake_Message_13 msg)=0
void reset_useless_records ()
RandomNumberGenerator & rng ()
SecretLoggerFn secret_logger () const
void send_flight (std::vector< Flight::Message > flight)
Session_Manager & session_manager ()
void set_record_size_limits (uint16_t outgoing_limit, uint16_t incoming_limit)
void set_selected_certificate_type (Certificate_Type cert_type)
Cipher_State & setup_cipher_state (std::unique_ptr< Cipher_State > cipher_state)

Protected Attributes

std::optional< Active_Connection_State_13 > m_active_state
std::shared_ptr< Channel_IO > m_channel_io
std::shared_ptr< Cipher_State > m_cipher_state
const Connection_Side m_side
std::optional< Transcript_Hash_State > m_transcript_hash

Detailed Description

Generic interface for TLS 1.3 endpoint

Definition at line 28 of file tls_channel_impl_13.h.

Constructor & Destructor Documentation

◆ Channel_Impl_13() [1/3]

Botan::TLS::Channel_Impl_13::Channel_Impl_13 ( const std::shared_ptr< Callbacks > & callbacks,
const std::shared_ptr< Session_Manager > & session_manager,
const std::shared_ptr< Credentials_Manager > & credentials_manager,
const std::shared_ptr< RandomNumberGenerator > & rng,
const std::shared_ptr< const Policy > & policy,
bool is_server )
explicit

Set up a new TLS 1.3 session

Parameters
callbackscontains a set of callback function references required by the TLS endpoint.
session_managermanages session state
credentials_managermanages application/user credentials
rnga random number generator
policyspecifies other connection policy information
is_serverwhether this is a server session or not

Definition at line 43 of file tls_channel_impl_13.cpp.

48 :
52 m_callbacks(callbacks),
53 m_session_manager(session_manager),
54 m_credentials_manager(credentials_manager),
55 m_rng(rng),
56 m_policy(policy),
57 m_can_read(true),
58 m_can_write(true) {
59 BOTAN_ASSERT_NONNULL(m_callbacks);
60 BOTAN_ASSERT_NONNULL(m_session_manager);
61 BOTAN_ASSERT_NONNULL(m_credentials_manager);
63 BOTAN_ASSERT_NONNULL(m_policy);
64}
#define BOTAN_ASSERT_NONNULL(ptr)
Definition assert.h:121
static std::shared_ptr< Channel_IO > create(Connection_Side side, TLS_Flavor flavor, std::shared_ptr< const Policy > policy, std::shared_ptr< Callbacks > callbacks)
const Policy & policy() const
Credentials_Manager & credentials_manager()
RandomNumberGenerator & rng()
std::optional< Transcript_Hash_State > m_transcript_hash
std::shared_ptr< Channel_IO > m_channel_io
Session_Manager & session_manager()

References BOTAN_ASSERT_NONNULL, callbacks(), credentials_manager(), m_channel_io, m_side, m_transcript_hash, policy(), rng(), and session_manager().

Referenced by Channel_Impl_13(), Channel_Impl_13(), Botan::TLS::Client_Impl_13::Client_Impl_13(), operator=(), operator=(), and Botan::TLS::Server_Impl_13::Server_Impl_13().

◆ Channel_Impl_13() [2/3]

Botan::TLS::Channel_Impl_13::Channel_Impl_13 ( const Channel_Impl_13 & other)
delete

References Channel_Impl_13().

◆ Channel_Impl_13() [3/3]

Botan::TLS::Channel_Impl_13::Channel_Impl_13 ( Channel_Impl_13 && other)
delete

References Channel_Impl_13().

◆ ~Channel_Impl_13()

Botan::TLS::Channel_Impl_13::~Channel_Impl_13 ( )
overridedefault

Member Function Documentation

◆ application_protocol()

virtual std::string Botan::TLS::Channel_Impl::application_protocol ( ) const
pure virtualinherited

Return the protocol notification set for this connection, if any (ALPN). This value is not tied to the session and a later renegotiation of the same session can choose a new protocol.

Implemented in Botan::TLS::Client_Impl_12, Botan::TLS::Client_Impl_13, and Botan::TLS::Server_Impl_13.

◆ callbacks()

◆ close()

void Botan::TLS::Channel_Impl::close ( )
inlineinherited

Send a close notification alert

Definition at line 90 of file tls_channel_impl.h.

90{ send_warning_alert(Alert::CloseNotify); }
void send_warning_alert(Alert::Type type)

References send_warning_alert().

◆ compat_mode_ccs_requested()

virtual bool Botan::TLS::Channel_Impl_13::compat_mode_ccs_requested ( ) const
protectedpure virtual

Referenced by send_alert().

◆ credentials_manager()

Credentials_Manager & Botan::TLS::Channel_Impl_13::credentials_manager ( )
inlineprotected

Definition at line 150 of file tls_channel_impl_13.h.

150{ return *m_credentials_manager; }

Referenced by Channel_Impl_13(), Botan::TLS::Server_Impl_13::create(), and Botan::TLS::Server_Impl_13::Server_Impl_13().

◆ expects_downgrade()

bool Botan::TLS::Channel_Impl::expects_downgrade ( ) const
inlineprotectedinherited

Definition at line 314 of file tls_channel_impl.h.

314 {
315#if defined(BOTAN_HAS_TLS_DOWNGRADE_SUPPORT)
316 return m_downgrade_info != nullptr;
317#else
318 return false;
319#endif
320 }

Referenced by Botan::TLS::Channel_Impl_13::from_peer().

◆ external_psk_identity()

virtual std::optional< std::string > Botan::TLS::Channel_Impl::external_psk_identity ( ) const
pure virtualinherited
Returns
identity of the PSK used for this connection or std::nullopt if no PSK was used.

Implemented in Botan::TLS::Channel_Impl_12, Botan::TLS::Client_Impl_13, and Botan::TLS::Server_Impl_13.

◆ from_peer()

size_t Botan::TLS::Channel_Impl_13::from_peer ( std::span< const uint8_t > data)
overridevirtual

Inject TLS traffic received from counterparty

Returns
a hint as the how many more bytes we need to q the current record (this may be 0 if on a record boundary)

Implements Botan::TLS::Channel_Impl.

Definition at line 75 of file tls_channel_impl_13.cpp.

75 {
77
78 // RFC 8446 6.1
79 // Any data received after a closure alert has been received MUST be ignored.
80 if(!m_can_read) {
81 return 0;
82 }
83
84 try {
85#if defined(BOTAN_HAS_TLS_DOWNGRADE_SUPPORT)
86 if(expects_downgrade()) {
87 preserve_peer_transcript(data);
88 }
89#endif
90
91 // First, ingest all incoming data...
92 m_channel_io->copy_data(data);
93
94 // ... then, process all pending events (i.e. decoded handshake messages,
95 // alerts, application data, etc.) until we either run out of events and
96 // have to wait for more data, or we encounter an exception and terminate.
97 while(true) {
98 // RFC 8446 6.1
99 // Any data received after a closure alert has been received MUST be ignored.
100 //
101 // ... this data might already be in the record layer's read buffer.
102 if(!m_can_read) {
103 return 0;
104 }
105
106 const auto bytes_needed = std::visit( //
108 [](BytesNeeded bytes) -> std::optional<BytesNeeded> { return bytes; },
109 // NOLINTNEXTLINE(*-missing-std-forward) false positive on templated lambdas in clang-tidy 23
110 [&]<typename T>(T&& event) -> std::optional<BytesNeeded> {
111 constexpr bool can_report_bytes_needed =
112 std::is_same_v<std::optional<BytesNeeded>, decltype(process(std::forward<T>(event)))>;
113 if constexpr(can_report_bytes_needed) {
114 return process(std::forward<T>(event));
115 } else {
116 process(std::forward<T>(event));
117 return {};
118 }
119 },
120 },
122
123 if(bytes_needed.has_value()) {
124 return *bytes_needed;
125 }
126 }
127
128 } catch(TLS_Exception& e) {
129 send_fatal_alert(e.type());
130 throw;
131 } catch(Invalid_Authentication_Tag&) {
132 // RFC 8446 5.2
133 // If the decryption fails, the receiver MUST terminate the connection
134 // with a "bad_record_mac" alert.
135 send_fatal_alert(Alert::BadRecordMac);
136 throw;
137 } catch(Decoding_Error&) {
138 send_fatal_alert(Alert::DecodeError);
139 throw;
140 } catch(...) {
141 send_fatal_alert(Alert::InternalError);
142 throw;
143 }
144}
#define BOTAN_STATE_CHECK(expr)
Definition assert.h:49
void send_fatal_alert(Alert::Type type)
virtual bool is_handshake_complete() const =0
size_t BytesNeeded
overloaded(Ts...) -> overloaded< Ts... >

References BOTAN_STATE_CHECK, Botan::TLS::Channel_Impl::expects_downgrade(), Botan::TLS::Channel_Impl::is_downgrading(), Botan::TLS::Channel_Impl::is_handshake_complete(), m_channel_io, m_transcript_hash, Botan::TLS::Channel_Impl::send_fatal_alert(), and Botan::TLS::TLS_Exception::type().

◆ handle()

void Botan::TLS::Channel_Impl_13::handle ( const Key_Update & key_update)
protected

Definition at line 146 of file tls_channel_impl_13.cpp.

146 {
147 m_channel_io->handle_key_update(key_update);
148}

References m_channel_io.

◆ is_active()

bool Botan::TLS::Channel_Impl_13::is_active ( ) const
overridevirtual
Returns
true iff the connection is active for sending application data

Note that the connection is active until the application has called close(), even if a CloseNotify has been received from the peer.

Implements Botan::TLS::Channel_Impl.

Definition at line 197 of file tls_channel_impl_13.cpp.

197 {
198 return m_cipher_state != nullptr && m_cipher_state->can_encrypt_application_traffic() // handshake done
199 && m_can_write; // close() hasn't been called
200}
std::shared_ptr< Cipher_State > m_cipher_state

References m_cipher_state.

Referenced by to_peer(), and update_traffic_keys().

◆ is_closed()

bool Botan::TLS::Channel_Impl_13::is_closed ( ) const
inlineoverridevirtual
Returns
true iff the connection has been closed, i.e. CloseNotify has been received from the peer.

Implements Botan::TLS::Channel_Impl.

Definition at line 77 of file tls_channel_impl_13.h.

bool is_closed_for_reading() const override
bool is_closed_for_writing() const override

References is_closed_for_reading(), and is_closed_for_writing().

Referenced by Botan::TLS::Server_Impl_13::is_handshake_complete().

◆ is_closed_for_reading()

bool Botan::TLS::Channel_Impl_13::is_closed_for_reading ( ) const
inlineoverridevirtual
Returns
true iff the connection is active for sending application data

Implements Botan::TLS::Channel_Impl.

Definition at line 79 of file tls_channel_impl_13.h.

79{ return !m_can_read; }

Referenced by is_closed().

◆ is_closed_for_writing()

bool Botan::TLS::Channel_Impl_13::is_closed_for_writing ( ) const
inlineoverridevirtual
Returns
true iff the connection has been definitely closed

Implements Botan::TLS::Channel_Impl.

Definition at line 81 of file tls_channel_impl_13.h.

81{ return !m_can_write; }

Referenced by is_closed().

◆ is_downgrading()

bool Botan::TLS::Channel_Impl::is_downgrading ( ) const
inlineprotectedinherited

Indicates whether a downgrade to TLS 1.2 or lower is in progress

See also
Downgrade_Information

Definition at line 306 of file tls_channel_impl.h.

306 {
307#if defined(BOTAN_HAS_TLS_DOWNGRADE_SUPPORT)
308 return m_downgrade_info && m_downgrade_info->will_downgrade;
309#else
310 return false;
311#endif
312 }

Referenced by Botan::TLS::Channel_Impl_13::from_peer(), Botan::TLS::Channel_Impl_13::key_material_export(), Botan::TLS::Channel_Impl_13::send_flight(), Botan::TLS::Channel_Impl_13::to_peer(), and Botan::TLS::Channel_Impl_13::update_traffic_keys().

◆ is_handshake_complete()

virtual bool Botan::TLS::Channel_Impl::is_handshake_complete ( ) const
pure virtualinherited

◆ key_material_export()

SymmetricKey Botan::TLS::Channel_Impl_13::key_material_export ( std::string_view label,
std::string_view context,
size_t length ) const
overridevirtual

Key material export (RFC 5705)

Parameters
labela disambiguating label string
contexta per-association context value
lengththe length of the desired key in bytes
Returns
key of length bytes

Implements Botan::TLS::Channel_Impl.

Definition at line 202 of file tls_channel_impl_13.cpp.

204 {
206 BOTAN_STATE_CHECK(m_cipher_state != nullptr && m_cipher_state->can_export_keys());
207 return SymmetricKey(m_cipher_state->export_key(label, context, length));
208}
OctetString SymmetricKey
Definition symkey.h:153

References BOTAN_STATE_CHECK, Botan::TLS::Channel_Impl::is_downgrading(), and m_cipher_state.

◆ maybe_log_secret()

virtual void Botan::TLS::Channel_Impl_13::maybe_log_secret ( std::string_view label,
std::span< const uint8_t > secret ) const
protectedpure virtual

◆ new_session_ticket_supported()

virtual bool Botan::TLS::Channel_Impl::new_session_ticket_supported ( ) const
inlinevirtualinherited
Returns
true if this channel can issue TLS 1.3 style session tickets.

Reimplemented in Botan::TLS::Server_Impl_13.

Definition at line 156 of file tls_channel_impl.h.

156{ return false; }

◆ next_retransmission_timeout()

virtual std::optional< std::chrono::milliseconds > Botan::TLS::Channel_Impl::next_retransmission_timeout ( ) const
inlinevirtualinherited

Reimplemented in Botan::TLS::Channel_Impl_12.

Definition at line 102 of file tls_channel_impl.h.

102{ return std::nullopt; }

◆ note_useless_record()

void Botan::TLS::Channel_Impl::note_useless_record ( const Policy & policy)
protectedinherited

Called for each received record that was dropped without having any effect, eg an empty record or a warning alert. Throws if too many of these arrive without any useful record between.

Definition at line 14 of file tls_channel_impl.cpp.

14 {
15 m_useless_records++;
16
17 if(const auto limit = policy.max_useless_records()) {
18 if(m_useless_records > *limit) {
19 throw TLS_Exception(Alert::UnexpectedMessage, "Peer sent too many consecutive useless records");
20 }
21 }
22}

References Botan::TLS::Policy::max_useless_records().

Referenced by Botan::TLS::Channel_Impl_12::from_peer().

◆ operator=() [1/2]

Channel_Impl_13 & Botan::TLS::Channel_Impl_13::operator= ( Channel_Impl_13 && other)
delete

References Channel_Impl_13().

◆ operator=() [2/2]

Channel_Impl_13 & Botan::TLS::Channel_Impl_13::operator= ( const Channel_Impl_13 & other)
delete

References Channel_Impl_13().

◆ peer_cert_chain()

virtual std::vector< X509_Certificate > Botan::TLS::Channel_Impl::peer_cert_chain ( ) const
pure virtualinherited
Returns
certificate chain of the peer (may be empty)

Implemented in Botan::TLS::Channel_Impl_12, Botan::TLS::Client_Impl_13, and Botan::TLS::Server_Impl_13.

◆ peer_raw_public_key()

virtual std::shared_ptr< const Public_Key > Botan::TLS::Channel_Impl::peer_raw_public_key ( ) const
pure virtualinherited
Returns
raw public key of the peer (may be nullptr)

Implemented in Botan::TLS::Channel_Impl_12, Botan::TLS::Client_Impl_13, and Botan::TLS::Server_Impl_13.

◆ policy()

◆ process_dummy_change_cipher_spec()

virtual void Botan::TLS::Channel_Impl_13::process_dummy_change_cipher_spec ( )
protectedpure virtual

◆ process_handshake_msg()

virtual void Botan::TLS::Channel_Impl_13::process_handshake_msg ( Handshake_Message_13 msg)
protectedpure virtual

◆ process_post_handshake_msg()

virtual void Botan::TLS::Channel_Impl_13::process_post_handshake_msg ( Post_Handshake_Message_13 msg)
protectedpure virtual

◆ renegotiate()

void Botan::TLS::Channel_Impl_13::renegotiate ( bool )
inlineoverridevirtual

Attempt to renegotiate the session

Implements Botan::TLS::Channel_Impl.

Definition at line 95 of file tls_channel_impl_13.h.

95 {
96 throw Invalid_Argument("renegotiation is not allowed in TLS 1.3");
97 }

◆ reset_useless_records()

void Botan::TLS::Channel_Impl::reset_useless_records ( )
inlineprotectedinherited

Called for each received record that made progress

Definition at line 211 of file tls_channel_impl.h.

211{ m_useless_records = 0; }

Referenced by Botan::TLS::Channel_Impl_12::from_peer().

◆ rng()

◆ secret_logger()

SecretLoggerFn Botan::TLS::Channel_Impl_13::secret_logger ( ) const
protected

Definition at line 215 of file tls_channel_impl_13.cpp.

215 {
216 return [weak = weak_from_this()](std::string_view label, std::span<const uint8_t> secret) {
217 if(const auto self = dynamic_pointer_cast<const Channel_Impl_13>(weak.lock())) {
218 self->maybe_log_secret(label, secret);
219 };
220 };
221}

◆ secure_renegotiation_supported()

bool Botan::TLS::Channel_Impl_13::secure_renegotiation_supported ( ) const
inlineoverridevirtual
Returns
true iff the counterparty supports the secure renegotiation extensions.

Implements Botan::TLS::Channel_Impl.

Definition at line 111 of file tls_channel_impl_13.h.

111 {
112 // Secure renegotiation is not supported in TLS 1.3, though BoGo
113 // tests expect us to claim that it is available.
114 return true;
115 }

◆ send_alert()

void Botan::TLS::Channel_Impl_13::send_alert ( const Alert & alert)
overridevirtual

Send a TLS alert message. If the alert is fatal, the internal state (keys, etc) will be reset.

Parameters
alertthe Alert to send

Implements Botan::TLS::Channel_Impl.

Definition at line 160 of file tls_channel_impl_13.cpp.

160 {
161 // An alert that cannot be encoded is never sent; a fatal one is a local teardown
162 if(!alert.is_valid()) {
163 if(alert.is_fatal()) {
164 shutdown();
165 }
166 return;
167 }
168
169 if(m_can_write) {
170 // RFC 8446 6.
171 // All the alerts listed in Section 6.2 MUST be sent with
172 // AlertLevel=fatal [...]
173 const Alert to_send = is_error_alert(alert) ? Alert(alert.type(), true) : alert;
174 try {
175 m_channel_io->send(to_send, compat_mode_ccs_requested());
176 } catch(...) { /* swallow it */
177 }
178 }
179
180 // Note: In TLS 1.3 sending a CloseNotify must not immediately lead to closing the reading end.
181 // RFC 8446 6.1
182 // Each party MUST send a "close_notify" alert before closing its write
183 // side of the connection, unless it has already sent some error alert.
184 // This does not have any effect on its read side of the connection.
185 if(is_close_notify_alert(alert) && m_can_write) {
186 m_can_write = false;
187 if(m_cipher_state) {
188 m_cipher_state->clear_write_keys();
189 }
190 }
191
192 if(is_error_alert(alert)) {
193 shutdown();
194 }
195}
virtual bool compat_mode_ccs_requested() const =0

References Botan::TLS::Alert, compat_mode_ccs_requested(), Botan::TLS::Alert::is_fatal(), Botan::TLS::Alert::is_valid(), m_channel_io, m_cipher_state, and Botan::TLS::Alert::type().

◆ send_fatal_alert()

void Botan::TLS::Channel_Impl::send_fatal_alert ( Alert::Type type)
inlineinherited

Send a fatal alert

Definition at line 85 of file tls_channel_impl.h.

85{ send_alert(Alert(type, true)); }
virtual void send_alert(const Alert &alert)=0

References Botan::TLS::Alert, and send_alert().

Referenced by Botan::TLS::Channel_Impl_12::from_peer(), and Botan::TLS::Channel_Impl_13::from_peer().

◆ send_flight()

void Botan::TLS::Channel_Impl_13::send_flight ( std::vector< Flight::Message > flight)
protected

Definition at line 223 of file tls_channel_impl_13.cpp.

223 {
224 BOTAN_STATE_CHECK(!flight.empty());
226 BOTAN_STATE_CHECK(m_can_write);
227
228 m_channel_io->send(std::move(flight));
229}

References BOTAN_STATE_CHECK, Botan::TLS::Channel_Impl::is_downgrading(), and m_channel_io.

Referenced by Botan::TLS::Server_Impl_13::send_new_session_tickets().

◆ send_new_session_tickets()

virtual size_t Botan::TLS::Channel_Impl::send_new_session_tickets ( const size_t )
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).

Returns
the number of session tickets successfully sent to the client

Reimplemented in Botan::TLS::Server_Impl_13.

Definition at line 169 of file tls_channel_impl.h.

169{ return 0; }

◆ send_warning_alert()

void Botan::TLS::Channel_Impl::send_warning_alert ( Alert::Type type)
inlineinherited

Send a warning alert

Definition at line 80 of file tls_channel_impl.h.

80{ send_alert(Alert(type, false)); }

References Botan::TLS::Alert, and send_alert().

Referenced by close().

◆ session_manager()

◆ set_record_size_limits()

void Botan::TLS::Channel_Impl_13::set_record_size_limits ( uint16_t outgoing_limit,
uint16_t incoming_limit )
protected

Set the record size limits as negotiated by the "record_size_limit" extension (RFC 8449).

Parameters
outgoing_limitthe maximal number of plaintext bytes to be sent in a protected record
incoming_limitthe maximal number of plaintext bytes to be accepted in a received protected record

Definition at line 379 of file tls_channel_impl_13.cpp.

379 {
380 m_channel_io->set_record_size_limits(outgoing_limit, incoming_limit);
381}

References m_channel_io.

◆ set_selected_certificate_type()

void Botan::TLS::Channel_Impl_13::set_selected_certificate_type ( Certificate_Type cert_type)
protected

Set the expected certificate type needed to parse Certificate messages in the handshake layer. See RFC 7250 and 8446 4.4.2 for further details.

Definition at line 383 of file tls_channel_impl_13.cpp.

383 {
384 m_channel_io->set_selected_certificate_type(cert_type);
385}

References m_channel_io.

◆ setup_cipher_state()

Cipher_State & Botan::TLS::Channel_Impl_13::setup_cipher_state ( std::unique_ptr< Cipher_State > cipher_state)
protected

Hands ownership of the channel's cipher state to this channel and its associated Channel_IO. Typically called once the handshake's key schedule produced the first traffic secrets.

Returns
a reference to the handed-off cipher state for convenience

Definition at line 66 of file tls_channel_impl_13.cpp.

66 {
67 BOTAN_ASSERT_NONNULL(cipher_state);
68 m_cipher_state = std::move(cipher_state);
69 m_channel_io->set_cipher_state(m_cipher_state);
70 return *m_cipher_state;
71}

References BOTAN_ASSERT_NONNULL, m_channel_io, and m_cipher_state.

◆ timeout_check()

bool Botan::TLS::Channel_Impl_13::timeout_check ( )
inlineoverridevirtual

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.

In the TLS 1.3 implementation, this always returns false.

Implements Botan::TLS::Channel_Impl.

Definition at line 125 of file tls_channel_impl_13.h.

125{ return false; }

◆ to_peer()

void Botan::TLS::Channel_Impl_13::to_peer ( std::span< const uint8_t > data)
overridevirtual

Inject plaintext intended for counterparty Throws an exception if is_active() is false

Implements Botan::TLS::Channel_Impl.

Definition at line 150 of file tls_channel_impl_13.cpp.

150 {
152
153 if(!is_active()) {
154 throw Invalid_State("Data cannot be sent on inactive TLS connection");
155 }
156
157 m_channel_io->send(data);
158}

References BOTAN_STATE_CHECK, is_active(), Botan::TLS::Channel_Impl::is_downgrading(), and m_channel_io.

◆ update_traffic_keys()

void Botan::TLS::Channel_Impl_13::update_traffic_keys ( bool request_peer_update = false)
overridevirtual

Attempt to update the session's traffic key material Note that this is possible with a TLS 1.3 channel, only.

Parameters
request_peer_updateif true, require a reciprocal key update

Implements Botan::TLS::Channel_Impl.

Definition at line 210 of file tls_channel_impl_13.cpp.

210 {
212 m_channel_io->update_traffic_keys(request_peer_update);
213}

References BOTAN_STATE_CHECK, is_active(), Botan::TLS::Channel_Impl::is_downgrading(), Botan::TLS::Channel_Impl::is_handshake_complete(), and m_channel_io.

Member Data Documentation

◆ m_active_state

◆ m_channel_io

std::shared_ptr<Channel_IO> Botan::TLS::Channel_Impl_13::m_channel_io
protected

◆ m_cipher_state

std::shared_ptr<Cipher_State> Botan::TLS::Channel_Impl_13::m_cipher_state
protected

◆ m_side

const Connection_Side Botan::TLS::Channel_Impl_13::m_side
protected

Definition at line 174 of file tls_channel_impl_13.h.

Referenced by Channel_Impl_13().

◆ m_transcript_hash

std::optional<Transcript_Hash_State> Botan::TLS::Channel_Impl_13::m_transcript_hash
protected

Definition at line 175 of file tls_channel_impl_13.h.

Referenced by Channel_Impl_13(), and from_peer().


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