Botan  2.6.0
Crypto and TLS for C++11
blake2b.h
Go to the documentation of this file.
1 /*
2 * Blake2b
3 * (C) 2016 cynecx
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7 
8 #ifndef BOTAN_BLAKE2B_H_
9 #define BOTAN_BLAKE2B_H_
10 
11 #include <botan/hash.h>
12 #include <string>
13 #include <memory>
14 
15 namespace Botan {
16 
17 /**
18 * BLAKE2B
19 */
20 class BOTAN_PUBLIC_API(2,0) Blake2b final : public HashFunction
21  {
22  public:
23  /**
24  * @param output_bits the output size of Blake2b in bits
25  */
26  explicit Blake2b(size_t output_bits = 512);
27 
28  size_t hash_block_size() const override { return 128; }
29  size_t output_length() const override { return m_output_bits / 8; }
30 
31  HashFunction* clone() const override;
32  std::string name() const override;
33  void clear() override;
34 
35  std::unique_ptr<HashFunction> copy_state() const 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  void state_init();
42  void compress(const uint8_t* data, size_t blocks, uint64_t increment);
43 
44  const size_t m_output_bits;
45 
46  secure_vector<uint8_t> m_buffer;
47  size_t m_bufpos;
48 
50  uint64_t m_T[2];
51  uint64_t m_F[2];
52  };
53 
54 }
55 
56 #endif
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:27
size_t hash_block_size() const override
Definition: blake2b.h:28
Definition: alg_id.cpp:13
size_t output_length() const override
Definition: blake2b.h:29
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:88