Botan
3.10.0
Crypto and TLS for C&
src
lib
pk_pad
mgf1
mgf1.cpp
Go to the documentation of this file.
1
/*
2
* (C) 1999-2007,2025 Jack Lloyd
3
*
4
* Botan is released under the Simplified BSD License (see license.txt)
5
*/
6
7
#include <botan/internal/mgf1.h>
8
9
#include <botan/hash.h>
10
#include <botan/mem_ops.h>
11
#include <algorithm>
12
13
namespace
Botan
{
14
15
void
mgf1_mask
(
HashFunction
& hash, std::span<const uint8_t> input, std::span<uint8_t> output) {
16
uint32_t counter = 0;
17
18
std::vector<uint8_t> buffer(hash.
output_length
());
19
while
(!output.empty()) {
20
hash.
update
(input);
21
hash.
update_be
(counter);
22
hash.
final
(buffer);
23
24
const
size_t
xored = std::min<size_t>(buffer.size(), output.size());
25
xor_buf
(output.first(xored), std::span{buffer}.first(xored));
26
output = output.subspan(xored);
27
28
++counter;
29
}
30
}
31
32
}
// namespace Botan
Botan::Buffered_Computation::update
void update(const uint8_t in[], size_t length)
Definition
buf_comp.h:34
Botan::Buffered_Computation::output_length
virtual size_t output_length() const =0
Botan::Buffered_Computation::update_be
void update_be(uint16_t val)
Definition
buf_comp.cpp:18
Botan::Buffered_Computation::final
void final(uint8_t out[])
Definition
buf_comp.h:69
Botan::HashFunction
Definition
hash.h:21
Botan
Definition
alg_id.cpp:13
Botan::mgf1_mask
void mgf1_mask(HashFunction &hash, std::span< const uint8_t > input, std::span< uint8_t > output)
Definition
mgf1.cpp:15
Botan::xor_buf
constexpr void xor_buf(ranges::contiguous_output_range< uint8_t > auto &&out, ranges::contiguous_range< uint8_t > auto &&in)
Definition
mem_ops.h:342
Generated by
1.15.0