00001
#ifndef CRYPTOPP_CBCMAC_H
00002
#define CRYPTOPP_CBCMAC_H
00003
00004
#include "seckey.h"
00005
#include "secblock.h"
00006
00007 NAMESPACE_BEGIN(CryptoPP)
00008
00009
00010 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE
CBC_MAC_Base : public
MessageAuthenticationCode
00011 {
00012
public:
00013
CBC_MAC_Base() {}
00014
00015
void CheckedSetKey(
void *, Empty empty,
const byte *key,
unsigned int length,
const NameValuePairs ¶ms);
00016
void Update(
const byte *input,
unsigned int length);
00017
void TruncatedFinal(byte *mac,
unsigned int size);
00018 unsigned int DigestSize()
const {
return const_cast<CBC_MAC_Base*>(
this)->AccessCipher().BlockSize();}
00019
00020
protected:
00021
virtual BlockCipher & AccessCipher() =0;
00022
00023
private:
00024
void ProcessBuf();
00025
SecByteBlock m_reg;
00026
unsigned int m_counter;
00027 };
00028
00029
00030
00031
00032
00033
00034
template <
class T>
00035 class CBC_MAC :
public MessageAuthenticationCodeImpl<CBC_MAC_Base, CBC_MAC<T> >,
public SameKeyLengthAs<T>
00036 {
00037
public:
00038
CBC_MAC() {}
00039
CBC_MAC(
const byte *key,
unsigned int length=
SameKeyLengthAs<T>::DEFAULT_KEYLENGTH)
00040 {this->
SetKey(key, length);}
00041
00042
static std::string StaticAlgorithmName() {
return std::string(
"CBC-MAC(") + T::StaticAlgorithmName() +
")";}
00043
00044
private:
00045
BlockCipher & AccessCipher() {
return m_cipher;}
00046
typename T::Encryption m_cipher;
00047 };
00048
00049 NAMESPACE_END
00050
00051
#endif