HMAC – a hash-based MAC
Hash-based Message Authentication Code (HMAC) is a MAC that is generated by the HMAC function.
The HMAC function uses a cryptographic hash function and a secret key. The function is not overly complex and can be understood by many non-cryptographers. It is defined as follows:
HMAC(K, message) = H(K' XOR opad ‖ H(K' XOR ipad ‖ message))
Here, the following can be understood:
Message
: This is the message to be authenticated.H
: This is the hash function, for example, SHA3-256.K
: This is the secret key.K'
: This is a block-sized key derived fromK
depending on the hash function’s internal block size,B
.ipad
: This is the inner padding, consisting of byte0x36
, which is repeatedB
times.opad
: This is the outer padding, consisting of byte0x5C
, which is repeatedB
times.- ‖: This refers to a concatenation.
Note that K'
is derived from K
, as follows:
- If...