Botan 2.19.5 Crypto and TLS for C&

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

`#include <emsa_pkcs1.h>`

Inheritance diagram for Botan::EMSA_PKCS1v15_Raw:

## Public Member Functions
EMSA * | clone () override
virtual AlgorithmIdentifier | config_for_x509 (const Private_Key &key, const std::string &cert_hash_name) const
| EMSA_PKCS1v15_Raw (const std::string &hash_algo="")
secure_vector< uint8_t > | encoding_of (const secure_vector< uint8_t > &, size_t, RandomNumberGenerator &rng) override
std::string | name () const override
secure_vector< uint8_t > | raw_data () override
void | update (const uint8_t[], size_t) override
bool | verify (const secure_vector< uint8_t > &, const secure_vector< uint8_t > &, size_t) override

## Detailed Description

EMSA_PKCS1v15_Raw which is EMSA_PKCS1v15 without a hash or digest id (which according to QCA docs is "identical to PKCS#11's CKM_RSA_PKCS mechanism", something I have not confirmed)

Definition at line 58 of file emsa_pkcs1.h.

## Constructor & Destructor Documentation

## ◆ EMSA_PKCS1v15_Raw()

Botan::EMSA_PKCS1v15_Raw::EMSA_PKCS1v15_Raw | ( | const std::string & | hash_algo = `""` | ) |

Parameters

  hash_algo | if non-empty, the digest id for that hash is included in the signature.

Definition at line 110 of file emsa_pkcs1.cpp.

111 {
112 if(!hash_algo.empty())
113 {
114 m_hash_id = pkcs_hash_id(hash_algo);
115 std::unique_ptr<HashFunction> hash(HashFunction::create_or_throw(hash_algo));
116 m_hash_name = hash->name();
117 m_hash_output_len = hash->output_length();
118 }
119 else
120 {
121 m_hash_output_len = 0;
122 }
123 }
Botan::HashFunction::create_or_throw
static std::unique_ptr< HashFunction > create_or_throw(const std::string &algo_spec, const std::string &provider="")
Definition: hash.cpp:329
Botan::pkcs_hash_id
std::vector< uint8_t > pkcs_hash_id(const std::string &name)
Definition: hash_id.cpp:77
hash
MechanismType hash
Definition: p11_mechanism.cpp:64
hash_algo
AlgorithmIdentifier hash_algo
Definition: x509_obj.cpp:22

References Botan::HashFunction::create_or_throw(), hash, hash_algo, and Botan::pkcs_hash_id().

## Member Function Documentation

## ◆ clone()

EMSA * Botan::EMSA_PKCS1v15_Raw::clone | ( |  | ) |
| inline override virtual

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

Implements Botan::EMSA.

Definition at line 61 of file emsa_pkcs1.h.

61{ return new EMSA_PKCS1v15_Raw(); }
Botan::EMSA_PKCS1v15_Raw::EMSA_PKCS1v15_Raw
EMSA_PKCS1v15_Raw(const std::string &hash_algo="")
Definition: emsa_pkcs1.cpp:110

## ◆ config_for_x509()

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

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 in Botan::EMSA1, Botan::EMSA_PKCS1v15, and Botan::PSSR.

Definition at line 38 of file emsa.cpp.

40 {
41 throw Not_Implemented("Encoding " + name() + " not supported for signing X509 objects");
42 }
Botan::EMSA::name
virtual std::string name() const =0

References Botan::EMSA::name().

## ◆ encoding_of()

secure_vector< uint8_t > Botan::EMSA_PKCS1v15_Raw::encoding_of | ( | const secure_vector< uint8_t > & | msg,
|  | size_t | output_bits,
|  | RandomNumberGenerator & | rng
| ) |  |
| override virtual

Return the encoding of a message

Parameters

  msg | the result of raw_data()
  output_bits | the desired output bit size
  rng | a random number generator

Returns
  encoded signature

Implements Botan::EMSA.

Definition at line 142 of file emsa_pkcs1.cpp.

145 {
146 return emsa3_encoding(msg, output_bits, m_hash_id.data(), m_hash_id.size());
147 }

## ◆ name()

std::string Botan::EMSA_PKCS1v15_Raw::name | ( |  | ) | const
| inline override virtual

Returns
  the SCAN name of the encoding/padding scheme

Implements Botan::EMSA.

Definition at line 79 of file emsa_pkcs1.h.

80 {
81 if(m_hash_name.empty()) return "EMSA3(Raw)";
82 else return "EMSA3(Raw," + m_hash_name + ")";
83 }

## ◆ raw_data()

secure_vector< uint8_t > Botan::EMSA_PKCS1v15_Raw::raw_data | ( |  | ) |
| override virtual

Returns
  raw hash

Implements Botan::EMSA.

Definition at line 130 of file emsa_pkcs1.cpp.

131 {
132 secure_vector<uint8_t> ret;
133 std::swap(ret, m_message);
134
135 if(m_hash_output_len > 0 && ret.size() != m_hash_output_len)
136 throw Encoding_Error("EMSA_PKCS1v15_Raw::encoding_of: Bad input length");
137
138 return ret;
139 }

## ◆ update()

void Botan::EMSA_PKCS1v15_Raw::update | ( | const uint8_t | input[],
|  | size_t | length
| ) |  |
| override virtual

Add more data to the signature computation

Parameters

  input | some data
  length | length of input in bytes

Implements Botan::EMSA.

Definition at line 125 of file emsa_pkcs1.cpp.

126 {
127 m_message += std::make_pair(input, length);
128 }

## ◆ verify()

bool Botan::EMSA_PKCS1v15_Raw::verify | ( | const secure_vector< uint8_t > & | coded,
|  | const secure_vector< uint8_t > & | raw,
|  | size_t | key_bits
| ) |  |
| override virtual

Verify the encoding

Parameters

  coded | the received (coded) message representative
  raw | the computed (local, uncoded) message representative
  key_bits | the size of the key in bits

Returns
  true if coded is a valid encoding of raw, otherwise false

Implements Botan::EMSA.

Definition at line 149 of file emsa_pkcs1.cpp.

152 {
153 if(m_hash_output_len > 0 && raw.size() != m_hash_output_len)
154 return false;
155
156 try
157 {
158 return (coded == emsa3_encoding(raw, key_bits, m_hash_id.data(), m_hash_id.size()));
159 }
160 catch(...)
161 {
162 return false;
163 }
164 }

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

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