Coverage Report

Created: 2023-02-22 06:39

/src/botan/build/include/botan/internal/blake2bmac.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
* BLAKE2b MAC
3
* (C) 1999-2007,2014 Jack Lloyd
4
* (C) 2020           Tom Crowley
5
*
6
* Botan is released under the Simplified BSD License (see license.txt)
7
*/
8
9
#ifndef BOTAN_BLAKE2MAC_H_
10
#define BOTAN_BLAKE2MAC_H_
11
12
#include <botan/mac.h>
13
#include <botan/internal/blake2b.h>
14
15
namespace Botan {
16
17
/**
18
* BLAKE2b MAC
19
*/
20
class BLAKE2bMAC final : public MessageAuthenticationCode
21
   {
22
   public:
23
      explicit BLAKE2bMAC(size_t output_bits = 512);
24
25
      BLAKE2bMAC(const BLAKE2bMAC&) = delete;
26
      BLAKE2bMAC& operator=(const BLAKE2bMAC&) = delete;
27
28
0
      std::string name() const override { return m_blake.name(); }
29
0
      size_t output_length() const override { return m_blake.output_length(); }
30
      std::unique_ptr<MessageAuthenticationCode> new_object() const override;
31
32
      void clear() override;
33
34
0
      bool has_keying_material() const override { return m_blake.has_keying_material(); }
35
36
      Key_Length_Specification key_spec() const override
37
0
         {
38
0
         return m_blake.key_spec();
39
0
         }
40
41
   private:
42
      void key_schedule(const uint8_t key[], size_t length) override
43
0
         {
44
0
         m_blake.set_key(key, length);
45
0
         }
46
47
      void add_data(const uint8_t input[], size_t length) override
48
0
         {
49
0
         assert_key_material_set();
50
0
         m_blake.update(input, length);
51
0
         }
52
53
      void final_result(uint8_t out[]) override
54
0
         {
55
0
         assert_key_material_set();
56
0
         m_blake.final(out);
57
0
         }
58
59
      BLAKE2b m_blake;
60
   };
61
62
}
63
64
#endif