Cryptography Reference
In-Depth Information
After 256 such iterations, the S array is completely permuted, with each ordinal
from 0 to 255 appearing once and only once.
With the key schedule computed, encryption — or decryption, remembering
that they're identical — can begin:
i = 0;
j = 0;
while ( plaintext_len-- )
{
i = ( i + 1 ) % 256;
j = ( j + S[ i ] ) % 256;
tmp = S[ i ];
S[ i ] = S[ j ];
S[ j ] = tmp;
*(ciphertext++) = S[ ( S[ i ] + S[ j ] ) % 256 ] ^ *(plaintext++);
}
}
First, the key schedule is permuted, again. The permutation is a bit simpler
and doesn't involve the key itself. Then the input is XORed with a byte of the
key schedule to produce the output (see Figure 2-16). That's all there is to it.
i
npu t
k
e
y
x
y
ou t
a
b
Figure 2-16: RC4 encryption and decryption
RC4 is simple — too simple, in fact. It's been shown to be fairly straightforward
to crack, yet, like DES, it continues to be a popular encryption algorithm choice.
In fact, WEP , the Wired Equivalent Privacy encryption routine built into — and
Search WWH ::




Custom Search