Coverage Report

Created: 2023-02-13 06:21

/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 <botan/sym_algo.h>
13
#include <string>
14
#include <memory>
15
16
namespace Botan {
17
18
class BLAKE2bMAC;
19
20
/**
21
* BLAKE2B
22
*/
23
class BLAKE2b final : public HashFunction, public SymmetricAlgorithm
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
0
      size_t hash_block_size() const override { return 128; }
32
0
      size_t output_length() const override { return m_output_bits / 8; }
33
0
      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
57
      secure_vector<uint8_t> m_buffer;
58
      size_t m_bufpos;
59
60
      secure_vector<uint64_t> m_H;
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
68
}
69
70
#endif