10#include <botan/tls_messages_13.h>
12#include <botan/tls_callbacks.h>
13#include <botan/tls_exceptn.h>
14#include <botan/tls_extensions_13.h>
15#include <botan/tls_session.h>
16#include <botan/internal/loadstor.h>
17#include <botan/internal/tls_reader.h>
25template <
typename lifetime_t = u
int32_t>
26void store_lifetime(std::span<uint8_t> sink, std::chrono::seconds lifetime) {
27 BOTAN_ARG_CHECK(lifetime.count() >= 0 && lifetime.count() <= std::numeric_limits<lifetime_t>::max(),
28 "Ticket lifetime is out of range");
29 store_be(
static_cast<lifetime_t
>(lifetime.count()), sink.data());
39 m_ticket_age_add(session.session_age_add()),
40 m_ticket_nonce(std::move(
nonce)),
41 m_handle(
handle.opaque_handle()) {
48 m_ticket_lifetime_hint = std::chrono::seconds(reader.
get_uint32_t());
53 if(m_ticket_lifetime_hint > std::chrono::days(7)) {
54 throw TLS_Exception(Alert::IllegalParameter,
"Received a session ticket with lifetime longer than one week.");
61 m_extensions.deserialize(reader, from,
type());
67 if(m_extensions.contains_implemented_extensions_other_than({Extension_Code::EarlyData})) {
68 throw TLS_Exception(Alert::IllegalParameter,
"NewSessionTicket message contained unexpected extension");
85 std::vector<uint8_t> result(8);
87 store_lifetime(std::span(result.data(), 4), m_ticket_lifetime_hint);
88 store_be(m_ticket_age_add, result.data() + 4);
93 if(m_extensions.empty()) {
94 result.push_back(0x00);
95 result.push_back(0x00);
#define BOTAN_ASSERT_NOMSG(expr)
#define BOTAN_ARG_CHECK(expr, msg)
virtual void tls_modify_extensions(Extensions &extn, Connection_Side which_side, Handshake_Type which_message)
std::optional< uint32_t > max_early_data_size() const
Handshake_Type type() const override
std::chrono::seconds lifetime_hint() const
std::optional< uint32_t > early_data_byte_limit() const
const Ticket_Nonce & nonce() const
New_Session_Ticket_13(Ticket_Nonce nonce, const Session &session, const Session_Handle &handle, Callbacks &callbacks)
const Opaque_Session_Handle & handle() const
std::vector< uint8_t > serialize() const override
Helper class to embody a session handle in all protocol versions.
std::vector< uint8_t > get_tls_length_value(size_t len_bytes)
void append_tls_length_value(std::vector< uint8_t, Alloc > &buf, const T *vals, size_t vals_size, size_t tag_size)
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...
constexpr auto store_be(ParamTs &&... params)