5#ifndef CRYPTOPP_IMPORTS
13 AssertValidKeyLength(keylength);
18 unsigned int blockSize = hash.
BlockSize();
21 throw InvalidArgument(
"HMAC: can only be used with a block-based hash function");
25 if (keylength <= blockSize)
28 if (AccessIpad() && userKey && keylength)
29 std::memcpy(AccessIpad(), userKey, keylength);
38 std::memset(AccessIpad()+keylength, 0, blockSize-keylength);
40 for (
unsigned int i=0; i<blockSize; i++)
42 AccessOpad()[i] = AccessIpad()[i] ^ 0x5c;
43 AccessIpad()[i] ^= 0x36;
47void HMAC_Base::KeyInnerHash()
52 m_innerHashKeyed =
true;
60 m_innerHashKeyed =
false;
66 if (!m_innerHashKeyed)
68 AccessHash().
Update(input, length);
73 ThrowIfInvalidTruncatedSize(size);
77 if (!m_innerHashKeyed)
79 hash.
Final(AccessInnerHash());
85 m_innerHashKeyed =
false;
void UncheckedSetKey(const byte *userKey, unsigned int keylength, const NameValuePairs ¶ms)
Sets the key for this object without performing parameter validation.
void TruncatedFinal(byte *mac, size_t size)
Computes the hash of the current message.
void Restart()
Restart the hash.
unsigned int DigestSize() const
Provides the digest size of the hash.
void Update(const byte *input, size_t length)
Updates a hash with additional input.
An invalid argument was detected.
Interface for retrieving values given their names.
void resize(size_type newSize)
Change size and preserve contents.
Classes for HMAC message authentication codes.
Crypto++ library namespace.
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.