Botan  2.1.0
Crypto and TLS for C++11
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Botan::PK_Ops::Verification_with_EMSA Class Referenceabstract

#include <pk_ops_impl.h>

Inheritance diagram for Botan::PK_Ops::Verification_with_EMSA:
Botan::PK_Ops::Verification

Public Member Functions

bool do_check (const secure_vector< uint8_t > &msg, const uint8_t sig[], size_t sig_len)
 
std::string hash_for_signature ()
 
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_EMSA ()=default
 

Protected Member Functions

virtual bool has_prefix ()
 
virtual size_t max_input_bits () const =0
 
virtual secure_vector< uint8_t > message_prefix () const
 
 Verification_with_EMSA (const std::string &emsa)
 
virtual bool verify (const uint8_t[], size_t, const uint8_t[], size_t)
 
virtual secure_vector< uint8_t > verify_mr (const uint8_t[], size_t)
 
virtual bool with_recovery () const =0
 

Protected Attributes

std::unique_ptr< EMSAm_emsa
 

Detailed Description

Definition at line 54 of file pk_ops_impl.h.

Constructor & Destructor Documentation

Botan::PK_Ops::Verification_with_EMSA::~Verification_with_EMSA ( )
default
Botan::PK_Ops::Verification_with_EMSA::Verification_with_EMSA ( const std::string &  emsa)
explicitprotected

Definition at line 94 of file pk_ops.cpp.

References m_emsa.

94  :
95  Verification(),
96  m_emsa(get_emsa(emsa)),
97  m_hash(hash_for_emsa(emsa)),
98  m_prefix_used(false)
99  {
100  if(!m_emsa)
101  throw Algorithm_Not_Found(emsa);
102  }
std::string hash_for_emsa(const std::string &algo_spec)
Definition: emsa.cpp:142
EMSA * get_emsa(const std::string &algo_spec)
Definition: emsa.cpp:36
std::unique_ptr< EMSA > m_emsa
Definition: pk_ops_impl.h:120
std::unique_ptr< HashFunction > m_hash
Definition: tpm.cpp:439

Member Function Documentation

bool Botan::PK_Ops::Verification_with_EMSA::do_check ( const secure_vector< uint8_t > &  msg,
const uint8_t  sig[],
size_t  sig_len 
)
virtual bool Botan::PK_Ops::Verification_with_EMSA::has_prefix ( )
inlineprotectedvirtual
Returns
boolean specifying if this signature scheme uses a message prefix returned by message_prefix()

Definition at line 80 of file pk_ops_impl.h.

80 { return false; }
std::string Botan::PK_Ops::Verification_with_EMSA::hash_for_signature ( )
inline

Definition at line 65 of file pk_ops_impl.h.

65 { return m_hash; }
std::unique_ptr< HashFunction > m_hash
Definition: tpm.cpp:439
bool Botan::PK_Ops::Verification_with_EMSA::is_valid_signature ( const uint8_t  sig[],
size_t  sig_len 
)
overridevirtual

Implements Botan::PK_Ops::Verification.

Definition at line 115 of file pk_ops.cpp.

References m_emsa.

116  {
117  m_prefix_used = false;
118  const secure_vector<uint8_t> msg = m_emsa->raw_data();
119 
120  if(with_recovery())
121  {
122  secure_vector<uint8_t> output_of_key = verify_mr(sig, sig_len);
123  return m_emsa->verify(output_of_key, msg, max_input_bits());
124  }
125  else
126  {
127  Null_RNG rng;
128  secure_vector<uint8_t> encoded = m_emsa->encoding_of(msg, max_input_bits(), rng);
129  return verify(encoded.data(), encoded.size(), sig, sig_len);
130  }
131  }
virtual bool verify(const uint8_t[], size_t, const uint8_t[], size_t)
Definition: pk_ops_impl.h:102
std::unique_ptr< EMSA > m_emsa
Definition: pk_ops_impl.h:120
virtual size_t max_input_bits() const =0
virtual bool with_recovery() const =0
virtual secure_vector< uint8_t > verify_mr(const uint8_t[], size_t)
Definition: pk_ops_impl.h:115
virtual size_t Botan::PK_Ops::Verification_with_EMSA::max_input_bits ( ) const
protectedpure virtual

Get the maximum message size in bits supported by this public key.

Returns
maximum message in bits
virtual secure_vector<uint8_t> Botan::PK_Ops::Verification_with_EMSA::message_prefix ( ) const
inlineprotectedvirtual
Returns
the message prefix if this signature scheme uses a message prefix, signaled via has_prefix()

Definition at line 86 of file pk_ops_impl.h.

86 { throw Exception( "No prefix" ); }
void Botan::PK_Ops::Verification_with_EMSA::update ( const uint8_t  msg[],
size_t  msg_len 
)
overridevirtual

Implements Botan::PK_Ops::Verification.

Definition at line 104 of file pk_ops.cpp.

References m_emsa.

105  {
106  if(has_prefix() && !m_prefix_used)
107  {
108  m_prefix_used = true;
109  secure_vector<uint8_t> prefix = message_prefix();
110  m_emsa->update(prefix.data(), prefix.size());
111  }
112  m_emsa->update(msg, msg_len);
113  }
virtual secure_vector< uint8_t > message_prefix() const
Definition: pk_ops_impl.h:86
std::unique_ptr< EMSA > m_emsa
Definition: pk_ops_impl.h:120
virtual bool Botan::PK_Ops::Verification_with_EMSA::verify ( const uint8_t  [],
size_t  ,
const uint8_t  [],
size_t   
)
inlineprotectedvirtual

Definition at line 102 of file pk_ops_impl.h.

104  {
105  throw Invalid_State("Message recovery required");
106  }
virtual secure_vector<uint8_t> Botan::PK_Ops::Verification_with_EMSA::verify_mr ( const uint8_t  [],
size_t   
)
inlineprotectedvirtual

Definition at line 115 of file pk_ops_impl.h.

116  {
117  throw Invalid_State("Message recovery not supported");
118  }
virtual bool Botan::PK_Ops::Verification_with_EMSA::with_recovery ( ) const
protectedpure virtual
Returns
boolean specifying if this key type supports message recovery and thus if you need to call verify() or verify_mr()

Member Data Documentation

std::unique_ptr<EMSA> Botan::PK_Ops::Verification_with_EMSA::m_emsa
protected

Definition at line 120 of file pk_ops_impl.h.

Referenced by Verification_with_EMSA().


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