Botan 3.5.0
Crypto and TLS for C&
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/block_cipher.h>
12#include <botan/mac.h>
13
14namespace Botan {
15
16/**
17* CMAC, also known as OMAC1
18*/
20 public:
21 std::string name() const override;
22
23 size_t output_length() const override { return m_block_size; }
24
25 std::unique_ptr<MessageAuthenticationCode> new_object() const override;
26
27 void clear() override;
28 bool has_keying_material() const override;
29
30 Key_Length_Specification key_spec() const override { return m_cipher->key_spec(); }
31
32 /**
33 * @param cipher the block cipher to use
34 */
35 explicit CMAC(std::unique_ptr<BlockCipher> cipher);
36
37 CMAC(const CMAC&) = delete;
38 CMAC& operator=(const CMAC&) = delete;
39
40 private:
41 void add_data(std::span<const uint8_t>) override;
42 void final_result(std::span<uint8_t>) override;
43 void key_schedule(std::span<const uint8_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} // namespace Botan
52
53#endif
size_t output_length() const override
Definition cmac.h:23
CMAC(std::unique_ptr< BlockCipher > cipher)
Definition cmac.cpp:111
std::unique_ptr< MessageAuthenticationCode > new_object() const override
Definition cmac.cpp:104
void clear() override
Definition cmac.cpp:85
bool has_keying_material() const override
Definition cmac.cpp:67
std::string name() const override
Definition cmac.cpp:97
CMAC(const CMAC &)=delete
Key_Length_Specification key_spec() const override
Definition cmac.h:30
CMAC & operator=(const CMAC &)=delete
int(* final)(unsigned char *, CTX *)
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:61