9#include <botan/tls_session_manager_stateless.h>
11#include <botan/credentials_manager.h>
12#include <botan/exceptn.h>
15#include <botan/internal/stl_util.h>
20 const std::shared_ptr<RandomNumberGenerator>& rng) :
26 const std::optional<Session_ID>&,
27 bool tls12_no_ticket) {
33 const auto key = get_ticket_key();
34 if(!key.has_value()) {
42 throw Invalid_Argument(
"A stateless Session Manager cannot store Sessions with their handle");
46 auto ticket = handle.
ticket();
47 if(!ticket.has_value()) {
51 const auto key = get_ticket_key();
52 if(!key.has_value()) {
58 }
catch(
const std::exception&) {
67 return get_ticket_key().has_value();
70std::optional<SymmetricKey> Session_Manager_Stateless::get_ticket_key() noexcept {
72 auto key = m_credentials_manager->psk(
"tls-server",
"session-ticket",
"");
#define BOTAN_ASSERT_NONNULL(ptr)
#define BOTAN_ASSERT(expr, assertion_made)
Connection_Side side() const
Helper class to embody a session handle in all protocol versions.
std::optional< Session_Ticket > ticket() const
Session_Manager_Stateless(const std::shared_ptr< Credentials_Manager > &credentials_manager, const std::shared_ptr< RandomNumberGenerator > &rng)
std::optional< Session_Handle > establish(const Session &session, const std::optional< Session_ID > &id=std::nullopt, bool tls12_no_ticket=false) override
Save a new Session and assign a Session_Handle (TLS Server)
void store(const Session &session, const Session_Handle &handle) override
Save a Session under a Session_Handle (TLS Client)
bool emits_session_tickets() override
std::optional< Session > retrieve_one(const Session_Handle &handle) override
Internal retrieval function for a single session.
std::shared_ptr< RandomNumberGenerator > m_rng
std::vector< uint8_t > encrypt(const SymmetricKey &key, RandomNumberGenerator &rng) const
static Session decrypt(const uint8_t ctext[], size_t ctext_size, const SymmetricKey &key)