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

#include <tls_flight_13.h>

Inheritance diagram for Botan::TLS::PostHandshakeFlight:
Botan::TLS::Flight

Public Member Functions

PostHandshakeFlight & add (const Post_Handshake_Message_13 &msg) &
PostHandshakeFlight add (const Post_Handshake_Message_13 &msg) &&
std::vector< Message > commit ()
 PostHandshakeFlight (Callbacks &callbacks)

Protected Types

using Message = std::variant<Dummy_ChangeCipherSpec, Message_Info>
enum class  PostHandshake : bool { No = false , Yes = true }

Protected Member Functions

Flight & add (Handshake_Message_13_Ref msg) &
Flight add (Handshake_Message_13_Ref msg) &&
Flight & add_dummy_change_cipher_spec () &
Flight add_dummy_change_cipher_spec () &&
void append (const Handshake_Message &message, PostHandshake post_handshake)
void append_ccs ()

Detailed Description

Helper class to coalesce post-handshake messages into a TLS flight.

Definition at line 147 of file tls_flight_13.h.

Member Typedef Documentation

◆ Message

Definition at line 48 of file tls_flight_13.h.

Member Enumeration Documentation

◆ PostHandshake

enum class Botan::TLS::Flight::PostHandshake : bool
stronginherited
Enumerator
No 
Yes 

Definition at line 50 of file tls_flight_13.h.

50: bool { No = false, Yes = true };

Constructor & Destructor Documentation

◆ PostHandshakeFlight()

Botan::TLS::PostHandshakeFlight::PostHandshakeFlight ( Callbacks & callbacks)
inlineexplicit

Definition at line 149 of file tls_flight_13.h.

149: Flight(callbacks) {}
Flight(Callbacks &callbacks)

References Botan::TLS::Flight::Flight().

Referenced by add(), and add().

Member Function Documentation

◆ add() [1/4]

Flight & Botan::TLS::Flight::add ( Handshake_Message_13_Ref msg) &
inlineinherited

Add a msg to this flight, updating the transcript hash associated with this flight and letting the user inspect the message first via the callbacks.

TODO(C++23): deducing-this

Parameters
msgThe handshake message to add to the flight
Exceptions
Invalid_Stateif the flight was already committed

Definition at line 78 of file tls_flight_13.h.

78 {
79 std::visit([&](const auto m) { append(m.get(), PostHandshake::No); }, msg);
80 return *this;
81 }
void append(const Handshake_Message &message, PostHandshake post_handshake)

References append(), Flight(), and No.

Referenced by Botan::TLS::Client_Impl_13::create().

◆ add() [2/4]

Flight Botan::TLS::Flight::add ( Handshake_Message_13_Ref msg) &&
inlineinherited

Add a msg to this flight, updating the transcript hash associated with this flight and letting the user inspect the message first via the callbacks.

TODO(C++23): deducing-this

Parameters
msgThe handshake message to add to the flight
Exceptions
Invalid_Stateif the flight was already committed

Definition at line 93 of file tls_flight_13.h.

93 {
94 std::visit([&](const auto m) { append(m.get(), PostHandshake::No); }, msg);
95 return std::move(*this);
96 }

References append(), Flight(), and No.

◆ add() [3/4]

PostHandshakeFlight & Botan::TLS::PostHandshakeFlight::add ( const Post_Handshake_Message_13 & msg) &
inline

Add a msg to this flight, letting the user inspect the message first via the callbacks. The transcript hash is unchanged for post-handshake messages.

TODO(C++23): deducing-this

Parameters
msgThe post-handshake message to add to the flight
Exceptions
Invalid_Stateif the flight was already committed

Definition at line 162 of file tls_flight_13.h.

162 {
163 std::visit([&](const auto& m) { append(m, PostHandshake::Yes); }, msg);
164 return *this;
165 }

References Botan::TLS::Flight::append(), PostHandshakeFlight(), and Botan::TLS::Flight::Yes.

◆ add() [4/4]

PostHandshakeFlight Botan::TLS::PostHandshakeFlight::add ( const Post_Handshake_Message_13 & msg) &&
inline

Add a msg to this flight, letting the user inspect the message first via the callbacks. The transcript hash is unchanged for post-handshake messages.

TODO(C++23): deducing-this

Parameters
msgThe post-handshake message to add to the flight
Exceptions
Invalid_Stateif the flight was already committed

Definition at line 177 of file tls_flight_13.h.

177 {
178 std::visit([&](const auto& m) { append(m, PostHandshake::Yes); }, msg);
179 return std::move(*this);
180 }

References Botan::TLS::Flight::append(), PostHandshakeFlight(), and Botan::TLS::Flight::Yes.

◆ add_dummy_change_cipher_spec() [1/2]

Flight & Botan::TLS::Flight::add_dummy_change_cipher_spec ( ) &
inlineinherited

Add a dummy ChangeCipherSpec message to the flight when following the compatibility mode for TLS 1.3. See RFC 9846 E.4 for details.

TODO(C++23): deducing-this

Exceptions
Invalid_Stateif the flight was already committed

Definition at line 106 of file tls_flight_13.h.

106 {
107 append_ccs();
108 return *this;
109 }

References append_ccs(), and Flight().

◆ add_dummy_change_cipher_spec() [2/2]

Flight Botan::TLS::Flight::add_dummy_change_cipher_spec ( ) &&
inlineinherited

Add a dummy ChangeCipherSpec message to the flight when following the compatibility mode for TLS 1.3. See RFC 9846 E.4 for details.

TODO(C++23): deducing-this

Exceptions
Invalid_Stateif the flight was already committed

Definition at line 119 of file tls_flight_13.h.

119 {
120 append_ccs();
121 return std::move(*this);
122 }

References append_ccs(), and Flight().

◆ append()

void Botan::TLS::Flight::append ( const Handshake_Message & message,
PostHandshake post_handshake )
protectedinherited

Definition at line 42 of file tls_flight_13.cpp.

42 {
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}
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:82
#define BOTAN_STATE_CHECK(expr)
Definition assert.h:49

References BOTAN_ASSERT_NOMSG, BOTAN_STATE_CHECK, and No.

Referenced by add(), add(), Botan::TLS::PostHandshakeFlight::add(), and Botan::TLS::PostHandshakeFlight::add().

◆ append_ccs()

void Botan::TLS::Flight::append_ccs ( )
protectedinherited

Definition at line 55 of file tls_flight_13.cpp.

55 {
56 BOTAN_STATE_CHECK(m_messages.has_value());
57 m_messages->push_back(Dummy_ChangeCipherSpec{});
58}

References BOTAN_STATE_CHECK.

Referenced by add_dummy_change_cipher_spec(), and add_dummy_change_cipher_spec().

◆ commit()

Extract the messages from the flight for sending. This invalidates the flight object and it cannot be used anymore.

Exceptions
Invalid_Stateif the flight was already committed or if it is empty

Definition at line 131 of file tls_flight_13.cpp.

35 {
36 BOTAN_STATE_CHECK(m_messages.has_value());
37 BOTAN_STATE_CHECK(!m_messages->empty());
38
39 return std::exchange(m_messages, {}).value();
40}

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