1
#ifndef CRYPTOPP_CMAC_H
2
#define CRYPTOPP_CMAC_H
7
NAMESPACE_BEGIN(CryptoPP)
10
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CMAC_Base : public MessageAuthenticationCode
15
void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms);
16
void Update(const byte *input, size_t length);
17
void TruncatedFinal(byte *mac, size_t size);
18
unsigned int DigestSize() const {return GetCipher().BlockSize();}
19
unsigned int OptimalBlockSize() const {return GetCipher().BlockSize();}
20
unsigned int OptimalDataAlignment() const {return GetCipher().OptimalDataAlignment();}
23
friend class EAX_Base;
25
const BlockCipher & GetCipher() const {return const_cast<CMAC_Base*>(this)->AccessCipher();}
26
virtual BlockCipher & AccessCipher() =0;
30
unsigned int m_counter;
33
/// <a href="http://www.cryptolounge.org/wiki/CMAC">CMAC</a>
34
/*! Template parameter T should be a class derived from BlockCipherDocumentation, for example AES, with a block size of 8, 16, or 32 */
36
class CMAC : public MessageAuthenticationCodeImpl<CMAC_Base, CMAC<T> >, public SameKeyLengthAs<T>
40
CMAC(const byte *key, size_t length=SameKeyLengthAs<T>::DEFAULT_KEYLENGTH)
41
{this->SetKey(key, length);}
43
static std::string StaticAlgorithmName() {return std::string("CMAC(") + T::StaticAlgorithmName() + ")";}
46
BlockCipher & AccessCipher() {return m_cipher;}
47
typename T::Encryption m_cipher;