Botan 3.4.0
Crypto and TLS for C&
shake.h
Go to the documentation of this file.
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
16namespace Botan {
17
18/**
19* SHAKE-128
20*/
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(); }
30
31 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 void clear() override { m_keccak.clear(); }
38
39 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*/
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(); }
61
62 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 void clear() override { m_keccak.clear(); }
69
70 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
size_t byte_rate() const
Definition keccak_perm.h:55
std::string provider() const
std::unique_ptr< HashFunction > new_object() const override
Definition shake.cpp:25
SHAKE_128(size_t output_bits)
Definition shake.cpp:15
std::string provider() const override
Definition shake.h:39
void clear() override
Definition shake.h:37
size_t hash_block_size() const override
Definition shake.h:29
std::string name() const override
Definition shake.cpp:21
size_t output_length() const override
Definition shake.h:31
std::unique_ptr< HashFunction > copy_state() const override
Definition shake.cpp:29
std::unique_ptr< HashFunction > new_object() const override
Definition shake.cpp:53
size_t output_length() const override
Definition shake.h:62
void clear() override
Definition shake.h:68
SHAKE_256(size_t output_bits)
Definition shake.cpp:43
std::string provider() const override
Definition shake.h:70
size_t hash_block_size() const override
Definition shake.h:60
std::string name() const override
Definition shake.cpp:49
std::unique_ptr< HashFunction > copy_state() const override
Definition shake.cpp:57
int(* final)(unsigned char *, CTX *)