Coverage Report

Created: 2020-09-16 07:52

/src/botan/build/include/botan/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
BOTAN_FUTURE_INTERNAL_HEADER(cmac.h)
15
16
namespace Botan {
17
18
/**
19
* CMAC, also known as OMAC1
20
*/
21
class BOTAN_PUBLIC_API(2,0) CMAC final : public MessageAuthenticationCode
22
   {
23
   public:
24
      std::string name() const override;
25
0
      size_t output_length() const override { return m_block_size; }
26
      MessageAuthenticationCode* clone() const override;
27
28
      void clear() override;
29
30
      Key_Length_Specification key_spec() const override
31
0
         {
32
0
         return m_cipher->key_spec();
33
0
         }
34
35
      /**
36
      * CMAC's polynomial doubling operation
37
      *
38
      * This function was only exposed for use elsewhere in the library, but it is not
39
      * longer used. This function will be removed in a future release.
40
      *
41
      * @param in the input
42
      */
43
      static secure_vector<uint8_t>
44
         BOTAN_DEPRECATED("This was only for internal use and is no longer used")
45
         poly_double(const secure_vector<uint8_t>& in);
46
47
      /**
48
      * @param cipher the block cipher to use
49
      */
50
      explicit CMAC(BlockCipher* cipher);
51
52
      CMAC(const CMAC&) = delete;
53
      CMAC& operator=(const CMAC&) = delete;
54
   private:
55
      void add_data(const uint8_t[], size_t) override;
56
      void final_result(uint8_t[]) override;
57
      void key_schedule(const uint8_t[], size_t) override;
58
59
      std::unique_ptr<BlockCipher> m_cipher;
60
      secure_vector<uint8_t> m_buffer, m_state, m_B, m_P;
61
      const size_t m_block_size;
62
      size_t m_position;
63
   };
64
65
}
66
67
#endif