Botan 3.6.1
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)
 
 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

◆ 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 28 of file tls_psk_identity_13.cpp.

30 :
31 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)

◆ PskIdentity() [3/3]

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

Construct from an externally provided PSK in the client

Definition at line 33 of file tls_psk_identity_13.cpp.

33 :
34 m_identity(to_byte_vector(identity.get())),
35
36 // RFC 8446 4.2.11
37 // For identities established externally, an obfuscated_ticket_age of
38 // 0 SHOULD be used, and servers MUST ignore the value.
39 m_obfuscated_age(0) {}
T to_byte_vector(std::string_view s)
Definition stl_util.h:29

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 41 of file tls_psk_identity_13.cpp.

41 {
42 return std::chrono::milliseconds(obfuscate_ticket_age(m_obfuscated_age, ticket_age_add));
43}

◆ 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; }

◆ identity_as_string()

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

Definition at line 45 of file tls_psk_identity_13.cpp.

45 {
46 return Botan::to_string(m_identity);
47}
std::string to_string(ErrorType type)
Convert an ErrorType to string.
Definition exceptn.cpp:13

References Botan::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; }

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