Botan 3.4.0
Crypto and TLS for C&
Public Member Functions | Protected Member Functions | List of all members
Botan::PK_Ops::Verification_with_Hash Class Referenceabstract

#include <pk_ops_impl.h>

Inheritance diagram for Botan::PK_Ops::Verification_with_Hash:
Botan::PK_Ops::Verification

Public Member Functions

std::string hash_function () const final
 
bool is_valid_signature (const uint8_t sig[], size_t sig_len) override
 
void update (const uint8_t msg[], size_t msg_len) override
 
 ~Verification_with_Hash () override=default
 

Protected Member Functions

 Verification_with_Hash (const AlgorithmIdentifier &alg_id, std::string_view pk_algo, bool allow_null_parameters=false)
 
 Verification_with_Hash (std::string_view hash)
 
virtual bool verify (const uint8_t msg[], size_t msg_len, const uint8_t sig[], size_t sig_len)=0
 

Detailed Description

Definition at line 50 of file pk_ops_impl.h.

Constructor & Destructor Documentation

◆ ~Verification_with_Hash()

Botan::PK_Ops::Verification_with_Hash::~Verification_with_Hash ( )
overridedefault

◆ Verification_with_Hash() [1/2]

Botan::PK_Ops::Verification_with_Hash::Verification_with_Hash ( std::string_view hash)
explicitprotected

Definition at line 126 of file pk_ops.cpp.

126 :
127 Verification(), m_hash(create_signature_hash(padding)) {}

◆ Verification_with_Hash() [2/2]

Botan::PK_Ops::Verification_with_Hash::Verification_with_Hash ( const AlgorithmIdentifier & alg_id,
std::string_view pk_algo,
bool allow_null_parameters = false )
explicitprotected

Definition at line 129 of file pk_ops.cpp.

131 {
132 const auto oid_info = split_on(alg_id.oid().to_formatted_string(), '/');
133
134 if(oid_info.size() != 2 || oid_info[0] != pk_algo) {
135 throw Decoding_Error(
136 fmt("Unexpected AlgorithmIdentifier OID {} in association with {} key", alg_id.oid(), pk_algo));
137 }
138
139 if(!alg_id.parameters_are_empty()) {
140 if(alg_id.parameters_are_null()) {
141 if(!allow_null_parameters) {
142 throw Decoding_Error(fmt("Unexpected NULL AlgorithmIdentifier parameters for {}", pk_algo));
143 }
144 } else {
145 throw Decoding_Error(fmt("Unexpected AlgorithmIdentifier parameters for {}", pk_algo));
146 }
147 }
148
149 m_hash = HashFunction::create_or_throw(oid_info[1]);
150}
static std::unique_ptr< HashFunction > create_or_throw(std::string_view algo_spec, std::string_view provider="")
Definition hash.cpp:298
std::string fmt(std::string_view format, const T &... args)
Definition fmt.h:53
std::vector< std::string > split_on(std::string_view str, char delim)
Definition parsing.cpp:111

References Botan::HashFunction::create_or_throw(), Botan::fmt(), Botan::AlgorithmIdentifier::oid(), Botan::AlgorithmIdentifier::parameters_are_empty(), Botan::AlgorithmIdentifier::parameters_are_null(), Botan::split_on(), and Botan::OID::to_formatted_string().

Member Function Documentation

◆ hash_function()

std::string Botan::PK_Ops::Verification_with_Hash::hash_function ( ) const
inlinefinalvirtual

Return the hash function being used by this signer

Implements Botan::PK_Ops::Verification.

Definition at line 57 of file pk_ops_impl.h.

57{ return m_hash->name(); }

◆ is_valid_signature()

bool Botan::PK_Ops::Verification_with_Hash::is_valid_signature ( const uint8_t sig[],
size_t sig_len )
overridevirtual

Perform a verification operation

Implements Botan::PK_Ops::Verification.

Definition at line 156 of file pk_ops.cpp.

156 {
157 const secure_vector<uint8_t> msg = m_hash->final();
158 return verify(msg.data(), msg.size(), sig, sig_len);
159}
virtual bool verify(const uint8_t msg[], size_t msg_len, const uint8_t sig[], size_t sig_len)=0

◆ update()

void Botan::PK_Ops::Verification_with_Hash::update ( const uint8_t msg[],
size_t msg_len )
overridevirtual

Add more data to the message currently being signed

Parameters
msgthe message
msg_lenthe length of msg in bytes

Implements Botan::PK_Ops::Verification.

Definition at line 152 of file pk_ops.cpp.

152 {
153 m_hash->update(msg, msg_len);
154}

◆ verify()

virtual bool Botan::PK_Ops::Verification_with_Hash::verify ( const uint8_t msg[],
size_t msg_len,
const uint8_t sig[],
size_t sig_len )
protectedpure virtual

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