Botan 2.19.5 Crypto and TLS for C&

Public Member Functions | List of all members
Botan::EMSA1 Class Referencefinal

`#include <emsa1.h>`

Inheritance diagram for Botan::EMSA1:

## Public Member Functions
EMSA * | clone () 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

## ◆ EMSA1()

Botan::EMSA1::EMSA1 | ( | HashFunction * | hash | ) |
| inline explicit

Parameters

  hash | the hash function to use

Definition at line 28 of file emsa1.h.

28: m_hash(hash) {}
hash
MechanismType hash
Definition: p11_mechanism.cpp:64

Referenced by clone().

## Member Function Documentation

## ◆ clone()

EMSA * Botan::EMSA1::clone | ( |  | ) |
| override virtual

Returns
  a new object representing the same encoding method as *this

Implements Botan::EMSA.

Definition at line 51 of file emsa1.cpp.

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

References EMSA1().

## ◆ config_for_x509()

AlgorithmIdentifier Botan::EMSA1::config_for_x509 | ( | const Private_Key & | key,
|  | const std::string & | cert_hash_name
| ) |  | const
| override virtual

Prepare sig_algo for use in choose_sig_format for x509 certs

Parameters

  key | used for checking compatibility with the encoding scheme
  cert_hash_name | is 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.

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 }
Botan::EMSA1::name
std::string name() const override
Definition: emsa1.cpp:46
Botan::OID::from_string
static OID from_string(const std::string &str)
Definition: asn1_oid.cpp:62
Botan::sig_algo_and_pad_ok
bool sig_algo_and_pad_ok(const std::string algo, const std::string padding)
Definition: padding.cpp:39

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

## ◆ name()

std::string Botan::EMSA1::name | ( |  | ) | const
| override virtual

Returns
  the SCAN name of the encoding/padding scheme

Implements Botan::EMSA.

Definition at line 46 of file emsa1.cpp.

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

Referenced by config_for_x509().

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

- src/lib/pk_pad/emsa1/emsa1.h
- src/lib/pk_pad/emsa1/emsa1.cpp