Botan 3.6.1
Crypto and TLS for C&
blake2s.h
Go to the documentation of this file.
1/*
2 * BLAKE2s
3 * (C) 2023 Richard Huveneers
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7
8#ifndef BOTAN_BLAKE2S_H_
9#define BOTAN_BLAKE2S_H_
10
11#include <botan/hash.h>
12
13namespace Botan {
14
15/**
16 * BLAKE2s
17 */
18class BLAKE2s final : public HashFunction {
19 public:
20 explicit BLAKE2s(size_t output_bits = 256);
21 ~BLAKE2s() override;
22
23 std::string name() const override;
24
25 size_t output_length() const override { return m_outlen; }
26
27 size_t hash_block_size() const override { return 64; }
28
29 std::unique_ptr<HashFunction> copy_state() const override;
30
31 std::unique_ptr<HashFunction> new_object() const override { return std::make_unique<BLAKE2s>(m_outlen << 3); }
32
33 void clear() override;
34
35 private:
36 void add_data(std::span<const uint8_t>) override;
37 void final_result(std::span<uint8_t>) override;
38 void state_init(size_t outlen, const uint8_t* key, size_t keylen);
39 void compress(bool last);
40
41 uint8_t m_b[64]; // input buffer
42 uint32_t m_h[8]; // chained state
43 uint32_t m_t[2]; // total number of bytes
44 uint8_t m_c; // pointer for b[]
45 size_t m_outlen; // digest size
46};
47
48} // namespace Botan
49
50#endif
void clear() override
Definition blake2s.cpp:114
std::unique_ptr< HashFunction > new_object() const override
Definition blake2s.h:31
std::unique_ptr< HashFunction > copy_state() const override
Definition blake2s.cpp:149
~BLAKE2s() override
Definition blake2s.cpp:168
size_t hash_block_size() const override
Definition blake2s.h:27
BLAKE2s(size_t output_bits=256)
Definition blake2s.cpp:161
std::string name() const override
Definition blake2s.cpp:41
size_t output_length() const override
Definition blake2s.h:25
int(* final)(unsigned char *, CTX *)