Botan  2.1.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 
21 };
22 
23 /**
24 * BLAKE2B
25 */
26 class BOTAN_DLL Blake2b final : public HashFunction
27  {
28  public:
29  /**
30  * @param output_bits the output size of Blake2b in bits
31  */
32  explicit Blake2b(size_t output_bits = 512);
33 
34  size_t hash_block_size() const override { return BLAKE2B_BLOCKBYTES; }
35  size_t output_length() const override { return m_output_bits / 8; }
36 
37  HashFunction* clone() const override;
38  std::string name() const override;
39  void clear() override;
40 
41  private:
42  void add_data(const uint8_t input[], size_t length) override;
43  void final_result(uint8_t out[]) override;
44 
45  inline void state_init();
46  inline void increment_counter(const uint64_t inc);
47  void compress(bool lastblock = false);
48 
49  size_t m_output_bits;
50 
51  secure_vector<uint8_t> m_buffer;
52  size_t m_buflen;
53 
55  uint64_t m_T[2];
56  uint64_t m_F[2];
57  };
58 
59 }
60 
61 #endif
size_t hash_block_size() const override
Definition: blake2b.h:34
blake2b_constant
Definition: blake2b.h:17
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:121
Definition: alg_id.cpp:13
size_t output_length() const override
Definition: blake2b.h:35