/src/botan/build/include/botan/internal/shake.h
Line  | Count  | Source (jump to first uncovered line)  | 
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  | 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_bits / 8; } | 
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  | 0  |       void clear() override { m_keccak.clear(); } | 
38  |  |  | 
39  | 0  |       std::string provider() const override { return m_keccak.provider(); } | 
40  |  |  | 
41  |  |    private:  | 
42  |  |       void add_data(std::span<const uint8_t> input) override;  | 
43  |  |       void final_result(std::span<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  | 0  |       size_t hash_block_size() const override { return m_keccak.byte_rate(); } | 
61  |  |  | 
62  | 0  |       size_t output_length() const override { return m_output_bits / 8; } | 
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  | 0  |       void clear() override { m_keccak.clear(); } | 
69  |  |  | 
70  | 0  |       std::string provider() const override { return m_keccak.provider(); } | 
71  |  |  | 
72  |  |    private:  | 
73  |  |       void add_data(std::span<const uint8_t> input) override;  | 
74  |  |       void final_result(std::span<uint8_t> out) override;  | 
75  |  |  | 
76  |  |       Keccak_Permutation m_keccak;  | 
77  |  |       size_t m_output_bits;  | 
78  |  | };  | 
79  |  |  | 
80  |  | }  // namespace Botan  | 
81  |  |  | 
82  |  | #endif  |