Coverage Report

Created: 2022-05-14 06:06

/src/botan/build/include/botan/internal/cmac.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
* CMAC
3
* (C) 1999-2007,2014 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7
8
#ifndef BOTAN_CMAC_H_
9
#define BOTAN_CMAC_H_
10
11
#include <botan/mac.h>
12
#include <botan/block_cipher.h>
13
14
namespace Botan {
15
16
/**
17
* CMAC, also known as OMAC1
18
*/
19
class CMAC final : public MessageAuthenticationCode
20
   {
21
   public:
22
      std::string name() const override;
23
0
      size_t output_length() const override { return m_block_size; }
24
      std::unique_ptr<MessageAuthenticationCode> new_object() const override;
25
26
      void clear() override;
27
28
      Key_Length_Specification key_spec() const override
29
0
         {
30
0
         return m_cipher->key_spec();
31
0
         }
32
33
      /**
34
      * @param cipher the block cipher to use
35
      */
36
      explicit CMAC(std::unique_ptr<BlockCipher> cipher);
37
38
      CMAC(const CMAC&) = delete;
39
      CMAC& operator=(const CMAC&) = delete;
40
   private:
41
      void add_data(const uint8_t[], size_t) override;
42
      void final_result(uint8_t[]) override;
43
      void key_schedule(const uint8_t[], size_t) override;
44
45
      std::unique_ptr<BlockCipher> m_cipher;
46
      secure_vector<uint8_t> m_buffer, m_state, m_B, m_P;
47
      const size_t m_block_size;
48
      size_t m_position;
49
   };
50
51
}
52
53
#endif