6 ms·
Encrypt-then-MAC
- cperciva 17y agoFor reference, the discussion about my earlier post is here: http://news.ycombinator.com/item?id=652768 http://news.ycombinator.com/item?id=652768
- ambition 17y agoIt'd be awesome if someone with great visual communication skills (Amy Hoy-/Dustin Curtis-/Bret Victor-style) teamed up with cperciva's intense summaries of encryption knowledge. That would be a helluva one-two punch.
- cperciva 17y agoThat's an interesting idea, but I'm not sure how well it would work in practice. Maybe I'm weird, but I find that making things look nice (whether via improved formatting or the addition of pictures) helps to draw readers' attention, it doesn't actually help get any more information across.
- aaronblohowiak 17y agoIt isn't about more information, but a different presentation of the same to help those with different learning styles.
- tdavis 17y agoI read all your articles that make it to HN, despite never understanding a damn word. I doubt some pictures would fix that ;)
- kragen 17y agoMerely making things look nice won't help, but sometimes things like dataflow diagrams can convey information more quickly and clearly than just words — maybe especially to people who are particularly visually oriented.
- cperciva 17y agoFair enough -- if someone wants to start drawing diagrams, I'd be happy to talk cryptography / security to them. :-)
- tptacek 17y agoThe reason you want to use EAX or CCM instead of CTR+HMAC is that EAX and CCM are standard constructions. CTR+HMAC isn't. Let's be clear about this, Colin. You're saying that EAX and CCM implementations are so untrustworthy that lay developers should implement their moral equivalents (substituting CBC-MAC and OMAC for HMAC) by hand. In order to use CTR+HMAC, you have to design your own construction to do so. You likely have to implement HMAC yourself. You have to determine when to apply it, and where to put it in your messages. CCM and EAX remove those degrees of freedom, which is exactly what you want: the fewer decisions a developer/designer needs to make, the fewer opportunities for things to blow up. It's the places where primitives join together --- encryption with MAC, for instance --- where crypto protocols are broken. The person who uses OpenSSL is far more likely to make a fatal error than the OpenSSL developers themselves. With all due respect to Colin, I think this take on how to minimize attack surface is, well, asinine. I think it's based on a bias against crypto library developers, based on the fact that Colin probably knows more about crypto than they do. Stipulated. But the point isn't that OpenSSL developers are better, or even comparable to Colin. It's that their code is 1000x more likely to be reviewed than anything anybody else writes. Your hand-hacked CTR + HMAC protocol isn't going to be reviewed by anyone who doesn't have a direct financial interest in your code.
- cperciva 17y agoThe reason you want to use EAX or CCM instead of CTR+HMAC is that EAX and CCM are standard constructions. CTR+HMAC isn't. I don't know from where you get the idea that Encrypt-then-MAC is not a standard construction. Encrypt-then-MAC was a standard construction long before EAX and CCM were invented -- in fact, in the paper where EAX is introduced, it is actually defined as an Encrypt-then-MAC composition! It's the places where primitives join together --- encryption with MAC, for instance --- where crypto protocols are broken. If you look carefully at recent breaks, they have been in Encrypt-and-MAC and MAC-then-Encrypt -- both of which I specifically mention as inferior to Encrypt-then-MAC. With all due respect to Colin, I think this take on how to minimize attack surface is, well, asinine. I think it's based on a bias against crypto library developers, based on the fact that Colin probably knows more about crypto than they do. I apply the same approach of minimizing attack surface even when it's only my own code which is being attacked. The question isn't how prone some code is to vulnerabilities (although in the examples I gave, there certainly is a poor track record) -- the issue is engineering code to eliminate potential risks.
- huhtenberg 17y agoA well known paper comparing encrypt-authenticate to authenticate-encrypt approaches (in the context of SSL) is http://www.iacr.org/archive/crypto2001/21390309.pdf http://www.iacr.org/archive/crypto2001/21390309.pdf
- kragen 17y ago"It doesn't pass untrusted data to AES" had never occurred to me as an advantage of CTR over CBC. The XORability of CTR always gives me the willies.
- tptacek 17y agoECB, CBC, CTR, CFB, and OFB are all "XORable", although if you're pointing out that CTR ciphertexts that share a keystream can be XOR'd to decrypt streams, that's a valid point, and one that a MAC (of any type) doesn't solve. You're so far better off not trying to implement any of this stuff that it's almost not worth studying. PGP at rest, TLS in motion. Spend your time and heartache on something that will make you money, not something that will get you laughed at by asshole pentesters.
- kragen 17y agoThere's the problem with keystream reuse, yes, and also the problem shared to some degree by CBC and OFB (but not ECB) that's at its worst in CTR — that you can flip single bits in the plaintext by flipping arbitrary bits in the ciphertext. (But of course that's why you use a correctly-implemented MAC, right?) I concur with you that new cryptographic protocols are likely to be flawed, and your recent blog post on that subject was excellent reading.
- brl 17y agoIt's probably as superstitious as your XORophobia but the counting part of CTR has always made be a bit uncomfortable.
- lisper 17y agoI think I'm missing something really basic here. If you encrypt-then-mac, what is to prevent an attacker from appending a valid MAC to a forged ciphertext (in order to mount a DOS attack for example)?
- chmike 17y agoI fully agree on the cypher then MAC policy. Deciphering is time consuming and by feeding bogus data could be used in a DOS attack. Without prior checking it may be possible to indirectly probe the deciphering process. What I am not so sure is the choice of CTR. I currently prefer CFB.
- tptacek 17y ago... because?
- chmike 17y agoCTR cyphers a value that changes with only a few bits, while CFB uses previous output which is much more random, though exposed, since it is the ciphered text. PS: http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation makes it clear.
- tptacek 17y agoSecurity under those circumstances is a design requirement for AES. CTR is secure if AES is secure. If known plaintext pairs differing in only a few bits break AES, we have bigger problems than CTR mode.
- weavejester 17y agoIs there a possibility of timing information being leaked if you verify a HMAC manually instead of using, say, CCM?