9#ifndef BOTAN_TLS_SESSION_STATE_H_
10#define BOTAN_TLS_SESSION_STATE_H_
12#include <botan/secmem.h>
13#include <botan/strong_type.h>
14#include <botan/symkey.h>
15#include <botan/tls_ciphersuite.h>
16#include <botan/tls_magic.h>
17#include <botan/tls_server_info.h>
18#include <botan/tls_session_id.h>
19#include <botan/tls_version.h>
48 uint16_t srtp_profile,
49 bool extended_master_secret,
50 bool encrypt_then_mac,
51 const std::vector<X509_Certificate>&
peer_certs,
163 const std::optional<Session_Ticket>&
session_ticket()
const {
return m_session_ticket; }
183 bool psk_used()
const {
return m_external_psk_identity.has_value(); }
192 std::string
kex_algo()
const {
return m_kex_algo; }
210#if defined(BOTAN_HAS_TLS_13)
213 const std::vector<X509_Certificate>&
peer_certs,
215 std::optional<std::string> psk_identity,
216 bool session_was_resumed,
218 std::chrono::system_clock::time_point current_timestamp);
221 void set_session_id(
Session_ID id) { m_session_id = std::move(
id); }
223 void set_session_ticket(
Session_Ticket ticket) { m_session_ticket = std::move(ticket); }
226 Session_ID m_session_id;
227 std::optional<Session_Ticket> m_session_ticket;
228 std::optional<std::string> m_external_psk_identity;
230 bool m_was_resumption;
231 std::string m_kex_algo;
232 std::optional<std::string> m_kex_parameters;
250 const std::vector<X509_Certificate>&
peer_certs,
252 uint16_t srtp_profile,
253 std::chrono::system_clock::time_point current_timestamp,
254 std::chrono::seconds
lifetime_hint = std::chrono::seconds::max());
256#if defined(BOTAN_HAS_TLS_13)
263 uint32_t ticket_age_add,
268 const std::vector<X509_Certificate>&
peer_certs,
271 std::chrono::system_clock::time_point current_timestamp);
280 const std::vector<X509_Certificate>&
peer_certs,
299 explicit Session(std::string_view pem);
335 std::string PEM_encode()
const;
387 static constexpr size_t TLS_SESSION_PARAM_STRUCT_VERSION = 20231031;
391 bool m_early_data_allowed;
392 uint32_t m_max_early_data_bytes;
393 uint32_t m_ticket_age_add;
394 std::chrono::seconds m_lifetime_hint;
#define BOTAN_PUBLIC_API(maj, min)
#define BOTAN_FUTURE_EXPLICIT
std::vector< X509_Certificate > m_peer_certs
Session_Base(std::chrono::system_clock::time_point start_time, Protocol_Version version, uint16_t ciphersuite, Connection_Side connection_side, uint16_t srtp_profile, bool extended_master_secret, bool encrypt_then_mac, const std::vector< X509_Certificate > &peer_certs, std::shared_ptr< const Public_Key > peer_raw_public_key, Server_Information server_info)
std::shared_ptr< const Public_Key > peer_raw_public_key() const
Session_Base & operator=(Session_Base &&other) noexcept
bool m_extended_master_secret
Session_Base(const Session_Base &other)
uint16_t dtls_srtp_profile() const
Protocol_Version version() const
Connection_Side side() const
bool supports_encrypt_then_mac() const
Protocol_Version m_version
std::chrono::system_clock::time_point m_start_time
Server_Information m_server_info
std::chrono::system_clock::time_point start_time() const
uint16_t ciphersuite_code() const
bool supports_extended_master_secret() const
Session_Base(Session_Base &&other) noexcept
Session_Base & operator=(const Session_Base &other)
Ciphersuite ciphersuite() const
const std::vector< X509_Certificate > & peer_certs() const
const Server_Information & server_info() const
std::shared_ptr< const Public_Key > m_peer_raw_public_key
Connection_Side m_connection_side
Helper class to embody a session handle in all protocol versions.
std::string cipher_algo() const
friend class Server_Impl_13
friend class Client_Impl_13
friend class Server_Impl_12
std::string mac_algo() const
bool was_resumption() const
std::string kex_algo() const
const std::optional< Session_Ticket > & session_ticket() const
friend class Client_Impl_12
const std::optional< std::string > & external_psk_identity() const
const Session_ID & session_id() const
std::string prf_algo() const
std::optional< std::string > kex_parameters() const
secure_vector< uint8_t > DER_encode() const
std::vector< uint8_t > encrypt(const SymmetricKey &key, RandomNumberGenerator &rng) const
std::chrono::seconds lifetime_hint() const
static Session decrypt(const uint8_t ctext[], size_t ctext_size, const SymmetricKey &key)
bool supports_early_data() const
uint32_t session_age_add() const
Session(const secure_vector< uint8_t > &master_secret, Protocol_Version version, uint16_t ciphersuite, Connection_Side side, bool supports_extended_master_secret, bool supports_encrypt_then_mac, const std::vector< X509_Certificate > &peer_certs, const Server_Information &server_info, uint16_t srtp_profile, std::chrono::system_clock::time_point current_timestamp, std::chrono::seconds lifetime_hint=std::chrono::seconds::max())
const secure_vector< uint8_t > & master_secret() const
uint32_t max_early_data_bytes() const
Strong< std::vector< uint8_t >, struct Session_ID_ > Session_ID
holds a TLS 1.2 session ID for stateful resumption
Strong< std::vector< uint8_t >, struct Session_Ticket_ > Session_Ticket
holds a TLS 1.2 session ticket for stateless resumption
std::vector< T, secure_allocator< T > > secure_vector