4 ms·
You're gradually deriving MAC-then-Encrypt. Switch the two around: encrypt, and then MAC (use HMAC, not simply a keyed hash). Authenticate the ciphertext, which
by tptacek 3y ago
You're gradually deriving MAC-then-Encrypt. Switch the two around: encrypt, and then MAC (use HMAC, not simply a keyed hash). Authenticate the ciphertext, which denies attackers any opportunity to alter the ciphertext bits. Now you have a construction that has a reasonably strong chance of being solid, assuming you manage the CTR nonce and counter safely. Because CTR nonces are such a reliable source of vulnerabilities in real software, go a step further and just use CBC mode, where a repeated/predictable IV is less devastating. Now you have a construction that might credibly even prefer to GCM.