Coverage Report

Created: 2025-10-13 07:10

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/Botan-3.4.0/src/lib/pk_pad/mgf1/mgf1.cpp
Line
Count
Source
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/internal/mgf1.h>
9
10
#include <botan/hash.h>
11
#include <algorithm>
12
13
namespace Botan {
14
15
0
void mgf1_mask(HashFunction& hash, const uint8_t in[], size_t in_len, uint8_t out[], size_t out_len) {
16
0
   uint32_t counter = 0;
17
18
0
   std::vector<uint8_t> buffer(hash.output_length());
19
0
   while(out_len) {
20
0
      hash.update(in, in_len);
21
0
      hash.update_be(counter);
22
0
      hash.final(buffer.data());
23
24
0
      const size_t xored = std::min<size_t>(buffer.size(), out_len);
25
0
      xor_buf(out, buffer.data(), xored);
26
0
      out += xored;
27
0
      out_len -= xored;
28
29
0
      ++counter;
30
0
   }
31
0
}
32
33
}  // namespace Botan