9#include <botan/internal/tls_channel_impl_12.h>
12#include <botan/tls_callbacks.h>
13#include <botan/tls_messages_12.h>
14#include <botan/tls_policy.h>
15#include <botan/x509cert.h>
16#include <botan/internal/concat_util.h>
17#include <botan/internal/ct_utils.h>
18#include <botan/internal/loadstor.h>
19#include <botan/internal/mem_utils.h>
20#include <botan/internal/stl_util.h>
21#include <botan/internal/tls_handshake_state.h>
22#include <botan/internal/tls_record.h>
23#include <botan/internal/tls_seq_numbers.h>
30bool is_new_dtls_association_client_hello(std::span<const uint8_t> msg_and_header,
Record_Type record_type) {
31 constexpr size_t DTLS_HANDSHAKE_HEADER_SIZE = 12;
38 load_be(msg_and_header.subspan<4, 2>()) == 0;
48constexpr size_t TLS_RETAINED_CIPHERSTATES = 2;
52constexpr uint64_t TCP_MSL_MS = 2 * 60 * 1000;
55void prune_old_cipher_states(std::map<uint16_t, T>& states) {
59 size_t non_zero = states.size() - states.count(0);
60 auto it = states.lower_bound(1);
61 while(non_zero > TLS_RETAINED_CIPHERSTATES) {
62 it = states.erase(it);
74bool absorb_malformed_input_errors(
bool absorb, F fn) {
82 }
catch(
const Decoding_Error&) {
94 const std::shared_ptr<RandomNumberGenerator>&
rng,
95 const std::shared_ptr<const Policy>&
policy,
98 size_t reserved_io_buffer_size) :
99 m_is_server(is_server),
105 m_has_been_closed(false) {
112 m_write_cipher_states[0] =
nullptr;
113 m_read_cipher_states[0] = {};
115 m_writebuf.reserve(reserved_io_buffer_size);
116 m_readbuf.reserve(reserved_io_buffer_size);
119void Channel_Impl_12::reset_state() {
120 m_active_state.reset();
121 m_pending_state.reset();
122 m_epochs_before_latest_renegotiation.reset();
123 m_dtls_pending_is_epoch0_restart =
false;
124 m_resumption_handle.reset();
126 m_write_cipher_states.clear();
127 m_read_cipher_states.clear();
131 m_resumption_handle = std::move(handle);
134std::vector<Session_Handle> Channel_Impl_12::take_sessions_to_invalidate() {
137 std::vector<Session_Handle> handles;
139 if(m_resumption_handle.has_value()) {
140 handles.push_back(m_resumption_handle.value());
141 m_resumption_handle.reset();
144 if(m_active_state.has_value()) {
145 const auto& sid = m_active_state->session_id();
147 handles.emplace_back(sid);
154void Channel_Impl_12::invalidate_sessions(
const std::vector<Session_Handle>& handles) {
165 for(
const auto& handle : handles) {
175 m_active_state.reset();
178 m_dtls_pending_is_epoch0_restart =
false;
179 m_read_cipher_states.clear();
180 m_write_cipher_states.clear();
182 m_write_cipher_states[0] =
nullptr;
183 m_read_cipher_states[0] = {};
185 if(m_sequence_numbers) {
186 m_sequence_numbers->reset();
193 BOTAN_ASSERT(m_sequence_numbers,
"Have a sequence numbers object");
194 return *m_sequence_numbers;
197std::shared_ptr<Connection_Cipher_State> Channel_Impl_12::read_cipher_state_epoch(uint16_t epoch)
const {
198 const auto i = m_read_cipher_states.find(epoch);
199 if(i == m_read_cipher_states.end()) {
200 throw Internal_Error(
"TLS::Channel_Impl_12 No read cipherstate for epoch " + std::to_string(epoch));
208 if(
const auto& retired_at = i->second.retired_at; retired_at.has_value()) {
210 const auto retired = retired_at.value();
212 if(now - retired > TCP_MSL_MS) {
213 throw Invalid_State(
"TLS::Channel_Impl_12 Read cipherstate for epoch " + std::to_string(epoch) +
214 " is past its retention window");
218 return i->second.state;
221std::shared_ptr<Connection_Cipher_State> Channel_Impl_12::write_cipher_state_epoch(uint16_t epoch)
const {
222 const auto i = m_write_cipher_states.find(epoch);
223 if(i == m_write_cipher_states.end()) {
224 throw Internal_Error(
"TLS::Channel_Impl_12 No write cipherstate for epoch " + std::to_string(epoch));
230 if(m_active_state.has_value()) {
231 return m_active_state->peer_certs();
233 return std::vector<X509_Certificate>();
237 if(m_active_state.has_value()) {
238 return m_active_state->psk_identity();
240 if(
const auto* state = pending_state()) {
241 return state->psk_identity();
248 std::optional<uint64_t> read_sequence_number,
249 std::optional<uint64_t> write_sequence_number) {
250 if(pending_state() !=
nullptr) {
251 throw Internal_Error(
"create_handshake_state called during handshake");
254 if(m_active_state.has_value()) {
259 "Active state using version " + active_version.
to_string() +
" cannot change to " +
264 if(!m_sequence_numbers) {
266 m_sequence_numbers = std::make_unique<Datagram_Sequence_Numbers>(read_sequence_number.value_or(0),
267 write_sequence_number.value_or(0));
269 BOTAN_ARG_CHECK(!read_sequence_number.has_value() && !write_sequence_number.has_value(),
270 "TLS does not support externally provided sequence numbers");
271 m_sequence_numbers = std::make_unique<Stream_Sequence_Numbers>();
279 m_epochs_before_latest_renegotiation = Epochs_Before_Latest_Renegotiation{sequence_numbers().current_read_epoch(),
280 sequence_numbers().current_write_epoch()};
290 const uint16_t initial_epoch = epoch0_restart ? 0 : m_epochs_before_latest_renegotiation->read_epoch;
292 using namespace std::placeholders;
294 std::unique_ptr<Handshake_IO> io;
297 if(policy_mtu > 0xFFFF) {
300 const uint16_t mtu =
static_cast<uint16_t
>(policy_mtu);
305 if(initial_timeout_ms == 0 || max_timeout_ms < initial_timeout_ms) {
306 throw Invalid_Argument(
"Policy specifies invalid DTLS retransmission timeouts");
310 const auto send_record_f = [
this](uint16_t epoch,
Record_Type record_type,
const std::vector<uint8_t>& record) {
311 send_record_under_epoch(epoch, record_type, record);
314 io = std::make_unique<Datagram_Handshake_IO>(send_record_f,
321 policy().maximum_handshake_message_size(),
325 const auto send_record_f = [
this](
Record_Type rec_type,
const std::vector<uint8_t>& record) {
326 send_record(rec_type, record);
328 io = std::make_unique<Stream_Handshake_IO>(send_record_f);
333 if(m_active_state.has_value()) {
334 m_pending_state->set_version(m_active_state->version());
337 return *m_pending_state;
340bool Channel_Impl_12::pending_handshake_epochs_unmoved()
const {
343 if(!m_pending_state || !m_epochs_before_latest_renegotiation.has_value()) {
349 return sequence_numbers().
current_read_epoch() == m_epochs_before_latest_renegotiation->read_epoch &&
350 sequence_numbers().
current_write_epoch() == m_epochs_before_latest_renegotiation->write_epoch;
353void Channel_Impl_12::clear_pending_handshake_state() {
354 m_pending_state.reset();
355 m_epochs_before_latest_renegotiation.reset();
356 m_dtls_pending_is_epoch0_restart =
false;
365void Channel_Impl_12::abandon_timed_out_handshake() {
366 if(m_active_state.has_value() && pending_handshake_epochs_unmoved()) {
370 clear_pending_handshake_state();
376 m_has_been_closed =
true;
384 return m_pending_state->handshake_io().timeout_check();
386 abandon_timed_out_handshake();
401 if(!next_timeout.has_value()) {
410 ++m_retransmission_timer_generation;
414 const auto on_timer = [self = weak_from_this(), generation = m_retransmission_timer_generation]()
mutable {
418 const auto channel = std::dynamic_pointer_cast<Channel_Impl_12>(self.lock());
431 if(generation != channel->m_retransmission_timer_generation) {
437 if(channel->timeout_check()) {
449 m_callbacks->tls_register_deferred_operation(next_timeout->count(), on_timer);
453 if(pending_state() !=
nullptr) {
457 if(m_active_state.has_value()) {
461 if(sequence_numbers().current_read_epoch() == 0xFFFF || sequence_numbers().current_write_epoch() == 0xFFFF) {
462 throw Invalid_State(
"TLS epoch counter exhausted, a new connection is required");
466 throw Invalid_State(
"Peer does not support secure renegotiation and policy prohibits insecure renegotiation");
469 if(!force_full_renegotiation) {
475 throw Invalid_State(
"Cannot renegotiate on inactive connection");
484 const auto* pending = pending_state();
486 BOTAN_ASSERT(pending && pending->has_server_hello(),
"Have received server hello");
488 if(pending->server_hello().compression_method() != 0) {
492 sequence_numbers().new_read_cipher_state();
494 const uint16_t epoch = sequence_numbers().current_read_epoch();
496 BOTAN_ASSERT(!m_read_cipher_states.contains(epoch),
"No read cipher state currently set for next epoch");
499 const auto read_state = std::make_shared<Connection_Cipher_State>(
503 pending->ciphersuite(),
504 pending->session_keys(),
505 pending->server_hello().supports_encrypt_then_mac());
511 if(
const auto prev = m_read_cipher_states.find(
static_cast<uint16_t
>(epoch - 1));
512 prev != m_read_cipher_states.end()) {
517 m_read_cipher_states[epoch] = Retained_Read_Cipher_State{.state = read_state, .retired_at = std::nullopt};
518 prune_old_cipher_states(m_read_cipher_states);
522 const auto* pending = pending_state();
524 BOTAN_ASSERT(pending && pending->has_server_hello(),
"Have received server hello");
526 if(pending->server_hello().compression_method() != 0) {
530 sequence_numbers().new_write_cipher_state();
532 const uint16_t epoch = sequence_numbers().current_write_epoch();
534 BOTAN_ASSERT(!m_write_cipher_states.contains(epoch),
"No write cipher state currently set for next epoch");
536 const auto write_state =
537 std::make_shared<Connection_Cipher_State>(pending->version(),
540 pending->ciphersuite(),
541 pending->session_keys(),
542 pending->server_hello().supports_encrypt_then_mac());
544 m_write_cipher_states[epoch] = write_state;
545 prune_old_cipher_states(m_write_cipher_states);
549 return m_active_state.has_value();
558 return m_pending_state->handshake_io().next_retransmission_timeout();
565 return m_has_been_closed;
571 const auto& state = *m_pending_state;
573 if(!state.version().is_datagram_protocol()) {
575 const uint16_t current_epoch = sequence_numbers().current_write_epoch();
577 const auto not_current_epoch = [current_epoch](uint16_t epoch) {
return (epoch != current_epoch); };
588 const bool sent_terminal_dtls_flight =
589 (m_flavor ==
TLS_Flavor::DTLS) && (m_is_server == state.has_server_hello_done());
591 const bool encrypt_then_mac_used = m_active_state.has_value() && m_active_state->encrypt_then_mac_used();
596 if(
auto* dtls_io = m_active_state->dtls_handshake_io()) {
600 dtls_io->finalize_handshake(sent_terminal_dtls_flight);
606 if(encrypt_then_mac_used) {
607 m_active_state->note_encrypt_then_mac_used();
610 clear_pending_handshake_state();
618 const auto* input = data.data();
619 auto input_size = data.size();
622 while(input_size > 0) {
627 if(m_had_fatal_alert) {
633 const auto get_epoch = [
this](uint16_t epoch) {
return read_cipher_state_epoch(epoch); };
641 m_sequence_numbers.get(),
643 allow_epoch0_restart);
645 const size_t needed = record.
needed();
649 BOTAN_ASSERT(consumed <= input_size,
"Record reader consumed sane amount");
652 input_size -= consumed;
654 BOTAN_ASSERT(input_size == 0 || needed == 0,
"Got a full record or consumed all input");
656 if(input_size == 0 && needed != 0) {
666 m_active_state.has_value() && sequence_numbers().current_read_epoch() > 0;
677 if(old_unprotected_record) {
681 throw TLS_Exception(Alert::RecordOverflow,
"TLS plaintext record is larger than allowed maximum");
684 const bool epoch0_restart = allow_epoch0_restart && record.
epoch() == 0 && m_active_state.has_value();
687 const bool initial_record = epoch0_restart || (pending_state() ==
nullptr && !m_active_state.has_value());
688 bool initial_handshake_message =
false;
698 throw TLS_Exception(Alert::ProtocolVersion,
"Received unexpected record version in initial record");
700 }
else if(
const auto* pending = pending_state()) {
701 if(pending->has_server_hello() && !initial_handshake_message && record.
version() != pending->version()) {
702 throw TLS_Exception(Alert::ProtocolVersion,
"Received unexpected record version");
704 }
else if(m_active_state.has_value()) {
705 if(record.
version() != m_active_state->version() && !initial_handshake_message) {
706 throw TLS_Exception(Alert::ProtocolVersion,
"Received unexpected record version");
724 if(m_has_been_closed) {
725 throw TLS_Exception(Alert::UnexpectedMessage,
"Received handshake data after connection closure");
727 if(counts_for_useless_records) {
728 if(m_record_buf.empty()) {
734 process_handshake_ccs(m_record_buf, record.
sequence(), record.
type(), record.
version(), epoch0_restart);
736 if(m_has_been_closed) {
737 throw TLS_Exception(Alert::UnexpectedMessage,
"Received application data after connection closure");
739 if(pending_state() !=
nullptr) {
759 const uint16_t active_epoch =
760 m_epochs_before_latest_renegotiation ? m_epochs_before_latest_renegotiation->read_epoch : 0;
762 if(!m_active_state.has_value() || record.
epoch() > active_epoch) {
766 throw TLS_Exception(Alert::UnexpectedMessage,
"Can't interleave application and handshake data");
769 process_application_data(record.
sequence(), m_record_buf);
771 process_alert(m_record_buf, counts_for_useless_records);
774 " from counterparty");
795 uint64_t record_sequence,
798 bool epoch0_restart) {
799 const auto process_retransmitted_record = [&] {
800 BOTAN_ASSERT(m_active_state.has_value(),
"Have active DTLS association for retransmission");
804 const bool unauthenticated = (record_sequence >> 48) == 0;
806 absorb_malformed_input_errors(unauthenticated, [&] {
807 m_active_state->dtls_handshake_io()->add_retransmitted_record(
808 record.data(), record.size(), record_type, record_sequence);
812 const bool no_pending_at_entry = !m_pending_state;
814 if(!m_pending_state) {
818 if(epoch0_restart && m_sequence_numbers && m_active_state.has_value()) {
819 const bool starts_new_handshake = is_new_dtls_association_client_hello(record, record_type);
821 if(!starts_new_handshake) {
822 process_retransmitted_record();
828 if(m_sequence_numbers) {
829 const uint16_t epoch = record_sequence >> 48;
830 const uint16_t current_epoch = sequence_numbers().current_read_epoch();
831 if(epoch == current_epoch) {
834 const bool starts_new_handshake =
839 if(m_active_state.has_value() && !starts_new_handshake) {
840 process_retransmitted_record();
844 }
else if(current_epoch > 0 && epoch == current_epoch - 1) {
845 process_retransmitted_record();
861 if(no_pending_at_entry && m_pending_state) {
862 m_dtls_pending_is_epoch0_restart = epoch0_restart;
866 if(m_pending_state) {
877 const bool unauthenticated_against_active_association =
878 (m_flavor ==
TLS_Flavor::DTLS) && (record_sequence >> 48) == 0 && m_active_state.has_value();
880 const bool absorbed = absorb_malformed_input_errors(unauthenticated_against_active_association, [&] {
881 m_pending_state->handshake_io().add_record(record.data(), record.size(), record_type, record_sequence);
883 while(
auto* pending = m_pending_state.get()) {
884 const auto msg = pending->get_next_handshake_msg(
policy().maximum_handshake_message_size());
892 if(!m_pending_state) {
904 if(absorbed && m_dtls_pending_is_epoch0_restart) {
905 clear_pending_handshake_state();
911 if(!m_active_state.has_value()) {
912 throw Unexpected_Message(
"Application data before handshake done");
916 const uint16_t read_epoch =
917 (m_flavor ==
TLS_Flavor::DTLS) ?
static_cast<uint16_t
>(seq_no >> 48) : sequence_numbers().current_read_epoch();
918 if(read_epoch == 0) {
919 throw Unexpected_Message(
"Application data received in unexpected read epoch");
931void Channel_Impl_12::process_alert(
const secure_vector<uint8_t>& record,
bool counts_for_useless_records) {
932 const Alert alert_msg(record);
934 if(counts_for_useless_records && !alert_msg.is_fatal() && alert_msg.type() != Alert::CloseNotify) {
950 if(alert_msg.type() == Alert::NoRenegotiation && m_active_state.has_value()) {
951 if(!pending_handshake_epochs_unmoved()) {
952 throw TLS_Exception(Alert::UnexpectedMessage,
"Received no_renegotiation after ChangeCipherSpec");
955 clear_pending_handshake_state();
958 if(alert_msg.is_fatal()) {
965 m_has_been_closed =
true;
966 m_had_fatal_alert =
true;
967 const auto invalidated = take_sessions_to_invalidate();
969 invalidate_sessions(invalidated);
974 if(alert_msg.type() == Alert::CloseNotify) {
975 m_peer_closed_connection =
true;
983 if(alert_msg.type() == Alert::CloseNotify || alert_msg.is_fatal()) {
984 m_has_been_closed =
true;
991 const uint8_t input[],
993 BOTAN_ASSERT(m_pending_state || m_active_state.has_value(),
"Some connection state exists");
995 const Protocol_Version record_version = (m_pending_state) ? (m_pending_state->version()) : m_active_state->version();
997 const uint64_t next_seq = sequence_numbers().next_write_sequence(epoch);
999 if(cipher_state ==
nullptr) {
1002 TLS::write_record(m_writebuf, record_type, record_version, next_seq, input, length, *cipher_state,
rng());
1008void Channel_Impl_12::send_record_array(uint16_t epoch,
Record_Type type,
const uint8_t input[],
size_t length) {
1013 const auto cipher_state = write_cipher_state_epoch(epoch);
1017 write_record(cipher_state.get(), epoch, type, input, sending);
1024void Channel_Impl_12::send_record(
Record_Type record_type,
const std::vector<uint8_t>& record) {
1025 send_record_array(sequence_numbers().current_write_epoch(), record_type, record.data(), record.size());
1028void Channel_Impl_12::send_record_under_epoch(uint16_t epoch,
1030 const std::vector<uint8_t>& record) {
1031 send_record_array(epoch, record_type, record.data(), record.size());
1036 throw Invalid_State(
"Data cannot be sent on inactive TLS connection");
1043 const bool ready_to_send_anything = !
is_closed() && m_sequence_numbers;
1044 if(alert.
is_valid() && ready_to_send_anything) {
1061 if(alert.
type() == Alert::NoRenegotiation && m_active_state.has_value()) {
1062 if(pending_handshake_epochs_unmoved()) {
1063 clear_pending_handshake_state();
1071 m_had_fatal_alert =
true;
1072 m_has_been_closed =
true;
1079 const auto invalidated =
1080 (alert.
type() == Alert::None) ? std::vector<Session_Handle>() : take_sessions_to_invalidate();
1083 invalidate_sessions(invalidated);
1086 if(alert.
type() == Alert::CloseNotify || alert.
is_fatal()) {
1087 m_has_been_closed =
true;
1095 if(!fresh_handshake_mode && m_active_state &&
1096 m_active_state->client_supports_secure_renegotiation() != secure_renegotiation) {
1097 throw TLS_Exception(Alert::HandshakeFailure,
"Client changed its mind about secure renegotiation");
1100 if(secure_renegotiation) {
1103 const auto expected =
1106 throw TLS_Exception(Alert::HandshakeFailure,
"Client sent bad values for secure renegotiation");
1115 if(m_active_state && m_active_state->server_supports_secure_renegotiation() != secure_renegotiation) {
1116 throw TLS_Exception(Alert::HandshakeFailure,
"Server changed its mind about secure renegotiation");
1119 if(secure_renegotiation) {
1124 throw TLS_Exception(Alert::HandshakeFailure,
"Server sent bad values for secure renegotiation");
1135 if(suite.has_value() && suite->cbc_ciphersuite()) {
1136 throw TLS_Exception(Alert::HandshakeFailure,
"Renegotiation would downgrade from encrypt-then-MAC");
1142 if(m_active_state.has_value()) {
1143 return m_active_state->client_finished_verify_data();
1145 return std::vector<uint8_t>();
1149 if(m_active_state.has_value()) {
1150 return concat(m_active_state->client_finished_verify_data(), m_active_state->server_finished_verify_data());
1157 if(m_active_state.has_value()) {
1158 return m_active_state->server_supports_secure_renegotiation();
1161 if(
const auto* pending = pending_state()) {
1162 if(
const auto* hello = pending->maybe_server_hello()) {
1163 return hello->secure_renegotiation();
1171 std::string_view context,
1172 size_t length)
const {
1173 if(!m_active_state.has_value()) {
1174 throw Invalid_State(
"Channel_Impl_12::key_material_export connection not active");
1180 if(pending_state() !=
nullptr) {
1181 throw Invalid_State(
"Channel_Impl_12::key_material_export cannot export during renegotiation");
1192 if(!m_active_state->supports_extended_master_secret()) {
1193 throw Invalid_State(
"Channel_Impl_12::key_material_export requires the extended master secret");
1198 if(context.size() > 0xFFFF) {
1199 throw Invalid_Argument(
"Channel_Impl_12::key_material_export context is too long");
1204 const auto salt = [&] {
1205 if(context.empty()) {
1206 return concat(m_active_state->client_random(), m_active_state->server_random());
1208 return concat(m_active_state->client_random(),
1209 m_active_state->server_random(),
1210 store_be(
static_cast<uint16_t
>(context.size())),
#define BOTAN_ASSERT_NOMSG(expr)
#define BOTAN_ASSERT_NONNULL(ptr)
#define BOTAN_ASSERT_IMPLICATION(expr1, expr2, msg)
#define BOTAN_ARG_CHECK(expr, msg)
#define BOTAN_ASSERT(expr, assertion_made)
std::vector< uint8_t > serialize() const
virtual void tls_session_activated()
virtual std::unique_ptr< KDF > tls12_protocol_specific_kdf(std::string_view prf_algo) const
virtual void tls_record_received(uint64_t seq_no, std::span< const uint8_t > data)=0
virtual void tls_alert(Alert alert)=0
virtual uint64_t tls_current_monotonic_clock_ms()
virtual bool tls_peer_closed_connection()
virtual void tls_emit_data(std::span< const uint8_t > data)=0
RandomNumberGenerator & rng()
bool is_closed() const override
void change_cipher_spec_reader(Connection_Side side)
void maybe_arm_dtls_retransmission_timer(TimerGeneration generation_policy=TimerGeneration::Advance)
virtual std::string negotiated_application_protocol() const =0
void update_traffic_keys(bool request_peer_update=false) override
std::vector< uint8_t > secure_renegotiation_data_for_server_hello() const
~Channel_Impl_12() override
bool is_handshake_complete() const override
Callbacks & callbacks() const
virtual bool dtls_epoch0_restart_enabled() const
size_t from_peer(std::span< const uint8_t > data) override
Channel_Impl_12(const std::shared_ptr< Callbacks > &callbacks, const std::shared_ptr< Session_Manager > &session_manager, const std::shared_ptr< RandomNumberGenerator > &rng, const std::shared_ptr< const Policy > &policy, bool is_server, TLS_Flavor flavor, size_t io_buf_sz=TLS::Channel::IO_BUF_DEFAULT_SIZE)
bool timeout_check() override
TLS_Flavor flavor() const
bool is_active() const override
Session_Manager & session_manager()
Handshake_State & create_handshake_state(Protocol_Version version, bool epoch0_restart=false, std::optional< uint64_t > read_sequence_number=std::nullopt, std::optional< uint64_t > write_sequence_number=std::nullopt)
const Policy & policy() const
void send_alert(const Alert &alert) override
virtual void initiate_handshake(Handshake_State &state, bool force_full_renegotiation)=0
std::vector< X509_Certificate > peer_cert_chain() const override
void to_peer(std::span< const uint8_t > data) override
void note_resumption_handle(std::optional< Session_Handle > handle)
void change_cipher_spec_writer(Connection_Side side)
std::vector< uint8_t > secure_renegotiation_data_for_client_hello() const
void secure_renegotiation_check(const Client_Hello_12 *client_hello, bool fresh_handshake_mode=false)
SymmetricKey key_material_export(std::string_view label, std::string_view context, size_t length) const override
std::optional< std::string > external_psk_identity() const override
void reset_active_association_state()
virtual std::unique_ptr< Handshake_State > new_handshake_state(std::unique_ptr< Handshake_IO > io)=0
std::optional< std::chrono::milliseconds > next_retransmission_timeout() const override
virtual void process_handshake_msg(Handshake_State &pending_state, Handshake_Type type, const std::vector< uint8_t > &contents, bool epoch0_restart)=0
bool secure_renegotiation_supported() const override
void renegotiate(bool force_full_renegotiation=false) override
void reset_useless_records()
void send_warning_alert(Alert::Type type)
void send_fatal_alert(Alert::Type type)
void note_useless_record(const Policy &policy)
static std::optional< Ciphersuite > by_id(uint16_t suite)
std::vector< uint8_t > renegotiation_info() const
bool secure_renegotiation() const
virtual uint16_t current_read_epoch() const =0
virtual uint16_t current_write_epoch() const =0
virtual size_t dtls_maximum_timeout() const
virtual size_t dtls_default_mtu() const
virtual std::optional< size_t > dtls_maximum_retransmissions() const
virtual size_t dtls_initial_timeout() const
virtual bool allow_resumption_for_renegotiation() const
std::string to_string() const
uint8_t major_version() const
bool is_datagram_protocol() const
bool supports_encrypt_then_mac() const
std::vector< uint8_t > renegotiation_info() const
bool secure_renegotiation() const
uint16_t ciphersuite() const
virtual size_t remove(const Session_Handle &handle)=0
constexpr CT::Mask< T > is_equal(const T x[], const T y[], size_t len)
void write_unencrypted_record(secure_vector< uint8_t > &output, Record_Type record_type, Protocol_Version version, uint64_t record_sequence, const uint8_t *message, size_t message_len)
void write_record(secure_vector< uint8_t > &output, Record_Type record_type, Protocol_Version version, uint64_t record_sequence, const uint8_t *message, size_t message_len, Connection_Cipher_State &cs, RandomNumberGenerator &rng)
Record_Header read_record(TLS_Flavor flavor, secure_vector< uint8_t > &readbuf, const uint8_t input[], size_t input_len, size_t &consumed, secure_vector< uint8_t > &recbuf, Connection_Sequence_Numbers *sequence_numbers, const get_cipherstate_fn &get_cipherstate, bool allow_epoch0_restart)
void map_remove_if(Pred pred, T &assoc)
std::span< const uint8_t > as_span_of_bytes(const char *s, size_t len)
constexpr auto concat(Rs &&... ranges)
std::vector< T, secure_allocator< T > > secure_vector
constexpr auto store_be(ParamTs &&... params)
constexpr auto load_be(ParamTs &&... params)