4 ms·
> If the attacker doesn't actually know the encryption key then the data will be garbled That depends on exactly what sort of cipher scheme is used. I don't kn
by Nursie 6y ago
> If the attacker doesn't actually know the encryption key then the data will be garbled
That depends on exactly what sort of cipher scheme is used. I don't know what exact scheme we're talking about here (it wasn't described in the post and I didn't go hunting any further) but there are stream constructions where if you change a bit in the ciphertext, it changes a corresponding bit in the plaintext that comes out. This is because in these modes the keystream is independent of the data and the ciphertext is the result of XORing the keystream with the plaintext. The plaintext is unrecoverable without the key, but what's decoded can be manipulated, even without knowing what it is. Mac-then-encrypt is definitely a problem in that circumstance.
Encrypt-then-Mac is better in that it protects you from even decrypting anything before you've authenticated the source.
> it can leak out into everything, ... MAC, timing...
A good MAC algorithm doesn't leak anything about the plaintext. A good mac-checking algorithm doesn't give anything away with timing either.
(edited to remove references to CFB, my memory of that stream construction was inaccurate, but the point in general stands, if I can manipulate some of the ciphertext that make known-changes to the plaintext decryption, I'm back to being able to make a timing analysis on MAC checking. It's better to check the MAC first, and in constant time.)
- just-ok 6y ago> A good MAC algorithm doesn't leak anything about the plaintext. Though this may be true for specific MAC algorithms, it's a very dangerous and incorrect assumption to hold in general. MACs are designed for integrity and nothing more.
- Nursie 6y agoFair enough, also not really at issue when we're talking about encrypt-then-mac I guess.
- just-ok 6y agoYep! Absolutely true, and one of the reasons why Encrypt-then-MAC is the only generic composition method scheme that always provides certain security properties (specifically, security against chosen-ciphertext attacks given that the "encrypt" part is secure against chosen-plaintext attacks and the "MAC" part is secure against forgeries).