Botan 3.14.1
Crypto and TLS for C&
Botan::PK_Encryption_Options_Reader Class Referencefinal

#include <pk_options_readers.h>

Public Member Functions

const std::optional< std::vector< uint8_t > > & context () const
const std::optional< std::string > & hash_function () const
const std::string & hash_function_name () const
const std::optional< std::string > & mgf1_hash_function () const
PK_Encryption_Options_Reader & operator= (const PK_Encryption_Options_Reader &)=delete
PK_Encryption_Options_Reader & operator= (PK_Encryption_Options_Reader &&)=delete
const std::optional< std::string > & padding () const
 PK_Encryption_Options_Reader (const PK_Encryption_Options_Reader &)=delete
 PK_Encryption_Options_Reader (PK_Encryption_Options_Reader &&)=delete
const std::optional< std::string > & provider () const
std::string to_string () const
 Format the options as a string, for error messages.
bool using_context () const
bool using_hash () const
bool using_mgf1_hash () const
bool using_padding () const
bool using_provider () const
 ~PK_Encryption_Options_Reader ()=default

Friends

class PK_Decryptor_EME
class PK_Encryptor_EME
class PK_Options_Reader_Access

Detailed Description

Read access to a PK_Encryption_Options

The library creates one of these when a PK_Encryptor_EME or PK_Decryptor_EME is constructed and passes it to the key's _create_encryption_op or _create_decryption_op; applications never create or hold one.

As with PK_Signature_Options_Reader, each getter records that the scheme examined the option, and any option set but never examined is rejected.

Definition at line 178 of file pk_options_readers.h.

Constructor & Destructor Documentation

◆ PK_Encryption_Options_Reader() [1/2]

Botan::PK_Encryption_Options_Reader::PK_Encryption_Options_Reader ( const PK_Encryption_Options_Reader & )
delete

◆ PK_Encryption_Options_Reader() [2/2]

Botan::PK_Encryption_Options_Reader::PK_Encryption_Options_Reader ( PK_Encryption_Options_Reader && )
delete

◆ ~PK_Encryption_Options_Reader()

Botan::PK_Encryption_Options_Reader::~PK_Encryption_Options_Reader ( )
default

Member Function Documentation

◆ context()

const std::optional< std::vector< uint8_t > > & Botan::PK_Encryption_Options_Reader::context ( ) const
inline

Definition at line 209 of file pk_options_readers.h.

209 {
210 note_examined(Option::Context);
211 return m_options.m_context;
212 }

Referenced by Botan::PKCS11::MechanismWrapper::create_rsa_crypt_mechanism(), Botan::OAEP::OAEP(), and using_context().

◆ hash_function()

const std::optional< std::string > & Botan::PK_Encryption_Options_Reader::hash_function ( ) const
inline

Definition at line 199 of file pk_options_readers.h.

199 {
200 note_examined(Option::Hash);
201 return m_options.m_hash_fn;
202 }

Referenced by Botan::SM2_PrivateKey::_create_decryption_op(), Botan::SM2_PublicKey::_create_encryption_op(), and using_hash().

◆ hash_function_name()

const std::string & Botan::PK_Encryption_Options_Reader::hash_function_name ( ) const

Return the name of the hash function to use

This will throw an exception if no hash function was configured

Definition at line 325 of file pk_options.cpp.

325 {
326 note_examined(Option::Hash);
327
328 if(m_options.m_hash_fn.has_value()) {
329 return m_options.m_hash_fn.value();
330 }
331
332 throw Invalid_State("This encryption scheme requires specifying a hash function");
333}

Referenced by Botan::PKCS11::MechanismWrapper::create_rsa_crypt_mechanism(), and Botan::OAEP::OAEP().

◆ mgf1_hash_function()

const std::optional< std::string > & Botan::PK_Encryption_Options_Reader::mgf1_hash_function ( ) const
inline

