Botan 3.0.0-alpha0
Crypto and TLS for C&
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 <botan/sym_algo.h>
13#include <string>
14#include <memory>
15
16namespace Botan {
17
18class BLAKE2bMAC;
19
20/**
21* BLAKE2B
22*/
24 {
25 public:
26 /**
27 * @param output_bits the output size of BLAKE2b in bits
28 */
29 explicit BLAKE2b(size_t output_bits = 512);
30
31 size_t hash_block_size() const override { return 128; }
32 size_t output_length() const override { return m_output_bits / 8; }
33 size_t key_size() const { return m_key_size; }
34
35 Key_Length_Specification key_spec() const override;
36
37 std::unique_ptr<HashFunction> new_object() const override;
38 std::string name() const override;
39 void clear() override;
40
41 std::unique_ptr<HashFunction> copy_state() const override;
42
43 protected:
44 friend class BLAKE2bMAC;
45
46 void key_schedule(const uint8_t key[], size_t length) override;
47
48 void add_data(const uint8_t input[], size_t length) override;
49 void final_result(uint8_t out[]) override;
50
51 private:
52 void state_init();
53 void compress(const uint8_t* data, size_t blocks, uint64_t increment);
54
55 const size_t m_output_bits;
56
58 size_t m_bufpos;
59
61 uint64_t m_T[2];
62 uint64_t m_F[2];
63
64 size_t m_key_size;
65 secure_vector<uint8_t> m_padded_key_buffer;
66 };
67
69
70}
71
72#endif
void key_schedule(const uint8_t key[], size_t length) override
Definition: blake2b.cpp:217
size_t key_size() const
Definition: blake2b.h:33
BLAKE2b(size_t output_bits=512)
Definition: blake2b.cpp:34
Key_Length_Specification key_spec() const override
Definition: blake2b.cpp:197
size_t output_length() const override
Definition: blake2b.h:32
std::unique_ptr< HashFunction > new_object() const override
Definition: blake2b.cpp:207
size_t hash_block_size() const override
Definition: blake2b.h:31
std::string name() const override
Definition: blake2b.cpp:202
void clear() override
Definition: blake2b.cpp:234
std::unique_ptr< HashFunction > copy_state() const override
Definition: blake2b.cpp:212
void final_result(uint8_t out[]) override
Definition: blake2b.cpp:187
void add_data(const uint8_t input[], size_t length) override
Definition: blake2b.cpp:148
int(* final)(unsigned char *, CTX *)
Definition: alg_id.cpp:13
BLAKE2b Blake2b
Definition: blake2b.h:68
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65