
related topics 
{math, number, function} 
{system, computer, user} 
{law, state, case} 
{war, force, army} 
{company, market, business} 
{style, bgcolor, rowspan} 

In cryptography, HMAC (Hashbased Message Authentication Code), is a specific construction for calculating a message authentication code (MAC) involving 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 cryptographic hash function, such as MD5 or SHA1, may be used in the calculation of an HMAC; the resulting MAC algorithm is termed HMACMD5 or HMACSHA1 accordingly. The cryptographic strength of the HMAC depends upon the cryptographic strength of the underlying hash function, the size of its hash output length in bits and on the size and quality of the cryptographic 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 SHA1 operate on 512bit 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 or SHA1, respectively), although it can be truncated if desired.
The definition and analysis of the HMAC construction was first published in 1996 by Mihir Bellare, Ran Canetti, and Hugo Krawczyk,^{[1]} who also wrote RFC 2104. This paper also defined a variant called NMAC that is rarely if ever used. FIPS PUB 198 generalizes and standardizes the use of HMACs. HMACSHA1 and HMACMD5 are used within the IPsec and TLS protocols.
Contents
Definition (from RFC 2104)
Let:
 H(·) be a cryptographic hash function
 K be a secret key padded to the right with extra zeros to the input block size of the hash function, or the hash of the original key if it's longer than that block size
 m be the message to be authenticated
 ∥ denote concatenation
 ⊕ denote exclusive or (XOR)
 opad be the outer padding (0x5c5c5c…5c5c, oneblocklong hexadecimal constant)
 ipad be the inner padding (0x363636…3636, oneblocklong hexadecimal constant)
Then HMAC(K,m) is mathematically defined by
Implementation
The following pseudocode demonstrates how HMAC may be implemented.
Full article ▸


related documents 
Banach algebra 
Commutator 
Squarefree integer 
Elementary function 
Cyclone (programming language) 
PreAbelian category 
Möbius function 
Bounded set 
String searching algorithm 
Fermat's little theorem 
Tuple 
Enriched category 
Linear classifier 
Binary space partitioning 
Floor and ceiling functions 
Principal ideal domain 
Multiplication table 
Caesar cipher 
Twin prime 
Infimum 
Loss of significance 
Homomorphism 
Pseudocode 
Möbius inversion formula 
ElGamal encryption 
Division ring 
Pike (programming language) 
BuraliForti paradox 
PSPACE 
Connected space 
