Botan: Botan::EMSA3 Class Reference

Botan 1.10.17

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

`#include <emsa3.h>`

Inheritance diagram for Botan::EMSA3:

## Public Member Functions
| EMSA3 (HashFunction *hash)
SecureVector< byte > | encoding_of (const MemoryRegion< byte > &, size_t, RandomNumberGenerator &rng)
SecureVector< byte > | raw_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

  hash | the 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 }
Botan::pkcs_hash_id
MemoryVector< byte > pkcs_hash_id(const std::string &name)
Definition: hash_id.cpp:60
Botan::Algorithm::name
virtual std::string name() const =0

## ◆ ~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

  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 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 }
Botan::MemoryRegion::size
size_t size() const
Definition: secmem.h:29
Botan::Buffered_Computation::output_length
virtual size_t output_length() const =0

## ◆ raw_data()

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 }
Botan::Buffered_Computation::final
void final(byte out[])
Definition: buf_comp.h:80

## ◆ update()

void Botan::EMSA3::update | ( | const byte | input[],
|  | size_t | length
| ) |  |
| 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 emsa3.cpp.

References Botan::Buffered_Computation::update().

44 {
45 hash->update(input, length);
46 }
Botan::Buffered_Computation::update
void update(const byte in[], size_t length)
Definition: buf_comp.h:33

## ◆ verify()

bool Botan::EMSA3::verify | ( | const MemoryRegion< byte > & | coded,
|  | const MemoryRegion< byte > & | raw,
|  | size_t | key_bits
| ) |  |
| 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 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 }
Botan::MemoryRegion::size
size_t size() const
Definition: secmem.h:29
Botan::Buffered_Computation::output_length
virtual size_t output_length() const =0

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

- src/pk_pad/emsa3/emsa3.h
- src/pk_pad/emsa3/emsa3.cpp