5 #ifndef CRYPTOPP_IMPORTS 11 static
void MulU(byte *k,
unsigned int length)
15 for (
int i=length-1; i>=1; i-=2)
17 byte carry2 = k[i] >> 7;
20 k[i-1] += k[i-1] + carry2;
46 unsigned int blockSize = cipher.
BlockSize();
48 cipher.
SetKey(key, length, params);
53 MulU(m_reg+blockSize, blockSize);
54 memcpy(m_reg+2*blockSize, m_reg+blockSize, blockSize);
55 MulU(m_reg+2*blockSize, blockSize);
60 assert((input && length) || !(input || length));
65 unsigned int blockSize = cipher.
BlockSize();
69 const unsigned int len =
UnsignedMin(blockSize - m_counter, length);
72 xorbuf(m_reg+m_counter, input, len);
78 if (m_counter == blockSize && length > 0)
85 if (length > blockSize)
87 assert(m_counter == 0);
89 input += (length - leftOver);
95 assert(m_counter + length <= blockSize);
96 xorbuf(m_reg+m_counter, input, length);
97 m_counter += (
unsigned int)length;
100 assert(m_counter > 0);
105 ThrowIfInvalidTruncatedSize(size);
108 unsigned int blockSize = cipher.
BlockSize();
110 if (m_counter < blockSize)
112 m_reg[m_counter] ^= 0x80;
118 memcpy(mac, m_reg, size);
121 memset(m_reg, 0, blockSize);
An invalid argument was detected.
virtual void SetKey(const byte *key, size_t length, const NameValuePairs ¶ms=g_nullNameValuePairs)
Sets or reset the key of this object.
void CleanNew(size_type newSize)
Change size without preserving contents.
Classes for CMAC message authentication code.
Interface for one direction (encryption or decryption) of a block cipher.
void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms)
Sets the key for this object without performing parameter validation.
const T1 UnsignedMin(const T1 &a, const T2 &b)
Safe comparison of values that could be neagtive and incorrectly promoted.
void xorbuf(byte *buf, const byte *mask, size_t count)
Performs an XOR of a buffer with a mask.
std::string IntToString(T value, unsigned int base=10)
Converts a value to a string.
void TruncatedFinal(byte *mac, size_t size)
Computes the hash of the current message.
Crypto++ library namespace.
void Update(const byte *input, size_t length)
Updates a hash with additional input.
Interface for retrieving values given their names.