Hash-based Message Authentication Code (RFC2104/1997)
MAC used with any cryptographic hash function
Method of creating an authentication code (MAC) using a hash (like SHA) value
How to use Hash function for MAC
- If someone knows the hash value of the message, they can change message and calculate a new hash value.
- If has function use Merkle-Damgård construction, appendix attack could be happen because of its block operation property.
When using a message or key directly for hashing, it is easy to be attacked, so to solve these problem, the key is used twice in the message and hash function.
- opad and ipad are constants but need to be different
- HMAC provides stronger security guarantees than what MAC requires. HMAC doesn't reveal any information about the message because of the key