Botan  2.1.0
Crypto and TLS for C++11
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/secmem.h>
13 #include <string>
14 
15 namespace Botan {
16 
17 /**
18 * SHAKE-128
19 */
20 class BOTAN_DLL SHAKE_128 : public HashFunction
21  {
22  public:
23 
24  /**
25  * @param output_bits the desired output size in bits
26  * must be a multiple of 8
27  */
28  SHAKE_128(size_t output_bits);
29 
30  size_t hash_block_size() const override { return SHAKE_128_BITRATE / 8; }
31  size_t output_length() const override { return m_output_bits / 8; }
32 
33  HashFunction* clone() const override;
34  std::string name() const override;
35  void clear() override;
36 
37  private:
38  void add_data(const uint8_t input[], size_t length) override;
39  void final_result(uint8_t out[]) override;
40 
41  static const size_t SHAKE_128_BITRATE = 1600 - 256;
42 
43  size_t m_output_bits;
45  size_t m_S_pos;
46  };
47 
48 /**
49 * SHAKE-256
50 */
51 class BOTAN_DLL SHAKE_256 : public HashFunction
52  {
53  public:
54 
55  /**
56  * @param output_bits the desired output size in bits
57  * must be a multiple of 8
58  */
59  SHAKE_256(size_t output_bits);
60 
61  size_t hash_block_size() const override { return SHAKE_256_BITRATE / 8; }
62  size_t output_length() const override { return m_output_bits / 8; }
63 
64  HashFunction* clone() const override;
65  std::string name() const override;
66  void clear() override;
67 
68  private:
69  void add_data(const uint8_t input[], size_t length) override;
70  void final_result(uint8_t out[]) override;
71 
72  static const size_t SHAKE_256_BITRATE = 1600 - 512;
73 
74  size_t m_output_bits;
76  size_t m_S_pos;
77  };
78 
79 }
80 
81 #endif
size_t hash_block_size() const override
Definition: shake.h:61
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:121
size_t output_length() const override
Definition: shake.h:31
size_t hash_block_size() const override
Definition: shake.h:30
Definition: alg_id.cpp:13
size_t output_length() const override
Definition: shake.h:62