Modes of Operation
Knowing which encryption algorithm was used is one thing, but knowing how they used it is another.
Here are 5 of the 9 NIST approved block cipher modes of operation:
Electronic Codebook (ECB)
Simplest of encryption modes.
Encrypts each block Bi independently.
Encryption: **Ci = Ek(Bi)** Ci: ciphertext block i Ek: block encryption algorithm Bi: plaintext block i Decryption: **Bi = Dk(Ci)** Dk: decryption algorithm
Cipher-Block Chaining Mode (CBC)
Avoids patterns.
First plaintext block is xor’d with an initialization vector.
Each block thereafter is xor’d with the previous ciphertext block before being encrypted.
Encryption: **Ci = Ek(Bi xor Ci-1)** C0: initialization vector Decryption: **Bi = Dk(Ci) xor Ci-1** C0: must be the _same_ initialization vector
Cipher Feedback Mode (CFB)
Similiar to CBC, Bi involves Ci-1.
May be faster than CBC depending on block cipher.
Encryption: **Ci = Ek(Ci-1) xor Bi** Decryption: **Bi = Ek(Ci - 1) xor Ci**
Output Feedback Mode (OFB)
Generates sequence of vectors V, where V0 is the initialization vector.
Block operations can be performed in parallel after vectors are are computed.
Vectors: **Vi: Ek(Vi-1)** Encryption: **Ci = Vi xor Bi** Decryption: **Bi = Vi xor Ci**
Counter Mode (CTR)
Vector generation and encryption or decryption can all be done in parallel.
Start with a random seed, s, and compute offset vectors independently.
Vectors: **Vi: Ek(s + i - 1)** s: random seed Encryption: **Ci = Vi xor Bi** Decryption: **Bi = Vi xor Ci**
http://csrc.nist.gov/groups/ST/toolkit/BCM/index.html http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation