Botan 1.10.17
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

◆ EMSA3()

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

Definition at line 94 of file emsa3.cpp.

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

References Botan::pkcs_hash_id().

Referenced by Botan::get_emsa().

◆ ~EMSA3()

Botan::EMSA3::~EMSA3 ( )

Definition at line 102 of file emsa3.cpp.

103 {
104 delete hash;
105 }

Member Function Documentation

◆ encoding_of()

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.

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 }
Encoding_Error(const std::string &name)
Definition exceptn.h:131

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

◆ raw_data()

SecureVector< byte > Botan::EMSA3::raw_data ( )
virtual
Returns
raw hash

Implements Botan::EMSA.

Definition at line 51 of file emsa3.cpp.

52 {
53 return hash->final();
54 }

◆ update()

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.

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

◆ verify()

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.

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 }

References Botan::MemoryRegion< T >::size().


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