Message Authentication Code (MAC)

MAC is a technique generates a small fixed-size block of data, using a secret key shared between sender and receiver(Symmetric Cryptography#), that will append to the message. It provides Security Services# such as Data Integrity# and data origin authentication# (whether the message is sent by the claimed sender).

The MAC, sometimes called cryptographic checksum, is computed based on the message itself using many-to-one function (many messages related to the same MAC), and it is not necessarily possible to revert to the original message by only using MAC. To verify MAC, the receiver performs the same computation as the sender did and compare the result with the received MAC to see if they are the same. The following #math notation shows the basic concept of MAC:

$$ \text{MAC} = C_K(M) $$

Where:

  • \(M\) is a variable-length message
  • \(K\) is a shared secret key
  • \(C\) is a cryptographic algorithm used to encrypt \(M\)

Note: The key size and the MAC size determine how secure is the MAC is.

For MAC to be secure, there are several requirements for it:

  • It should be computationally infeasible# to find another message with same MAC knowing a message and MAC
  • MACs should be uniformly distributed so randomly chosen messages having less chance of having the same MAC
  • MAC should depend equally on all bits of the message (Avalanche Effect)

Note: To crack the key, see Brute Force Attack.

The following shows several implementations of MAC:

Links to this page
  • Transport Layer Security (TLS)

    TLS is an upgrade over #Secure Socket Layer (SSL) version 3 (SSLv3) defined in RFC 5246. It has now been widely adopted as it is more secure and efficient than its predecessor in message authentication, key material generation and supported cipher suites. It uses the same record format and MAC# generation algorithm, HMAC, as SSLv3. That being said, the algorithm XORs the padding bytes with the secret key padded to the block length instead of concatenated with the secret key as in SSLv3. Furthermore, the MAC calculation also including the field TLSCompressed.version which defined the protocol version being used.

  • TAC3121 Chapter 6: Message Authentication and Hash Functions
  • Secure Socket Layer (SSL)

    An association between client and server called SSL session will be established by SSL Handshake Protocol, which could be shared among multiple SSL connection that are transient, #p2p, communications links. Each SSL connection is private (encrypted with Symmetric Cryptographic algorithms#) and reliable (message integrity check by Message Authentication Code (MAC)# using SHA, MD5 etc. hash functions on compressed SSL data), and for each web component (provide suitable services). The session could define a set of Cryptographic parameters such as keys and algorithms used which could be shared by multiple connections. The session is kept alive by SSL Alert Protocol, where the peer’s identity can be authenticated with Asymmetric Cryptographic Scheme#. SSL Change Cipher Spec Protocol would be used if the peer wants the consequent messages to be encrypted for transmission. With SSL session, there is no need to exchange security parameters for each SSL connection which could be expensive.

  • IP Security (IPsec)

    The data encapsulation is done by two extension headers (append to the IP header): Authentication Header (AH) and Encapsulating Security Payload (ESP), defined by RFC 4303 and RFC 4302 respectively. AH provides Access Control#, Authentication# (including the IP Address#) and Connectionless Data Integrity# services using Message Authentication Code (MAC# /HMAC) where both parties must share secret key. It guards against address spoofing attacks and Replay Attack. ESP provides Confidentiality# services over message contents and traffic flow (but limited) and optionally support Access Control# services like in AH using MAC. It can also guard against Replay Attack#. The users can design which kind of ciphers, modes, and padding to be used in ESP. The IPsec could be set up to have AH only or ESP only or both.

  • Data Authentication Algorithm (DAA)

    DAA is one of the implementations of #Message Authentication Code (MAC) defined by FIPS PUB 113 and ANSI X9.17 which is based on Cipher Block Chaining (CBC)#. The initialisation value (IV) used is 0 and the final block is padded by 0s, which is where the MAC derived from. If the final block is too big, it will use the left most \(M\) (\(16 \le M \le 64\)) bits of the final block as the MAC.

  • Cryptographic Primitives
#authentication #) #math