Botan 3.7.1
Crypto and TLS for C&
Botan::PK_Ops::Encryption_with_EME Class Referenceabstract

#include <pk_ops_impl.h>

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

Protected Member Functions

 Encryption_with_EME (std::string_view eme)
 

Detailed Description

Definition at line 23 of file pk_ops_impl.h.

Constructor & Destructor Documentation

◆ ~Encryption_with_EME()

Botan::PK_Ops::Encryption_with_EME::~Encryption_with_EME ( )
overridedefault

◆ Encryption_with_EME()

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

Definition at line 29 of file pk_ops.cpp.

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

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_EME::encrypt ( std::span< const uint8_t > msg,
RandomNumberGenerator & rng )
overridevirtual

Encrypt a message returning the ciphertext

Implements Botan::PK_Ops::Encryption.

Definition at line 37 of file pk_ops.cpp.

37 {
38 const size_t max_input_bits = max_ptext_input_bits();
39 const size_t max_input_bytes = (max_input_bits + 7) / 8;
40 BOTAN_ARG_CHECK(msg.size() <= max_input_bytes, "Plaintext too large");
41
43 const size_t written = m_eme->pad(eme_output, msg, max_input_bits, rng);
44 return raw_encrypt(std::span{eme_output}.first(written), rng);
45}
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:29
size_t max_input_bits() const override
Definition pk_ops.cpp:33
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:61

References BOTAN_ARG_CHECK.

◆ max_input_bits()

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

Return the maximum input size for this key

Implements Botan::PK_Ops::Encryption.

Definition at line 33 of file pk_ops.cpp.

33 {
34 return 8 * m_eme->maximum_input_size(max_ptext_input_bits());
35}

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