Botan 3.14.1
Crypto and TLS for C&
Botan::PK_Signature_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 > & externally_computed_prehash_function () const
const std::optional< std::string > & hash_function () const
const std::string & hash_function_name () const
PK_Signature_Options_Reader & operator= (const PK_Signature_Options_Reader &)=delete
PK_Signature_Options_Reader & operator= (PK_Signature_Options_Reader &&)=delete
const std::optional< std::string > & padding () const
 PK_Signature_Options_Reader (const PK_Signature_Options_Reader &)=delete
 PK_Signature_Options_Reader (PK_Signature_Options_Reader &&)=delete
const std::optional< std::string > & prehash_function () const
const std::optional< std::string > & provider () const
const std::optional< size_t > & salt_size () const
std::string to_string () const
 Format the options as a string, for error messages.
bool using_context () const
bool using_der_encoded_signature () const
bool using_deterministic_signature () const
bool using_explicit_trailer_field () const
bool using_externally_computed_prehash () const
bool using_hash () const
bool using_padding () const
bool using_prehash () const
bool using_provider () const
bool using_salt_size () const
 ~PK_Signature_Options_Reader ()=default

Friends

class PK_Options_Reader_Access
class PK_Signer
class PK_Verifier

Detailed Description

Read access to a PK_Signature_Options

The library creates one of these when a PK_Signer or PK_Verifier is constructed and passes it to the key's _create_signature_op or _create_verification_op; applications never create or hold one.

Each getter records that the scheme examined the option. Any option the caller set which the scheme never examined is then rejected, since it would otherwise be silently ignored. A scheme should therefore only read an option that it will actually act on.

Definition at line 38 of file pk_options_readers.h.

Constructor & Destructor Documentation

◆ PK_Signature_Options_Reader() [1/2]

Botan::PK_Signature_Options_Reader::PK_Signature_Options_Reader ( const PK_Signature_Options_Reader & )
delete

◆ PK_Signature_Options_Reader() [2/2]

Botan::PK_Signature_Options_Reader::PK_Signature_Options_Reader ( PK_Signature_Options_Reader && )
delete

◆ ~PK_Signature_Options_Reader()

Botan::PK_Signature_Options_Reader::~PK_Signature_Options_Reader ( )
default

Member Function Documentation

◆ context()

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

Definition at line 74 of file pk_options_readers.h.

74 {
75 note_examined(Option::Context);
76 return m_options.m_context;
77 }

Referenced by using_context().

◆ externally_computed_prehash_function()

const std::optional< std::string > & Botan::PK_Signature_Options_Reader::externally_computed_prehash_function ( ) const
inline

Definition at line 64 of file pk_options_readers.h.

64 {
65 note_examined(Option::ExternalPrehash);
66 return m_options.m_external_prehash;
67 }

Referenced by Botan::externally_computed_prehash_name().

◆ hash_function()

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

Definition at line 54 of file pk_options_readers.h.

54 {
55 note_examined(Option::Hash);
56 return m_options.m_hash_fn;
57 }

Referenced by Botan::SphincsPlus_PrivateKey::_create_signature_op(), Botan::SphincsPlus_PublicKey::_create_verification_op(), Botan::externally_computed_prehash_name(), and using_hash().

◆ hash_function_name()

const std::string & Botan::PK_Signature_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 140 of file pk_options.cpp.

140 {
141 note_examined(Option::Hash);
142
143 if(m_options.m_hash_fn.has_value()) {
144 return m_options.m_hash_fn.value();
145 }
146
147 throw Invalid_State("This signature scheme requires specifying a hash function");
148}

Referenced by Botan::TPM_PrivateKey::_create_signature_op(), Botan::SignaturePaddingScheme::create_or_throw(), Botan::PKCS11::MechanismWrapper::create_rsa_sign_mechanism(), and Botan::validate_for_hash_based_signature().

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ padding()

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

Definition at line 69 of file pk_options_readers.h.

69 {
70 note_examined(Option::Padding);
71 return m_options.m_padding;
72 }

