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

randombit / botan / 17696043001

13 Sep 2025 11:42AM UTC coverage: 90.67% (+0.002%) from 90.668%
17696043001

Pull #5097

github

web-flow
Merge 67e0edd81 into 0d4cd13de
Pull Request #5097: Refactor: Clarify Padding Specification in Keccak-based Functions

100385 of 110715 relevant lines covered (90.67%)

12404591.65 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,656,117✔
35
   m_keccak.absorb(input);
84,656,117✔
36
}
84,656,117✔
37

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

44
SHAKE_256::SHAKE_256(size_t output_bits) :
6,082✔
45
      m_keccak({.capacity_bits = 512, .padding = KeccakPadding::shake()}), m_output_bits(output_bits) {
6,082✔
46
   if(output_bits % 8 != 0) {
6,082✔
47
      throw Invalid_Argument(fmt("SHAKE_256: Invalid output length {}", output_bits));
×
48
   }
49
}
6,082✔
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,409,197✔
64
   m_keccak.absorb(input);
494,409,197✔
65
}
494,409,197✔
66

67
void SHAKE_256::final_result(std::span<uint8_t> output) {
140,965,263✔
68
   m_keccak.finish();
140,965,263✔
69
   m_keccak.squeeze(output);
140,965,263✔
70
   clear();
140,965,263✔
71
}
140,965,263✔
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