Botan 3.4.0
Crypto and TLS for C&
Public Member Functions | List of all members
Botan::PK_Encryptor_EME Class Referencefinal

#include <pubkey.h>

Inheritance diagram for Botan::PK_Encryptor_EME:
Botan::PK_Encryptor

Public Member Functions

size_t ciphertext_length (size_t ptext_len) const override
 
std::vector< uint8_t > encrypt (const uint8_t in[], size_t length, RandomNumberGenerator &rng) const
 
std::vector< uint8_t > encrypt (std::span< const uint8_t > in, RandomNumberGenerator &rng) const
 
size_t maximum_input_size () const override
 
PK_Encryptor_EMEoperator= (const PK_Encryptor_EME &)=delete
 
PK_Encryptor_EMEoperator= (PK_Encryptor_EME &&) noexcept
 
 PK_Encryptor_EME (const PK_Encryptor_EME &)=delete
 
 PK_Encryptor_EME (const Public_Key &key, RandomNumberGenerator &rng, std::string_view padding, std::string_view provider="")
 
 PK_Encryptor_EME (PK_Encryptor_EME &&) noexcept
 
 ~PK_Encryptor_EME () override
 

Detailed Description

Encryption using a standard message recovery algorithm like RSA or ElGamal, paired with an encoding scheme like OAEP.

Definition at line 476 of file pubkey.h.

Constructor & Destructor Documentation

◆ PK_Encryptor_EME() [1/3]

Botan::PK_Encryptor_EME::PK_Encryptor_EME ( const Public_Key & key,
RandomNumberGenerator & rng,
std::string_view padding,
std::string_view provider = "" )

Construct an instance.

Parameters
keythe key to use inside the encryptor
rngthe RNG to use
paddingthe message encoding scheme to use (eg "OAEP(SHA-256)")
providerthe provider to use

Definition at line 86 of file pubkey.cpp.

89 {
90 m_op = key.create_encryption_op(rng, padding, provider);
91 if(!m_op) {
92 throw Invalid_Argument(fmt("Key type {} does not support encryption", key.algo_name()));
93 }
94}
std::string fmt(std::string_view format, const T &... args)
Definition fmt.h:53

References Botan::Asymmetric_Key::algo_name(), Botan::Public_Key::create_encryption_op(), and Botan::fmt().

◆ ~PK_Encryptor_EME()

Botan::PK_Encryptor_EME::~PK_Encryptor_EME ( )
overridedefault

◆ PK_Encryptor_EME() [2/3]

Botan::PK_Encryptor_EME::PK_Encryptor_EME ( const PK_Encryptor_EME & )
delete

◆ PK_Encryptor_EME() [3/3]

Botan::PK_Encryptor_EME::PK_Encryptor_EME ( PK_Encryptor_EME && )
defaultnoexcept

Member Function Documentation

◆ ciphertext_length()

size_t Botan::PK_Encryptor_EME::ciphertext_length ( size_t ptext_len) const
overridevirtual

Return an upper bound on the ciphertext length for a particular plaintext input length

Implements Botan::PK_Encryptor.

Definition at line 101 of file pubkey.cpp.

101 {
102 return m_op->ciphertext_length(ptext_len);
103}

References ciphertext_length().

Referenced by ciphertext_length().

◆ encrypt() [1/2]

std::vector< uint8_t > Botan::PK_Encryptor::encrypt ( const uint8_t in[],
size_t length,
RandomNumberGenerator & rng ) const
inlineinherited

Encrypt a message.

Parameters
inthe message as a byte array
lengththe length of the above byte array
rngthe random number source to use
Returns
encrypted message

Definition at line 37 of file pubkey.h.

37 {
38 return enc(in, length, rng);
39 }

Referenced by Botan::TLS::Client_Key_Exchange::Client_Key_Exchange(), and Botan::KeyPair::encryption_consistency_check().

◆ encrypt() [2/2]

std::vector< uint8_t > Botan::PK_Encryptor::encrypt ( std::span< const uint8_t > in,
RandomNumberGenerator & rng ) const
inlineinherited

Encrypt a message.

Parameters
inthe message
rngthe random number source to use
Returns
encrypted message

Definition at line 47 of file pubkey.h.

47 {
48 return enc(in.data(), in.size(), rng);
49 }

◆ maximum_input_size()

size_t Botan::PK_Encryptor_EME::maximum_input_size ( ) const
overridevirtual

Return the maximum allowed message size in bytes.

Returns
maximum message size in bytes

Implements Botan::PK_Encryptor.

Definition at line 109 of file pubkey.cpp.

109 {
110 return m_op->max_input_bits() / 8;
111}

Referenced by Botan::KeyPair::encryption_consistency_check().

◆ operator=() [1/2]

PK_Encryptor_EME & Botan::PK_Encryptor_EME::operator= ( const PK_Encryptor_EME & )
delete

◆ operator=() [2/2]

PK_Encryptor_EME & Botan::PK_Encryptor_EME::operator= ( PK_Encryptor_EME && )
defaultnoexcept

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