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

#include <mgf1.h>

Inheritance diagram for Botan::MGF1:
Botan::MGF

Public Member Functions

void mask (const byte[], size_t, byte[], size_t) const
 
 MGF1 (HashFunction *hash)
 
 ~MGF1 ()
 

Detailed Description

MGF1 from PKCS #1 v2.0

Definition at line 19 of file mgf1.h.

Constructor & Destructor Documentation

Botan::MGF1::MGF1 ( HashFunction hash)

MGF1 constructor: takes ownership of hash

Definition at line 42 of file mgf1.cpp.

42  : hash(h)
43  {
44  if(!hash)
45  throw Invalid_Argument("MGF1 given null hash object");
46  }
std::invalid_argument Invalid_Argument
Definition: exceptn.h:20
Botan::MGF1::~MGF1 ( )

Definition at line 51 of file mgf1.cpp.

52  {
53  delete hash;
54  }

Member Function Documentation

void Botan::MGF1::mask ( const byte  in[],
size_t  in_len,
byte  out[],
size_t  out_len 
) const
virtual

Implements Botan::MGF.

Definition at line 19 of file mgf1.cpp.

References Botan::Buffered_Computation::final(), Botan::MemoryRegion< T >::size(), Botan::Buffered_Computation::update(), Botan::Buffered_Computation::update_be(), and Botan::xor_buf().

21  {
22  u32bit counter = 0;
23 
24  while(out_len)
25  {
26  hash->update(in, in_len);
27  hash->update_be(counter);
28  SecureVector<byte> buffer = hash->final();
29 
30  size_t xored = std::min<size_t>(buffer.size(), out_len);
31  xor_buf(out, &buffer[0], xored);
32  out += xored;
33  out_len -= xored;
34 
35  ++counter;
36  }
37  }
void update(const byte in[], size_t length)
Definition: buf_comp.h:33
void final(byte out[])
Definition: buf_comp.h:80
void update_be(const T in)
Definition: buf_comp.h:48
void xor_buf(byte out[], const byte in[], size_t length)
Definition: xor_buf.h:21
unsigned int u32bit
Definition: types.h:32

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