-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
Both OFB and CFB are unauthenticated encryption modes, which should be used only in very particular circumstances. They are also way less popular than the most used unauthenticated encryption mode, CTR, and our implementations are less optimized and not covered by the Go+BoringCrypto mode.
OFB mode is essentially unused (four real Debian CodeSearch hits). CFB mode is almost unused (five real Debian CodeSearch hits, a few more using other code search tools)
The CFB implementation in crypto/cipher arguably misuses the Stream interface, too. Unlike CTR or OFB that turn a block cipher into a true stream cipher by producing a keystream that is then XOR'd with the plaintext or ciphertext, CFB operates on the actual plaintext or ciphertext input. This is visible in the Encrypter / Decrypter asymmetry, and makes it impossible to XOR some zeroes to then XOR the result with the plaintext/ciphertext, which would be a reasonable expectation to have of a Stream.
We'd not be adding these if we were deciding today, we are not going to take optimizations for them, and we want to generally steer users away from them and towards authenticated modes like GCM or at least towards the more popular, more optimized, and Go+BoringCrypto covered CTR.
/cc @golang/security @golang/proposal-review