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

randombit / botan / 5230455705

10 Jun 2023 02:30PM UTC coverage: 91.715% (-0.03%) from 91.746%
5230455705

push

github

randombit
Merge GH #3584 Change clang-format AllowShortFunctionsOnASingleLine config from All to Inline

77182 of 84154 relevant lines covered (91.72%)

11975295.43 hits per line

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

95.45
/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
#include <botan/internal/sha3.h>
13

14
namespace Botan {
15

16
SHAKE_128::SHAKE_128(size_t output_bits) : m_output_bits(output_bits), m_S(25), m_S_pos(0) {
1,060✔
17
   if(output_bits % 8 != 0) {
1,060✔
18
      throw Invalid_Argument(fmt("SHAKE_128: Invalid output length {}", output_bits));
×
19
   }
20
}
1,060✔
21

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

26
std::unique_ptr<HashFunction> SHAKE_128::new_object() const {
426✔
27
   return std::make_unique<SHAKE_128>(m_output_bits);
426✔
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::clear() {
14,285,402✔
35
   zeroise(m_S);
14,285,402✔
36
   m_S_pos = 0;
14,285,402✔
37
}
14,285,402✔
38

39
void SHAKE_128::add_data(const uint8_t input[], size_t length) {
57,137,193✔
40
   m_S_pos = SHA_3::absorb(SHAKE_128_BITRATE, m_S, m_S_pos, input, length);
57,137,193✔
41
}
57,137,193✔
42

43
void SHAKE_128::final_result(uint8_t output[]) {
14,284,879✔
44
   SHA_3::finish(SHAKE_128_BITRATE, m_S, m_S_pos, 0x1F, 0x80);
14,284,879✔
45
   SHA_3::expand(SHAKE_128_BITRATE, m_S, output, output_length());
14,284,879✔
46
   clear();
14,284,879✔
47
}
14,284,879✔
48

49
SHAKE_256::SHAKE_256(size_t output_bits) : m_output_bits(output_bits), m_S(25), m_S_pos(0) {
37,537✔
50
   if(output_bits % 8 != 0) {
37,537✔
51
      throw Invalid_Argument(fmt("SHAKE_256: Invalid output length {}", output_bits));
×
52
   }
53
}
37,537✔
54

55
std::string SHAKE_256::name() const {
12✔
56
   return fmt("SHAKE-256({})", m_output_bits);
12✔
57
}
58

59
std::unique_ptr<HashFunction> SHAKE_256::new_object() const {
1,277✔
60
   return std::make_unique<SHAKE_256>(m_output_bits);
1,277✔
61
}
62

63
std::unique_ptr<HashFunction> SHAKE_256::copy_state() const {
3✔
64
   return std::make_unique<SHAKE_256>(*this);
3✔
65
}
66

67
void SHAKE_256::clear() {
52,975,874✔
68
   zeroise(m_S);
52,975,874✔
69
   m_S_pos = 0;
52,975,874✔
70
}
52,975,874✔
71

72
void SHAKE_256::add_data(const uint8_t input[], size_t length) {
211,816,345✔
73
   m_S_pos = SHA_3::absorb(SHAKE_256_BITRATE, m_S, m_S_pos, input, length);
211,816,345✔
74
}
211,816,345✔
75

76
void SHAKE_256::final_result(uint8_t output[]) {
52,975,021✔
77
   SHA_3::finish(SHAKE_256_BITRATE, m_S, m_S_pos, 0x1F, 0x80);
52,975,021✔
78
   SHA_3::expand(SHAKE_256_BITRATE, m_S, output, output_length());
52,975,021✔
79

80
   clear();
52,975,021✔
81
}
52,975,021✔
82

83
}  // 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