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::Signature_with_EMSA Class Referenceabstract

#include <pk_ops_impl.h>

Inheritance diagram for Botan::PK_Ops::Signature_with_EMSA:
Botan::PK_Ops::Signature

Public Member Functions

secure_vector< uint8_t > sign (RandomNumberGenerator &rng) override
 
void update (const uint8_t msg[], size_t msg_len) override
 

Protected Member Functions

virtual bool has_prefix ()
 
std::string hash_for_signature ()
 
virtual secure_vector< uint8_t > message_prefix () const
 
 Signature_with_EMSA (const std::string &emsa)
 
 ~Signature_with_EMSA ()=default
 

Protected Attributes

std::unique_ptr< EMSAm_emsa
 

Detailed Description

Definition at line 127 of file pk_ops_impl.h.

Constructor & Destructor Documentation

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

Definition at line 65 of file pk_ops.cpp.

References m_emsa.

65  :
66  Signature(),
67  m_emsa(get_emsa(emsa)),
68  m_hash(hash_for_emsa(emsa)),
69  m_prefix_used(false)
70  {
71  if(!m_emsa)
72  throw Algorithm_Not_Found(emsa);
73  }
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:151
std::unique_ptr< HashFunction > m_hash
Definition: tpm.cpp:439
Botan::PK_Ops::Signature_with_EMSA::~Signature_with_EMSA ( )
protecteddefault

Member Function Documentation

virtual bool Botan::PK_Ops::Signature_with_EMSA::has_prefix ( )
inlineprotectedvirtual
Returns
boolean specifying if this signature scheme uses a message prefix returned by message_prefix()

Definition at line 143 of file pk_ops_impl.h.

143 { return false; }
std::string Botan::PK_Ops::Signature_with_EMSA::hash_for_signature ( )
inlineprotected

Definition at line 137 of file pk_ops_impl.h.

137 { return m_hash; }
std::unique_ptr< HashFunction > m_hash
Definition: tpm.cpp:439
virtual secure_vector<uint8_t> Botan::PK_Ops::Signature_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 149 of file pk_ops_impl.h.

149 { throw Exception( "No prefix" ); }
secure_vector< uint8_t > Botan::PK_Ops::Signature_with_EMSA::sign ( RandomNumberGenerator rng)
overridevirtual

Implements Botan::PK_Ops::Signature.

Definition at line 86 of file pk_ops.cpp.

References m_emsa.

87  {
88  m_prefix_used = false;
89  const secure_vector<uint8_t> msg = m_emsa->raw_data();
90  const auto padded = m_emsa->encoding_of(msg, this->max_input_bits(), rng);
91  return raw_sign(padded.data(), padded.size(), rng);
92  }
std::unique_ptr< EMSA > m_emsa
Definition: pk_ops_impl.h:151
void Botan::PK_Ops::Signature_with_EMSA::update ( const uint8_t  msg[],
size_t  msg_len 
)
overridevirtual

Implements Botan::PK_Ops::Signature.

Definition at line 75 of file pk_ops.cpp.

References m_emsa.

76  {
77  if(has_prefix() && !m_prefix_used)
78  {
79  m_prefix_used = true;
80  secure_vector<uint8_t> prefix = message_prefix();
81  m_emsa->update(prefix.data(), prefix.size());
82  }
83  m_emsa->update(msg, msg_len);
84  }
virtual secure_vector< uint8_t > message_prefix() const
Definition: pk_ops_impl.h:149
std::unique_ptr< EMSA > m_emsa
Definition: pk_ops_impl.h:151

Member Data Documentation

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

Definition at line 151 of file pk_ops_impl.h.

Referenced by Signature_with_EMSA().


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