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

randombit / botan / 5079590438

25 May 2023 12:28PM UTC coverage: 92.228% (+0.5%) from 91.723%
5079590438

Pull #3502

github

Pull Request #3502: Apply clang-format to the codebase

75589 of 81959 relevant lines covered (92.23%)

12139530.51 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
#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 { return fmt("SHAKE-128({})", m_output_bits); }
642✔
23

24
std::unique_ptr<HashFunction> SHAKE_128::new_object() const { return std::make_unique<SHAKE_128>(m_output_bits); }
426✔
25

26
std::unique_ptr<HashFunction> SHAKE_128::copy_state() const { return std::make_unique<SHAKE_128>(*this); }
207✔
27

28
void SHAKE_128::clear() {
14,295,032✔
29
   zeroise(m_S);
14,295,032✔
30
   m_S_pos = 0;
14,295,032✔
31
}
14,295,032✔
32

33
void SHAKE_128::add_data(const uint8_t input[], size_t length) {
57,175,688✔
34
   m_S_pos = SHA_3::absorb(SHAKE_128_BITRATE, m_S, m_S_pos, input, length);
57,175,688✔
35
}
57,175,688✔
36

37
void SHAKE_128::final_result(uint8_t output[]) {
14,294,504✔
38
   SHA_3::finish(SHAKE_128_BITRATE, m_S, m_S_pos, 0x1F, 0x80);
14,294,504✔
39
   SHA_3::expand(SHAKE_128_BITRATE, m_S, output, output_length());
14,294,504✔
40
   clear();
14,294,504✔
41
}
14,294,504✔
42

43
SHAKE_256::SHAKE_256(size_t output_bits) : m_output_bits(output_bits), m_S(25), m_S_pos(0) {
37,377✔
44
   if(output_bits % 8 != 0) {
37,377✔
45
      throw Invalid_Argument(fmt("SHAKE_256: Invalid output length {}", output_bits));
×
46
   }
47
}
37,377✔
48

49
std::string SHAKE_256::name() const { return fmt("SHAKE-256({})", m_output_bits); }
12✔
50

51
std::unique_ptr<HashFunction> SHAKE_256::new_object() const { return std::make_unique<SHAKE_256>(m_output_bits); }
1,277✔
52

53
std::unique_ptr<HashFunction> SHAKE_256::copy_state() const { return std::make_unique<SHAKE_256>(*this); }
3✔
54

55
void SHAKE_256::clear() {
52,982,729✔
56
   zeroise(m_S);
52,982,729✔
57
   m_S_pos = 0;
52,982,729✔
58
}
52,982,729✔
59

60
void SHAKE_256::add_data(const uint8_t input[], size_t length) {
211,844,134✔
61
   m_S_pos = SHA_3::absorb(SHAKE_256_BITRATE, m_S, m_S_pos, input, length);
211,844,134✔
62
}
211,844,134✔
63

64
void SHAKE_256::final_result(uint8_t output[]) {
52,981,876✔
65
   SHA_3::finish(SHAKE_256_BITRATE, m_S, m_S_pos, 0x1F, 0x80);
52,981,876✔
66
   SHA_3::expand(SHAKE_256_BITRATE, m_S, output, output_length());
52,981,876✔
67

68
   clear();
52,981,876✔
69
}
52,981,876✔
70

71
}
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