Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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 */
19 class BOTAN_DLL CMAC final : public MessageAuthenticationCode
20 {
21 public:
22 std::string name() const override;
23 size_t output_length() const override { return m_cipher->block_size(); }
24 MessageAuthenticationCode* clone() const override;
25
26 void clear() override;
27
28 Key_Length_Specification key_spec() const override
29 {
30 return m_cipher->key_spec();
31 }
32
33 /**
34 * CMAC's polynomial doubling operation
35 * @param in the input
36 */
37 static secure_vector<uint8_t> poly_double(const secure_vector<uint8_t>& in);
38
39 /**
40 * @param cipher the block cipher to use
41 */
42 explicit CMAC(BlockCipher* cipher);
43
44 CMAC(const CMAC&) = delete;
45 CMAC& operator=(const CMAC&) = delete;
46 private:
47 void add_data(const uint8_t[], size_t) override;
48 void final_result(uint8_t[]) override;
49 void key_schedule(const uint8_t[], size_t) override;
50
51 std::unique_ptr<BlockCipher> m_cipher;
52 secure_vector<uint8_t> m_buffer, m_state, m_B, m_P;
53 size_t m_position;
54 };
55
56 }
57
58 #endif
Botan::Key_Length_Specification
Definition: key_spec.h:18
Botan::CMAC::output_length
size_t output_length() const override
Definition: cmac.h:23
Botan::MessageAuthenticationCode
Definition: mac.h:20
Botan::secure_vector
std::vector< T, secure_allocator< T >> secure_vector
Definition: secmem.h:121
Botan
Definition: alg_id.cpp:13
Botan::CMAC::key_spec
Key_Length_Specification key_spec() const override
Definition: cmac.h:28
Botan::CMAC
Definition: cmac.h:19
Botan::BlockCipher
Definition: block_cipher.h:19