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

#include <pk_ops_impl.h>

Inheritance diagram for Botan::PK_Ops::Encryption_with_Padding:
Botan::PK_Ops::Encryption

Public Member Functions

virtual size_t ciphertext_length (size_t ptext_len) const =0
std::vector< uint8_t > encrypt (std::span< const uint8_t > ptext, RandomNumberGenerator &rng) override
size_t max_input_bits () const override
 ~Encryption_with_Padding () override

Protected Member Functions

 Encryption_with_Padding (std::string_view padding)

Detailed Description

Definition at line 25 of file pk_ops_impl.h.

Constructor & Destructor Documentation

◆ ~Encryption_with_Padding()

Botan::PK_Ops::Encryption_with_Padding::~Encryption_with_Padding ( )
overridedefault

◆ Encryption_with_Padding()

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

Definition at line 30 of file pk_ops.cpp.

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

Member Function Documentation

◆ ciphertext_length()

virtual size_t Botan::PK_Ops::Encryption::ciphertext_length ( size_t ptext_len) const
pure virtualinherited

Given the plaintext length, return an upper bound of the ciphertext length for this key and padding.

◆ encrypt()

std::vector< uint8_t > Botan::PK_Ops::Encryption_with_Padding::encrypt ( std::span< const uint8_t > msg,
RandomNumberGenerator & rng )
overridevirtual

Encrypt a message returning the ciphertext

Implements Botan::PK_Ops::Encryption.

Definition at line 39 of file pk_ops.cpp.

40 {
41 const size_t max_input_bits = max_ptext_input_bits();
42 const size_t max_input_bytes = (max_input_bits + 7) / 8;
43 BOTAN_ARG_CHECK(msg.size() <= max_input_bytes, "Plaintext too large");
44
46 const size_t written = m_padding->pad(padded_ptext, msg, max_input_bits, rng);
47 return raw_encrypt(std::span{padded_ptext}.first(written), rng);
48}
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:33
size_t max_input_bits() const override
Definition pk_ops.cpp:35
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:69

References BOTAN_ARG_CHECK, and max_input_bits().

◆ max_input_bits()

size_t Botan::PK_Ops::Encryption_with_Padding::max_input_bits ( ) const
overridevirtual

Return the maximum input size for this key

Implements Botan::PK_Ops::Encryption.

Definition at line 35 of file pk_ops.cpp.

35 {
36 return 8 * m_padding->maximum_input_size(max_ptext_input_bits());
37}

Referenced by encrypt().


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