7 #ifndef CRYPTOPP_DMAC_H
8 #define CRYPTOPP_DMAC_H
19 static std::string StaticAlgorithmName() {
return std::string(
"DMAC(") + T::StaticAlgorithmName() +
")";}
21 CRYPTOPP_CONSTANT(DIGESTSIZE=T::BLOCKSIZE)
23 DMAC_Base() : m_subkeylength(0), m_counter(0) {}
25 void UncheckedSetKey(
const byte *key,
unsigned int length,
const NameValuePairs ¶ms);
26 void Update(
const byte *input,
size_t length);
31 byte *GenerateSubKeys(
const byte *key,
size_t keylength);
33 size_t m_subkeylength;
36 typename T::Encryption m_f2;
37 unsigned int m_counter;
50 {this->
SetKey(key, length);}
56 m_subkeylength = T::StaticGetValidKeyLength(T::BLOCKSIZE);
57 m_subkeys.resize(2*
UnsignedMin((
unsigned int)T::BLOCKSIZE, m_subkeylength));
58 m_mac1.SetKey(GenerateSubKeys(key, length), m_subkeylength, params);
59 m_f2.SetKey(m_subkeys+m_subkeys.size()/2, m_subkeylength, params);
67 m_mac1.Update(input, length);
68 m_counter = (
unsigned int)((m_counter + length) % T::BLOCKSIZE);
74 ThrowIfInvalidTruncatedSize(size);
76 byte pad[T::BLOCKSIZE];
77 byte padByte = byte(T::BLOCKSIZE-m_counter);
78 memset(pad, padByte, padByte);
79 m_mac1.Update(pad, padByte);
80 m_mac1.TruncatedFinal(mac, size);
81 m_f2.ProcessBlock(mac);
89 typename T::Encryption cipher(key, keylength);
90 memset(m_subkeys, 0, m_subkeys.size());
91 cipher.ProcessBlock(m_subkeys);
92 m_subkeys[m_subkeys.size()/2 + T::BLOCKSIZE - 1] = 1;
93 cipher.ProcessBlock(m_subkeys+m_subkeys.size()/2);