Botan  2.13.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 
16 
17 namespace Botan {
18 
19 /**
20 * SHAKE-128
21 */
23  {
24  public:
25 
26  /**
27  * @param output_bits the desired output size in bits
28  * must be a multiple of 8
29  */
30  explicit SHAKE_128(size_t output_bits);
31 
32  size_t hash_block_size() const override { return SHAKE_128_BITRATE / 8; }
33  size_t output_length() const override { return m_output_bits / 8; }
34 
35  HashFunction* clone() const override;
36  std::unique_ptr<HashFunction> copy_state() const override;
37  std::string name() const override;
38  void clear() override;
39 
40  private:
41  void add_data(const uint8_t input[], size_t length) override;
42  void final_result(uint8_t out[]) override;
43 
44  static const size_t SHAKE_128_BITRATE = 1600 - 256;
45 
46  size_t m_output_bits;
48  size_t m_S_pos;
49  };
50 
51 /**
52 * SHAKE-256
53 */
55  {
56  public:
57 
58  /**
59  * @param output_bits the desired output size in bits
60  * must be a multiple of 8
61  */
62  explicit SHAKE_256(size_t output_bits);
63 
64  size_t hash_block_size() const override { return SHAKE_256_BITRATE / 8; }
65  size_t output_length() const override { return m_output_bits / 8; }
66 
67  HashFunction* clone() const override;
68  std::unique_ptr<HashFunction> copy_state() const override;
69  std::string name() const override;
70  void clear() override;
71 
72  private:
73  void add_data(const uint8_t input[], size_t length) override;
74  void final_result(uint8_t out[]) override;
75 
76  static const size_t SHAKE_256_BITRATE = 1600 - 512;
77 
78  size_t m_output_bits;
80  size_t m_S_pos;
81  };
82 
83 }
84 
85 #endif
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
virtual std::string name() const =0
virtual HashFunction * clone() const =0
size_t hash_block_size() const override
Definition: shake.h:64
size_t output_length() const override
Definition: shake.h:33
size_t hash_block_size() const override
Definition: shake.h:32
Definition: alg_id.cpp:13
size_t output_length() const override
Definition: shake.h:65
virtual void clear()=0
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65
virtual std::unique_ptr< HashFunction > copy_state() const =0
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition: compiler.h:139