Botan 3.9.0
Crypto and TLS for C&
Botan::TLS::PskIdentity Class Reference

#include <tls_psk_identity_13.h>

Public Member Functions

std::chrono::milliseconds age (uint32_t ticket_age_add) const
const std::vector< uint8_t > & identity () const
std::string identity_as_string () const
uint32_t obfuscated_age () const
 PskIdentity (Opaque_Session_Handle identity, std::chrono::milliseconds age, uint32_t ticket_age_add)
BOTAN_FUTURE_EXPLICIT PskIdentity (PresharedKeyID identity)
 PskIdentity (std::vector< uint8_t > identity, const uint32_t obfuscated_age)

Detailed Description

Represents a TLS 1.3 PSK identity as found in the Preshared Key extension with an opaque identity and an associated (obfuscated) ticket age. The latter is not applicable for externally provided PSKs.

Definition at line 30 of file tls_psk_identity_13.h.

Constructor & Destructor Documentation

◆ PskIdentity() [1/3]

Botan::TLS::PskIdentity::PskIdentity ( std::vector< uint8_t > identity,
const uint32_t obfuscated_age )
inline

Construct from information provided in the peer's ClientHello

Definition at line 35 of file tls_psk_identity_13.h.

35 :
36 m_identity(std::move(identity)), m_obfuscated_age(obfuscated_age) {}
uint32_t obfuscated_age() const
const std::vector< uint8_t > & identity() const

References identity(), and obfuscated_age().

Referenced by PskIdentity().

◆ PskIdentity() [2/3]

Botan::TLS::PskIdentity::PskIdentity ( Opaque_Session_Handle identity,
std::chrono::milliseconds age,
uint32_t ticket_age_add )

Construct from a session stored by the client

Definition at line 32 of file tls_psk_identity_13.cpp.

34 :
35 PskIdentity(std::move(identity.get()), obfuscate_ticket_age(age.count(), ticket_age_add)) {}
std::chrono::milliseconds age(uint32_t ticket_age_add) const
PskIdentity(std::vector< uint8_t > identity, const uint32_t obfuscated_age)

References age(), identity(), and PskIdentity().

◆ PskIdentity() [3/3]

Botan::TLS::PskIdentity::PskIdentity ( PresharedKeyID identity)

Construct from an externally provided PSK in the client

Definition at line 37 of file tls_psk_identity_13.cpp.

37 :
38 m_identity(to_byte_vector(identity.get())),
39
40 // RFC 8446 4.2.11
41 // For identities established externally, an obfuscated_ticket_age of
42 // 0 SHOULD be used, and servers MUST ignore the value.
43 m_obfuscated_age(0) {}

References identity().

Member Function Documentation

◆ age()

std::chrono::milliseconds Botan::TLS::PskIdentity::age ( uint32_t ticket_age_add) const

If this represents a PSK for session resumption, it returns the session's age given the de-obfuscation parameter ticket_age_add. For externally provided PSKs this method does not provide any meaningful information.

Definition at line 45 of file tls_psk_identity_13.cpp.

45 {
46 return std::chrono::milliseconds(obfuscate_ticket_age(m_obfuscated_age, ticket_age_add));
47}

Referenced by PskIdentity().

◆ identity()

const std::vector< uint8_t > & Botan::TLS::PskIdentity::identity ( ) const
inline

Definition at line 48 of file tls_psk_identity_13.h.

48{ return m_identity; }

Referenced by PskIdentity(), PskIdentity(), and PskIdentity().

◆ identity_as_string()

std::string Botan::TLS::PskIdentity::identity_as_string ( ) const

Definition at line 49 of file tls_psk_identity_13.cpp.

49 {
50 return bytes_to_string(m_identity);
51}
std::string bytes_to_string(std::span< const uint8_t > bytes)
Definition mem_utils.h:45

References Botan::bytes_to_string().

◆ obfuscated_age()

uint32_t Botan::TLS::PskIdentity::obfuscated_age ( ) const
inline

Definition at line 60 of file tls_psk_identity_13.h.

60{ return m_obfuscated_age; }

Referenced by PskIdentity().


The documentation for this class was generated from the following files: