Botan  2.4.0
Crypto and TLS for C++11
cmac.h
Go to the documentation of this file.
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 */
20  {
21  public:
22  std::string name() const override;
23  size_t output_length() const override { return m_block_size; }
24  MessageAuthenticationCode* clone() const override;
25 
26  void clear() override;
27 
29  {
30  return m_cipher->key_spec();
31  }
32 
33  /**
34  * CMAC's polynomial doubling operation
35  *
36  * This function was only exposed for use elsewhere in the library, but it is not
37  * longer used. This function will be removed in a future release.
38  *
39  * @param in the input
40  */
42  BOTAN_DEPRECATED("This was only for internal use and is no longer used")
43  poly_double(const secure_vector<uint8_t>& in);
44 
45  /**
46  * @param cipher the block cipher to use
47  */
48  explicit CMAC(BlockCipher* cipher);
49 
50  CMAC(const CMAC&) = delete;
51  CMAC& operator=(const CMAC&) = delete;
52  private:
53  void add_data(const uint8_t[], size_t) override;
54  void final_result(uint8_t[]) override;
55  void key_schedule(const uint8_t[], size_t) override;
56 
57  std::unique_ptr<BlockCipher> m_cipher;
58  secure_vector<uint8_t> m_buffer, m_state, m_B, m_P;
59  const size_t m_block_size;
60  size_t m_position;
61  };
62 
63 }
64 
65 #endif
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:27
size_t output_length() const override
Definition: cmac.h:23
Definition: alg_id.cpp:13
Key_Length_Specification key_spec() const override
Definition: cmac.h:28
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:88