So what is exactly a Mac? What is the message of authentication code? Well, it seems that Mac's are very similar to symmetric encryption in the sense that both take a message and encrypted using a key. So, what are the differences? Well, what do you take a message in a Mac function, the output is smaller at the end is in fixed size than the original message and and this is a big end it cannot be decrypted. In Mac function, the function itself is irreversible.
We use it fortification purposes in symmetric encryption as well. learned, it can be decrypted using the reverse function of the algorithm. And the key. And the cipher text is exactly the same size as the plain text. So when do we use Mac's when we want to be sure that the message came from the right source and haven't been changed? We don't care if the text will be sent in plain text.
Just no one has touched it. Why don't we use a hash as we saw in the earlier video, because the attacker can also take the text modified and hash it. So how do we use the Mac function? We take our message, we apply the Mac function which is a mathematic function. And we add up a key, a key that is known both to user a and to user B. And we get the message a checksum of the message, which is encrypted.
We concatenate it into the original message and send it to user B. B receives the message and the Mac. He calculates the Mac of the received message and compares it to the one he received. User B must have the same key and how to they deliver the keys is not really relevant. It could be using diffie Hellman or any other method of generated a shared secret key