Botan  2.15.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 
16 
17 namespace Botan {
18 
19 /**
20 * BLAKE2B
21 */
23  {
24  public:
25  /**
26  * @param output_bits the output size of BLAKE2b in bits
27  */
28  explicit BLAKE2b(size_t output_bits = 512);
29 
30  size_t hash_block_size() const override { return 128; }
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  std::unique_ptr<HashFunction> copy_state() const override;
38 
39  private:
40  void add_data(const uint8_t input[], size_t length) override;
41  void final_result(uint8_t out[]) override;
42 
43  void state_init();
44  void compress(const uint8_t* data, size_t blocks, uint64_t increment);
45 
46  const size_t m_output_bits;
47 
48  secure_vector<uint8_t> m_buffer;
49  size_t m_bufpos;
50 
52  uint64_t m_T[2];
53  uint64_t m_F[2];
54  };
55 
56 typedef BLAKE2b Blake2b;
57 
58 }
59 
60 #endif
BLAKE2b Blake2b
Definition: blake2b.h:56
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
Definition: alg_id.cpp:13
size_t hash_block_size() const override
Definition: blake2b.h:30
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
size_t output_length() const override
Definition: blake2b.h:31
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition: compiler.h:145