Coverage Report

Created: 2026-02-07 06:16

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
* (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
0
void mgf1_mask(HashFunction& hash, std::span<const uint8_t> input, std::span<uint8_t> output) {
16
0
   uint32_t counter = 0;
17
18
0
   std::vector<uint8_t> buffer(hash.output_length());
19
0
   while(!output.empty()) {
20
0
      hash.update(input);
21
0
      hash.update_be(counter);
22
0
      hash.final(buffer);
23
24
0
      const size_t xored = std::min<size_t>(buffer.size(), output.size());
25
0
      xor_buf(output.first(xored), std::span{buffer}.first(xored));
26
0
      output = output.subspan(xored);
27
28
0
      ++counter;
29
0
   }
30
0
}
31
32
}  // namespace Botan