• 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

66.67
/src/lib/hash/keccak/keccak.h
1
/*
2
* Keccak
3
* (C) 2010 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7

8
#ifndef BOTAN_KECCAK_H_
9
#define BOTAN_KECCAK_H_
10

11
#include <botan/hash.h>
12
#include <botan/secmem.h>
13
#include <botan/internal/keccak_perm.h>
14
#include <string>
15

16
namespace Botan {
17

18
/**
19
* Keccak[1600], the SHA-3 submission without any final bit padding. Not an official NIST SHA-3-derived hash function.
20
*
21
* In the terminology of the official SHA-3 specification [1],
22
* the instantiations of this hash function
23
* (with the output bit size in brackets) are given as
24
*
25
* Keccak1600[224](M) = KECCAK[448] (M, 224)
26
* Keccak1600[256](M) = KECCAK[512] (M, 256)
27
* Keccak1600[384](M) = KECCAK[768] (M, 384)
28
* Keccak1600[512](M) = KECCAK[1024] (M, 512)
29
*
30
* i.e., as raw Keccak[c] without any additional final bit padding.
31
*
32
* [1] https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf#page=28
33
*
34
*/
35
class Keccak_1600 final : public HashFunction {
×
36
   public:
37
      /**
38
      * @param output_bits the size of the hash output; must be one of
39
      *                    224, 256, 384, or 512
40
      */
41
      explicit Keccak_1600(size_t output_bits = 512);
42

43
      size_t hash_block_size() const override { return m_keccak.byte_rate(); }
2,144✔
44

45
      size_t output_length() const override { return m_output_length; }
8,524✔
46

47
      std::unique_ptr<HashFunction> new_object() const override;
48
      std::unique_ptr<HashFunction> copy_state() const override;
49
      std::string name() const override;
50
      void clear() override;
51
      std::string provider() const override;
52

53
   private:
54
      void add_data(const uint8_t input[], size_t length) override;
55
      void final_result(uint8_t out[]) override;
56

57
   private:
58
      Keccak_Permutation m_keccak;
59
      size_t m_output_length;
60
};
61

62
}  // namespace Botan
63

64
#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