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