Botan 3.6.1
Crypto and TLS for C&
Botan::PK_Ops::Decryption_with_EME Class Referenceabstract

#include <pk_ops_impl.h>

Inheritance diagram for Botan::PK_Ops::Decryption_with_EME:
Botan::PK_Ops::Decryption

Public Member Functions

secure_vector< uint8_t > decrypt (uint8_t &valid_mask, std::span< const uint8_t > ctext) override
 
virtual size_t plaintext_length (size_t ctext_len) const =0
 
 ~Decryption_with_EME () override=default
 

Protected Member Functions

 Decryption_with_EME (std::string_view eme)
 

Detailed Description

Definition at line 36 of file pk_ops_impl.h.

Constructor & Destructor Documentation

◆ ~Decryption_with_EME()

Botan::PK_Ops::Decryption_with_EME::~Decryption_with_EME ( )
overridedefault

◆ Decryption_with_EME()

Botan::PK_Ops::Decryption_with_EME::Decryption_with_EME ( std::string_view eme)
explicitprotected

Definition at line 41 of file pk_ops.cpp.

41: m_eme(EME::create(eme)) {}
static std::unique_ptr< EME > create(std::string_view algo_spec)
Definition eme.cpp:28

Member Function Documentation

◆ decrypt()

secure_vector< uint8_t > Botan::PK_Ops::Decryption_with_EME::decrypt ( uint8_t & valid_mask,
std::span< const uint8_t > ctext )
overridevirtual

Implements Botan::PK_Ops::Decryption.

Definition at line 43 of file pk_ops.cpp.

43 {
44 const secure_vector<uint8_t> raw = raw_decrypt(ctext);
45
46 secure_vector<uint8_t> ptext(raw.size());
47 auto len = m_eme->unpad(ptext, raw);
48
49 valid_mask = CT::Mask<uint8_t>::from_choice(len.has_value()).if_set_return(0xFF);
50
51 /*
52 This is potentially not const time, depending on how std::vector is
53 implemented. But since we are always reducing length, it should
54 just amount to setting the member var holding the length. Resizing
55 downwards is guaranteed to not change the capacity, and since we
56 set ctext to the maximum possible size (equal to the raw input) we
57 know that this is always, if anything, resizing smaller than the
58 capacity, so no reallocation occurs.
59 */
60
61 ptext.resize(len.value_or(0));
62 return ptext;
63}
static constexpr Mask< T > from_choice(Choice c)
Definition ct_utils.h:394
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:61

References Botan::CT::Mask< T >::from_choice().

◆ plaintext_length()

virtual size_t Botan::PK_Ops::Decryption::plaintext_length ( size_t ctext_len) const
pure virtualinherited

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