Botan 3.14.1
Crypto and TLS for C&
Botan::TLS::Client_Impl_13 Class Referencefinal

#include <tls_client_impl_13.h>

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

Public Member Functions

std::string application_protocol () const override
 Client_Impl_13 (Private dont_call_me, 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())
void close ()
std::optional< std::string > external_psk_identity () const override
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_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
virtual std::optional< std::chrono::milliseconds > next_retransmission_timeout () 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) 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

Static Public Member Functions

static std::shared_ptr< Client_Impl_13 > create (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(), const std::vector< std::string > &next_protocols={})

Protected Member Functions

Callbacks & callbacks () const
Credentials_Manager & credentials_manager ()
bool expects_downgrade () const
bool is_downgrading () const
void note_useless_record (const Policy &policy)
const Policy & policy () const
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

SSL/TLS Client 1.3 implementation

Definition at line 27 of file tls_client_impl_13.h.

Constructor & Destructor Documentation

◆ Client_Impl_13()

Botan::TLS::Client_Impl_13::Client_Impl_13 ( Private dont_call_me,
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() )
inline

Definition at line 55 of file tls_client_impl_13.h.

61 :
62 Channel_Impl_13(callbacks, session_manager, creds, rng, policy, false /* is_server */),
63 m_info(std::move(server_info)),
64 m_handshake(std::make_unique<Pending_Handshake>()) {}
const Policy & policy() const
RandomNumberGenerator & rng()
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)
Session_Manager & session_manager()

References Botan::TLS::Channel_Impl_13::callbacks(), Botan::TLS::Channel_Impl_13::Channel_Impl_13(), Botan::TLS::Channel_Impl_13::policy(), Botan::TLS::Channel_Impl_13::rng(), and Botan::TLS::Channel_Impl_13::session_manager().

Member Function Documentation

◆ application_protocol()

std::string Botan::TLS::Client_Impl_13::application_protocol ( ) const
overridevirtual
Returns
network protocol as advertised by the TLS server, if server sent the ALPN extension

Implements Botan::TLS::Channel_Impl.

Definition at line 900 of file tls_client_impl_13.cpp.

900 {
901 if(m_active_state.has_value()) {
902 return m_active_state->application_protocol();
903 }
904
905 return "";
906}
std::optional< Active_Connection_State_13 > m_active_state

References Botan::TLS::Channel_Impl_13::m_active_state.

◆ 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().

◆ create()

std::shared_ptr< Client_Impl_13 > Botan::TLS::Client_Impl_13::create ( 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(),
const std::vector< std::string > & next_protocols = {} )
static

Set up a new TLS client session

Parameters
callbackscontains a set of callback function references required by the TLS client.
session_managermanages session state
credsmanages application/user credentials
policyspecifies other connection policy information
rnga random number generator
server_infois identifying information about the TLS server
next_protocolsspecifies protocols to advertise with ALPN

Definition at line 26 of file tls_client_impl_13.cpp.

