Botan 3.4.0
Crypto and TLS for C&
Public Member Functions | Static Public Member Functions | List of all members
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 855 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 943 of file tls_extensions.cpp.

945 {
946 if(message_type == Handshake_Type::NewSessionTicket) {
947 if(extension_size != 4) {
948 throw TLS_Exception(Alert::DecodeError,
949 "Received an early_data extension in a NewSessionTicket message "
950 "without maximum early data size indication");
951 }
952
953 m_max_early_data_size = reader.get_uint32_t();
954 } else if(extension_size != 0) {
955 throw TLS_Exception(Alert::DecodeError,
956 "Received an early_data extension containing an unexpected data "
957 "size indication");
958 }
959}

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

874 :
875 m_max_early_data_size(std::move(max_early_data_size)) {}
std::optional< uint32_t > max_early_data_size() const

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

961 {
962 // This extension may be empty by definition but still carry information
963 return false;
964}

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

116{ return true; }

◆ max_early_data_size()

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

Definition at line 865 of file tls_extensions.h.

865{ return m_max_early_data_size; }

Referenced by Botan::TLS::New_Session_Ticket_13::early_data_byte_limit().

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

931 {
932 std::vector<uint8_t> result;
933 if(m_max_early_data_size.has_value()) {
934 const auto max_data = m_max_early_data_size.value();
935 result.push_back(get_byte<0>(max_data));
936 result.push_back(get_byte<1>(max_data));
937 result.push_back(get_byte<2>(max_data));
938 result.push_back(get_byte<3>(max_data));
939 }
940 return result;
941}

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

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

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