Botan 1.10.17
cmac.h
Go to the documentation of this file.
1/*
2* CMAC
3* (C) 1999-2007 Jack Lloyd
4*
5* Distributed under the terms of the Botan license
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
14namespace Botan {
15
16/**
17* CMAC, also known as OMAC1
18*/
19class BOTAN_DLL CMAC : public MessageAuthenticationCode
20 {
21 public:
22 std::string name() const;
23 size_t output_length() const { return e->block_size(); }
24 MessageAuthenticationCode* clone() const;
25
26 void clear();
27
29 {
30 return e->key_spec();
31 }
32
33 /**
34 * CMAC's polynomial doubling operation
35 * @param in the input
36 * @param polynomial the byte value of the polynomial
37 */
38 static SecureVector<byte> poly_double(const MemoryRegion<byte>& in,
39 byte polynomial);
40
41 /**
42 * @param cipher the underlying block cipher to use
43 */
44 CMAC(BlockCipher* cipher);
45 ~CMAC();
46 private:
47 void add_data(const byte[], size_t);
48 void final_result(byte[]);
49 void key_schedule(const byte[], size_t);
50
51 BlockCipher* e;
52 SecureVector<byte> buffer, state, B, P;
53 size_t position;
54 byte polynomial;
55 };
56
57}
58
59#endif
Key_Length_Specification key_spec() const
Definition cmac.h:28
size_t output_length() const
Definition cmac.h:23
std::string name() const
Definition cmac.cpp:116
CMAC(BlockCipher *cipher)
Definition cmac.cpp:132