OFB Mode Encryption-Decryption Symmetry
- •
What it is
- •
OFB (like CTR/CFB) generates a keystream from the key and IV alone, independent of the plaintext, and XORs it in — making encryption and decryption literally the same operation. If an attacker can get arbitrary data encrypted under the exact IV a secret was originally encrypted with, feeding that secret's ciphertext back through "encrypt" reproduces the original plaintext.
- •
- •
When to apply
- •
An oracle exposes an "encrypt with chosen plaintext and IV" endpoint, plus a separately generated OFB/CTR-encrypted secret whose IV is revealed (often prepended to its ciphertext) — reusing that IV cancels the keystream.
- •
- •
Math
- •
.
- •
- •
Python
- •
recovered_plaintext = encrypt_oracle(secret_ciphertext, secret_iv)
- •
- •
- •
Cards
- •
Why are OFB encryption and decryption the same operation?
- •
Both just XOR the data with a keystream derived from the key and IV alone; XOR is self-inverse.
- •
- •
What do you need control over to exploit OFB's symmetry via an encrypt oracle?
- •
The ability to encrypt chosen data under the exact same IV the secret was encrypted with.
- •
- •
- •
Worked example
- •
With one-byte plaintext and keystream , OFB encryption gives . Applying the same keystream again gives . The property requires the same key, IV, and starting position.
- •