Botan 3.11.0
Crypto and TLS for C&
tls_session_manager_stateless.h
Go to the documentation of this file.
1/**
2 * TLS Stateless Session Manager for stateless servers
3 * (C) 2023 Jack Lloyd
4 * 2023 René Meusel - Rohde & Schwarz Cybersecurity
5 *
6 * Botan is released under the Simplified BSD License (see license.txt)
7 */
8
9#ifndef BOTAN_TLS_SESSION_MANAGER_STATELESS_H_
10#define BOTAN_TLS_SESSION_MANAGER_STATELESS_H_
11
12#include <botan/tls_session_manager.h>
13
14namespace Botan {
15
18class OctetString;
20
21namespace TLS {
22
23/**
24 * A Session_Manager that emits Session_Handle objects with a Session_Ticket.
25 *
26 * This is useful for servers that do not want to hold any state about resumable
27 * sessions. Using this implementation in a TLS client won't make sense.
28 *
29 * Returned Session_Handle objects won't contain a Session_ID. Retrieving
30 * sessions via Session_ID will never return a session. Neither will searching
31 * sessions by server information yield any result.
32 */
34 public:
35 /**
36 * The key to encrypt and authenticate session information will be drawn
37 * from @p credentials_manager as `psk("tls-server", "session-ticket")`.
38 * It is the responsibility of the calling application to set up its own
39 * Credentials_Manager to provide a suitable key for this purpose.
40 */
41 Session_Manager_Stateless(const std::shared_ptr<Credentials_Manager>& credentials_manager,
42 const std::shared_ptr<RandomNumberGenerator>& rng);
43
44 std::optional<Session_Handle> establish(const Session& session,
45 const std::optional<Session_ID>& id = std::nullopt,
46 bool tls12_no_ticket = false) override;
47
48 void store(const Session& session, const Session_Handle& handle) override;
49
50 size_t remove(const Session_Handle& /*handle*/) override { return 0; }
51
52 size_t remove_all() override { return 0; }
53
54 bool emits_session_tickets() override;
55
56 protected:
57 std::optional<Session> retrieve_one(const Session_Handle& handle) override;
58
59 // Returns empty by default
60 std::vector<Session_with_Handle> find_some(const Server_Information& info, size_t max_sessions_hint) override;
61
62 private:
63 std::optional<SymmetricKey> get_ticket_key() noexcept;
64
65 private:
66 std::shared_ptr<Credentials_Manager> m_credentials_manager;
67};
68
69} // namespace TLS
70
71} // namespace Botan
72
73#endif
#define BOTAN_PUBLIC_API(maj, min)
Definition api.h:21
Helper class to embody a session handle in all protocol versions.
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).
size_t remove(const Session_Handle &) override
BOTAN_FUTURE_EXPLICIT Session_Manager(const std::shared_ptr< RandomNumberGenerator > &rng)
OctetString SymmetricKey
Definition symkey.h:140