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

#include <tls_extensions.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 854 of file tls_extensions.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 954 of file tls_extensions.cpp.

956 {
957 if(message_type == Handshake_Type::NewSessionTicket) {
958 if(extension_size != 4) {
959 throw TLS_Exception(Alert::DecodeError,
960 "Received an early_data extension in a NewSessionTicket message "
961 "without maximum early data size indication");
962 }
963
964 m_max_early_data_size = reader.get_uint32_t();
965 } else if(extension_size != 0) {
966 throw TLS_Exception(Alert::DecodeError,
967 "Received an early_data extension containing an unexpected data "
968 "size indication");
969 }
970}

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

873 :
874 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 972 of file tls_extensions.cpp.

972 {
973 // This extension may be empty by definition but still carry information
974 return false;
975}

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

115{ return true; }

◆ max_early_data_size()

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

Definition at line 864 of file tls_extensions.h.

864{ 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 942 of file tls_extensions.cpp.

942 {
943 std::vector<uint8_t> result;
944 if(m_max_early_data_size.has_value()) {
945 const auto max_data = m_max_early_data_size.value();
946 result.push_back(get_byte<0>(max_data));
947 result.push_back(get_byte<1>(max_data));
948 result.push_back(get_byte<2>(max_data));
949 result.push_back(get_byte<3>(max_data));
950 }
951 return result;
952}
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 858 of file tls_extensions.h.

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

References static_type().


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