Botan 3.4.0
Crypto and TLS for C&
Public Member Functions | Protected Member Functions | List of all members
Botan::PK_Ops::KEM_Decryption_with_KDF Class Referenceabstract

#include <pk_ops_impl.h>

Inheritance diagram for Botan::PK_Ops::KEM_Decryption_with_KDF:
Botan::PK_Ops::KEM_Decryption

Public Member Functions

virtual size_t encapsulated_key_length () const =0
 
void kem_decrypt (std::span< uint8_t > out_shared_key, std::span< const uint8_t > encapsulated_key, 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_Decryption_with_KDF () override=default
 

Protected Member Functions

 KEM_Decryption_with_KDF (std::string_view kdf)
 
virtual void raw_kem_decrypt (std::span< uint8_t > out_raw_shared_key, std::span< const uint8_t > encapsulated_key)=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_Decryption_with_KDF()

Botan::PK_Ops::KEM_Decryption_with_KDF::~KEM_Decryption_with_KDF ( )
overridedefault

◆ KEM_Decryption_with_KDF()

Botan::PK_Ops::KEM_Decryption_with_KDF::KEM_Decryption_with_KDF ( std::string_view kdf)
explicitprotected

Definition at line 223 of file pk_ops.cpp.

223 {
224 if(kdf != "Raw") {
225 m_kdf = KDF::create_or_throw(kdf);
226 }
227}
static std::unique_ptr< KDF > create_or_throw(std::string_view algo_spec, std::string_view provider="")
Definition kdf.cpp:193

References Botan::KDF::create_or_throw().

Member Function Documentation

◆ encapsulated_key_length()

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

◆ kem_decrypt()

void Botan::PK_Ops::KEM_Decryption_with_KDF::kem_decrypt ( std::span< uint8_t > out_shared_key,
std::span< const uint8_t > encapsulated_key,
size_t desired_shared_key_len,
std::span< const uint8_t > salt )
finalvirtual

Implements Botan::PK_Ops::KEM_Decryption.

Definition at line 204 of file pk_ops.cpp.

207 {
208 BOTAN_ARG_CHECK(salt.empty() || m_kdf, "PK_KEM_Decryptor::decrypt requires a KDF to use a salt");
209
210 if(m_kdf) {
212 out_shared_key.size(), desired_shared_key_len, "KDF output length and shared key length match");
213
214 secure_vector<uint8_t> raw_shared(raw_kem_shared_key_length());
215 this->raw_kem_decrypt(raw_shared, encapsulated_key);
216 m_kdf->derive_key(out_shared_key, raw_shared, salt, {});
217 } else {
218 BOTAN_ASSERT_EQUAL(out_shared_key.size(), raw_kem_shared_key_length(), "Shared key has raw KEM output length");
219 this->raw_kem_decrypt(out_shared_key, encapsulated_key);
220 }
221}
#define BOTAN_ASSERT_EQUAL(expr1, expr2, assertion_made)
Definition assert.h:68
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:29
virtual void raw_kem_decrypt(std::span< uint8_t > out_raw_shared_key, std::span< const uint8_t > encapsulated_key)=0
virtual size_t raw_kem_shared_key_length() const =0

References BOTAN_ARG_CHECK, and BOTAN_ASSERT_EQUAL.

◆ raw_kem_decrypt()

virtual void Botan::PK_Ops::KEM_Decryption_with_KDF::raw_kem_decrypt ( std::span< uint8_t > out_raw_shared_key,
std::span< const uint8_t > encapsulated_key )
protectedpure virtual

◆ raw_kem_shared_key_length()

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

◆ shared_key_length()

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

Implements Botan::PK_Ops::KEM_Decryption.

Definition at line 196 of file pk_ops.cpp.

196 {
197 if(m_kdf) {
198 return desired_shared_key_len;
199 } else {
200 return this->raw_kem_shared_key_length();
201 }
202}

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