It seems that even in MAC-then-encrypt systems like SSL, something like HMAC is
ID: 648389 • Letter: I
Question
It seems that even in MAC-then-encrypt systems like SSL, something like HMAC is used rather than a plain hash. Why?
Suppose we use some stream cipher; then why can't we use Encrypt(m|H(m)) as the MAC-then-encrypted version of the message? Assuming no bad relations between Encrypt and H, what are the possible weaknesses? It seems that in this case we are encrypting the hash with part of a secretly keyed stream cipher keystream, and the hash is secure; does this not fulfil an approximation of the ideal MAC?
This must be somehow bad, since no secure protocol seems to use it. Why?
Explanation / Answer
Two things going on that together may make plain-hash-then-encrypt insecure.
First, the distinction between secure MACs and hashes, which is that a hash function may allow you to derive H(m?) from H(m) even if you only know how m? and m differ. Length extension attacks on SHA-1 and SHA-2 are a practical way that can happen, but there could be others if the hash function doesn't specifically guarantee that there isn't.
Second, stream ciphers allow you to make deterministic changes to the plaintext. Specifically, you can flip any bits you like in the ciphertext and they'll be flipped in the decrypted plaintext as well (assuming the cipher uses XOR as most do).
Put those together and it could be possible to e.g. flip the last message bit, determine which bits that would flip in the hash, then flip those.
Additionally, even if you chose a secure MAC as H, having the hash inside encryption means you need to decrypt and hash before deciding whether the ciphertext has been corrupted, increasing retransmission latency on a noisy channel compared to encrypt-then-hash.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.