Botan 3.11.0
Crypto and TLS for C&
tls_psk_identity_13.h
Go to the documentation of this file.
1/**
2 * Wrapper type for a TLS 1.3 session ticket
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_13_TICKET_H_
10#define BOTAN_TLS_13_TICKET_H_
11
12#include <botan/strong_type.h>
13#include <botan/tls_external_psk.h>
14#include <botan/tls_session.h> // TODO remove this dep
15#include <botan/types.h>
16#include <chrono>
17#include <vector>
18
19namespace Botan::TLS {
20
21/// @brief holds a PSK identity as used in TLS 1.3
23
24/**
25 * Represents a TLS 1.3 PSK identity as found in the Preshared Key extension
26 * with an opaque identity and an associated (obfuscated) ticket age. The latter
27 * is not applicable for externally provided PSKs.
28 */
30 public:
31 /**
32 * Construct from information provided in the peer's ClientHello
33 */
34 PskIdentity(std::vector<uint8_t> identity, const uint32_t obfuscated_age) :
35 m_identity(std::move(identity)), m_obfuscated_age(obfuscated_age) {}
36
37 /**
38 * Construct from a session stored by the client
39 */
40 PskIdentity(Opaque_Session_Handle identity, std::chrono::milliseconds age, uint32_t ticket_age_add);
41
42 /**
43 * Construct from an externally provided PSK in the client
44 */
46
47 const std::vector<uint8_t>& identity() const { return m_identity; }
48
49 std::string identity_as_string() const;
50
51 /**
52 * If this represents a PSK for session resumption, it returns the
53 * session's age given the de-obfuscation parameter @p ticket_age_add. For
54 * externally provided PSKs this method does not provide any meaningful
55 * information.
56 */
57 std::chrono::milliseconds age(uint32_t ticket_age_add) const;
58
59 uint32_t obfuscated_age() const { return m_obfuscated_age; }
60
61 private:
62 std::vector<uint8_t> m_identity;
63 uint32_t m_obfuscated_age;
64};
65
66/**
67 * Botan 3.0.0 used the class name "Ticket". In Botan 3.1.0 we decided to
68 * re-name it to the more generic term "PskIdentity" to better reflect its dual
69 * use case for resumption and externally provided PSKs.
70 */
71BOTAN_DEPRECATED("Use PskIdentity") typedef PskIdentity Ticket;
72
73} // namespace Botan::TLS
74
75#endif
#define BOTAN_PUBLIC_API(maj, min)
Definition api.h:21
#define BOTAN_DEPRECATED(msg)
Definition api.h:73
#define BOTAN_FUTURE_EXPLICIT
Definition api.h:52
PskIdentity(std::vector< uint8_t > identity, const uint32_t obfuscated_age)
uint32_t obfuscated_age() const
const std::vector< uint8_t > & identity() const
Strong< std::string, struct PresharedKeyID_ > PresharedKeyID
holds a PSK identity as used in TLS 1.3
PskIdentity Ticket
Strong< std::vector< uint8_t >, struct Opaque_Session_Handle_ > Opaque_Session_Handle
holds an opaque session handle as used in TLS 1.3 that could be either a ticket for stateless resumpt...