Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

mgf1.cpp
Go to the documentation of this file.
1 /*
2 * MGF1
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7
8 #include <botan/mgf1.h>
9 #include <botan/exceptn.h>
10 #include <algorithm>
11
12 namespace Botan {
13
14 void mgf1_mask(HashFunction& hash,
15 const uint8_t in[], size_t in_len,
16 uint8_t out[], size_t out_len)
17 {
18 uint32_t counter = 0;
19
20 while(out_len)
21 {
22 hash.update(in, in_len);
23 hash.update_be(counter);
24 secure_vector<uint8_t> buffer = hash.final();
25
26 size_t xored = std::min<size_t>(buffer.size(), out_len);
27 xor_buf(out, buffer.data(), xored);
28 out += xored;
29 out_len -= xored;
30
31 ++counter;
32 }
33 }
34
35 }
Botan::xor_buf
void xor_buf(T out[], const T in[], size_t length)
Definition: mem_ops.h:115
Botan::Buffered_Computation::final
void final(uint8_t out[])
Definition: buf_comp.h:89
Botan::secure_vector
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:121
Botan
Definition: alg_id.cpp:13
Botan::HashFunction
Definition: hash.h:19
Botan::mgf1_mask
void mgf1_mask(HashFunction &hash, const uint8_t in[], size_t in_len, uint8_t out[], size_t out_len)
Definition: mgf1.cpp:14
Botan::Buffered_Computation::update
void update(const uint8_t in[], size_t length)
Definition: buf_comp.h:34
Botan::Buffered_Computation::update_be
void update_be(const T in)
Definition: buf_comp.h:58
hash
MechanismType hash
Definition: p11_mechanism.cpp:63