Botan  1.11.15
Public Types | Public Member Functions
Botan::EMSA_PKCS1v15 Class Reference

#include <emsa_pkcs1.h>

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

List of all members.

Public Types

typedef SCAN_Name Spec

Public Member Functions

 EMSA_PKCS1v15 (HashFunction *hash)
secure_vector< byteencoding_of (const secure_vector< byte > &, size_t, RandomNumberGenerator &rng)
secure_vector< byteraw_data ()
void update (const byte[], size_t)
bool verify (const secure_vector< byte > &, const secure_vector< byte > &, size_t)

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.


Member Typedef Documentation

typedef SCAN_Name Botan::EMSA::Spec [inherited]

Definition at line 23 of file emsa.h.


Constructor & Destructor Documentation

Parameters:
hashthe hash object to use

Definition at line 91 of file emsa_pkcs1.cpp.

References Botan::pkcs_hash_id().

                                               : m_hash(hash)
   {
   m_hash_id = pkcs_hash_id(m_hash->name());
   }

Member Function Documentation

secure_vector< byte > Botan::EMSA_PKCS1v15::encoding_of ( const secure_vector< byte > &  msg,
size_t  output_bits,
RandomNumberGenerator rng 
) [virtual]

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 62 of file emsa_pkcs1.cpp.

   {
   if(msg.size() != m_hash->output_length())
      throw Encoding_Error("EMSA_PKCS1v15::encoding_of: Bad input length");

   return emsa3_encoding(msg, output_bits,
                         &m_hash_id[0], m_hash_id.size());
   }
secure_vector< byte > Botan::EMSA_PKCS1v15::raw_data ( ) [virtual]
Returns:
raw hash

Implements Botan::EMSA.

Definition at line 56 of file emsa_pkcs1.cpp.

   {
   return m_hash->final();
   }
void Botan::EMSA_PKCS1v15::update ( const byte  input[],
size_t  length 
) [virtual]

Add more data to the signature computation

Parameters:
inputsome data
lengthlength of input in bytes

Implements Botan::EMSA.

Definition at line 51 of file emsa_pkcs1.cpp.

   {
   m_hash->update(input, length);
   }
bool Botan::EMSA_PKCS1v15::verify ( const secure_vector< byte > &  coded,
const secure_vector< byte > &  raw,
size_t  key_bits 
) [virtual]

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 73 of file emsa_pkcs1.cpp.

   {
   if(raw.size() != m_hash->output_length())
      return false;

   try
      {
      return (coded == emsa3_encoding(raw, key_bits,
                                      &m_hash_id[0], m_hash_id.size()));
      }
   catch(...)
      {
      return false;
      }
   }

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