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)
26 memcpy(AccessIpad(), userKey, keylength);
29 AccessHash().CalculateDigest(AccessIpad(), userKey, keylength);
34 memset(AccessIpad()+keylength, 0, blockSize-keylength);
36 for (
unsigned int i=0; i<blockSize; i++)
38 AccessOpad()[i] = AccessIpad()[i] ^ 0x5c;
39 AccessIpad()[i] ^= 0x36;
43 void HMAC_Base::KeyInnerHash()
48 m_innerHashKeyed =
true;
56 m_innerHashKeyed =
false;
62 if (!m_innerHashKeyed)
64 AccessHash().
Update(input, length);
69 ThrowIfInvalidTruncatedSize(size);
73 if (!m_innerHashKeyed)
75 hash.
Final(AccessInnerHash());
81 m_innerHashKeyed =
false;
const char * DigestSize()
int, in bytes
An invalid argument was detected.
Classes for HMAC message authentication codes.
void Update(const byte *input, size_t length)
Updates a hash with additional input.
void Restart()
Restart the hash.
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.
void TruncatedFinal(byte *mac, size_t size)
Computes the hash of the current message.
const char * BlockSize()
int, in bytes
Crypto++ library namespace.
Interface for retrieving values given their names.