Botan  2.4.0
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 20 of file emsa1.h.

Constructor & Destructor Documentation

◆ EMSA1()

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

Definition at line 26 of file emsa1.h.

Referenced by clone().

26 : m_hash(hash) {}
MechanismType hash

Member Function Documentation

◆ clone()

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

Implements Botan::EMSA.

Definition at line 52 of file emsa1.cpp.

References Botan::constant_time_compare(), and EMSA1().

53  {
54  return new EMSA1(m_hash->clone());
55  }
EMSA1(HashFunction *hash)
Definition: emsa1.h:26

◆ config_for_x509()

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

References Botan::Public_Key::algo_name(), Botan::Public_Key::algorithm_identifier(), Botan::OIDS::lookup(), name(), Botan::AlgorithmIdentifier::oid, Botan::AlgorithmIdentifier::parameters, and Botan::sig_algo_and_pad_ok().

107  {
108  if(cert_hash_name != m_hash->name())
109  throw Invalid_Argument("Hash function from opts and hash_fn argument"
110  " need to be identical");
111  // check that the signature algorithm and the padding scheme fit
112  if(!sig_algo_and_pad_ok(key.algo_name(), "EMSA1"))
113  {
114  throw Invalid_Argument("Encoding scheme with canonical name EMSA1"
115  " not supported for signature algorithm " + key.algo_name());
116  }
117 
118  AlgorithmIdentifier sig_algo;
119  sig_algo.oid = OIDS::lookup( key.algo_name() + "/" + name() );
120 
121  std::string algo_name = key.algo_name();
122  if(algo_name == "DSA" ||
123  algo_name == "ECDSA" ||
124  algo_name == "ECGDSA" ||
125  algo_name == "ECKCDSA" ||
126  algo_name == "GOST-34.10")
127  {
128  // for DSA, ECDSA, GOST parameters "SHALL" be empty
129  sig_algo.parameters = {};
130  }
131  else
132  {
133  sig_algo.parameters = key.algorithm_identifier().parameters;
134  }
135 
136  return sig_algo;
137  }
bool sig_algo_and_pad_ok(const std::string algo, const std::string padding)
Definition: padding.cpp:37
std::string name() const override
Definition: emsa1.cpp:47
std::string lookup(const OID &oid)
Definition: oids.cpp:18

◆ name()

std::string Botan::EMSA1::name ( ) const
overridevirtual
Returns
the SCAN name of the encoding/padding scheme

Implements Botan::EMSA.

Definition at line 47 of file emsa1.cpp.

Referenced by config_for_x509().

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

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