Let 2
Let 2
Secret Key
Keystream
Key generator
...10100101
… 01101011 ...11001110
Requirements for a good keystream
• Good randomness distribution
• Long period
• High complexity
Linear Feedback Shift Registers
Feedback shift registers are small circuits
containing a number of memory cells, each of
which holds one bit of information. The
working is explained as follows
Feedback function
Example 1 - LFSR
st+3 = st+1+ st
S0 S1 S2
S0 S1 S2
0 0 1
0 1 0
1 0 1
states 1 1 1
1 1 0
Generates a periodic sequence 1 0 0
…0010111... -----------------
0 0 1
Maximal period 2 -1=7
3
RC4 Basics
RC4
Keystream
Encrypted
Plain Text + Text
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
ii == jj == 0;0;
While
While (more_byte_to_encrypt)
(more_byte_to_encrypt)
ii == (i(i ++ 1)
1) (mod
(mod 256);
256);
jj == (j(j ++ S[i])
S[i]) (mod
(mod 256);
256);
swap(S[i],
swap(S[i], S[j]);
S[j]);
kk == (S[i]
(S[i] ++ S[j])
S[j]) (mod
(mod 256);
256);
CCii == MMii XOR
XOR S[k];
S[k];
ii == jj == 0;0;
While (more_byte_to_encrypt)
While (more_byte_to_encrypt)
ii == (i(i ++ 1)
1) (mod
(mod 256);
256);
jj == (j(j ++ S[i])
S[i]) (mod
(mod 256);
256);
swap(S[i], S[j]);
swap(S[i], S[j]);
kk == (S[i]
(S[i] ++ S[j])
S[j]) (mod
(mod 256);
256);
CCii == MMii XOR
XOR S[k];
S[k];
Detailed Diagram
Overall Operation of RC4