/src/botan/build/include/botan/internal/sha3.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * SHA-3 |
3 | | * (C) 2010,2016 Jack Lloyd |
4 | | * |
5 | | * Botan is released under the Simplified BSD License (see license.txt) |
6 | | */ |
7 | | |
8 | | #ifndef BOTAN_SHA3_H_ |
9 | | #define BOTAN_SHA3_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 | | * SHA-3 |
20 | | */ |
21 | | class SHA_3 : public HashFunction { |
22 | | public: |
23 | | /** |
24 | | * @param output_bits the size of the hash output; must be one of |
25 | | * 224, 256, 384, or 512 |
26 | | */ |
27 | | explicit SHA_3(size_t output_bits); |
28 | | |
29 | 0 | size_t hash_block_size() const override { return m_keccak.byte_rate(); } |
30 | | |
31 | 0 | size_t output_length() const override { return m_output_length; } |
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 | | void clear() override; |
37 | | std::string provider() const override; |
38 | | |
39 | | private: |
40 | | void add_data(std::span<const uint8_t> input) override; |
41 | | void final_result(std::span<uint8_t> out) override; |
42 | | |
43 | | private: |
44 | | Keccak_Permutation m_keccak; |
45 | | size_t m_output_length; |
46 | | }; |
47 | | |
48 | | /** |
49 | | * SHA-3-224 |
50 | | */ |
51 | | class SHA_3_224 final : public SHA_3 { |
52 | | public: |
53 | 0 | SHA_3_224() : SHA_3(224) {} |
54 | | }; |
55 | | |
56 | | /** |
57 | | * SHA-3-256 |
58 | | */ |
59 | | class SHA_3_256 final : public SHA_3 { |
60 | | public: |
61 | 0 | SHA_3_256() : SHA_3(256) {} |
62 | | }; |
63 | | |
64 | | /** |
65 | | * SHA-3-384 |
66 | | */ |
67 | | class SHA_3_384 final : public SHA_3 { |
68 | | public: |
69 | 0 | SHA_3_384() : SHA_3(384) {} |
70 | | }; |
71 | | |
72 | | /** |
73 | | * SHA-3-512 |
74 | | */ |
75 | | class SHA_3_512 final : public SHA_3 { |
76 | | public: |
77 | 0 | SHA_3_512() : SHA_3(512) {} |
78 | | }; |
79 | | |
80 | | } // namespace Botan |
81 | | |
82 | | #endif |