The RC4 Algorithm: Network Security
The RC4 Algorithm: Network Security
Network Security
1
The RC4 Algorithm
• RC4 is a stream cipher
designed in 1987 by
Ron Rivest for RSA
Security.
• It is a variable key-size
stream cipher with
byte-oriented
operations.
2
The RC4 Algorithm
• RC4 is used in the
Secure Sockets
Layer/Transport Layer
Security (SSL/TLS)
standards that have
been defined for
communication
between Web
browsers and servers.
3
The RC4 Algorithm
• Also used in the Wired
Equivalent Privacy
(WEP) protocol and
the newer WiFi
Protected Access
(WPA) protocol that
are part of the IEEE
802.11 wireless LAN
standard.
4
The RC4 Algorithm
A generic
view
5
The RC4 Algorithm
• The RC4 algorithm is
remarkably simple.
• A variable-length key
of from 1 to 256 bytes
Secret Key (8 to 2048 bits) is used
to initialize a 256-byte
state vector S, with
RC4
elements S[0],
S[1], . . . , S[255].
Keystream
Encrypted
Plain Text + Text
6
The RC4 Algorithm
• For encryption and
decryption, a byte k is
generated from S by
selecting one of the
255 entries in a
systematic fashion.
• As each value of k is
generated, the entries
in S are once again
permuted.
7
RC4 …Inside
• Consists of 2 parts:
– Key Scheduling Algorithm (KSA)
– Pseudo-Random Generation
Algorithm (PRGA)
• KSA
– Generate State array KSA
• PRGA on the KSA PRGA
– Generate keystream
– XOR keystream with the
data to generated
encrypted stream
The KSA
1 2
After KSA, the input key and the temporary vector T will be no longer used
The PRGA
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
The RC4 Algorithm
14
The RC4 Algorithm
Strength of RC4:
• A number of papers
have been published
analyzing methods of
attacking RC4.
• None of these
approaches is
practical against RC4
with a reasonable key
length, such as 128
bits.
15