Crypto 0 to hero - Episode 06 - Integrity with MAC In previous...

@mattpiz
Matthieu Pizenberg@mattpiz
21 views Jun 26, 2024 ~3 min read
Advertisement
1
Crypto 0 to hero - Episode 06 - Integrity with MAC

In previous episodes, we explained how stream and block ciphers can provide message confidentiality. Today, let’s talk about message integrity, with MAC (Message Authentication Codes). 1/n
Media image
2
Ciphers are not sufficient to ensure that a message has not been tampered with. Indeed if an attacker intercepts an encrypted message and modify it, you have no way to know it. The decrypted message will be different, but it could as well be the original message. 2/n
3
The idea with MAC, is to add a code at the end of a message that can be used to verify the message was not modified. It is a very common technique to protect publicly shared data such as software packages, or to protect files on disk. 3/n
4
A MAC scheme is divided in two, a signing algorithm S and a verifier algorithm V. The signing takes a key and a message and outputs a tag = S(k,m). The verifier takes the same key, the message, the tag and outputs True or False. V(k, m, tag) = True | False. 4/n
5
Of course, a MAC has to be secure! Otherwise it cannot be trusted. In the context of integrity, we noted that an attack could be a "ciphertext-only attack" (COA) for single usage keys or a "chosen plaintext attack" (CPA) for reusable keys. 5/n
6
For MAC, we describe security related to "chosen message attack" (CMA). The attacker can request tags of some messages, and will try to forge a tag for an unknown new message. Tag length should be long enough to mitigate random attempts. TLS uses 96 bits tags for example. 6/n
7
It is easy to show that we could use a cipher for a MAC by appending it to the message itself. It isn’t efficient since it doubles the message size. But we could truncate the cipher to a smaller size since that’s still random. In practice it’s not often the chosen approach. 7/n
8
Another idea consists in using a small size cipher, and to expand it to big messages in a smart way. For example, we can chain AES calls with block outputs as the new key. This is called CBC-MAC. 8/n
Media image
9
A parallel approach also exists, called PMAC where all cipher blocks are computed in parallel, XOR aggregated and encrypted again to produce the tag. Some care must be given to make sure blocks cannot be reordered by for example adding the block index somehow in the mix. 9/n
10
PMAC is also very interesting for incremental changes. Since all encrypted block are XORed before the final step, we could just recompute the parts of the message that changed and update the final tag very efficiently. 10/n
11
Finally, I wanted to mention another construct, called a Carter-Wegman MAC. We can apply a very fast MAC which is only secure for one-time usage, and combine it by XORing with a secure slow MAC only applied to nonce, which is publicly distributed at the start of the message. 11/n
12
Of course there are other MAC approaches, even more used based on collision-resistant functions (SHA, etc.) but that will be the subject of another thread! That’s all for today! I hope you liked it. See you in the next episode!
Actions
What You Can Do
  • Export as PDF or Markdown
  • Batch Export to Notion
  • Bookmark & Highlight
  • Screenshot Tweet
Create Free Account

Includes 7-day Premium trial

Advertisement