Botan 3.8.1
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 951 of file tls_extensions.cpp.

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

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)
inline

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(std::move(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 969 of file tls_extensions.cpp.

969 {
970 // This extension may be empty by definition but still carry information
971 return false;
972}

◆ 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 939 of file tls_extensions.cpp.

939 {
940 std::vector<uint8_t> result;
941 if(m_max_early_data_size.has_value()) {
942 const auto max_data = m_max_early_data_size.value();
943 result.push_back(get_byte<0>(max_data));
944 result.push_back(get_byte<1>(max_data));
945 result.push_back(get_byte<2>(max_data));
946 result.push_back(get_byte<3>(max_data));
947 }
948 return result;
949}
constexpr uint8_t get_byte(T input)
Definition loadstor.h:79

References Botan::get_byte().

◆ static_type()

static 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: