# Computer Network | HMAC Algorithm

**HMAC algorithm** stands for Hashed or Hash based Message Authentication Code. It is a result of work done on developing a MAC derived from cryptographic hash functions. HMAC is a great resistant towards cryptanalysis attacks as it uses the Hashing concept twice. HMAC consists of twin benefits of Hashing and MAC, and thus is more secure than any other authentication codes. RFC 2104 has issued HMAC, and HMAC has been made compulsory to implement in IP security. The FIPS 198 NIST standard has also issued HMAC.

**Objectives –**

- As the Hash Function, HMAC is also aimed to be one way, i.e, easy to generate output from input but complex the other way round.
- It aims at being less effected by collisions than the hash functions.
- HMAC reuses the algorithms like MD5 and SHA-1 and checks to replace the embedded hash functions with more secure hash functions, in case found.
- HMAC tries to handle the Keys in more simple manner.

**HMAC algorithm –**

The working of HMAC starts with taking a message M containing blocks of length *b* bits. An input signature is padded to the left of the message and the whole is given as input to a hash function which gives us a temporary message digest MD’. MD’ again is appended to an output signature and the whole is applied a hash function again, the result is our final message digest MD.

Here is a simple structure of HMAC:

Here, H stands for Hashing function,

M is original message

Si and So are input and output signatures respectively,

Yi is the ith block in original message M, where i ranges from [1, L)

L = the count of blocks in M

K is the secret key used for hashing

IV is an initial vector (some constant)

The generation of input signature and output signature *Si* and *So* respectively.

To a normal hash function HMAC adds a compression instance to the processing. This structural implementation holds efficiency for shorter MAC values.

## Recommended Posts:

- Computer Networks | Set 1
- Computer Networks | Set 2
- Computer Networks | Set 5
- Computer Networks | Set 3
- Computer Networks | Set 4
- Computer Networks | Set 12
- Computer Networks | Set 6
- Computer Networks | Set 7
- Computer Networks | Set 8
- Computer Networks | Set 9
- Computer Networks | Set 10
- Computer Networks | Set 11
- RSA Algorithm in Cryptography
- Last Minute Notes - Computer Networks
- Internet Control Message Protocol (ICMP) | Computer Networks

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.