|
 
 
     
A stream cipher is an algorithm that encrypts data one bit at a time. Since stream cipher encrypt data bit by bit, they require that the data be in binary form. Stream ciphers are best explained using examples. Here is our plaintext that we would like to encrypt. We have already converted our plaintext string to binary:
Plaintext: 100110111101000011100101000110111101
Now, let's look at a simple stream cipher. All stream ciphers have something called a keystream generator. A keystream generator simply spits out a stream of 1s and 0s. If we use an exclusive or (XOR) with the keystream and plaintext, we get ciphertext. An exclusive or compares two bits. If exactly one of the bits is a 1, then the exclusive or returns a 1. If both bits are 1s or both bits are 0s, then the exclusive or returns a 0. The exclusive or can be used with corresponding bits of the plaintext and the keystream. We will use a simple and insecure keystream that alternates 0s and 1s in the example below. This keystream is called periodic, since the sequence '10' repeats over and over.
Plaintext: 100110111101000011100101000110111101
Keystream: 101010101010101010101010101010101010
Ciphertext (XOR): 001100010111101001001111101100010111
To decrypt this ciphertext, all we need to do is again XOR the ciphertext with the keystream:
Ciphertext: 001100010111101001001111101100010111
Keystream: 101010101010101010101010101010101010
Plaintext (XOR): 100110111101000011100101000110111101
So why is this stream cipher insecure? First, the keystream is extremely weak. All a cryptanalysist has to do is switch every other bit (change a 0 to 1, or 1 to 0) of the ciphertext to get the plaintext. Additionally, if a cryptanalysist gets a copy of the plaintext and ciphertext, he can simply XOR them together to get the keystream. This would enable the cryptanalysist to decipher any piece of ciphertext encrypted with this method. Here is how simple it is to get the keystream:
Plaintext: 100110111101000011100101000110111101
Ciphertext: 001100010111101001001111101100010111
Keystream (XOR): 101010101010101010101010101010101010
For this reason, virtually all stream ciphers make use of a key. In general, the key is used to modify what comes out of the keystream generator. Therefore, each key will cause the keystream generator to output a different stream of bits. The next section, the keystream generator, will cover creating keystream generators and using keys in more detail.
 
|