Initialization vector
|
In cryptography, an initialization vector (IV) is a block of bits that is combined with the first block of data in any of several modes of a block cipher. In some cryptosystems it is random and is sent with the ciphertext; in others, such as a disk encryption subsystem, it is based on some info, such as the file's inode, that does not have to be put in the ciphertext.
Initialization vectors are very important when different files are encrypted using the same key. In general, XORing two ciphertexts created using a stream cipher initialized with the same key will yield the same result as XORing the two different plaintext. Recovering both is then simple. Thus, if the same key needs to be reused, a few random bytes, which can be written into the start of the encrypted file, are prepended to the key, assuring a different initialization of the cipherstream for every encryption process.
The situation is different for block ciphers. In ECB (electronic code book) mode same plain text will encrypt to same ciphertext (for the same key). This reveals patterns in the code. In CBC (cipher block chaining) mode, each block is XORed with the result of the encryption of the previous block. This hides patterns. However, two similar plain text will have (for the same encryption key) the same ciphertext up to the block containing the first difference. This problem can be circumnavigated by prepending a random IV block to the plain text. This will make each ciphertext unique, even when similar plain text is encrypted with the same key in CBC mode.
References
- B. Schneier, 'Applied Cryptography', Wiley 1996
External links
- Ciphersaber (RC4 with IV) (http://ciphersaber.gurus.com/)