Coverage Report

Created: 2023-02-22 06:14

/src/botan/build/include/botan/internal/cmac.h
Line
Count
Source
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
44.5k
      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
      bool has_keying_material() const override;
28
29
      Key_Length_Specification key_spec() const override
30
1.37k
         {
31
1.37k
         return m_cipher->key_spec();
32
1.37k
         }
33
34
      /**
35
      * @param cipher the block cipher to use
36
      */
37
      explicit CMAC(std::unique_ptr<BlockCipher> cipher);
38
39
      CMAC(const CMAC&) = delete;
40
      CMAC& operator=(const CMAC&) = delete;
41
   private:
42
      void add_data(const uint8_t[], size_t) override;
43
      void final_result(uint8_t[]) override;
44
      void key_schedule(const uint8_t[], size_t) override;
45
46
      std::unique_ptr<BlockCipher> m_cipher;
47
      secure_vector<uint8_t> m_buffer, m_state, m_B, m_P;
48
      const size_t m_block_size;
49
      size_t m_position;
50
   };
51
52
}
53
54
#endif