Botan 3.6.1
Crypto and TLS for C&
tls_channel_impl_12.cpp
Go to the documentation of this file.
1/*
2* TLS Channels
3* (C) 2011,2012,2014,2015,2016 Jack Lloyd
4* 2016 Matthias Gierlings
5*
6* Botan is released under the Simplified BSD License (see license.txt)
7*/
8
9#include <botan/internal/tls_channel_impl_12.h>
10
11#include <botan/kdf.h>
12#include <botan/tls_messages.h>
13#include <botan/tls_policy.h>
14#include <botan/x509cert.h>
15#include <botan/internal/loadstor.h>
16#include <botan/internal/stl_util.h>
17#include <botan/internal/tls_handshake_state.h>
18#include <botan/internal/tls_record.h>
19#include <botan/internal/tls_seq_numbers.h>
20
21namespace Botan::TLS {
22
23Channel_Impl_12::Channel_Impl_12(const std::shared_ptr<Callbacks>& callbacks,
24 const std::shared_ptr<Session_Manager>& session_manager,
25 const std::shared_ptr<RandomNumberGenerator>& rng,
26 const std::shared_ptr<const Policy>& policy,
27 bool is_server,
28 bool is_datagram,
29 size_t reserved_io_buffer_size) :
30 m_is_server(is_server),
31 m_is_datagram(is_datagram),
32 m_callbacks(callbacks),
33 m_session_manager(session_manager),
34 m_policy(policy),
35 m_rng(rng),
36 m_has_been_closed(false) {
37 BOTAN_ASSERT_NONNULL(m_callbacks);
38 BOTAN_ASSERT_NONNULL(m_session_manager);
40 BOTAN_ASSERT_NONNULL(m_policy);
41
42 /* epoch 0 is plaintext, thus null cipher state */
43 m_write_cipher_states[0] = nullptr;
44 m_read_cipher_states[0] = nullptr;
45
46 m_writebuf.reserve(reserved_io_buffer_size);
47 m_readbuf.reserve(reserved_io_buffer_size);
48}
49
50void Channel_Impl_12::reset_state() {
51 m_active_state.reset();
52 m_pending_state.reset();
53 m_readbuf.clear();
54 m_write_cipher_states.clear();
55 m_read_cipher_states.clear();
56}
57
59 // This operation only makes sense for DTLS
60 BOTAN_ASSERT_NOMSG(m_is_datagram);
61 m_active_state.reset();
62 m_read_cipher_states.clear();
63 m_write_cipher_states.clear();
64
65 m_write_cipher_states[0] = nullptr;
66 m_read_cipher_states[0] = nullptr;
67
68 if(m_sequence_numbers) {
69 m_sequence_numbers->reset();
70 }
71}
72
74
75Connection_Sequence_Numbers& Channel_Impl_12::sequence_numbers() const {
76 BOTAN_ASSERT(m_sequence_numbers, "Have a sequence numbers object");
77 return *m_sequence_numbers;
78}
79
80std::shared_ptr<Connection_Cipher_State> Channel_Impl_12::read_cipher_state_epoch(uint16_t epoch) const {
81 auto i = m_read_cipher_states.find(epoch);
82 if(i == m_read_cipher_states.end()) {
83 throw Internal_Error("TLS::Channel_Impl_12 No read cipherstate for epoch " + std::to_string(epoch));
84 }
85 return i->second;
86}
87
88std::shared_ptr<Connection_Cipher_State> Channel_Impl_12::write_cipher_state_epoch(uint16_t epoch) const {
89 auto i = m_write_cipher_states.find(epoch);
90 if(i == m_write_cipher_states.end()) {
91 throw Internal_Error("TLS::Channel_Impl_12 No write cipherstate for epoch " + std::to_string(epoch));
92 }
93 return i->second;
94}
95
96std::vector<X509_Certificate> Channel_Impl_12::peer_cert_chain() const {
97 if(auto active = active_state()) {
98 return get_peer_cert_chain(*active);
99 }
100 return std::vector<X509_Certificate>();
101}
102
103std::optional<std::string> Channel_Impl_12::external_psk_identity() const {
104 const auto* state = (active_state() != nullptr) ? active_state() : pending_state();
105 if(state) {
106 return state->psk_identity();
107 } else {
108 return std::nullopt;
109 }
110}
111
113 if(pending_state()) {
114 throw Internal_Error("create_handshake_state called during handshake");
115 }
116
117 if(auto active = active_state()) {
118 Protocol_Version active_version = active->version();
119
120 if(active_version.is_datagram_protocol() != version.is_datagram_protocol()) {
121 throw TLS_Exception(Alert::ProtocolVersion,
122 "Active state using version " + active_version.to_string() + " cannot change to " +
123 version.to_string() + " in pending");
124 }
125 }
126
127 if(!m_sequence_numbers) {
128 if(version.is_datagram_protocol()) {
129 m_sequence_numbers = std::make_unique<Datagram_Sequence_Numbers>();
130 } else {
131 m_sequence_numbers = std::make_unique<Stream_Sequence_Numbers>();
132 }
133 }
134
135 using namespace std::placeholders;
136
137 std::unique_ptr<Handshake_IO> io;
138 if(version.is_datagram_protocol()) {
139 io =
140 std::make_unique<Datagram_Handshake_IO>(std::bind(&Channel_Impl_12::send_record_under_epoch, this, _1, _2, _3),
141 sequence_numbers(),
142 static_cast<uint16_t>(policy().dtls_default_mtu()),
143 policy().dtls_initial_timeout(),
144 policy().dtls_maximum_timeout());
145 } else {
146 io = std::make_unique<Stream_Handshake_IO>(std::bind(&Channel_Impl_12::send_record, this, _1, _2));
147 }
148
149 m_pending_state = new_handshake_state(std::move(io));
150
151 if(auto active = active_state()) {
152 m_pending_state->set_version(active->version());
153 }
154
155 return *m_pending_state;
156}
157
159 if(m_pending_state) {
160 return m_pending_state->handshake_io().timeout_check();
161 }
162
163 //FIXME: scan cipher suites and remove epochs older than 2*MSL
164 return false;
165}
166
167void Channel_Impl_12::renegotiate(bool force_full_renegotiation) {
168 if(pending_state()) { // currently in handshake?
169 return;
170 }
171
172 if(auto active = active_state()) {
173 if(force_full_renegotiation == false) {
174 force_full_renegotiation = !policy().allow_resumption_for_renegotiation();
175 }
176
177 initiate_handshake(create_handshake_state(active->version()), force_full_renegotiation);
178 } else {
179 throw Invalid_State("Cannot renegotiate on inactive connection");
180 }
181}
182
184 throw Invalid_Argument("cannot update traffic keys on a TLS 1.2 channel");
185}
186
188 auto pending = pending_state();
189
190 BOTAN_ASSERT(pending && pending->server_hello(), "Have received server hello");
191
192 if(pending->server_hello()->compression_method() != 0) {
193 throw Internal_Error("Negotiated unknown compression algorithm");
194 }
195
196 sequence_numbers().new_read_cipher_state();
197
198 const uint16_t epoch = sequence_numbers().current_read_epoch();
199
200 BOTAN_ASSERT(!m_read_cipher_states.contains(epoch), "No read cipher state currently set for next epoch");
201
202 // flip side as we are reading
203 std::shared_ptr<Connection_Cipher_State> read_state(
204 new Connection_Cipher_State(pending->version(),
206 false,
207 pending->ciphersuite(),
208 pending->session_keys(),
209 pending->server_hello()->supports_encrypt_then_mac()));
210
211 m_read_cipher_states[epoch] = read_state;
212}
213
215 auto pending = pending_state();
216
217 BOTAN_ASSERT(pending && pending->server_hello(), "Have received server hello");
218
219 if(pending->server_hello()->compression_method() != 0) {
220 throw Internal_Error("Negotiated unknown compression algorithm");
221 }
222
223 sequence_numbers().new_write_cipher_state();
224
225 const uint16_t epoch = sequence_numbers().current_write_epoch();
226
227 BOTAN_ASSERT(!m_write_cipher_states.contains(epoch), "No write cipher state currently set for next epoch");
228
229 std::shared_ptr<Connection_Cipher_State> write_state(
230 new Connection_Cipher_State(pending->version(),
231 side,
232 true,
233 pending->ciphersuite(),
234 pending->session_keys(),
235 pending->server_hello()->supports_encrypt_then_mac()));
236
237 m_write_cipher_states[epoch] = write_state;
238}
239
241 return (active_state() != nullptr);
242}
243
245 return !is_closed() && is_handshake_complete();
246}
247
249 return m_has_been_closed;
250}
251
253 std::swap(m_active_state, m_pending_state);
254 m_pending_state.reset();
255
256 if(!m_active_state->version().is_datagram_protocol()) {
257 // TLS is easy just remove all but the current state
258 const uint16_t current_epoch = sequence_numbers().current_write_epoch();
259
260 const auto not_current_epoch = [current_epoch](uint16_t epoch) { return (epoch != current_epoch); };
261
262 map_remove_if(not_current_epoch, m_write_cipher_states);
263 map_remove_if(not_current_epoch, m_read_cipher_states);
264 }
265
267}
268
269size_t Channel_Impl_12::from_peer(std::span<const uint8_t> data) {
270 const bool allow_epoch0_restart = m_is_datagram && m_is_server && policy().allow_dtls_epoch0_restart();
271
272 auto input = data.data();
273 auto input_size = data.size();
274
275 try {
276 while(input_size) {
277 size_t consumed = 0;
278
279 auto get_epoch = [this](uint16_t epoch) { return read_cipher_state_epoch(epoch); };
280
281 const Record_Header record = read_record(m_is_datagram,
282 m_readbuf,
283 input,
284 input_size,
285 consumed,
286 m_record_buf,
287 m_sequence_numbers.get(),
288 get_epoch,
289 allow_epoch0_restart);
290
291 const size_t needed = record.needed();
292
293 BOTAN_ASSERT(consumed > 0, "Got to eat something");
294
295 BOTAN_ASSERT(consumed <= input_size, "Record reader consumed sane amount");
296
297 input += consumed;
298 input_size -= consumed;
299
300 BOTAN_ASSERT(input_size == 0 || needed == 0, "Got a full record or consumed all input");
301
302 if(input_size == 0 && needed != 0) {
303 return needed; // need more data to complete record
304 }
305
306 // Ignore invalid records in DTLS
307 if(m_is_datagram && record.type() == Record_Type::Invalid) {
308 return 0;
309 }
310
311 if(m_record_buf.size() > MAX_PLAINTEXT_SIZE) {
312 throw TLS_Exception(Alert::RecordOverflow, "TLS plaintext record is larger than allowed maximum");
313 }
314
315 const bool epoch0_restart = m_is_datagram && record.epoch() == 0 && active_state();
316 BOTAN_ASSERT_IMPLICATION(epoch0_restart, allow_epoch0_restart, "Allowed state");
317
318 const bool initial_record = epoch0_restart || (!pending_state() && !active_state());
319 bool initial_handshake_message = false;
320 if(record.type() == Record_Type::Handshake && !m_record_buf.empty()) {
321 Handshake_Type type = static_cast<Handshake_Type>(m_record_buf[0]);
322 initial_handshake_message = (type == Handshake_Type::ClientHello);
323 }
324
325 if(record.type() != Record_Type::Alert) {
326 if(initial_record) {
327 // For initial records just check for basic sanity
328 if(record.version().major_version() != 3 && record.version().major_version() != 0xFE) {
329 throw TLS_Exception(Alert::ProtocolVersion, "Received unexpected record version in initial record");
330 }
331 } else if(auto pending = pending_state()) {
332 if(pending->server_hello() != nullptr && !initial_handshake_message &&
333 record.version() != pending->version()) {
334 throw TLS_Exception(Alert::ProtocolVersion, "Received unexpected record version");
335 }
336 } else if(auto active = active_state()) {
337 if(record.version() != active->version() && !initial_handshake_message) {
338 throw TLS_Exception(Alert::ProtocolVersion, "Received unexpected record version");
339 }
340 }
341 }
342
343 if(record.type() == Record_Type::Handshake || record.type() == Record_Type::ChangeCipherSpec) {
344 if(m_has_been_closed) {
345 throw TLS_Exception(Alert::UnexpectedMessage, "Received handshake data after connection closure");
346 }
347 process_handshake_ccs(m_record_buf, record.sequence(), record.type(), record.version(), epoch0_restart);
348 } else if(record.type() == Record_Type::ApplicationData) {
349 if(m_has_been_closed) {
350 throw TLS_Exception(Alert::UnexpectedMessage, "Received application data after connection closure");
351 }
352 if(pending_state() != nullptr) {
353 throw TLS_Exception(Alert::UnexpectedMessage, "Can't interleave application and handshake data");
354 }
355 process_application_data(record.sequence(), m_record_buf);
356 } else if(record.type() == Record_Type::Alert) {
357 process_alert(m_record_buf);
358 } else if(record.type() != Record_Type::Invalid) {
359 throw Unexpected_Message("Unexpected record type " + std::to_string(static_cast<size_t>(record.type())) +
360 " from counterparty");
361 }
362 }
363
364 return 0; // on a record boundary
365 } catch(TLS_Exception& e) {
367 throw;
369 send_fatal_alert(Alert::BadRecordMac);
370 throw;
371 } catch(Decoding_Error&) {
372 send_fatal_alert(Alert::DecodeError);
373 throw;
374 } catch(...) {
375 send_fatal_alert(Alert::InternalError);
376 throw;
377 }
378}
379
380void Channel_Impl_12::process_handshake_ccs(const secure_vector<uint8_t>& record,
381 uint64_t record_sequence,
382 Record_Type record_type,
383 Protocol_Version record_version,
384 bool epoch0_restart) {
385 if(!m_pending_state) {
386 // No pending handshake, possibly new:
387 if(record_version.is_datagram_protocol() && !epoch0_restart) {
388 if(m_sequence_numbers) {
389 /*
390 * Might be a peer retransmit under epoch - 1 in which
391 * case we must retransmit last flight
392 */
393 sequence_numbers().read_accept(record_sequence);
394
395 const uint16_t epoch = record_sequence >> 48;
396
397 if(epoch == sequence_numbers().current_read_epoch()) {
398 create_handshake_state(record_version);
399 } else if(epoch == sequence_numbers().current_read_epoch() - 1) {
400 BOTAN_ASSERT(m_active_state, "Have active state here");
401 m_active_state->handshake_io().add_record(record.data(), record.size(), record_type, record_sequence);
402 }
403 } else {
404 create_handshake_state(record_version);
405 }
406 } else {
407 create_handshake_state(record_version);
408 }
409 }
410
411 // May have been created in above conditional
412 if(m_pending_state) {
413 m_pending_state->handshake_io().add_record(record.data(), record.size(), record_type, record_sequence);
414
415 while(auto pending = m_pending_state.get()) {
416 auto msg = pending->get_next_handshake_msg();
417
418 if(msg.first == Handshake_Type::None) { // no full handshake yet
419 break;
420 }
421
422 process_handshake_msg(active_state(), *pending, msg.first, msg.second, epoch0_restart);
423
424 if(!m_pending_state) {
425 break;
426 }
427 }
428 }
429}
430
431void Channel_Impl_12::process_application_data(uint64_t seq_no, const secure_vector<uint8_t>& record) {
432 if(!active_state()) {
433 throw Unexpected_Message("Application data before handshake done");
434 }
435
436 callbacks().tls_record_received(seq_no, record);
437}
438
439void Channel_Impl_12::process_alert(const secure_vector<uint8_t>& record) {
440 Alert alert_msg(record);
441
442 if(alert_msg.type() == Alert::NoRenegotiation) {
443 m_pending_state.reset();
444 }
445
446 callbacks().tls_alert(alert_msg);
447
448 if(alert_msg.is_fatal()) {
449 if(auto active = active_state()) {
450 const auto& session_id = active->server_hello()->session_id();
451 if(!session_id.empty()) {
452 session_manager().remove(session_id);
453 }
454 }
455 }
456
457 if(alert_msg.type() == Alert::CloseNotify) {
458 // TLS 1.2 requires us to immediately react with our "close_notify",
459 // the return value of the application's callback has no effect on that.
461 send_warning_alert(Alert::CloseNotify); // reply in kind
462 }
463
464 if(alert_msg.type() == Alert::CloseNotify || alert_msg.is_fatal()) {
465 m_has_been_closed = true;
466 }
467}
468
469void Channel_Impl_12::write_record(Connection_Cipher_State* cipher_state,
470 uint16_t epoch,
471 Record_Type record_type,
472 const uint8_t input[],
473 size_t length) {
474 BOTAN_ASSERT(m_pending_state || m_active_state, "Some connection state exists");
475
476 const Protocol_Version record_version =
477 (m_pending_state) ? (m_pending_state->version()) : (m_active_state->version());
478
479 const uint64_t next_seq = sequence_numbers().next_write_sequence(epoch);
480
481 if(cipher_state == nullptr) {
482 TLS::write_unencrypted_record(m_writebuf, record_type, record_version, next_seq, input, length);
483 } else {
484 TLS::write_record(m_writebuf, record_type, record_version, next_seq, input, length, *cipher_state, rng());
485 }
486
487 callbacks().tls_emit_data(m_writebuf);
488}
489
490void Channel_Impl_12::send_record_array(uint16_t epoch, Record_Type type, const uint8_t input[], size_t length) {
491 if(length == 0) {
492 return;
493 }
494
495 auto cipher_state = write_cipher_state_epoch(epoch);
496
497 while(length) {
498 const size_t sending = std::min<size_t>(length, MAX_PLAINTEXT_SIZE);
499 write_record(cipher_state.get(), epoch, type, input, sending);
500
501 input += sending;
502 length -= sending;
503 }
504}
505
506void Channel_Impl_12::send_record(Record_Type record_type, const std::vector<uint8_t>& record) {
507 send_record_array(sequence_numbers().current_write_epoch(), record_type, record.data(), record.size());
508}
509
510void Channel_Impl_12::send_record_under_epoch(uint16_t epoch,
511 Record_Type record_type,
512 const std::vector<uint8_t>& record) {
513 send_record_array(epoch, record_type, record.data(), record.size());
514}
515
516void Channel_Impl_12::to_peer(std::span<const uint8_t> data) {
517 if(!is_active()) {
518 throw Invalid_State("Data cannot be sent on inactive TLS connection");
519 }
520
521 send_record_array(sequence_numbers().current_write_epoch(), Record_Type::ApplicationData, data.data(), data.size());
522}
523
525 const bool ready_to_send_anything = !is_closed() && m_sequence_numbers;
526 if(alert.is_valid() && ready_to_send_anything) {
527 try {
528 send_record(Record_Type::Alert, alert.serialize());
529 } catch(...) { /* swallow it */
530 }
531 }
532
533 if(alert.type() == Alert::NoRenegotiation) {
534 m_pending_state.reset();
535 }
536
537 if(alert.is_fatal()) {
538 if(auto active = active_state()) {
539 const auto& session_id = active->server_hello()->session_id();
540 if(!session_id.empty()) {
541 session_manager().remove(Session_ID(session_id));
542 }
543 }
544 reset_state();
545 }
546
547 if(alert.type() == Alert::CloseNotify || alert.is_fatal()) {
548 m_has_been_closed = true;
549 }
550}
551
553 const bool secure_renegotiation = client_hello->secure_renegotiation();
554
555 if(auto active = active_state()) {
556 const bool active_sr = active->client_hello()->secure_renegotiation();
557
558 if(active_sr != secure_renegotiation) {
559 throw TLS_Exception(Alert::HandshakeFailure, "Client changed its mind about secure renegotiation");
560 }
561 }
562
563 if(secure_renegotiation) {
564 const std::vector<uint8_t>& data = client_hello->renegotiation_info();
565
567 throw TLS_Exception(Alert::HandshakeFailure, "Client sent bad values for secure renegotiation");
568 }
569 }
570}
571
573 const bool secure_renegotiation = server_hello->secure_renegotiation();
574
575 if(auto active = active_state()) {
576 const bool active_sr = active->server_hello()->secure_renegotiation();
577
578 if(active_sr != secure_renegotiation) {
579 throw TLS_Exception(Alert::HandshakeFailure, "Server changed its mind about secure renegotiation");
580 }
581 }
582
583 if(secure_renegotiation) {
584 const std::vector<uint8_t>& data = server_hello->renegotiation_info();
585
587 throw TLS_Exception(Alert::HandshakeFailure, "Server sent bad values for secure renegotiation");
588 }
589 }
590}
591
593 if(auto active = active_state()) {
594 return active->client_finished()->verify_data();
595 }
596 return std::vector<uint8_t>();
597}
598
600 if(auto active = active_state()) {
601 std::vector<uint8_t> buf = active->client_finished()->verify_data();
602 buf += active->server_finished()->verify_data();
603 return buf;
604 }
605
606 return std::vector<uint8_t>();
607}
608
610 if(auto active = active_state()) {
611 return active->server_hello()->secure_renegotiation();
612 }
613
614 if(auto pending = pending_state()) {
615 if(auto hello = pending->server_hello()) {
616 return hello->secure_renegotiation();
617 }
618 }
619
620 return false;
621}
622
624 std::string_view context,
625 size_t length) const {
626 if(auto active = active_state()) {
627 if(pending_state() != nullptr) {
628 throw Invalid_State("Channel_Impl_12::key_material_export cannot export during renegotiation");
629 }
630
631 auto prf = active->protocol_specific_prf();
632
633 const secure_vector<uint8_t>& master_secret = active->session_keys().master_secret();
634
635 std::vector<uint8_t> salt;
636 salt += active->client_hello()->random();
637 salt += active->server_hello()->random();
638
639 if(!context.empty()) {
640 size_t context_size = context.length();
641 if(context_size > 0xFFFF) {
642 throw Invalid_Argument("key_material_export context is too long");
643 }
644 salt.push_back(get_byte<0>(static_cast<uint16_t>(context_size)));
645 salt.push_back(get_byte<1>(static_cast<uint16_t>(context_size)));
646 salt += to_byte_vector(context);
647 }
648
649 return SymmetricKey(prf->derive_key(length, master_secret, salt, to_byte_vector(label)));
650 } else {
651 throw Invalid_State("Channel_Impl_12::key_material_export connection not active");
652 }
653}
654
655} // namespace Botan::TLS
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:59
#define BOTAN_ASSERT_NONNULL(ptr)
Definition assert.h:86
#define BOTAN_ASSERT_IMPLICATION(expr1, expr2, msg)
Definition assert.h:77
#define BOTAN_ASSERT(expr, assertion_made)
Definition assert.h:50
bool is_valid() const
Definition tls_alert.h:77
std::vector< uint8_t > serialize() const
Definition tls_alert.cpp:32
bool is_fatal() const
Definition tls_alert.h:92
Type type() const
Definition tls_alert.h:99
virtual void tls_session_activated()
virtual void tls_record_received(uint64_t seq_no, std::span< const uint8_t > data)=0
virtual void tls_alert(Alert alert)=0
virtual bool tls_peer_closed_connection()
virtual void tls_emit_data(std::span< const uint8_t > data)=0
RandomNumberGenerator & rng()
virtual std::vector< X509_Certificate > get_peer_cert_chain(const Handshake_State &state) const =0
void change_cipher_spec_reader(Connection_Side side)
void update_traffic_keys(bool request_peer_update=false) override
Handshake_State & create_handshake_state(Protocol_Version version)
std::vector< uint8_t > secure_renegotiation_data_for_server_hello() const
bool is_handshake_complete() const override
size_t from_peer(std::span< const uint8_t > data) override
void secure_renegotiation_check(const Client_Hello_12 *client_hello)
Session_Manager & session_manager()
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 change_cipher_spec_writer(Connection_Side side)
std::vector< uint8_t > secure_renegotiation_data_for_client_hello() const
virtual std::unique_ptr< Handshake_State > new_handshake_state(std::unique_ptr< class Handshake_IO > io)=0
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, bool is_datagram, size_t io_buf_sz=TLS::Channel::IO_BUF_DEFAULT_SIZE)
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
virtual void process_handshake_msg(const Handshake_State *active_state, 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 send_warning_alert(Alert::Type type)
void send_fatal_alert(Alert::Type type)
std::vector< uint8_t > renegotiation_info() const
virtual uint16_t current_read_epoch() const =0
virtual void read_accept(uint64_t seq)=0
virtual uint16_t current_write_epoch() const =0
virtual uint64_t next_write_sequence(uint16_t)=0
virtual bool allow_dtls_epoch0_restart() const
virtual bool allow_resumption_for_renegotiation() const
std::string to_string() const
uint8_t major_version() const
Definition tls_version.h:89
Protocol_Version version() const
Definition tls_record.h:80
Record_Type type() const
Definition tls_record.h:92
uint64_t sequence() const
Definition tls_record.h:85
size_t needed() const
Definition tls_record.h:78
uint16_t epoch() const
Definition tls_record.h:90
std::vector< uint8_t > renegotiation_info() const
virtual size_t remove(const Session_Handle &handle)=0
Alert::Type type() const
Definition tls_exceptn.h:21
Record_Header read_record(bool is_datagram, 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)
@ MAX_PLAINTEXT_SIZE
Definition tls_magic.h:30
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)
Strong< std::vector< uint8_t >, struct Session_ID_ > Session_ID
holds a TLS 1.2 session ID for stateful resumption
Definition tls_session.h:32
constexpr uint8_t get_byte(T input)
Definition loadstor.h:75
void map_remove_if(Pred pred, T &assoc)
Definition stl_util.h:70
T to_byte_vector(std::string_view s)
Definition stl_util.h:29
OctetString SymmetricKey
Definition symkey.h:140
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:61