Botan  2.8.0
Crypto and TLS for C++11
Public Member Functions | Protected Member Functions | 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

std::unique_ptr< EMSAclone_emsa () const
 
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
 

Detailed Description

Definition at line 53 of file pk_ops_impl.h.

Constructor & Destructor Documentation

◆ ~Verification_with_EMSA()

Botan::PK_Ops::Verification_with_EMSA::~Verification_with_EMSA ( )
default

◆ Verification_with_EMSA()

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

Definition at line 95 of file pk_ops.cpp.

95  :
96  Verification(),
97  m_emsa(get_emsa(emsa)),
98  m_hash(hash_for_emsa(emsa)),
99  m_prefix_used(false)
100  {
101  if(!m_emsa)
102  throw Algorithm_Not_Found(emsa);
103  }
std::string hash_for_emsa(const std::string &algo_spec)
Definition: emsa.cpp:189
EMSA * get_emsa(const std::string &algo_spec)
Definition: emsa.cpp:44

Member Function Documentation

◆ clone_emsa()

std::unique_ptr<EMSA> Botan::PK_Ops::Verification_with_EMSA::clone_emsa ( ) const
inlineprotected

Definition at line 119 of file pk_ops_impl.h.

119 { return std::unique_ptr<EMSA>(m_emsa->clone()); }

◆ do_check()

bool Botan::PK_Ops::Verification_with_EMSA::do_check ( const secure_vector< uint8_t > &  msg,
const uint8_t  sig[],
size_t  sig_len 
)

◆ has_prefix()

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 79 of file pk_ops_impl.h.

79 { return false; }

◆ hash_for_signature()

std::string Botan::PK_Ops::Verification_with_EMSA::hash_for_signature ( )
inline

Definition at line 64 of file pk_ops_impl.h.

64 { return m_hash; }

◆ is_valid_signature()

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 116 of file pk_ops.cpp.

117  {
118  m_prefix_used = false;
119  const secure_vector<uint8_t> msg = m_emsa->raw_data();
120 
121  if(with_recovery())
122  {
123  secure_vector<uint8_t> output_of_key = verify_mr(sig, sig_len);
124  return m_emsa->verify(output_of_key, msg, max_input_bits());
125  }
126  else
127  {
128  Null_RNG rng;
129  secure_vector<uint8_t> encoded = m_emsa->encoding_of(msg, max_input_bits(), rng);
130  return verify(encoded.data(), encoded.size(), sig, sig_len);
131  }
132  }
virtual bool verify(const uint8_t[], size_t, const uint8_t[], size_t)
Definition: pk_ops_impl.h:101
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:114

◆ max_input_bits()

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

◆ message_prefix()

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 85 of file pk_ops_impl.h.

85 { throw Exception( "No prefix" ); }

◆ update()

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 105 of file pk_ops.cpp.

106  {
107  if(has_prefix() && !m_prefix_used)
108  {
109  m_prefix_used = true;
110  secure_vector<uint8_t> prefix = message_prefix();
111  m_emsa->update(prefix.data(), prefix.size());
112  }
113  m_emsa->update(msg, msg_len);
114  }
virtual secure_vector< uint8_t > message_prefix() const
Definition: pk_ops_impl.h:85

◆ verify()

virtual bool Botan::PK_Ops::Verification_with_EMSA::verify ( const uint8_t  [],
size_t  ,
const uint8_t  [],
size_t   
)
inlineprotectedvirtual

Definition at line 101 of file pk_ops_impl.h.

103  {
104  throw Invalid_State("Message recovery required");
105  }

◆ verify_mr()

virtual secure_vector<uint8_t> Botan::PK_Ops::Verification_with_EMSA::verify_mr ( const uint8_t  [],
size_t   
)
inlineprotectedvirtual

Definition at line 114 of file pk_ops_impl.h.

115  {
116  throw Invalid_State("Message recovery not supported");
117  }

◆ with_recovery()

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()

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