Coverage Report

Created: 2025-04-11 06:34

/src/botan/src/lib/xof/shake_xof/shake_xof.cpp
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * SHAKE-128 and SHAKE-256 as XOFs
3
 *
4
 * (C) 2016-2023 Jack Lloyd
5
 *     2022-2023 Fabian Albert, Michael Boric, René Meusel - Rohde & Schwarz Cybersecurity
6
 *
7
 * Botan is released under the Simplified BSD License (see license.txt)
8
 */
9
10
#include <botan/internal/shake_xof.h>
11
12
#include <botan/assert.h>
13
14
namespace Botan {
15
16
270
SHAKE_XOF::SHAKE_XOF(size_t capacity) : m_keccak(capacity, 0b1111, 4), m_output_generated(false) {
17
270
   BOTAN_ASSERT_NOMSG(capacity == 256 || capacity == 512);
18
270
}
19
20
0
void SHAKE_XOF::reset() {
21
0
   m_keccak.clear();
22
0
   m_output_generated = false;
23
0
}
24
25
160
void SHAKE_XOF::add_data(std::span<const uint8_t> input) {
26
160
   BOTAN_STATE_CHECK(!m_output_generated);
27
160
   m_keccak.absorb(input);
28
160
}
29
30
160
void SHAKE_XOF::generate_bytes(std::span<uint8_t> output) {
31
160
   if(!m_output_generated) {
32
160
      m_output_generated = true;
33
160
      m_keccak.finish();
34
160
   }
35
36
160
   m_keccak.squeeze(output);
37
160
}
38
39
}  // namespace Botan