Chapter 3 Cryptography 45
Cryptography Overview
Output Feedback (OFB) Mode
Output feedback mode is similar to CFB mode, except that the quantity XORed with
each plaintext block is generated independently of both the plaintext and the
ciphertext.
To encrypt a plaintext using OFB, first generate the output used for encryption.
This is intermediate data that is used in the encryption process. In OFB, the output
depends only on the key and the initialization vector.
1. Generate your key and your IV.
2. Encrypt the IV with the key to get a block of output, B1.
3. Encrypt B1 with the key to get the second block of output, B2.
4. Continue encrypting recursively: encrypt Bi to get Bi+1.
This process gives you an arbitrarily long sequence of pseudo-random blocks that you
can use to encrypt the data. To use the output to encrypt:
5. XOR your plaintext with the output, block by block. The result of the XOR is the
ciphertext.
OFB does not require padding. If your data length is not a multiple of the block size,
simply truncate the final block of the output to be the same size as the final segment of
the data, and then XOR it.
The decryptor can use the same (secret) key and IV to generate the same sequence of
output blocks and XOR the sequence with the ciphertext to recover the plaintext.