HMAC, Keyed-Hashing for Message Authentication

Description Glossary RFCs Publications Obsolete RFCs


Type:Hashing algorithm.
Output:128 bit hash.
MIME subtype:
Working groups:

RFC 2403:

HMAC is a secret key authentication algorithm. Data integrity and data origin authentication as provided by HMAC are dependent upon the scope of the distribution of the secret key. If only the source and destination know the HMAC key, this provides both data origin authentication and data integrity for packets sent between the two parties; if the HMAC is correct, this proves that it must have been added by the source.

RFC 2104:

HMAC can be used with any iterative cryptographic hash function, e.g., MD5, SHA-1, in combination with a secret shared key. The cryptographic strength of HMAC depends on the properties of the underlying hash function.

Specific instantiations of HMAC need to define a particular hash function. Current candidates for such hash functions include SHA-1, MD5, RIPEMD-128/160. These different realizations of HMAC will be denoted by HMAC-SHA1, HMAC-MD5, HMAC-RIPEMD, etc.

HMAC provides message authentication through the use of cryptographic hash functions.


MAC, Message Authentication Codes.
Message authentication codes with shared keys are used to provide integrity checks.

(RFC 2104) Keys need to be chosen at random (or using a cryptographically strong pseudo-random generator seeded with a random seed), and periodically refreshed. The choice of random (or cryptographically pseudorandom) keys, a secure key exchange mechanism, frequent key refreshments, and good secrecy protection of keys are all essential ingredients for the security of the integrity verification mechanism provided by HMAC.


[RFC 2085] HMAC-MD5 IP Authentication with Replay Prevention.

[RFC 2104] HMAC: Keyed-Hashing for Message Authentication.

[RFC 2202] Test Cases for HMAC-MD5 and HMAC-SHA-1.

[RFC 2286] Test Cases for HMAC-RIPEMD160 and HMAC-RIPEMD128.

[RFC 2403] The Use of HMAC-MD5-96 within ESP and AH.

[RFC 2857] The Use of HMAC-RIPEMD-160-96 within ESP and AH.

[RFC 3537] Wrapping a Hashed Message Authentication Code (HMAC) key with a Triple-Data Encryption Standard (DES) Key or an Advanced Encryption Standard (AES) Key.

[RFC 4231] Identifiers and Test Vectors for HMAC-SHA-224, HMAC-SHA-256, HMAC-SHA-384, and HMAC-SHA-512.

[RFC 4305] Cryptographic Algorithm Implementation Requirements for Encapsulating Security Payload (ESP) and Authentication Header (AH).

[RFC 5289] TLS Elliptic Curve Cipher Suites with SHA-256/384 and AES Galois Counter Mode (GCM).


Obsolete RFCs:

[RFC 2404] The Use of HMAC-SHA-1-96 within ESP and AH.

Description Glossary RFCs Publications Obsolete RFCs