Botan 3.12.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 147 of file tls_extensions_13.cpp.

149 {
150 if(message_type == Handshake_Type::NewSessionTicket) {
151 if(extension_size != 4) {
152 throw TLS_Exception(Alert::DecodeError,
153 "Received an early_data extension in a NewSessionTicket message "
154 "without maximum early data size indication");
155 }
156
157 m_max_early_data_size = reader.get_uint32_t();
158 } else if(extension_size != 0) {
159 throw TLS_Exception(Alert::DecodeError,
160 "Received an early_data extension containing an unexpected data "
161 "size indication");
162 }
163}

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 165 of file tls_extensions_13.cpp.

165 {
166 // This extension may be empty by definition but still carry information
167 return false;
168}

◆ 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 100 of file tls_extensions.h.

100{ 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 135 of file tls_extensions_13.cpp.

135 {
136 std::vector<uint8_t> result;
137 if(m_max_early_data_size.has_value()) {
138 const auto max_data = m_max_early_data_size.value();
139 result.push_back(get_byte<0>(max_data));
140 result.push_back(get_byte<1>(max_data));
141 result.push_back(get_byte<2>(max_data));
142 result.push_back(get_byte<3>(max_data));
143 }
144 return result;
145}
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: