Botan 3.4.0
Crypto and TLS for C&
Public Member Functions | List of all members
Botan::TLS::New_Session_Ticket_13 Class Referencefinal

#include <tls_messages.h>

Inheritance diagram for Botan::TLS::New_Session_Ticket_13:
Botan::TLS::Handshake_Message

Public Member Functions

std::optional< uint32_t > early_data_byte_limit () const
 
const Extensionsextensions () const
 
const Opaque_Session_Handlehandle () const
 
std::chrono::seconds lifetime_hint () const
 
 New_Session_Ticket_13 (const std::vector< uint8_t > &buf, Connection_Side from)
 
 New_Session_Ticket_13 (Ticket_Nonce nonce, const Session &session, const Session_Handle &handle, Callbacks &callbacks)
 
const Ticket_Noncenonce () const
 
std::vector< uint8_t > serialize () const override
 
uint32_t ticket_age_add () const
 
Handshake_Type type () const override
 
std::string type_string () const
 
virtual Handshake_Type wire_type () const
 

Detailed Description

Definition at line 968 of file tls_messages.h.

Constructor & Destructor Documentation

◆ New_Session_Ticket_13() [1/2]

Botan::TLS::New_Session_Ticket_13::New_Session_Ticket_13 ( Ticket_Nonce nonce,
const Session & session,
const Session_Handle & handle,
Callbacks & callbacks )

Definition at line 69 of file msg_session_ticket.cpp.

72 :
73 m_ticket_lifetime_hint(session.lifetime_hint()),
74 m_ticket_age_add(session.session_age_add()),
75 m_ticket_nonce(std::move(nonce)),
76 m_handle(handle.opaque_handle()) {
77 callbacks.tls_modify_extensions(m_extensions, Connection_Side::Server, type());
78}
Handshake_Type type() const override
const Ticket_Nonce & nonce() const
const Opaque_Session_Handle & handle() const

References Botan::TLS::Server, Botan::TLS::Callbacks::tls_modify_extensions(), and type().

◆ New_Session_Ticket_13() [2/2]

Botan::TLS::New_Session_Ticket_13::New_Session_Ticket_13 ( const std::vector< uint8_t > & buf,
Connection_Side from )

Definition at line 80 of file msg_session_ticket.cpp.

80 {
81 TLS_Data_Reader reader("New_Session_Ticket_13", buf);
82
83 m_ticket_lifetime_hint = std::chrono::seconds(reader.get_uint32_t());
84
85 // RFC 8446 4.6.1
86 // Servers MUST NOT use any value [of ticket_lifetime] greater than 604800
87 // seconds (7 days).
88 if(m_ticket_lifetime_hint > std::chrono::days(7)) {
89 throw TLS_Exception(Alert::IllegalParameter, "Received a session ticket with lifetime longer than one week.");
90 }
91
92 m_ticket_age_add = reader.get_uint32_t();
93 m_ticket_nonce = Ticket_Nonce(reader.get_tls_length_value(1));
94 m_handle = Opaque_Session_Handle(reader.get_tls_length_value(2));
95
96 m_extensions.deserialize(reader, from, type());
97
98 // RFC 8446 4.6.1
99 // The sole extension currently defined for NewSessionTicket is
100 // "early_data", indicating that the ticket may be used to send 0-RTT
101 // data [...]. Clients MUST ignore unrecognized extensions.
102 if(m_extensions.contains_implemented_extensions_other_than({Extension_Code::EarlyData})) {
103 throw TLS_Exception(Alert::IllegalParameter, "NewSessionTicket message contained unexpected extension");
104 }
105
106 reader.assert_done();
107}
bool contains_implemented_extensions_other_than(const std::set< Extension_Code > &allowed_extensions) const
void deserialize(TLS_Data_Reader &reader, Connection_Side from, Handshake_Type message_type)
Strong< std::vector< uint8_t >, struct Ticket_Nonce_ > Ticket_Nonce
Used to derive the ticket's PSK from the resumption_master_secret.
Strong< std::vector< uint8_t >, struct Opaque_Session_Handle_ > Opaque_Session_Handle
holds an opaque session handle as used in TLS 1.3 that could be either a ticket for stateless resumpt...
Definition tls_session.h:39

References Botan::TLS::TLS_Data_Reader::assert_done(), Botan::TLS::Extensions::contains_implemented_extensions_other_than(), Botan::TLS::Extensions::deserialize(), Botan::TLS::TLS_Data_Reader::get_tls_length_value(), Botan::TLS::TLS_Data_Reader::get_uint32_t(), and type().

Member Function Documentation

◆ early_data_byte_limit()

std::optional< uint32_t > Botan::TLS::New_Session_Ticket_13::early_data_byte_limit ( ) const
Returns
the number of bytes allowed for early data or std::nullopt when early data is not allowed at all

Definition at line 109 of file msg_session_ticket.cpp.

109 {
110 if(!m_extensions.has<EarlyDataIndication>()) {
111 return std::nullopt;
112 }
113
114 const EarlyDataIndication* ext = m_extensions.get<EarlyDataIndication>();
115 BOTAN_ASSERT_NOMSG(ext->max_early_data_size().has_value());
116 return ext->max_early_data_size().value();
117}
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:59

References BOTAN_ASSERT_NOMSG, Botan::TLS::Extensions::get(), Botan::TLS::Extensions::has(), and Botan::TLS::EarlyDataIndication::max_early_data_size().

◆ extensions()

const Extensions & Botan::TLS::New_Session_Ticket_13::extensions ( ) const
inline

Definition at line 981 of file tls_messages.h.

981{ return m_extensions; }

◆ handle()

const Opaque_Session_Handle & Botan::TLS::New_Session_Ticket_13::handle ( ) const
inline

Definition at line 983 of file tls_messages.h.

983{ return m_handle; }

◆ lifetime_hint()

std::chrono::seconds Botan::TLS::New_Session_Ticket_13::lifetime_hint ( ) const
inline

Definition at line 989 of file tls_messages.h.

989{ return m_ticket_lifetime_hint; }

◆ nonce()

const Ticket_Nonce & Botan::TLS::New_Session_Ticket_13::nonce ( ) const
inline

Definition at line 985 of file tls_messages.h.

985{ return m_ticket_nonce; }

◆ serialize()

std::vector< uint8_t > Botan::TLS::New_Session_Ticket_13::serialize ( ) const
overridevirtual
Returns
DER representation of this message

Implements Botan::TLS::Handshake_Message.

Definition at line 119 of file msg_session_ticket.cpp.

119 {
120 std::vector<uint8_t> result(8);
121
122 store_lifetime(std::span(result.data(), 4), m_ticket_lifetime_hint);
123 store_be(m_ticket_age_add, result.data() + 4);
124 append_tls_length_value(result, m_ticket_nonce.get(), 1);
125 append_tls_length_value(result, m_handle.get(), 2);
126
127 // TODO: re-evaluate this construction when reworking message marshalling
128 if(m_extensions.empty()) {
129 result.push_back(0x00);
130 result.push_back(0x00);
131 } else {
132 result += m_extensions.serialize(Connection_Side::Server);
133 }
134
135 return result;
136}
std::vector< uint8_t > serialize(Connection_Side whoami) const
void append_tls_length_value(std::vector< uint8_t, Alloc > &buf, const T *vals, size_t vals_size, size_t tag_size)
Definition tls_reader.h:180
constexpr auto store_be(ParamTs &&... params)
Definition loadstor.h:711

References Botan::TLS::append_tls_length_value(), Botan::TLS::Extensions::empty(), Botan::detail::Strong_Base< T >::get(), Botan::TLS::Extensions::serialize(), Botan::TLS::Server, and Botan::store_be().

◆ ticket_age_add()

uint32_t Botan::TLS::New_Session_Ticket_13::ticket_age_add ( ) const
inline

Definition at line 987 of file tls_messages.h.

987{ return m_ticket_age_add; }

◆ type()

Handshake_Type Botan::TLS::New_Session_Ticket_13::type ( ) const
inlineoverridevirtual
Returns
the message type

Implements Botan::TLS::Handshake_Message.

Definition at line 970 of file tls_messages.h.

Referenced by New_Session_Ticket_13(), and New_Session_Ticket_13().

◆ type_string()

std::string Botan::TLS::Handshake_Message::type_string ( ) const
inherited
Returns
string representation of this message type

Definition at line 19 of file tls_handshake_state.cpp.

19 {
21}
virtual Handshake_Type type() const =0
const char * handshake_type_to_string(Handshake_Type type)

References Botan::TLS::handshake_type_to_string(), and Botan::TLS::Handshake_Message::type().

◆ wire_type()

virtual Handshake_Type Botan::TLS::Handshake_Message::wire_type ( ) const
inlinevirtualinherited
Returns
the wire representation of the message's type

Reimplemented in Botan::TLS::Hello_Retry_Request.

Definition at line 39 of file tls_handshake_msg.h.

39 {
40 // Usually equal to the Handshake_Type enum value,
41 // with the exception of TLS 1.3 Hello Retry Request.
42 return type();
43 }

Referenced by Botan::TLS::Stream_Handshake_IO::send().


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