Botan 3.6.1
Crypto and TLS for C&
Botan::TLS::PSK_Key_Exchange_Modes Class Referencefinal

#include <tls_extensions.h>

Inheritance diagram for Botan::TLS::PSK_Key_Exchange_Modes:
Botan::TLS::Extension

Public Member Functions

bool empty () const override
 
virtual bool is_implemented () const
 
const std::vector< PSK_Key_Exchange_Mode > & modes () const
 
 PSK_Key_Exchange_Modes (std::vector< PSK_Key_Exchange_Mode > modes)
 
 PSK_Key_Exchange_Modes (TLS_Data_Reader &reader, uint16_t extension_size)
 
std::vector< uint8_t > serialize (Connection_Side whoami) const override
 
Extension_Code type () const override
 

Static Public Member Functions

static Extension_Code static_type ()
 

Detailed Description

Pre-Shared Key Exchange Modes from RFC 8446 4.2.9

Definition at line 616 of file tls_extensions.h.

Constructor & Destructor Documentation

◆ PSK_Key_Exchange_Modes() [1/2]

Botan::TLS::PSK_Key_Exchange_Modes::PSK_Key_Exchange_Modes ( std::vector< PSK_Key_Exchange_Mode > modes)
inlineexplicit

Definition at line 628 of file tls_extensions.h.

628: m_modes(std::move(modes)) {}
const std::vector< PSK_Key_Exchange_Mode > & modes() const

◆ PSK_Key_Exchange_Modes() [2/2]

Botan::TLS::PSK_Key_Exchange_Modes::PSK_Key_Exchange_Modes ( TLS_Data_Reader & reader,
uint16_t extension_size )
explicit

Definition at line 878 of file tls_extensions.cpp.

878 {
879 if(extension_size < 2) {
880 throw Decoding_Error("Empty psk_key_exchange_modes extension is illegal");
881 }
882
883 const auto mode_count = reader.get_byte();
884 for(uint16_t i = 0; i < mode_count; ++i) {
885 const auto mode = static_cast<PSK_Key_Exchange_Mode>(reader.get_byte());
887 m_modes.push_back(mode);
888 }
889 }
890}

References Botan::TLS::TLS_Data_Reader::get_byte(), Botan::TLS::PSK_DHE_KE, and Botan::TLS::PSK_KE.

Member Function Documentation

◆ empty()

bool Botan::TLS::PSK_Key_Exchange_Modes::empty ( ) const
inlineoverridevirtual
Returns
if we should encode this extension or not

Implements Botan::TLS::Extension.

Definition at line 624 of file tls_extensions.h.

624{ return m_modes.empty(); }

◆ is_implemented()

virtual bool Botan::TLS::Extension::is_implemented ( ) const
inlinevirtualinherited
Returns
true if this extension is known and implemented by Botan

Reimplemented in Botan::TLS::Unknown_Extension.

Definition at line 116 of file tls_extensions.h.

116{ return true; }

◆ modes()

const std::vector< PSK_Key_Exchange_Mode > & Botan::TLS::PSK_Key_Exchange_Modes::modes ( ) const
inline

Definition at line 626 of file tls_extensions.h.

626{ return m_modes; }

Referenced by Botan::TLS::Server_Impl_13::new_session_ticket_supported().

◆ serialize()

std::vector< uint8_t > Botan::TLS::PSK_Key_Exchange_Modes::serialize ( Connection_Side whoami) const
overridevirtual
Returns
serialized binary for the extension

Implements Botan::TLS::Extension.

Definition at line 866 of file tls_extensions.cpp.

866 {
867 std::vector<uint8_t> buf;
868
869 BOTAN_ASSERT_NOMSG(m_modes.size() < 256);
870 buf.push_back(static_cast<uint8_t>(m_modes.size()));
871 for(const auto& mode : m_modes) {
872 buf.push_back(static_cast<uint8_t>(mode));
873 }
874
875 return buf;
876}
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:59

References BOTAN_ASSERT_NOMSG.

◆ static_type()

static Extension_Code Botan::TLS::PSK_Key_Exchange_Modes::static_type ( )
inlinestatic

Definition at line 618 of file tls_extensions.h.

◆ type()

Extension_Code Botan::TLS::PSK_Key_Exchange_Modes::type ( ) const
inlineoverridevirtual
Returns
code number of the extension

Implements Botan::TLS::Extension.

Definition at line 620 of file tls_extensions.h.

620{ return static_type(); }
static Extension_Code static_type()

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