Botan  2.19.1
Crypto and TLS for C++11
Public Member Functions | List of all members
Botan::EMSA1 Class Referencefinal

#include <emsa1.h>

Inheritance diagram for Botan::EMSA1:
Botan::EMSA

Public Member Functions

EMSAclone () override
 
AlgorithmIdentifier config_for_x509 (const Private_Key &key, const std::string &cert_hash_name) const override
 
 EMSA1 (HashFunction *hash)
 
std::string name () const override
 

Detailed Description

EMSA1 from IEEE 1363 Essentially, sign the hash directly

Definition at line 22 of file emsa1.h.

Constructor & Destructor Documentation

Botan::EMSA1::EMSA1 ( HashFunction hash)
inlineexplicit
Parameters
hashthe hash function to use

Definition at line 28 of file emsa1.h.

Referenced by clone().

28 : m_hash(hash) {}
MechanismType hash

Member Function Documentation

EMSA * Botan::EMSA1::clone ( )
overridevirtual
Returns
a new object representing the same encoding method as *this

Implements Botan::EMSA.

Definition at line 51 of file emsa1.cpp.

References EMSA1().

52  {
53  return new EMSA1(m_hash->clone());
54  }
EMSA1(HashFunction *hash)
Definition: emsa1.h:28
AlgorithmIdentifier Botan::EMSA1::config_for_x509 ( const Private_Key key,
const std::string &  cert_hash_name 
) const
overridevirtual

Prepare sig_algo for use in choose_sig_format for x509 certs

Parameters
keyused for checking compatibility with the encoding scheme
cert_hash_nameis checked to equal the hash for the encoding
Returns
algorithm identifier to signatures created using this key, padding method and hash.

Reimplemented from Botan::EMSA.

Definition at line 98 of file emsa1.cpp.

References Botan::Public_Key::algo_name(), Botan::Public_Key::algorithm_identifier(), Botan::OID::from_string(), Botan::AlgorithmIdentifier::get_parameters(), name(), and Botan::sig_algo_and_pad_ok().

100  {
101  if(cert_hash_name != m_hash->name())
102  throw Invalid_Argument("Hash function from opts and hash_fn argument"
103  " need to be identical");
104  // check that the signature algorithm and the padding scheme fit
105  if(!sig_algo_and_pad_ok(key.algo_name(), "EMSA1"))
106  {
107  throw Invalid_Argument("Encoding scheme with canonical name EMSA1"
108  " not supported for signature algorithm " + key.algo_name());
109  }
110 
111  const OID oid = OID::from_string(key.algo_name() + "/" + name());
112 
113  const std::string algo_name = key.algo_name();
114  std::vector<uint8_t> parameters;
115  if(algo_name == "DSA" ||
116  algo_name == "ECDSA" ||
117  algo_name == "ECGDSA" ||
118  algo_name == "ECKCDSA" ||
119  algo_name == "GOST-34.10" ||
120  algo_name == "GOST-34.10-2012-256" ||
121  algo_name == "GOST-34.10-2012-512")
122  {
123  // for DSA, ECDSA, GOST parameters "SHALL" be empty
124  }
125  else
126  {
127  parameters = key.algorithm_identifier().get_parameters();
128  }
129 
130  return AlgorithmIdentifier(oid, parameters);
131  }
bool sig_algo_and_pad_ok(const std::string algo, const std::string padding)
Definition: padding.cpp:39
std::string name() const override
Definition: emsa1.cpp:46
static OID from_string(const std::string &str)
Definition: asn1_oid.cpp:62
std::string Botan::EMSA1::name ( ) const
overridevirtual
Returns
the SCAN name of the encoding/padding scheme

Implements Botan::EMSA.

Definition at line 46 of file emsa1.cpp.

Referenced by config_for_x509().

47  {
48  return "EMSA1(" + m_hash->name() + ")";
49  }

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