Referenced by Botan::TPM_PrivateKey::_create_signature_op(), Botan::SignaturePaddingScheme::create_or_throw(), Botan::PKCS11::MechanismWrapper::create_rsa_sign_mechanism(), and using_padding().

◆ prehash_function()

const std::optional< std::string > & Botan::PK_Signature_Options_Reader::prehash_function ( ) const
inline

◆ provider()

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

Definition at line 79 of file pk_options_readers.h.

79 {
80 note_examined(Option::Provider);
81 return m_options.m_provider;
82 }

◆ salt_size()

const std::optional< size_t > & Botan::PK_Signature_Options_Reader::salt_size ( ) const
inline

Definition at line 84 of file pk_options_readers.h.

84 {
85 note_examined(Option::SaltSize);
86 return m_options.m_salt_size;
87 }

Referenced by Botan::PKCS11::MechanismWrapper::create_rsa_sign_mechanism(), and using_salt_size().

◆ to_string()

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

Format the options as a string, for error messages.

Definition at line 47 of file pk_options_readers.h.

47{ return m_options.to_string(); }

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

◆ using_context()

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

Definition at line 106 of file pk_options_readers.h.

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

References context().

◆ using_der_encoded_signature()

bool Botan::PK_Signature_Options_Reader::using_der_encoded_signature ( ) const
inline

Definition at line 89 of file pk_options_readers.h.

89 {
90 note_examined(Option::DerEncoded);
91 return m_options.m_use_der;
92 }

Referenced by Botan::PK_Signer::PK_Signer(), and Botan::PK_Verifier::PK_Verifier().

◆ using_deterministic_signature()

bool Botan::PK_Signature_Options_Reader::using_deterministic_signature ( ) const
inline

Definition at line 94 of file pk_options_readers.h.

94 {
95 note_examined(Option::Deterministic);
96 return m_options.m_deterministic_sig && m_usage == Usage::Signing;
97 }

Referenced by Botan::SphincsPlus_PrivateKey::_create_signature_op(), Botan::acknowledge_always_deterministic(), Botan::PKCS11::MechanismWrapper::create_rsa_sign_mechanism(), Botan::ISO_9796_DS2::ISO_9796_DS2(), Botan::PSS_Raw::PSS_Raw(), and Botan::PSSR::PSSR().

◆ using_explicit_trailer_field()

bool Botan::PK_Signature_Options_Reader::using_explicit_trailer_field ( ) const
inline

Definition at line 99 of file pk_options_readers.h.

99 {
100 note_examined(Option::ExplicitTrailer);
101 return m_options.m_explicit_trailer_field;
102 }

◆ using_externally_computed_prehash()

bool Botan::PK_Signature_Options_Reader::using_externally_computed_prehash ( ) const
inline

◆ using_hash()

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

◆ using_padding()

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

◆ using_prehash()

bool Botan::PK_Signature_Options_Reader::using_prehash ( ) const
inline

◆ using_provider()

bool Botan::PK_Signature_Options_Reader::using_provider ( ) const

Definition at line 135 of file pk_options.cpp.

135 {
136 note_examined(Option::Provider);
137 return provider_is_in_use(m_options.m_provider);
138}

◆ using_salt_size()

bool Botan::PK_Signature_Options_Reader::using_salt_size ( ) const
inline

Definition at line 120 of file pk_options_readers.h.

120{ return salt_size().has_value(); }
const std::optional< size_t > & salt_size() const

References salt_size().

Referenced by Botan::PKCS11::MechanismWrapper::create_rsa_sign_mechanism().

◆ PK_Options_Reader_Access

friend class PK_Options_Reader_Access
friend

Definition at line 127 of file pk_options_readers.h.

References PK_Options_Reader_Access.

Referenced by PK_Options_Reader_Access.

◆ PK_Signer

friend class PK_Signer
friend

Definition at line 125 of file pk_options_readers.h.

References PK_Signer.

Referenced by PK_Signer.

◆ PK_Verifier

friend class PK_Verifier
friend

Definition at line 126 of file pk_options_readers.h.

References PK_Verifier.

Referenced by PK_Verifier.


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