32 {
33 auto self = std::make_shared<Client_Impl_13>(
34 Private{}, callbacks, session_manager, creds, policy, rng, std::move(server_info));
35
36#if defined(BOTAN_HAS_TLS_DOWNGRADE_SUPPORT)
37 if(policy->allow_tls12()) {
38 self->expect_downgrade(self->m_info, next_protocols);
39 }
40#endif
41
42 if(auto session = self->find_session_for_resumption()) {
43 if(session->session.version().is_tls_13_or_later()) {
44 self->m_handshake->resumed_session = std::move(session);
45 }
46#if defined(BOTAN_HAS_TLS_DOWNGRADE_SUPPORT)
47 else if(self->expects_downgrade()) {
48 // If we found a session that was created with TLS 1.2, we downgrade
49 // the implementation right away, before even issuing a Client Hello.
50 self->request_downgrade_for_resumption(std::move(session.value()));
51 return self;
52 }
53#endif
54 }
55
56 BOTAN_ASSERT_NOMSG(self->m_transcript_hash.has_value());
57
58 auto flight = Flight(*self->m_transcript_hash, self->callbacks())
59 .add(self->m_handshake->state.sending(
60 Client_Hello_13(*policy,
61 *callbacks,
62 *rng,
63 self->m_info.hostname(),
64 next_protocols,
65 self->m_handshake->resumed_session,
66 creds->find_preshared_keys(self->m_info.hostname(), Connection_Side::Client),
68
69 // RFC 9846 E.4
70 // [...] If offering early data, the [dummy Change Cipher Spec record]
71 // is placed immediately after the first ClientHello.
72 //
73 // TODO(0-RTT): When implementing early data, we need to add the dummy CCS
74 // record to this initial ClientHello flight!
75
76 self->send_flight(flight.commit());
77
78 self->m_handshake->transitions.set_expected_next({Handshake_Type::ServerHello, Handshake_Type::HelloRetryRequest});
79
80 return self;
81}
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:82

References Botan::TLS::Flight::add(), BOTAN_ASSERT_NOMSG, Botan::TLS::Channel_Impl_13::callbacks(), Botan::TLS::Client, Botan::TLS::HelloRetryRequest, Botan::TLS::Channel_Impl_13::policy(), Botan::TLS::Channel_Impl_13::rng(), Botan::TLS::ServerHello, Botan::TLS::Channel_Impl_13::session_manager(), and Botan::TLS::TLS.

Referenced by Botan::TLS::Client::Client().

◆ credentials_manager()

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

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()

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

Implements Botan::TLS::Channel_Impl.

Definition at line 869 of file tls_client_impl_13.cpp.

869 {
870 if(m_active_state.has_value()) {
871 return m_active_state->psk_identity();
872 }
873 if(m_handshake) {
874 return m_handshake->psk_identity;
875 }
876 return std::nullopt;
877}

References Botan::TLS::Channel_Impl_13::m_active_state.

◆ from_peer()

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

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
std::optional< Transcript_Hash_State > m_transcript_hash
std::shared_ptr< Channel_IO > m_channel_io
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().

◆ is_active()

bool Botan::TLS::Channel_Impl_13::is_active ( ) const
overridevirtualinherited
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
inlineoverridevirtualinherited
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
inlineoverridevirtualinherited
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
inlineoverridevirtualinherited
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()

bool Botan::TLS::Client_Impl_13::is_handshake_complete ( ) const
overridevirtual
Returns
true if the TLS handshake finished successfully

Implements Botan::TLS::Channel_Impl.

Definition at line 135 of file tls_client_impl_13.cpp.

135 {
136 return m_active_state.has_value();
137}

References Botan::TLS::Channel_Impl_13::m_active_state.

◆ key_material_export()

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

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.

◆ 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().

◆ peer_cert_chain()

std::vector< X509_Certificate > Botan::TLS::Client_Impl_13::peer_cert_chain ( ) const
overridevirtual
Returns
certificate chain of the peer (may be empty)

Implements Botan::TLS::Channel_Impl.

Definition at line 829 of file tls_client_impl_13.cpp.

829 {
830 if(m_active_state.has_value()) {
831 return m_active_state->peer_certs();
832 }
833
834 // During handshake, before m_active_state is populated
835 if(m_handshake) {
836 if(m_handshake->state.has_server_certificate_msg() &&
837 m_handshake->state.server_certificate().has_certificate_chain()) {
838 return m_handshake->state.server_certificate().cert_chain();
839 }
840
841 if(m_handshake->resumed_session.has_value()) {
842 return m_handshake->resumed_session->session.peer_certs();
843 }
844 }
845
846 return {};
847}

References Botan::TLS::Channel_Impl_13::m_active_state.

◆ peer_raw_public_key()

std::shared_ptr< const Public_Key > Botan::TLS::Client_Impl_13::peer_raw_public_key ( ) const
overridevirtual
Returns
raw public key of the peer (may be nullptr)

Implements Botan::TLS::Channel_Impl.

Definition at line 849 of file tls_client_impl_13.cpp.

849 {
850 if(m_active_state.has_value()) {
851 return m_active_state->peer_raw_public_key();
852 }
853
854 // During handshake, before m_active_state is populated
855 if(m_handshake) {
856 if(m_handshake->state.has_server_certificate_msg() &&
857 m_handshake->state.server_certificate().is_raw_public_key()) {
858 return m_handshake->state.server_certificate().public_key();
859 }
860
861 if(m_handshake->resumed_session.has_value()) {
862 return m_handshake->resumed_session->session.peer_raw_public_key();
863 }
864 }
865
866 return nullptr;
867}

References Botan::TLS::Channel_Impl_13::m_active_state.

◆ policy()

◆ renegotiate()

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

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
protectedinherited

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
inlineoverridevirtualinherited
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)
overridevirtualinherited

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)
protectedinherited

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 )
protectedinherited

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)
protectedinherited

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)
protectedinherited

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}
#define BOTAN_ASSERT_NONNULL(ptr)
Definition assert.h:121

References BOTAN_ASSERT_NONNULL, m_channel_io, and m_cipher_state.

◆ timeout_check()

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

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)
overridevirtualinherited

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)
overridevirtualinherited

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
protectedinherited

◆ m_cipher_state

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

◆ m_side

const Connection_Side Botan::TLS::Channel_Impl_13::m_side
protectedinherited

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
protectedinherited

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: