HMAC

From Free net encyclopedia

A keyed-hash message authentication code, or HMAC, is a type of message authentication code (MAC) calculated using a cryptographic hash function in combination with a secret key. As with any MAC, it may be used to simultaneously verify both the data integrity and the authenticity of a message. Any iterative cryptographic hash function, such as MD5 or SHA-1, may be used in the calculation of an HMAC; the resulting MAC algorithm is termed HMAC-MD5 or HMAC-SHA-1 accordingly. The cryptographic strength of the HMAC depends upon the cryptographic strength of the underlying hash function and on the size and quality of the key.

An iterative hash function breaks up a message into blocks of a fixed size and iterates over them with a compression function. For example, MD5 and SHA-1 operate on 512-bit blocks. The size of the output of HMAC is the same as that of the underlying hash function (128 or 160 bits in the case of MD5 and SHA-1), although it can be truncated if desired.

HMAC is defined as

<math>\mathrm{HMAC}_K(m) = h\Bigg((K \oplus \mathrm{opad}) \| h\Big((K \oplus \mathrm{ipad}) \| m\Big)\Bigg),</math>

where <math>h</math> is an iterated hash function, <math>K</math> is a secret key padded with extra zeros to the block size of the hash function, <math>m</math> is the message to be authenticated, <math>\|</math> denotes concatenation, <math>\oplus</math> denotes exclusive or, and the outer padding <math>\mathrm{opad} = \texttt{0x5c5c5c\ldots5c5c}</math> and inner padding <math>\mathrm{ipad} = \texttt{0x363636\ldots3636}</math> are two one-block–long hexadecimal constants.

The construction and analysis of HMACs was first published in 1996 by Mihir Bellare, Ran Canetti, and Hugo Krawczyk, who also wrote RFC 2104. FIPS PUB 198 generalizes and standardizes the use of HMACs. HMAC-SHA-1 and HMAC-MD5 are used within the IPsec and TLS protocols.

Typical usage

A pizza restaurant that suffers from attackers that place bogus orders may insist that all its customers deposit a secret key with the restaurant. Along with an order, a customer must supply the order's HMAC digest, computed using the customer's secret key. The restaurant, knowing the customer's secret key, can then verify that the order originated from the stated customer and has not been tampered with.

External links

References

  • Mihir Bellare, Ran Canetti and Hugo Krawczyk, Keying Hash Functions for Message Authentication, CRYPTO 1996, pp1–15 (PS or PDF).
  • Mihir Bellare, Ran Canetti and Hugo Krawczyk, Message authentication using hash functions: The HMAC construction, CryptoBytes 2(1), Spring 1996 (PS or PDF).

Template:Cryptographic hash functionsde:HMAC fr:HMAC ja:HMAC