Botan 3.6.1
Crypto and TLS for C&
|
#include <tls_session_manager_noop.h>
Public Member Functions | |
virtual std::optional< std::pair< Session, uint16_t > > | choose_from_offered_tickets (const std::vector< PskIdentity > &tickets, std::string_view hash_function, Callbacks &callbacks, const Policy &policy) |
virtual bool | emits_session_tickets () |
std::optional< Session_Handle > | establish (const Session &, const std::optional< Session_ID > &=std::nullopt, bool=false) override |
Save a new Session and assign a Session_Handle (TLS Server) | |
virtual std::vector< Session_with_Handle > | find (const Server_Information &info, Callbacks &callbacks, const Policy &policy) |
Find all sessions that match a given server info . | |
size_t | remove (const Session_Handle &) override |
size_t | remove_all () override |
virtual std::optional< Session > | retrieve (const Session_Handle &handle, Callbacks &callbacks, const Policy &policy) |
Retrieves a specific session given a handle . | |
Session_Manager_Noop () | |
void | store (const Session &, const Session_Handle &) override |
Save a Session under a Session_Handle (TLS Client) | |
Protected Member Functions | |
std::vector< Session_with_Handle > | find_some (const Server_Information &, const size_t) override |
Internal retrieval function to find sessions to resume. | |
recursive_mutex_type & | mutex () |
std::optional< Session > | retrieve_one (const Session_Handle &) override |
Internal retrieval function for a single session. | |
Protected Attributes | |
std::shared_ptr< RandomNumberGenerator > | m_rng |
An implementation of Session_Manager that does not save sessions at all, preventing session resumption.
For applications that do not want to support session resumption at all, this is typically a good choice.
Definition at line 23 of file tls_session_manager_noop.h.
Botan::TLS::Session_Manager_Noop::Session_Manager_Noop | ( | ) |
Definition at line 15 of file tls_session_manager_noop.cpp.
|
virtualinherited |
Lets the server application choose a PSK to use for a new TLS connection. Implementers must make sure that the PSK's associated hash function is equal to the passed hash_function
.
RFC 8446 4.2.11 The server MUST ensure that it selects a compatible PSK (if any) and cipher suite.
The default implementation simply tries to retrieve all tickets in the order offered by the peer and picks the first that is found and features a matching hash algorithm.
This method is called only by TLS 1.3 servers.
tickets | a list of tickets that were offered by the client |
hash_function | the hash algorithm name we are going to use for the to-be-negotiated connection |
callbacks | callbacks to be used for session policy decisions |
policy | policy to be used for session policy decisions |
Definition at line 206 of file tls_session_manager.cpp.
Referenced by Botan::TLS::PSK::select_offered_psk().
|
inlinevirtualinherited |
Declares whether the given Session_Manager implementation may emit session tickets. Note that this does not mean that the implementation must always emit tickets.
Concrete implementations should declare this, to allow the TLS implementations to act accordingly. E.g. to advertise support for session tickets in their Server Hello.
Reimplemented in Botan::TLS::Session_Manager_Hybrid, Botan::TLS::Session_Manager_In_Memory, Botan::TLS::Session_Manager_SQL, and Botan::TLS::Session_Manager_Stateless.
Definition at line 214 of file tls_session_manager.h.
|
inlineoverridevirtual |
Save a new Session and assign a Session_Handle (TLS Server)
Save a new session on a best effort basis; the manager may not in fact be able to save the session for whatever reason; this is not an error. Callers cannot assume that calling establish() followed immediately by retrieve() or choose_from_offered_tickets() will result in a successful lookup. In case no session was stored, std::nullopt is returned.
This method is only called on TLS servers.
Note that implementations will silently refrain from sending session tickets to the client when this method returns std::nullopt.
session | to save |
id | to use (instead of an ID chosen by the manager) |
tls12_no_ticket | disable tickets for this establishment (set when TLS 1.2 client does not support them) |
Reimplemented from Botan::TLS::Session_Manager.
Definition at line 27 of file tls_session_manager_noop.h.
|
virtualinherited |
Find all sessions that match a given server info
.
TLS clients use this to obtain session resumption information for a server they are wishing to handshake with. Typically, session info will have been received in prior connections to that same server and stored using Session_Manager::store().
The default implementation will invoke Session_Manager::find_some() and filter the result against a policy. Most notably an expiry check. Expired sessions will be removed via Session_Manager::remove().
The TLS client implementations will query the session manager exactly once per handshake attempt. If no reuse is desired, the session manager may remove the sessions internally when handing them out to the client. The default implementation adheres to Policy::reuse_session_tickets().
For TLS 1.2 the client implementation will attempt a resumption with the first session in the returned list. For TLS 1.3, it will offer all found sessions to the server.
Applications that wish to implement their own Session_Manager may override the default implementation to add further policy checks. Though, typically implementing Session_Manager::find_some() and relying on the default implementation is enough.
info | the info about the server we want to handshake with |
callbacks | callbacks to be used for session policy decisions |
policy | policy to be used for session policy decisions |
Reimplemented in Botan::TLS::Session_Manager_Hybrid.
Definition at line 161 of file tls_session_manager.cpp.
References BOTAN_ASSERT_NOMSG, Botan::TLS::Policy::maximum_session_tickets_per_client_hello(), and Botan::TLS::Policy::reuse_session_tickets().
|
inlineoverrideprotectedvirtual |
Internal retrieval function to find sessions to resume.
Try to find saved sessions using info about the server we're planning to connect to. It should return a list of sessions in preference order of the session manager.
Applications that wish to implement their own Session_Manager will have to provide an implementation for it.
Note that the TLS client implementations do not perform any checks on the validity of the session for a given info
. Particularly, it is the Session_Manager's responsibility to ensure the restrictions posed in RFC 8446 4.6.1 regarding server certificate validity for the given info
.
This is called for TLS clients only.
info | the information about the server |
max_sessions_hint | a non-binding guideline for an upper bound of sessions to return from this method (will be at least 1 but potentially more) |
Implements Botan::TLS::Session_Manager.
Definition at line 42 of file tls_session_manager_noop.h.
|
inlineprotectedinherited |
Returns the base class' recursive mutex for reuse in derived classes
Definition at line 267 of file tls_session_manager.h.
Referenced by Botan::TLS::Session_Manager_In_Memory::find_some(), Botan::TLS::Session_Manager_SQL::find_some(), Botan::TLS::Session_Manager_In_Memory::remove(), Botan::TLS::Session_Manager_SQL::remove(), Botan::TLS::Session_Manager_In_Memory::remove_all(), Botan::TLS::Session_Manager_SQL::remove_all(), Botan::TLS::Session_Manager_In_Memory::retrieve_one(), Botan::TLS::Session_Manager_SQL::retrieve_one(), Botan::TLS::Session_Manager_In_Memory::store(), and Botan::TLS::Session_Manager_SQL::store().
|
inlineoverridevirtual |
Remove a specific session from the cache, if it exists. The handle might contain either a session ID or a ticket.
handle | a Session_Handle of the session to be removed |
Implements Botan::TLS::Session_Manager.
Definition at line 35 of file tls_session_manager_noop.h.
|
inlineoverridevirtual |
Remove all sessions from the cache
Implements Botan::TLS::Session_Manager.
Definition at line 37 of file tls_session_manager_noop.h.
|
virtualinherited |
Retrieves a specific session given a handle
.
This is typically used by TLS servers to obtain resumption information for a previous call to Session_Manager::establish() when a client requested resumption using the handle
.
Even if the session is found successfully, it is returned only if it passes policy validations. Most notably an expiry check. If the expiry check fails, the default implementation calls Session_Manager::remove() for the provided handle
.
Applications that wish to implement their own Session_Manager may override the default implementation to add further policy checks. Though, typically implementing Session_Manager::retrieve_one() and relying on the default implementation is enough.
handle | the Session_Handle to be retrieved |
callbacks | callbacks to be used for session policy decisions |
policy | policy to be used for session policy decisions |
Reimplemented in Botan::TLS::Session_Manager_Hybrid.
Definition at line 36 of file tls_session_manager.cpp.
References Botan::TLS::Session_Manager::remove(), Botan::TLS::Session_Manager::retrieve_one(), Botan::TLS::Policy::session_ticket_lifetime(), and Botan::TLS::Callbacks::tls_current_timestamp().
|
inlineoverrideprotectedvirtual |
Internal retrieval function for a single session.
Try to obtain a Session from a Session_Handle that contains either a session ID or a session ticket. This method should not apply any policy decision (such as ticket expiry) but simply be a storage interface.
Applications that wish to implement their own Session_Manager will have to provide an implementation for it.
This method is called only by servers.
handle | a Session_Handle containing either an ID or a ticket |
Implements Botan::TLS::Session_Manager.
Definition at line 40 of file tls_session_manager_noop.h.
|
inlineoverridevirtual |
Save a Session under a Session_Handle (TLS Client)
Save a session on a best effort basis; the manager may not in fact be able to save the session for whatever reason; this is not an error. Callers cannot assume that calling store() followed immediately by find() will result in a successful lookup.
In contrast to establish(), this stores sessions that were created by the server along with a Session_Handle also coined by the server.
This method is only called on TLS clients.
session | to save |
handle | a Session_Handle on which this session shoud by stored |
Implements Botan::TLS::Session_Manager.
Definition at line 33 of file tls_session_manager_noop.h.
|
protectedinherited |
Definition at line 275 of file tls_session_manager.h.
Referenced by Botan::TLS::Session_Manager::establish(), Botan::TLS::Session_Manager_Stateless::establish(), Botan::TLS::Session_Manager::Session_Manager(), Botan::TLS::Session_Manager_In_Memory::store(), and Botan::TLS::Session_Manager_SQL::store().