Botan 3.14.1
Crypto and TLS for C&
Botan::HPKE::KDF_Id Class Referencefinal

#include <hpke.h>

Public Member Functions

constexpr KDF_Code code () const
bool is_available () const
constexpr bool is_known () const
constexpr KDF_Id (KDF_Code code)
constexpr KDF_Id (uint16_t code)
constexpr bool operator== (const KDF_Id &other) const
constexpr bool operator== (KDF_Code code) const
size_t output_length () const
std::optional< std::string > to_string () const
constexpr uint16_t wire_code () const

Detailed Description

Identifies the KDF used by an HPKE ciphersuite

Definition at line 139 of file hpke.h.

Constructor & Destructor Documentation

◆ KDF_Id() [1/2]

Botan::HPKE::KDF_Id::KDF_Id ( KDF_Code code)
inlineconstexpr

Definition at line 144 of file hpke.h.

144: m_code(code) {}
constexpr KDF_Code code() const
Definition hpke.h:150

References code().

Referenced by operator==().

◆ KDF_Id() [2/2]

Botan::HPKE::KDF_Id::KDF_Id ( uint16_t code)
inlineconstexpr

Definition at line 148 of file hpke.h.

148: m_code(static_cast<KDF_Code>(code)) {}

References code().

Member Function Documentation

◆ code()

KDF_Code Botan::HPKE::KDF_Id::code ( ) const
inlineconstexpr

Definition at line 150 of file hpke.h.

150{ return m_code; }

Referenced by KDF_Id(), KDF_Id(), and operator==().

◆ is_available()

bool Botan::HPKE::KDF_Id::is_available ( ) const

Definition at line 151 of file hpke.cpp.

151 {
152 if(const auto info = kdf_info(m_code)) {
153 return MessageAuthenticationCode::create(fmt("HMAC({})", info->hash)) != nullptr;
154 }
155 return false;
156}
static std::unique_ptr< MessageAuthenticationCode > create(std::string_view algo_spec, std::string_view provider="")
Definition mac.cpp:51
std::string fmt(std::string_view format, const T &... args)
Definition fmt.h:53

References Botan::MessageAuthenticationCode::create(), and Botan::fmt().

◆ is_known()

bool Botan::HPKE::KDF_Id::is_known ( ) const
inlineconstexpr

Definition at line 158 of file hpke.h.

158 {
159 switch(m_code) {
163 return true;
164 }
165 return false;
166 }

References Botan::HPKE::HKDF_SHA256, Botan::HPKE::HKDF_SHA384, and Botan::HPKE::HKDF_SHA512.

◆ operator==() [1/2]

bool Botan::HPKE::KDF_Id::operator== ( const KDF_Id & other) const
inlineconstexpr

Definition at line 154 of file hpke.h.

154{ return m_code == other.m_code; }

References KDF_Id().

◆ operator==() [2/2]

bool Botan::HPKE::KDF_Id::operator== ( KDF_Code code) const
inlineconstexpr

Definition at line 156 of file hpke.h.

156{ return m_code == code; }

References code().

◆ output_length()

size_t Botan::HPKE::KDF_Id::output_length ( ) const

The KDF output length Nh; throws Invalid_State for unknown codepoints See RFC 9180 Section 7.2

Definition at line 158 of file hpke.cpp.

158 {
159 if(const auto info = kdf_info(m_code)) {
160 return info->nh;
161 }
162 throw Invalid_State(fmt("Unknown HPKE KDF {}", wire_code()));
163}
constexpr uint16_t wire_code() const
Definition hpke.h:152

References Botan::fmt(), and wire_code().

◆ to_string()

std::optional< std::string > Botan::HPKE::KDF_Id::to_string ( ) const

Definition at line 165 of file hpke.cpp.

165 {
166 if(const auto info = kdf_info(m_code)) {
167 return std::string(info->name);
168 }
169 return std::nullopt;
170}

◆ wire_code()

uint16_t Botan::HPKE::KDF_Id::wire_code ( ) const
inlineconstexpr

Definition at line 152 of file hpke.h.

152{ return static_cast<uint16_t>(m_code); }

Referenced by output_length().


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