Botan 2.13.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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

`#include <pssr.h>`

Inheritance diagram for Botan::PSSR:

## Public Member Functions
EMSA * | clone () override
AlgorithmIdentifier | config_for_x509 (const Private_Key &key, const std::string &cert_hash_name) const override
std::string | name () const override
| PSSR (HashFunction *hash)
| PSSR (HashFunction *hash, size_t salt_size)

## Detailed Description

PSSR (called EMSA4 in IEEE 1363 and in old versions of the library)

Definition at line 21 of file pssr.h.

## Constructor & Destructor Documentation

Botan::PSSR::PSSR | ( | HashFunction * | hash | ) |
| explicit

Parameters

  hash | the hash function to use

Definition at line 128 of file pssr.cpp.

Referenced by clone().

128 :
129 m_hash(h),
130 m_salt_size(m_hash->output_length()),
131 m_required_salt_len(false)
132 {
133 }

Botan::PSSR::PSSR | ( | HashFunction * | hash,
|  | size_t | salt_size
| ) |  |

Parameters

  hash | the hash function to use
  salt_size | the size of the salt to use in bytes

Definition at line 135 of file pssr.cpp.

135 :
136 m_hash(h),
137 m_salt_size(salt_size),
138 m_required_salt_len(true)
139 {
140 }
salt_size
size_t salt_size
Definition: p11_mechanism.cpp:70

## Member Function Documentation

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

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

Implements Botan::EMSA.

Definition at line 182 of file pssr.cpp.

References PSSR().

183 {
184 return new PSSR(m_hash->clone(), m_salt_size);
185 }
Botan::PSSR::PSSR
PSSR(HashFunction *hash)
Definition: pssr.cpp:128

AlgorithmIdentifier Botan::PSSR::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 192 of file pssr.cpp.

References Botan::Public_Key::algo_name(), Botan::ASN1_Object::BER_encode(), Botan::CONTEXT_SPECIFIC, Botan::DER_Encoder::encode(), Botan::DER_Encoder::end_cons(), Botan::SEQUENCE, Botan::sig_algo_and_pad_ok(), Botan::DER_Encoder::start_cons(), and Botan::AlgorithmIdentifier::USE_NULL_PARAM.

194 {
195 if(cert_hash_name != m_hash->name())
196 throw Invalid_Argument("Hash function from opts and hash_fn argument"
197 " need to be identical");
198 // check that the signature algorithm and the padding scheme fit
199 if(!sig_algo_and_pad_ok(key.algo_name(), "EMSA4"))
200 {
201 throw Invalid_Argument("Encoding scheme with canonical name EMSA4"
202 " not supported for signature algorithm " + key.algo_name());
203 }
204
205 const AlgorithmIdentifier hash_id(cert_hash_name, AlgorithmIdentifier::USE_NULL_PARAM);
206 const AlgorithmIdentifier mgf_id("MGF1", hash_id.BER_encode());
207
208 std::vector<uint8_t> parameters;
209 DER_Encoder(parameters)
210 .start_cons(SEQUENCE)
211 .start_cons(ASN1_Tag(0), CONTEXT_SPECIFIC).encode(hash_id).end_cons()
212 .start_cons(ASN1_Tag(1), CONTEXT_SPECIFIC).encode(mgf_id).end_cons()
213 .start_cons(ASN1_Tag(2), CONTEXT_SPECIFIC).encode(m_salt_size).end_cons()
214 .start_cons(ASN1_Tag(3), CONTEXT_SPECIFIC).encode(size_t(1)).end_cons() // trailer field
215 .end_cons();
216
217 // hardcoded as RSA is the only valid algorithm for EMSA4 at the moment
218 return AlgorithmIdentifier("RSA/EMSA4", parameters);
219 }
Botan::ASN1_Tag
ASN1_Tag
Definition: asn1_obj.h:23
Botan::sig_algo_and_pad_ok
bool sig_algo_and_pad_ok(const std::string algo, const std::string padding)
Definition: padding.cpp:39
Botan::SEQUENCE
Definition: asn1_obj.h:40
Botan::CONTEXT_SPECIFIC
Definition: asn1_obj.h:26
Botan::AlgorithmIdentifier::USE_NULL_PARAM
Definition: alg_id.h:24

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

Returns
  the SCAN name of the encoding/padding scheme

Implements Botan::EMSA.

Definition at line 187 of file pssr.cpp.

References Botan::ASN1::to_string().

188 {
189 return "EMSA4(" + m_hash->name() + ",MGF1," + std::to_string(m_salt_size) + ")";
190 }
Botan::ASN1::to_string
std::string to_string(const BER_Object &obj)
Definition: asn1_obj.cpp:213

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

- src/lib/pk_pad/emsa_pssr/pssr.h
- src/lib/pk_pad/emsa_pssr/pssr.cpp