Botan 3.3.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
16class RandomNumberGenerator;
17class Credentials_Manager;
18
19namespace TLS {
20
21/**
22 * A Session_Manager that emits Session_Handle objects with a Session_Ticket.
23 *
24 * This is useful for servers that do not want to hold any state about resumable
25 * sessions. Using this implementation in a TLS client won't make sense.
26 *
27 * Returned Session_Handle objects won't contain a Session_ID. Retrieving
28 * sessions via Session_ID will never return a session. Neither will searching
29 * sessions by server information yield any result.
30 */
32 public:
33 /**
34 * The key to encrypt and authenticate session information will be drawn
35 * from @p credentials_manager as `psk("tls-server", "session-ticket")`.
36 * It is the responsibility of the calling application to set up its own
37 * Credentials_Manager to provide a suitable key for this purpose.
38 */
39 Session_Manager_Stateless(const std::shared_ptr<Credentials_Manager>& credentials_manager,
40 const std::shared_ptr<RandomNumberGenerator>& rng);
41
42 std::optional<Session_Handle> establish(const Session& session,
43 const std::optional<Session_ID>& id = std::nullopt,
44 bool tls12_no_ticket = false) override;
45
46 void store(const Session& session, const Session_Handle& handle) override;
47
48 size_t remove(const Session_Handle&) override { return 0; }
49
50 size_t remove_all() override { return 0; }
51
52 bool emits_session_tickets() override;
53
54 protected:
55 std::optional<Session> retrieve_one(const Session_Handle& handle) override;
56
57 std::vector<Session_with_Handle> find_some(const Server_Information&, const size_t) override { return {}; }
58
59 private:
60 std::optional<SymmetricKey> get_ticket_key() noexcept;
61
62 private:
63 std::shared_ptr<Credentials_Manager> m_credentials_manager;
64};
65
66} // namespace TLS
67
68} // namespace Botan
69
70#endif
Helper class to embody a session handle in all protocol versions.
Definition tls_session.h:64
std::vector< Session_with_Handle > find_some(const Server_Information &, const size_t) override
Internal retrieval function to find sessions to resume.
size_t remove(const Session_Handle &) override
#define BOTAN_PUBLIC_API(maj, min)
Definition compiler.h:31