Botan 3.0.0-alpha0
Crypto and TLS for C&
Public Member Functions | Protected Member Functions | 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
 
virtual size_t signature_length () const =0
 
void update (const uint8_t msg[], size_t msg_len) override
 

Protected Member Functions

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

Detailed Description

Definition at line 124 of file pk_ops_impl.h.

Constructor & Destructor Documentation

◆ Signature_with_EMSA()

Botan::PK_Ops::Signature_with_EMSA::Signature_with_EMSA ( const std::string &  emsa,
bool  with_message_recovery = false 
)
explicitprotected

Definition at line 62 of file pk_ops.cpp.

62 :
63 Signature(),
64 m_emsa(EMSA::create_or_throw(emsa)),
65 m_hash(hash_for_emsa(emsa)),
66 m_prefix_used(false)
67 {
68 if(!with_message_recovery && m_emsa->requires_message_recovery())
69 {
70 throw Invalid_Argument("Signature padding method " + emsa +
71 " requires message recovery, which is not supported by this scheme");
72 }
73 }
static std::unique_ptr< EMSA > create_or_throw(const std::string &algo_spec)
Definition: emsa.cpp:189
std::string hash_for_emsa(const std::string &algo_spec)
Definition: emsa.cpp:197

◆ ~Signature_with_EMSA()

Botan::PK_Ops::Signature_with_EMSA::~Signature_with_EMSA ( )
protecteddefault

Member Function Documentation

◆ clone_emsa()

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

Definition at line 149 of file pk_ops_impl.h.

149{ return m_emsa->new_object(); }

◆ has_prefix()

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

141{ return false; }

◆ hash_for_signature()

std::string Botan::PK_Ops::Signature_with_EMSA::hash_for_signature ( )
inlineprotected

Definition at line 135 of file pk_ops_impl.h.

135{ return m_hash; }

◆ message_prefix()

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

147{ throw Invalid_State("No prefix"); }

◆ sign()

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.

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 }

◆ signature_length()

virtual size_t Botan::PK_Ops::Signature::signature_length ( ) const
pure virtualinherited

◆ update()

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.

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:147

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