5 #ifndef CRYPTOPP_IMPORTS
10 ANONYMOUS_NAMESPACE_BEGIN
15 void MulU(
byte *k,
unsigned int len)
18 for (
int i=len-1; i>=1; i-=2)
20 byte carry2 = k[i] >> 7;
23 k[i-1] += k[i-1] + carry2;
26 #ifndef CRYPTOPP_CMAC_WIDE_BLOCK_CIPHERS
72 #endif // CRYPTOPP_CMAC_WIDE_BLOCK_CIPHERS
75 ANONYMOUS_NAMESPACE_END
82 cipher.
SetKey(key, length, params);
84 unsigned int blockSize = cipher.
BlockSize();
85 m_reg.CleanNew(3*blockSize);
89 MulU(m_reg+blockSize, blockSize);
90 memcpy(m_reg+2*blockSize, m_reg+blockSize, blockSize);
91 MulU(m_reg+2*blockSize, blockSize);
101 unsigned int blockSize = cipher.
BlockSize();
105 const unsigned int len =
UnsignedMin(blockSize - m_counter, length);
108 xorbuf(m_reg+m_counter, input, len);
114 if (m_counter == blockSize && length > 0)
121 if (length > blockSize)
125 input += (length - leftOver);
132 xorbuf(m_reg+m_counter, input, length);
133 m_counter += (
unsigned int)length;
141 ThrowIfInvalidTruncatedSize(size);
144 unsigned int blockSize = cipher.
BlockSize();
146 if (m_counter < blockSize)
148 m_reg[m_counter] ^= 0x80;
154 memcpy(mac, m_reg, size);
157 memset(m_reg, 0, blockSize);