Botan 3.14.1
Crypto and TLS for C&
Botan::PK_Ops::KEM_Encryption_with_KDF Class Referenceabstract

#include <pk_ops_impl.h>

Inheritance diagram for Botan::PK_Ops::KEM_Encryption_with_KDF:
Botan::PK_Ops::KEM_Encryption Botan::Classic_McEliece_Encryptor Botan::Kyber_KEM_Encryptor_Base Botan::Kyber_KEM_Encryptor Botan::ML_KEM_Encryptor

Public Member Functions

virtual size_t encapsulated_key_length () const =0
void kem_encrypt (std::span< uint8_t > out_encapsulated_key, std::span< uint8_t > out_shared_key, RandomNumberGenerator &rng, size_t desired_shared_key_len, std::span< const uint8_t > salt) final
size_t shared_key_length (size_t desired_shared_key_len) const final
 ~KEM_Encryption_with_KDF () override

Protected Member Functions

 KEM_Encryption_with_KDF (const PK_KEM_Options_Reader &options, KemSharedKeyQuality raw_key)
virtual void raw_kem_encrypt (std::span< uint8_t > out_encapsulated_key, std::span< uint8_t > out_raw_shared_key, RandomNumberGenerator &rng)=0
virtual size_t raw_kem_shared_key_length () const =0

Detailed Description

Definition at line 146 of file pk_ops_impl.h.

Constructor & Destructor Documentation

◆ ~KEM_Encryption_with_KDF()

Botan::PK_Ops::KEM_Encryption_with_KDF::~KEM_Encryption_with_KDF ( )
overridedefault

◆ KEM_Encryption_with_KDF()

Botan::PK_Ops::KEM_Encryption_with_KDF::KEM_Encryption_with_KDF ( const PK_KEM_Options_Reader & options,
KemSharedKeyQuality raw_key )
protected
Parameters
optionsthe KEM options; if these do not specify a KDF then whether the raw output can be used directly is decided by raw_key

Definition at line 259 of file pk_ops.cpp.

260 :
261 m_kdf(kem_kdf_from_options(options, raw_key)) {}

Referenced by Botan::Classic_McEliece_Encryptor::Classic_McEliece_Encryptor(), Botan::Kyber_KEM_Encryptor_Base::Kyber_KEM_Encryptor_Base(), and raw_kem_shared_key_length().

Member Function Documentation

◆ encapsulated_key_length()

virtual size_t Botan::PK_Ops::KEM_Encryption::encapsulated_key_length ( ) const
pure virtualinherited

◆ kem_encrypt()

void Botan::PK_Ops::KEM_Encryption_with_KDF::kem_encrypt ( std::span< uint8_t > out_encapsulated_key,
std::span< uint8_t > out_shared_key,
RandomNumberGenerator & rng,
size_t desired_shared_key_len,
std::span< const uint8_t > salt )
finalvirtual

Implements Botan::PK_Ops::KEM_Encryption.

Definition at line 219 of file pk_ops.cpp.

223 {
224 BOTAN_ARG_CHECK(salt.empty() || m_kdf, "PK_KEM_Encryptor::encrypt requires a KDF to use a salt");
225 BOTAN_ASSERT_NOMSG(out_encapsulated_key.size() == encapsulated_key_length());
226
227 if(m_kdf) {
229 out_shared_key.size(), desired_shared_key_len, "KDF output length and shared key length match");
230
232 this->raw_kem_encrypt(out_encapsulated_key, raw_shared, rng);
233 m_kdf->derive_key(out_shared_key, raw_shared, salt, {});
234 } else {
235 BOTAN_ASSERT_EQUAL(out_shared_key.size(), raw_kem_shared_key_length(), "Shared key has raw KEM output length");
236 this->raw_kem_encrypt(out_encapsulated_key, out_shared_key, rng);
237 }
238}
#define BOTAN_ASSERT_NOMSG(expr)
Definition assert.h:82
#define BOTAN_ASSERT_EQUAL(expr1, expr2, assertion_made)
Definition assert.h:95
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:33
virtual size_t raw_kem_shared_key_length() const =0
virtual void raw_kem_encrypt(std::span< uint8_t > out_encapsulated_key, std::span< uint8_t > out_raw_shared_key, RandomNumberGenerator &rng)=0
virtual size_t encapsulated_key_length() const =0
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:128

References BOTAN_ARG_CHECK, BOTAN_ASSERT_EQUAL, BOTAN_ASSERT_NOMSG, Botan::PK_Ops::KEM_Encryption::encapsulated_key_length(), raw_kem_encrypt(), and raw_kem_shared_key_length().

◆ raw_kem_encrypt()

virtual void Botan::PK_Ops::KEM_Encryption_with_KDF::raw_kem_encrypt ( std::span< uint8_t > out_encapsulated_key,
std::span< uint8_t > out_raw_shared_key,
RandomNumberGenerator & rng )
protectedpure virtual

◆ raw_kem_shared_key_length()

virtual size_t Botan::PK_Ops::KEM_Encryption_with_KDF::raw_kem_shared_key_length ( ) const
protectedpure virtual

◆ shared_key_length()

size_t Botan::PK_Ops::KEM_Encryption_with_KDF::shared_key_length ( size_t desired_shared_key_len) const
finalvirtual

Implements Botan::PK_Ops::KEM_Encryption.

Definition at line 211 of file pk_ops.cpp.

211 {
212 if(m_kdf) {
213 return desired_shared_key_len;
214 } else {
215 return this->raw_kem_shared_key_length();
216 }
217}

References raw_kem_shared_key_length().


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