

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: What Is a Message Integrity?
incomplete
2: Message Authentication Code (MAC)
incomplete
3: Message Authentication Code (MAC)
incomplete
4: Hash-Based Message Authentication Code
incomplete
5: Toy HMAC
incomplete
6: MACs and JWTs
incomplete
7: Asymmetric JWTs
incomplete
8: Asymmetric JWT Review
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
A MAC takes advantage of the irreversibility property of hash functions. A MAC is the hash of a message concatenated with a key.
mac = hash(message + key)
As with a checksum, a mac can be sent along with the message in a communication. A man in the middle won't be able to alter the message secretly, because they can't produce a new valid mac without access to the secret key.
hash(message + key)mac == hash(message + key) then the message is validThe disadvantage of a MAC is that the receiver will also need a copy of the secret key. This is why MACs are generally only used when the sender and the receiver are the same entity.
Fix the macMatches function. It currently uses a plain checksum. Concatenate the key to the end of the message before hashing it.