• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 18006513906

25 Sep 2025 11:49AM UTC coverage: 90.363% (-0.3%) from 90.668%
18006513906

Pull #4540

github

web-flow
Merge b4994b5c0 into 14e54e7a1
Pull Request #4540: PKCS #11 Version 3.2 Support

100474 of 111189 relevant lines covered (90.36%)

12143908.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.74
/src/lib/hash/shake/shake.cpp
1
/*
2
* SHAKE-128/256 as a hash
3
* (C) 2016 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7

8
#include <botan/internal/shake.h>
9

10
#include <botan/exceptn.h>
11
#include <botan/internal/fmt.h>
12

13
namespace Botan {
14

15
SHAKE_128::SHAKE_128(size_t output_bits) :
2,135✔
16
      m_keccak({.capacity_bits = 256, .padding = KeccakPadding::shake()}), m_output_bits(output_bits) {
2,135✔
17
   if(output_bits % 8 != 0) {
2,135✔
18
      throw Invalid_Argument(fmt("SHAKE_128: Invalid output length {}", output_bits));
×
19
   }
20
}
2,135✔
21

22
std::string SHAKE_128::name() const {
726✔
23
   return fmt("SHAKE-128({})", m_output_bits);
726✔
24
}
25

26
std::unique_ptr<HashFunction> SHAKE_128::new_object() const {
1,158✔
27
   return std::make_unique<SHAKE_128>(m_output_bits);
1,158✔
28
}
29

30
std::unique_ptr<HashFunction> SHAKE_128::copy_state() const {
207✔
31
   return std::make_unique<SHAKE_128>(*this);
207✔
32
}
33

34
void SHAKE_128::add_data(std::span<const uint8_t> input) {
84,665,856✔
35
   m_keccak.absorb(input);
84,665,856✔
36
}
84,665,856✔
37

38
void SHAKE_128::final_result(std::span<uint8_t> output) {
21,178,746✔
39
   m_keccak.finish();
21,178,746✔
40
   m_keccak.squeeze(output);
21,178,746✔
41
   clear();
21,178,746✔
42
}
21,178,746✔
43

44
SHAKE_256::SHAKE_256(size_t output_bits) :
6,072✔
45
      m_keccak({.capacity_bits = 512, .padding = KeccakPadding::shake()}), m_output_bits(output_bits) {
6,072✔
46
   if(output_bits % 8 != 0) {
6,072✔
47
      throw Invalid_Argument(fmt("SHAKE_256: Invalid output length {}", output_bits));
×
48
   }
49
}
6,072✔
50

51
std::string SHAKE_256::name() const {
12✔
52
   return fmt("SHAKE-256({})", m_output_bits);
12✔
53
}
54

55
std::unique_ptr<HashFunction> SHAKE_256::new_object() const {
2,332✔
56
   return std::make_unique<SHAKE_256>(m_output_bits);
2,332✔
57
}
58

59
std::unique_ptr<HashFunction> SHAKE_256::copy_state() const {
3✔
60
   return std::make_unique<SHAKE_256>(*this);
3✔
61
}
62

63
void SHAKE_256::add_data(std::span<const uint8_t> input) {
494,372,507✔
64
   m_keccak.absorb(input);
494,372,507✔
65
}
494,372,507✔
66

67
void SHAKE_256::final_result(std::span<uint8_t> output) {
140,954,599✔
68
   m_keccak.finish();
140,954,599✔
69
   m_keccak.squeeze(output);
140,954,599✔
70
   clear();
140,954,599✔
71
}
140,954,599✔
72

73
}  // namespace Botan
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc