Botan 2.1.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::EMSA_PKCS1v15 Class Referencefinal

`#include <emsa_pkcs1.h>`

Inheritance diagram for Botan::EMSA_PKCS1v15:

## Public Member Functions
EMSA * | clone () override
| EMSA_PKCS1v15 (HashFunction *hash)
secure_vector< uint8_t > | encoding_of (const secure_vector< uint8_t > &, size_t, RandomNumberGenerator &rng) 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

PKCS #1 v1.5 signature padding aka PKCS #1 block type 1 aka EMSA3 from IEEE 1363

Definition at line 21 of file emsa_pkcs1.h.

## Constructor & Destructor Documentation

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

Parameters

  hash | the hash function to use

Definition at line 83 of file emsa_pkcs1.cpp.

References Botan::pkcs_hash_id().

83 : m_hash(hash)
84 {
85 m_hash_id = pkcs_hash_id(m_hash->name());
86 }
Botan::pkcs_hash_id
std::vector< uint8_t > pkcs_hash_id(const std::string &name)
Definition: hash_id.cpp:56
hash
MechanismType hash
Definition: p11_mechanism.cpp:63

## Member Function Documentation

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

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

Implements Botan::EMSA.

Definition at line 29 of file emsa_pkcs1.h.

References m_hash.

29 { return new EMSA_PKCS1v15(m_hash->clone()); }
Botan::EMSA_PKCS1v15::EMSA_PKCS1v15
EMSA_PKCS1v15(HashFunction *hash)
Definition: emsa_pkcs1.cpp:83

secure_vector< uint8_t > Botan::EMSA_PKCS1v15::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 54 of file emsa_pkcs1.cpp.

57 {
58 if(msg.size() != m_hash->output_length())
59 throw Encoding_Error("EMSA_PKCS1v15::encoding_of: Bad input length");
60
61 return emsa3_encoding(msg, output_bits,
62 m_hash_id.data(), m_hash_id.size());
63 }

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

Returns
  raw hash

Implements Botan::EMSA.

Definition at line 48 of file emsa_pkcs1.cpp.

49 {
50 return m_hash->final();
51 }

void Botan::EMSA_PKCS1v15::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 43 of file emsa_pkcs1.cpp.

44 {
45 m_hash->update(input, length);
46 }

bool Botan::EMSA_PKCS1v15::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 65 of file emsa_pkcs1.cpp.

68 {
69 if(raw.size() != m_hash->output_length())
70 return false;
71
72 try
73 {
74 return (coded == emsa3_encoding(raw, key_bits,
75 m_hash_id.data(), m_hash_id.size()));
76 }
77 catch(...)
78 {
79 return false;
80 }
81 }

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