Botan 3.11.0
Crypto and TLS for C&
Botan::TLS::EarlyDataIndication Class Referencefinal

#include <tls_extensions_13.h>

Inheritance diagram for Botan::TLS::EarlyDataIndication:
Botan::TLS::Extension

Public Member Functions

 EarlyDataIndication (std::optional< uint32_t > max_early_data_size=std::nullopt)
 EarlyDataIndication (TLS_Data_Reader &reader, uint16_t extension_size, Handshake_Type message_type)
bool empty () const override
virtual bool is_implemented () const
std::optional< uint32_t > max_early_data_size () const
std::vector< uint8_t > serialize (Connection_Side whoami) const override
Extension_Code type () const override

Static Public Member Functions

static Extension_Code static_type ()

Detailed Description

Indicates usage or support of early data as described in RFC 8446 4.2.10.

Definition at line 304 of file tls_extensions_13.h.

Constructor & Destructor Documentation

◆ EarlyDataIndication() [1/2]

Botan::TLS::EarlyDataIndication::EarlyDataIndication ( TLS_Data_Reader & reader,
uint16_t extension_size,
Handshake_Type message_type )

Definition at line 139 of file tls_extensions_13.cpp.

141 {
142 if(message_type == Handshake_Type::NewSessionTicket) {
143 if(extension_size != 4) {
144 throw TLS_Exception(Alert::DecodeError,
145 "Received an early_data extension in a NewSessionTicket message "
146 "without maximum early data size indication");
147 }
148
149 m_max_early_data_size = reader.get_uint32_t();
150 } else if(extension_size != 0) {
151 throw TLS_Exception(Alert::DecodeError,
152 "Received an early_data extension containing an unexpected data "
153 "size indication");
154 }
155}

References Botan::TLS::TLS_Data_Reader::get_uint32_t(), and Botan::TLS::NewSessionTicket.

◆ EarlyDataIndication() [2/2]

Botan::TLS::EarlyDataIndication::EarlyDataIndication ( std::optional< uint32_t > max_early_data_size = std::nullopt)
inlineexplicit

The max_early_data_size is exclusively provided by servers when using this extension in the NewSessionTicket message! Otherwise it stays std::nullopt and results in an empty extension. (RFC 8446 4.2.10).

Definition at line 323 of file tls_extensions_13.h.

323 :
324 m_max_early_data_size(max_early_data_size) {}
std::optional< uint32_t > max_early_data_size() const

References max_early_data_size().

Member Function Documentation

◆ empty()

bool Botan::TLS::EarlyDataIndication::empty ( ) const
overridevirtual
Returns
if we should encode this extension or not

Implements Botan::TLS::Extension.

Definition at line 157 of file tls_extensions_13.cpp.

157 {
158 // This extension may be empty by definition but still carry information
159 return false;
160}

◆ is_implemented()

virtual bool Botan::TLS::Extension::is_implemented ( ) const
inlinevirtualinherited
Returns
true if this extension is known and implemented by Botan

Reimplemented in Botan::TLS::Unknown_Extension.

Definition at line 95 of file tls_extensions.h.

95{ return true; }

◆ max_early_data_size()

std::optional< uint32_t > Botan::TLS::EarlyDataIndication::max_early_data_size ( ) const
inline

Definition at line 314 of file tls_extensions_13.h.

314{ return m_max_early_data_size; }

Referenced by Botan::TLS::New_Session_Ticket_13::early_data_byte_limit(), and EarlyDataIndication().

◆ serialize()

std::vector< uint8_t > Botan::TLS::EarlyDataIndication::serialize ( Connection_Side whoami) const
overridevirtual
Returns
serialized binary for the extension

Implements Botan::TLS::Extension.

Definition at line 127 of file tls_extensions_13.cpp.

127 {
128 std::vector<uint8_t> result;
129 if(m_max_early_data_size.has_value()) {
130 const auto max_data = m_max_early_data_size.value();
131 result.push_back(get_byte<0>(max_data));
132 result.push_back(get_byte<1>(max_data));
133 result.push_back(get_byte<2>(max_data));
134 result.push_back(get_byte<3>(max_data));
135 }
136 return result;
137}
constexpr uint8_t get_byte(T input)
Definition loadstor.h:79

References Botan::get_byte().

◆ static_type()

Extension_Code Botan::TLS::EarlyDataIndication::static_type ( )
inlinestatic

◆ type()

Extension_Code Botan::TLS::EarlyDataIndication::type ( ) const
inlineoverridevirtual
Returns
code number of the extension

Implements Botan::TLS::Extension.

Definition at line 308 of file tls_extensions_13.h.

308{ return static_type(); }
static Extension_Code static_type()

References static_type().


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