Botan 3.7.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
 

Protected Member Functions

 Decryption_with_EME (std::string_view eme)
 

Detailed Description

Definition at line 41 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 47 of file pk_ops.cpp.

47: 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 51 of file pk_ops.cpp.

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