What is a MAC?
A MAC is a short array of bits, for example, 256 bits, that authenticates a message. Message authentication means that the receiver of the message can verify that the message is coming from the stated sender and has not been changed during the transfer. In order to generate a MAC, the sender needs a message and a secret key. In order to verify the MAC, the receiver requires the message and the same secret key. A MAC is produced by a MAC function.
The difference between a MAC and a message digest is that a message digest is not protected against forgery; however, a MAC does have such protection. If both the message and its digest are transmitted over an unprotected network, an attacker can change the message and recalculate its digest so that the changed digest will match the changed message. On the other hand, if a message is transmitted with its MAC, an attacker cannot recalculate the MAC for the changed message in the same way. This is because they do not possess...