Definition at line 204 of file pk_options_readers.h.

204 {
205 note_examined(Option::Mgf1Hash);
206 return m_options.m_mgf1_hash_fn;
207 }

Referenced by Botan::PKCS11::MechanismWrapper::create_rsa_crypt_mechanism(), Botan::OAEP::OAEP(), and using_mgf1_hash().

◆ operator=() [1/2]

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

◆ operator=() [2/2]

PK_Encryption_Options_Reader & Botan::PK_Encryption_Options_Reader::operator= ( PK_Encryption_Options_Reader && )
delete

◆ padding()

const std::optional< std::string > & Botan::PK_Encryption_Options_Reader::padding ( ) const
inline

Definition at line 194 of file pk_options_readers.h.

194 {
195 note_examined(Option::Padding);
196 return m_options.m_padding;
197 }

Referenced by Botan::EncryptionPaddingScheme::create_or_throw(), Botan::PKCS11::MechanismWrapper::create_rsa_crypt_mechanism(), and using_padding().

◆ provider()

const std::optional< std::string > & Botan::PK_Encryption_Options_Reader::provider ( ) const
inline

Definition at line 214 of file pk_options_readers.h.

214 {
215 note_examined(Option::Provider);
216 return m_options.m_provider;
217 }

◆ to_string()

std::string Botan::PK_Encryption_Options_Reader::to_string ( ) const
inline

Format the options as a string, for error messages.

Definition at line 187 of file pk_options_readers.h.

187{ return m_options.to_string(); }

Referenced by Botan::EncryptionPaddingScheme::create_or_throw().

◆ using_context()

bool Botan::PK_Encryption_Options_Reader::using_context ( ) const
inline

Definition at line 225 of file pk_options_readers.h.

225{ return context().has_value(); }
const std::optional< std::vector< uint8_t > > & context() const

References context().

◆ using_hash()

bool Botan::PK_Encryption_Options_Reader::using_hash ( ) const
inline

Definition at line 221 of file pk_options_readers.h.

221{ return hash_function().has_value(); }
const std::optional< std::string > & hash_function() const

References hash_function().

Referenced by Botan::PKCS11::MechanismWrapper::create_rsa_crypt_mechanism(), and Botan::OAEP::OAEP().

◆ using_mgf1_hash()

bool Botan::PK_Encryption_Options_Reader::using_mgf1_hash ( ) const
inline

Definition at line 223 of file pk_options_readers.h.

223{ return mgf1_hash_function().has_value(); }
const std::optional< std::string > & mgf1_hash_function() const

References mgf1_hash_function().

Referenced by Botan::PKCS11::MechanismWrapper::create_rsa_crypt_mechanism(), and Botan::OAEP::OAEP().

◆ using_padding()

bool Botan::PK_Encryption_Options_Reader::using_padding ( ) const
inline

Definition at line 219 of file pk_options_readers.h.

219{ return padding().has_value(); }
const std::optional< std::string > & padding() const

References padding().

Referenced by Botan::EncryptionPaddingScheme::create_or_throw(), and Botan::PKCS11::MechanismWrapper::create_rsa_crypt_mechanism().

◆ using_provider()

bool Botan::PK_Encryption_Options_Reader::using_provider ( ) const

Definition at line 320 of file pk_options.cpp.

320 {
321 note_examined(Option::Provider);
322 return provider_is_in_use(m_options.m_provider);
323}

◆ PK_Decryptor_EME

friend class PK_Decryptor_EME
friend

Definition at line 231 of file pk_options_readers.h.

References PK_Decryptor_EME.

Referenced by PK_Decryptor_EME.

◆ PK_Encryptor_EME

friend class PK_Encryptor_EME
friend

Definition at line 230 of file pk_options_readers.h.

References PK_Encryptor_EME.

Referenced by PK_Encryptor_EME.

◆ PK_Options_Reader_Access

friend class PK_Options_Reader_Access
friend

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