Botan 3.14.1
Crypto and TLS for C&
tls_flight_13.cpp
Go to the documentation of this file.
1/*
2* TLS 1.3 Flights
3* (C) 2026 Jack Lloyd
4* 2026 Amos Treiber, René Meusel - Rohde & Schwarz Networks and Cybersecurity GmbH
5*
6* Botan is released under the Simplified BSD License (see license.txt)
7*/
8
9#include <botan/internal/tls_flight_13.h>
10
11#include <botan/tls_callbacks.h>
12#include <botan/internal/stl_util.h>
13#include <botan/internal/tls_handshake_layer_13.h>
14#include <botan/internal/tls_transcript_hash_13.h>
15
16#include <utility>
17
18namespace Botan::TLS {
19
20namespace {
21
22Flight::Message_Info make_message_info(const Handshake_Message& message, const Flight::PostHandshake post_handshake) {
23 BOTAN_UNUSED(post_handshake);
24
25 auto serialized_message = Handshake_Layer::serialize(message);
26 return {
27 .wire_type = message.wire_type(),
28 .header = TLS_Handshake_Layer::prepare_header(message.wire_type(), serialized_message.size()),
29 .serialized = std::move(serialized_message),
30 };
31}
32
33} // namespace
34
35std::vector<Flight::Message> Flight::commit() {
36 BOTAN_STATE_CHECK(m_messages.has_value());
37 BOTAN_STATE_CHECK(!m_messages->empty());
38
39 return std::exchange(m_messages, {}).value();
40}
41
42void Flight::append(const Handshake_Message& message, PostHandshake post_handshake) {
43 BOTAN_STATE_CHECK(m_messages.has_value());
44
45 m_callbacks.tls_inspect_handshake_msg(message);
46
47 auto msg_info = make_message_info(message, post_handshake);
48 if(post_handshake == PostHandshake::No) {
49 BOTAN_ASSERT_NOMSG(m_transcript_hash.has_value());
50 m_transcript_hash->get().update(msg_info.header, msg_info.serialized);
51 }
52 m_messages->push_back(std::move(msg_info));
53}
54
56 BOTAN_STATE_CHECK(m_messages.has_value());
57 m_messages->push_back(Dummy_ChangeCipherSpec{});
58}
59
60} // namespace Botan::TLS
#define BOTAN_UNUSED
Definition assert.h:151
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:82
#define BOTAN_STATE_CHECK(expr)
Definition assert.h:49
void append(const Handshake_Message &message, PostHandshake post_handshake)
std::vector< Message > commit()
static SerializedHandshakeMessage serialize(const Handshake_Message &message)
static HandshakeProtocolHeader prepare_header(Handshake_Type type, size_t payload_length)