/src/botan/build/include/internal/botan/internal/keccak.h
Line | Count | Source (jump to first uncovered line) |
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 | 0 | size_t hash_block_size() const override { return m_keccak.byte_rate(); } |
44 | | |
45 | 0 | size_t output_length() const override { return m_output_length; } |
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(std::span<const uint8_t> input) override; |
55 | | void final_result(std::span<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 |