Stream Cipher: July 2011
Stream Cipher: July 2011
July 2011
Topics
One-Time-Pad
Random Number Generator
Stream Cipher
RC4
RC4 and WEP
One-Time Pad
Developed by Gilbert Vernam in 1918, another name: Vernam Cipher
The key
a truly random sequence of 0s and 1s
the same length as the message
use one time only
The encryption
adding the key to the message modulo 2, bit by bit.
Encryption ci mi ki i 1,2,3,...
Decryption mi ci ki i 1,2,3,...
mi : plain-text bits.
ki : key (key-stream ) bits
ci : cipher-text bits.
Example
Encryption:
1001001 1000110 plaintext
1010110 0110001 key
0011111 1110110 ciphertext
Decryption:
0011111 1110110 ciphertext
1010110 0110001 key
1001001 1000110 plaintext
One-Time pad practical Problem
Key-stream should be as long as plain-text
Difficult in Key distribution & Management
Solution :
Stream Ciphers
Key-stream is generated in pseudo-random fashion form
Relatively short secret key
Stream Cipher Model
Output function appears random
CTR
Xi = EK[Vi]
OFB
Xi = EK[Xi-1]
Stream Ciphers
Secret Key
RC4
Keystream
Encrypted
Plain Text + Text
KSA
Generate State array KSA
PRGA on the KSA PRGA
Generate keystream
XOR keystream with the data
to generated encrypted
stream
The KSA
Use the secret key to initialize and permutation of state vector
S, done in two steps
1 2
j = 0;
for i = 0 to 255 do for i = 0 to 255 do
S[i] = i; j = (j+S[i]+T[i])(mod 256)
T[i] = K[i mod(|K|)]); swap (S[i], S[j])
After KSA, the input key and the temporary vector T will be no longer used
The PRGA
Generate key stream k , one by one
XOR S[k] with next byte of message to encrypt/decrypt
i = j = 0;
While (more_byte_to_encrypt)
i = (i + 1) (mod 256);
j = (j + S[i]) (mod 256);
swap(S[i], S[j]);
k = (S[i] + S[j]) (mod 256);
Ci = Mi XOR S[k];
i = j = 0;
While (more_byte_to_encrypt)
i = (i + 1) (mod 256);
j = (j + S[i]) (mod 256);
swap(S[i], S[j]);
k = (S[i] + S[j]) (mod 256);
http://en.wikipedia.org/wiki/File:RC4.svg Ci = Mi XOR S[k];
Detailed Diagram
Overall Operation of RC4
Decryption using RC4
Use the same secret key as during the encryption phase.
Generate keystream by running the KSA and PRGA.
XOR keystream with the encrypted text to generate the plain
text.
Logic is simple :
(A xor B) xor B = A
encrypted
30
WEP Vulnerability
WEP protocol has several flaws but not the RC4 itself
Short IV length
24 bits IV not sufficient
Clear text IV as part of the key
24 bits of every key in cleartext
Collect and analyze IVs to extract the WEP key
Weak IVs
Some generated IVs do not provide enough randomness
Can be used to extract the key
Q&A