Botan 3.10.0
Crypto and TLS for C&
Botan::PK_Ops::Decryption_with_Padding Class Referenceabstract

#include <pk_ops_impl.h>

Inheritance diagram for Botan::PK_Ops::Decryption_with_Padding:
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_Padding () override

Protected Member Functions

 Decryption_with_Padding (std::string_view padding)

Detailed Description

Definition at line 43 of file pk_ops_impl.h.

Constructor & Destructor Documentation

◆ ~Decryption_with_Padding()

Botan::PK_Ops::Decryption_with_Padding::~Decryption_with_Padding ( )
overridedefault

◆ Decryption_with_Padding()

Botan::PK_Ops::Decryption_with_Padding::Decryption_with_Padding ( std::string_view padding)
explicitprotected

Definition at line 50 of file pk_ops.cpp.

50 :
51 m_padding(EncryptionPaddingScheme::create(padding)) {}
static std::unique_ptr< EncryptionPaddingScheme > create(std::string_view algo_spec)

Member Function Documentation

◆ decrypt()

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

Implements Botan::PK_Ops::Decryption.

Definition at line 55 of file pk_ops.cpp.

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

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: