Botan  2.1.0
Crypto and TLS for C++11
Public Member Functions | List of all members
Botan::EMSA_PKCS1v15 Class Referencefinal

#include <emsa_pkcs1.h>

Inheritance diagram for Botan::EMSA_PKCS1v15:
Botan::EMSA

Public Member Functions

EMSAclone () 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
hashthe 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  }
std::vector< uint8_t > pkcs_hash_id(const std::string &name)
Definition: hash_id.cpp:56
MechanismType hash

Member Function Documentation

EMSA* Botan::EMSA_PKCS1v15::clone ( )
inlineoverridevirtual
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()); }
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 
)
overridevirtual

Return the encoding of a message

Parameters
msgthe result of raw_data()
output_bitsthe desired output bit size
rnga 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 ( )
overridevirtual
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 
)
overridevirtual

Add more data to the signature computation

Parameters
inputsome data
lengthlength 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 
)
overridevirtual

Verify the encoding

Parameters
codedthe received (coded) message representative
rawthe computed (local, uncoded) message representative
key_bitsthe 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: