Botan 3.12.0
Crypto and TLS for C&
Botan::TLS::ExternalPSK Class Referencefinal

#include <tls_external_psk.h>

Public Member Functions

 ExternalPSK (const ExternalPSK &)=delete
 ExternalPSK (ExternalPSK &&)=default
 ExternalPSK (std::string_view identity, std::string_view prf_algo, secure_vector< uint8_t > psk)
 ExternalPSK (std::string_view identity, std::string_view prf_algo, secure_vector< uint8_t > psk, bool imported)
secure_vector< uint8_t > extract_master_secret ()
const std::string & identity () const
bool is_imported () const
ExternalPSKoperator= (const ExternalPSK &)=delete
ExternalPSKoperator= (ExternalPSK &&)=default
const std::string & prf_algo () const
 ~ExternalPSK ()=default

Detailed Description

This is an externally provided PreSharedKey along with its identity, master secret and (in case of TLS 1.3) a pre-provisioned Pseudo Random Function.

Definition at line 22 of file tls_external_psk.h.

Constructor & Destructor Documentation

◆ ExternalPSK() [1/4]

Botan::TLS::ExternalPSK::ExternalPSK ( const ExternalPSK & )
delete

◆ ExternalPSK() [2/4]

Botan::TLS::ExternalPSK::ExternalPSK ( ExternalPSK && )
default

References ExternalPSK().

◆ ~ExternalPSK()

Botan::TLS::ExternalPSK::~ExternalPSK ( )
default

◆ ExternalPSK() [3/4]

Botan::TLS::ExternalPSK::ExternalPSK ( std::string_view identity,
std::string_view prf_algo,
secure_vector< uint8_t > psk )
inline

Definition at line 30 of file tls_external_psk.h.

30 :
31 m_identity(identity), m_prf_algo(prf_algo), m_master_secret(std::move(psk)), m_is_imported(false) {}
const std::string & prf_algo() const
const std::string & identity() const

References identity(), and prf_algo().

◆ ExternalPSK() [4/4]

Botan::TLS::ExternalPSK::ExternalPSK ( std::string_view identity,
std::string_view prf_algo,
secure_vector< uint8_t > psk,
bool imported )
inline

Definition at line 33 of file tls_external_psk.h.

33 :
34 m_identity(identity), m_prf_algo(prf_algo), m_master_secret(std::move(psk)), m_is_imported(imported) {}

References identity(), and prf_algo().

Member Function Documentation

◆ extract_master_secret()

secure_vector< uint8_t > Botan::TLS::ExternalPSK::extract_master_secret ( )

Returns the master secret by moving it out of this object. Do not call this method more than once.

Definition at line 16 of file tls_external_psk.cpp.

16 {
17 BOTAN_STATE_CHECK(!m_master_secret.empty());
18 return std::exchange(m_master_secret, {});
19}
#define BOTAN_STATE_CHECK(expr)
Definition assert.h:49

References BOTAN_STATE_CHECK.

◆ identity()

const std::string & Botan::TLS::ExternalPSK::identity ( ) const
inline

Identity (e.g. username of the PSK owner) of the preshared key. Despite the std::string return type, this may or may not be a human-readable/printable string.

Definition at line 41 of file tls_external_psk.h.

41{ return m_identity; }

Referenced by ExternalPSK(), and ExternalPSK().

◆ is_imported()

bool Botan::TLS::ExternalPSK::is_imported ( ) const
inline

Returns true if this PSK was derived using the PSK importer mechanism from RFC 9258. Imported PSKs use the "imp binder" label for binder computation instead of "ext binder".

Definition at line 61 of file tls_external_psk.h.

61{ return m_is_imported; }

◆ operator=() [1/2]

ExternalPSK & Botan::TLS::ExternalPSK::operator= ( const ExternalPSK & )
delete

References ExternalPSK().

◆ operator=() [2/2]

ExternalPSK & Botan::TLS::ExternalPSK::operator= ( ExternalPSK && )
default

References ExternalPSK().

◆ prf_algo()

const std::string & Botan::TLS::ExternalPSK::prf_algo ( ) const
inline

External preshared keys in TLS 1.3 must be provisioned with a pseudo-random function (typically SHA-256 or the like). This is needed to calculate/verify the PSK binder values in the client hello.

Definition at line 54 of file tls_external_psk.h.

54{ return m_prf_algo; }

Referenced by ExternalPSK(), and ExternalPSK().


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