Information Security Unit-2 - 9 HMAC
Information Security Unit-2 - 9 HMAC
Information Security Unit-2 - 9 HMAC
HMAC
HMAC
Interest in developing a MAC, derived from a cryptographic hash code has been increasing
mainly because hash functions are generally faster and are also not limited by export restrictions
unlike block ciphers. Additional reason also would be that the library code for cryptographic hash
functions is widely available. The original proposal is for incorporation of a secret key into an
existing hash algorithm and the approach that received most support is HMAC. HMAC is specified
as Internet standard RFC2104. It makes use of the hash function on the given message. Any of
MD5, SHA-1, RIPEMD-160 can be used.
The first two objectives are very important for the acceptability of HMAC. HMAC treats the
hash function as a “black box”, which has two benefits. First is that an existing implementation of
the hash function can be used for implementing HMAC making the bulk of HMAC code readily
available without modification. Second is that if ever an existing hash function is to be replaced,
the existing hash function module is removed and new module is dropped in. The last design
objective provides the main advantage of HMAC over other proposed hash-based schemes.
HMAC can be proven secure provided that the embedded hash function has some reasonable
cryptographic strengths.
73
Information Security Unit-2 Symmetric Encryption, DES, AES Message Authentication, Hash algorithms,
HMAC
HMAC Algorithm
HMAC Structure:
74
Information Security Unit-2 Symmetric Encryption, DES, AES Message Authentication, Hash algorithms,
HMAC
The XOR with ipad results in flipping one-half of the bits of K. Similarly, XOR with opad results
in flipping one-half of the bits of K, but different set of bits. By passing S i and S0 through the
compression function of the hash algorithm, we have pseudorandomly generated two keys from
K.
HMAC should execute in approximately the same time as the embedded hash function for
long messages. HMAC adds three executions of the hash compression function (for S0, Si, and the
block produced from the inner hash)
As shown in the above figure, the values are needed to be computed initially and every time a
key changes. The precomputed quantities substitute for the initial value (IV) in the hash function.
With this implementation, only one additional instance of the compression function is added to
the processing normally produced by the hash function. This implementation is worthwhile if
most of the messages for which a MAC is computed are short.
Security of HMAC:
75
Information Security Unit-2 Symmetric Encryption, DES, AES Message Authentication, Hash algorithms,
HMAC
The appeal of HMAC is that its designers have been able to prove an exact relationship
between the strength of the embedded hash function and the strength of HMAC. The security of
a MAC function is generally expressed in terms of the probability of successful forgery with a
given amount of time spent by the forger and a given number of message-MAC pairs created
with the same key. Have two classes of attacks on the embedded hash function:
The attacker is able to compute an output of the compression function even with an IV that is
random, secret and unknown to the attacker.
The attacker finds collisions in the hash function even when the IV is random and secret.
These attacks are likely to be caused by brute force attack on key used which has work of order
n (n/2)
2 ; or a birthday attack which requires work of order 2 - but which requires the attacker to
n
observe 2 blocks of messages using the same key - very unlikely. So even MD5 is still secure for
use in HMAC given these constraints.
76