/src/botan/build/include/botan/internal/blake2b.h
Line | Count | Source (jump to first uncovered line) |
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 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 | 0 | size_t hash_block_size() const override { return 128; } |
29 | 0 | 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 | | |
49 | | secure_vector<uint64_t> m_H; |
50 | | uint64_t m_T[2]; |
51 | | uint64_t m_F[2]; |
52 | | }; |
53 | | |
54 | | typedef BLAKE2b Blake2b; |
55 | | |
56 | | } |
57 | | |
58 | | #endif |