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;
61 cipher.
SetKey(key, length, params);
63 unsigned int blockSize = cipher.
BlockSize();
68 MulU(m_reg+blockSize, blockSize);
69 memcpy(m_reg+2*blockSize, m_reg+blockSize, blockSize);
70 MulU(m_reg+2*blockSize, blockSize);
80 unsigned int blockSize = cipher.
BlockSize();
84 const unsigned int len =
UnsignedMin(blockSize - m_counter, length);
87 xorbuf(m_reg+m_counter, input, len);
93 if (m_counter == blockSize && length > 0)
100 if (length > blockSize)
104 input += (length - leftOver);
111 xorbuf(m_reg+m_counter, input, length);
112 m_counter += (
unsigned int)length;
120 ThrowIfInvalidTruncatedSize(size);
123 unsigned int blockSize = cipher.
BlockSize();
125 if (m_counter < blockSize)
127 m_reg[m_counter] ^= 0x80;
133 memcpy(mac, m_reg, size);
136 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.
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.
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.