Botan  1.10.9
Public Member Functions | List of all members
Botan::EMSA3 Class Reference

#include <emsa3.h>

Inheritance diagram for Botan::EMSA3:
Botan::EMSA

Public Member Functions

 EMSA3 (HashFunction *hash)
 
SecureVector< byteencoding_of (const MemoryRegion< byte > &, size_t, RandomNumberGenerator &rng)
 
SecureVector< byteraw_data ()
 
void update (const byte[], size_t)
 
bool verify (const MemoryRegion< byte > &, const MemoryRegion< byte > &, size_t)
 
 ~EMSA3 ()
 

Detailed Description

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

Definition at line 21 of file emsa3.h.

Constructor & Destructor Documentation

Botan::EMSA3::EMSA3 ( HashFunction hash)
Parameters
hashthe hash object to use

Definition at line 94 of file emsa3.cpp.

References Botan::Algorithm::name(), and Botan::pkcs_hash_id().

94  : hash(hash_in)
95  {
96  hash_id = pkcs_hash_id(hash->name());
97  }
MemoryVector< byte > pkcs_hash_id(const std::string &name)
Definition: hash_id.cpp:60
virtual std::string name() const =0
Botan::EMSA3::~EMSA3 ( )

Definition at line 102 of file emsa3.cpp.

103  {
104  delete hash;
105  }

Member Function Documentation

SecureVector< byte > Botan::EMSA3::encoding_of ( const MemoryRegion< 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 59 of file emsa3.cpp.

References Botan::Buffered_Computation::output_length(), and Botan::MemoryRegion< T >::size().

62  {
63  if(msg.size() != hash->output_length())
64  throw Encoding_Error("EMSA3::encoding_of: Bad input length");
65 
66  return emsa3_encoding(msg, output_bits,
67  &hash_id[0], hash_id.size());
68  }
size_t size() const
Definition: secmem.h:29
virtual size_t output_length() const =0
SecureVector< byte > Botan::EMSA3::raw_data ( )
virtual
Returns
raw hash

Implements Botan::EMSA.

Definition at line 51 of file emsa3.cpp.

References Botan::Buffered_Computation::final().

52  {
53  return hash->final();
54  }
void final(byte out[])
Definition: buf_comp.h:80
void Botan::EMSA3::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 43 of file emsa3.cpp.

References Botan::Buffered_Computation::update().

44  {
45  hash->update(input, length);
46  }
void update(const byte in[], size_t length)
Definition: buf_comp.h:33
bool Botan::EMSA3::verify ( const MemoryRegion< byte > &  coded,
const MemoryRegion< 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 emsa3.cpp.

References Botan::Buffered_Computation::output_length(), and Botan::MemoryRegion< T >::size().

76  {
77  if(raw.size() != hash->output_length())
78  return false;
79 
80  try
81  {
82  return (coded == emsa3_encoding(raw, key_bits,
83  &hash_id[0], hash_id.size()));
84  }
85  catch(...)
86  {
87  return false;
88  }
89  }
size_t size() const
Definition: secmem.h:29
virtual size_t output_length() const =0

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