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

randombit / botan / 6052601502

01 Sep 2023 03:07AM UTC coverage: 91.704% (-0.004%) from 91.708%
6052601502

push

github

web-flow
Merge pull request #3673 from falko-strenzke/refact-sha3

Refactoring SHA3: based on new permutation keccak-fips

78576 of 85684 relevant lines covered (91.7%)

8473544.9 hits per line

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

80.0
/src/lib/hash/shake/shake.h
1
/*
2
* SHAKE hash functions
3
* (C) 2010,2016 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7

8
#ifndef BOTAN_SHAKE_HASH_H_
9
#define BOTAN_SHAKE_HASH_H_
10

11
#include <botan/hash.h>
12
#include <botan/internal/keccak_perm.h>
13

14
#include <string>
15

16
namespace Botan {
17

18
/**
19
* SHAKE-128
20
*/
21
class SHAKE_128 final : public HashFunction {
×
22
   public:
23
      /**
24
      * @param output_bits the desired output size in bits
25
      * must be a multiple of 8
26
      */
27
      explicit SHAKE_128(size_t output_bits);
28

29
      size_t hash_block_size() const override { return m_keccak.byte_rate(); }
426✔
30

31
      size_t output_length() const override { return m_output_bits / 8; }
14,288,338✔
32

33
      std::unique_ptr<HashFunction> new_object() const override;
34
      std::unique_ptr<HashFunction> copy_state() const override;
35
      std::string name() const override;
36

37
      void clear() override { m_keccak.clear(); }
14,288,864✔
38

39
      std::string provider() const override { return m_keccak.provider(); }
213✔
40

41
   private:
42
      void add_data(const uint8_t input[], size_t length) override;
43
      void final_result(uint8_t out[]) override;
44

45
      Keccak_Permutation m_keccak;
46
      size_t m_output_bits;
47
};
48

49
/**
50
* SHAKE-256
51
*/
52
class SHAKE_256 final : public HashFunction {
×
53
   public:
54
      /**
55
      * @param output_bits the desired output size in bits
56
      * must be a multiple of 8
57
      */
58
      explicit SHAKE_256(size_t output_bits);
59

60
      size_t hash_block_size() const override { return m_keccak.byte_rate(); }
8✔
61

62
      size_t output_length() const override { return m_output_bits / 8; }
67,229,986✔
63

64
      std::unique_ptr<HashFunction> new_object() const override;
65
      std::unique_ptr<HashFunction> copy_state() const override;
66
      std::string name() const override;
67

68
      void clear() override { m_keccak.clear(); }
854✔
69

70
      std::string provider() const override { return m_keccak.provider(); }
4✔
71

72
   private:
73
      void add_data(const uint8_t input[], size_t length) override;
74
      void final_result(uint8_t out[]) override;
75

76
      Keccak_Permutation m_keccak;
77
      size_t m_output_bits;
78
};
79

80
}  // namespace Botan
81

82
#endif
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

© 2025 Coveralls, Inc