The Wayback Machine - https://web.archive.org/web/20240912005401/https://www.geeksforgeeks.org/hmac-algorithm-in-computer-network/
Open In App

HMAC Algorithm in Computer Network

Last Updated : 31 Jul, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

HMAC (Hash-based Message Authentication Code) is a type of message authentication code (MAC) that is acquired by executing a cryptographic hash function on the data that is to be authenticated and a secret shared key. Like any of the MACs, it is used for both data integrity and authentication. In this article, we will discuss every point about HMAC.

What is HMAC?

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 resistance to 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 code. RFC 2104 has issued HMAC, and HMAC has been made compulsory to implement in IP security. The FIPS 198 NIST standard has also been issued by HMAC. 

Objectives of HMAC

  • 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 around. 
  • It aims at being less affected by collisions than the hash functions. 
  • HMAC reuses 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 a more simple manner. 

Working of 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: 

HMAC

  • Here, H stands for Hashing function, 
  • M is the 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.

Security in Hash-based Message Authentication Code 

HMAC is more secure than MAC since the key and message are hashed in different steps:

HMAC(key, message) = H(mod1(key) || H(mod2(key) || message).

The data is initially hashed by the client using a private key before being sent to the server as part of the request. The server then creates its own HMAC. This assures that the process is not vulnerable to attacks, which could result in crucial data being disclosed as subsequent MACs are generated. Additionally, once the procedure is completed, the delivered message becomes irreversible and resistant to hackers. Even if a malicious party attempts to steal the communication, they will be unable to determine its length or decrypt it because they do not have the decryption key.

Advantages of HMAC

  • HMACs are ideal for high-performance systems like routers due to the use of hash functions which are calculated and verified quickly unlike the public key systems.
  • Digital signatures are larger than HMACs, yet the HMACs provide comparably higher security.
  • HMACs are used in administrations where public key systems are prohibited.

Disadvantages of HMAC

  • HMACs uses shared key which may lead to non-repudiation. If either sender or receiver’s key is compromised then it will be easy for attackers to create unauthorized messages.
  • Securely managing and distributing secret keys can be challenging.
  • Although unlikely, hash collisions (where two different messages produce the same hash) can occur.
  • The security of HMAC depends on the length of the secret key. Short keys are more vulnerable to brute-force attacks.
  • The security of HMAC relies on the strength of the chosen hash function (e.g., SHA-256). If the hash function is compromised, HMAC is also affected.

Applications of HMAC

  • Verification of e-mail address during activation or creation of an account.
  • Authentication of form data that is sent to the client browser and then submitted back.
  • HMACs can be used for Internet of things (IoT) due to less cost.
  • Whenever there is a need to reset the password, a link that can be used once is sent without adding a server state.
  • It can take a message of any length and convert it into a fixed-length message digest. That is even if you got a long message, the message digest will be small and thus permits maximizing bandwidth.

Conclusion

HMAC (Hash-Based Message Authentication Code) is a cryptographic technique that ensures data integrity and authenticity using a hash function and a secret key. It is widely used in secure communication protocols like HTTPS and SFTP. HMAC provides higher security than traditional MACs due to its two-step hashing process, making it resistant to certain types of attacks. Despite challenges like key management and potential hash collisions, HMAC remains a robust and efficient method for securing data in various applications, including email verification, IoT, and password reset mechanisms.

Frequently Asked Questions on HMAC – FAQs

What is HMAC SHA1 used for?

An HMAC can be used to determine whether a message received via an insecure channel has been tampered , assuming the sender and receiver share a secret key.

Where is HMAC used?

HMAC encryption is also ideal for IoT devices, high-performance systems such as routers, and email address verification.

What is the size of the HMAC key?

The size of the HMAC key is 64 bytes.

Is HMAC reversible?

No HMAC is always irrevesible.


Previous Article
Next Article

Similar Reads

What is HMAC(Hash based Message Authentication Code)?
HMAC (Hash-based Message Authentication Code) is a type of message authentication code (MAC) that is acquired by executing a cryptographic hash function on the data that is to be authenticated and a secret shared key. Like any of the MACs, it is used for both data integrity and authentication. What is HMAC?HMAC (Hash-Based Message Authentication Co
7 min read
Why Star network is More Efficient in Network Fault Tolerance in Place of Bus Network?
Answer: Star networks offer better fault tolerance than bus networks because a single point of failure in a star network (the central hub) affects only the connected device, while a fault in a bus network can disrupt communication for all devices on the bus.Advantages of Star Topology Over Bus Topology Individual Connection Points: In a star networ
2 min read
Basic Network Attacks in Computer Network
Many people rely on the Internet for many of their professional, social and personal activities. But there are also people who attempt to damage our Internet-connected computers, violate our privacy and render inoperable the Internet services. Given the frequency and variety of existing attacks as well as the threat of new and more destructive futu
7 min read
How to Find Network IP Address of Computer Using Computer Name?
Answer: By using the command "ping" followed by the computer name in the command prompt or terminal.To find the network IP address of a computer using its computer name: Open Command Prompt or Terminal Begin by opening the Command Prompt (Windows) or Terminal (macOS/Linux) on your computer. Use the Ping Command Type "ping" followed by the computer
1 min read
Computer Network | Leaky bucket algorithm
In the network layer, before the network can make Quality of service guarantees, it must know what traffic is being guaranteed. One of the main causes of congestion is that traffic is often bursty. To understand this concept first we have to know little about traffic shaping. Traffic Shaping is a mechanism to control the amount and the rate of traf
11 min read
Shortest Path Algorithm in Computer Network
In between sending and receiving data packets from the sender to the receiver, it will go through many routers and subnets. So as a part of increasing the efficiency in routing the data packets and decreasing the traffic, we must find the shortest path. In this article, we are discussing the shortest path algorithms. What is Shortest Path Routing?
6 min read
Difference between Storage Area Network (SAN) and Network Attached Storage (NAS)
Storage Area Network (SAN) is used for transferring the data between the servers and the storage devices' fiber channels and switches. In SAN (Storage Area Network), data is identified by disk block. Protocols that are used in SAN are SCSI (Small Computer System Interface), SATA (Serial Advanced Technology Attachment), etc. Components of Storage Ar
2 min read
Differences between Wireless Adhoc Network and Wireless Sensor Network
1. Wireless Adhoc Network: A wireless ad-hoc network is a wireless network deployed without any framework or infrastructure. This incorporates wireless mesh networks, mobile ad-hoc networks, and vehicular ad-hoc networks. Its history could be traced back to the Defense Advanced Research Project Agency (DARPA) and Packet Radio Networks (PRNET) which
3 min read
Difference between Next Generation Network and Traditional Network
1. Next Generation Network : In short Next Generation Network is termed as NGN which is packet based network used for both telephony and data. It uses multiple broadband and Quality of Services (QoS) enabled transport technologies to establish advance communication system. NGN can handle multiple type of services/traffic such as voice, audio, video
5 min read
Difference between Network Administrator and Network Engineer
1. Network Administrator :A network administrator is a someone in an organization whose job is to manage organization's computer network. They also do jobs like on-site server organization , software networking and also placing the network in there correct position which is also called as Network Integrity. Those are the main thing in their job to
3 min read
Difference Between Network Security and Network Administration
In the world of information technology, there are two important and distinct roles that are often confused: network security and network administration. While these two jobs may be closely related, they require different sets of skills and responsibilities. It’s significant to understand the differences between network security and network administ
5 min read
Difference Between Network Management and Network Monitoring
Pre-requisites: Areas of Network Management Network management and Network monitoring are two important functions in maintaining the performance and security of a network. While they are often used interchangeably, they are distinct concepts with different goals and methods. Network management refers to the process of controlling, configuring, and
3 min read
Difference Between Network Congestion and Network Latency
Network congestion refers to a situation in which a network experiences an excessive amount of traffic, resulting in a reduction of available bandwidth and increased delays for network users. This can occur in both wired and wireless networks and can have a significant impact on the performance and reliability of the network. Congestion can occur d
9 min read
How Does a Network Topology Affect Your Decision in Setting up a Network?
Answer: Different Network Topology offer different costs, security, reliability, etc. So we choose one of the network topology as a blueprint for setting up our network according to the features that we required.By Network Topology we get to know how different nodes are connected in the network. There are different types of network topology like Bu
2 min read
How does a Network Interface Card (NIC) Facilitate Connectivity in a Wired Network?
Answer: A network interface card (NIC) facilitates connectivity in a wired network by providing an interface between the physical layer which provides the physical connection with the cables and the data link layer which provides reliable communication channel. The NIC converts the digital data into electrical data so that it can be transferred usi
2 min read
Difference Between Network Topology and Network Protocols
Network Topology and Network Protocols are closely related but distinct concepts in the field of computer networking. Network Topology refers to the physical and logical arrangement of devices on a network, while Network Protocols refer to the rules and standards that govern the communication between devices on a network. Understanding the differen
5 min read
Difference between Software Defined Network and Traditional Network
Whenever it comes to networks, new trends keep on adding up and thus it becomes essential to know about the dissimilarities that SDN Networks and Traditional Networks possess. Given the ever-increasing need for the expansion, fault tolerance, and resource optimization of the networks that connect today’s business environments, organizations, and IT
7 min read
MAC Filtering in Computer Network
There are two kinds of network Adapters. A wired adapter allows us to set up a connection to a modem or router via Ethernet in a computer whereas a wireless adapter identifies and connects to remote hot spots. Each adapter has a distinct label known as a MAC address which recognizes and authenticates the computer. Mac address is shown in the format
10 min read
DHCP Relay Agent in Computer Network
Prerequisite - Dynamic Host Configuration Protocol (DHCP), How DHCP server dynamically assigns IP address to a host? To assign an IP address to the host dynamically, the DHCP client exchanges DHCP messages with the DHCP server in the DORA process. In the DORA process, the discover and request message is broadcast, the offer and the acknowledgement
6 min read
Redundant Link problems in Computer Network
Basically, redundant links are used to prevent nasty network failure. These are used to provide redundancy, i.e back up when a link fails, i.e a frame can be forwarded out through another path but it can cause problems also. Here are some of these problems: Broadcast Storm - A switch forwards out the broadcast frame, generated by another device, to
4 min read
Port Security in Computer Network
Attackers' task is comparatively very easy when they can enter the network they want to attack. Ethernet LANs are very much vulnerable to attack as the switch ports are open to use by default. Various attacks such as Dos attack at layer 2, address spoofing can take place. If the administrator has control over the network then obviously the network
3 min read
EtherChannel in Computer Network
EtherChannel is a port link aggregation technology in which multiple physical port links are grouped into one logical link. It is used to provide high-speed links and redundancy. A maximum of 8 links can be aggregated to form a single logical link. EtherChannel, also known as Link Aggregation Control Protocol (LACP), is a technique used in computer
5 min read
Bit Stuffing in Computer Network
The data link layer is responsible for something called Framing, which is the division of stream of bits from network layer into manageable units (called frames). Frames could be of fixed size or variable size. In variable-size framing, we need a way to define the end of the frame and the beginning of the next frame. Bit stuffing is the insertion o
2 min read
Computer Network | AAA (Authentication, Authorization and Accounting)
The administrator can take access to a router or a device through a console but it is very inconvenient if he is sitting far from the place of that device. So, eventually, he has to take remote access to that device. But as remote access will be available by using an IP address, therefore, it is possible that an unauthorized user can take access us
4 min read
Types of MANET in Computer Network
Prerequisite - MANET: Mobile Ad hoc Network MANET stands for Mobile ad hoc Network also called as wireless ad hoc network or ad hoc wireless network. They consist of a set of mobile nodes connected wirelessly in a self-configured, self-healing network without having a fixed infrastructure. MANET nodes are free to move randomly as the network topolo
12 min read
Redistribution in Computer Network
Often, using a single routing protocol in an organisation is preferred but there are some conditions in which we have to use multi protocol routing. These conditions include multiple administrator running multiple protocols, company mergers or usage of multi-vendors devices. Therefore, we have to advertise a route learned through a routing protocol
5 min read
Type-C Port in Computer Network
Type-C (or USB-C) is a 24-pin USB connector system. This is distinguished by its two-fold rotationally symmetrical connector. The USB Type-C Specification 1.0 was published by the USB Implementers Forum (USB-IF). It was finalized in August 2014. A device that implements USB-C does not necessarily implement USB Power Delivery, USB 3.1, or Alternate
4 min read
Asynchronous Transfer Mode (ATM) in Computer Network
Why ATM networks? Driven by the integration of services and performance requirements of both telephony and data networking: "broadband integrated service vision" (B-ISON). Telephone networks support a single quality of service and are expensive to boot. Internet supports no quality of service but is flexible and cheap. ATM networks were meant to su
5 min read
Puzzle | Eliminating Virus from a Computer Network
In a network of infinitely many computers, 650 computers got infected with certain virus. The IT support team has access to five different types of antivirus software packages (let us call them A, B, C, D and E) that can work on eliminating this virus. Each of the antivirus software packages 'X' can eliminate virus from Xr infected computers if the
3 min read
Elements of Computer Network
Computer Network is a system in which multiple nodes are connected to each other to share information and resources. A computer network allows sharing of resources between different nodes connected within it. Computer Network Elements: The objects basically used in a computer network are known as Computer Network Elements (CNEs). There are basicall
3 min read
Article Tags :