Coverage Report

Created: 2026-06-07 07:04

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