Cryptography Reference
In-Depth Information
Description of RC4
RC4 is a stream cipher, i.e., a secret key is used to create a secret byte sequence
( K i ) , and simple XOR is used for encryption and decryption:
Ciphertext byte i
=
plaintext byte i
K i
Plaintext byte i
=
ciphertext byte i
K i
Internal Key
Two bytes, i and j , and a permutation, (P i ) i = 0 ,..., 255 , of the numbers 0 ,..., 255 are
used as internal key, i.e., each of these numbers occurs exactly once in sequence
( P i ) . The size of the key space is approximately 2 1700
( = 256 2
256!).
Ciphering
A step to create a key byte, K , looks like this:
i = i + 1 mod 256
j=j+P i mod 256
swap P i and P j
t=P i +P j mod 256
K=P t .
(A modulo-256 addition is simply a bytewise addition — in C adding two data of
the type unsigned char .)
Creating the Internal Key
Let the key entered consist of l bytes, S 0 ,...,S l 1 .Weset
i=0
j=0
P k = k (k=0,...,255)
and compute the following 256 times:
j=j+P i +S i mod 256
swap P i and P j
i = i + 1 mod l.
With this, i, j , and the P k are initialized.
Comment : In [SchnCr, 17.1], i traverses all indices from 0 to 255, and the key
is iterated as often as needed until all 256 bytes, S 0 ,...,S 255 , are filled. I didn't
check whether or not the two versions are equivalent. My variant stems from tested
C programs.
Figure 5.21: Description of the RC4 stream cipher.
Search WWH ::




Custom Search