This post is from my series of short essays on cybersecurity.
In my last post Cryptography – The game of confusion and diffusion , I started the conversation on confidentiality that was first component of CIA – Confidentiality, Integrity, and Availability. Now the next question is when you receive a message, how can you confirm that the message content is not tampered in the middle and the message is authentic. By definition Integrity is the assurance that the information is protected from any unauthorized alterations. Message Authentication Code (MAC) is an elegant cryptography application in the security toolbox that guarantees message authenticity and integrity. It is based on the symmetric key cryptography. Sender and receiver have a shared secret key. Idea is simple: the sender computes the checksum of the message and appends it in the message. The receiver on the other end performs the same operation on the received message and validates that the calculated checksum is matching with what is appended in the received message. Since the key is only shared between the communicating parties, the receiver can be confident that the message is not tampered in the middle assuming that the secrecy of the key is maintained. Few interesting things to note here about MAC: 1) MAC is not about secrecy of the message, we are not encrypting the message content, instead only adding the checksum as a stamp to ensure the message’s integrity. 2) MAC is based on a shared key, that means no protection against repudiation, the receiving party can alter the message, nothing can be done to verify. 3) Receiver should be aware of the message source and secret key before the message exchange.
Message Authentication Code (MAC) is based on a shared key, it provide assurance against message tampering, but no protection against repudiation. Receiver should know the message source and secret key before the message exchange.
So how MAC code is computed, one commonly used method is to compute the cryptographic hash of the message, known as HMAC (message hashing) . A cryptographic hash function H takes an arbitrary length input and produces a fixed-length output that is called message digest or hashcode. Security strength of the cryptographic hash function is in its collision resistance – different input messages x and x’ resulting in the same hashcode is hash collision. Second property of cryptographic hash algorithm is that it should be a one way function, calculating hash(x)=hash_value should be easy, but for a given hash_value it should be infeasible to generate a message x or find another input x’ to represent the same hash_value.
Early implementations of Hashing algorithms are known as the widely used MD-4 family of functions (MD-4, MD-5, SHA-1). But vulnerabilities were detected in almost all early MD-4 family versions. The current recommendation is to migrate all applications to SHA-2 and SHA-3. Here SHA-3 is the latest, that was the outcome of a NIST 2007 competition similar to AES competition that is fully described in the 2015 publication, SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions. Another interesting reference is NIST SP 800-1 Recommendation for Applications Using Approved Hash Algorithms that discusses the recommendation and security guidelines for the desired security strengths of several cryptographic applications. HMAC is one of the widely used algorithms used for message integrity within several security protocols like IPsec, SSH and TLS protocols and for JSON Web Tokens.
Pingback: Digital signature – you can’t deny you authorized it | Adarsh Khare's Blog
Pingback: Authentication – How do I know you are the one who you claim? | Adarsh Khare's Blog