Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The MAC algortihm which is used along with a secret key to generate a MAC tag on the sender end ,is it same at the receiver end also who again uses a MAC algorithm to generate a tag?

If yes, then how is the MAC algorithm generated. Is it just a function(a mathematical function to compute)??

If no, then how does the tag get matched to preserve the data integrity??

Is the MAC algorithm, is present as a layer inside of SSL????

share|improve this question
Cursory research should answer your questions – hunter Sep 2 '14 at 16:48
up vote 2 down vote accepted

Yes, the MAC algorithm works the same way on both sides. It is a mathematical function that computes the tag from the key and the message. On the sender side, the message is processed as follows:

  1. Calculate T = MAC(key, raw_message).
  2. Send the raw_message and the tag value T. Many communication protocols append them in this order but anything will do as long as the receiver agrees on the format.

On the receiver side, the processing goes as follows:

  1. Parse the received data is parsed as a raw message and a tag value.
  2. Calculate T' = MAC(key, received_raw_message).
  3. Compare T' with received_T. If the values are equal then the message is authentic, otherwise it is not.

SSL does use a MAC to verify data integrity. Strictly speaking, the MAC itself only ensures authenticity, not integrity: a MAC alone does not protect against replay attacks, whereby an adversary repeats a legitimate message. To protect against replay attacks, protocols such as SSL include a nonce in the authenticated message: if the message is genuine and contains the expected nonce, then it hasn't been modified or switched in transit.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.