0% found this document useful (0 votes)
2 views

7

RC4 is a stream cipher designed by Ronald Rivest in 1984, widely used in protocols like SSL/TLS. It operates by exclusive-oring plaintext bytes with key bytes generated from a secret key, which can range from 1 to 256 bytes. While RC4 is considered secure with key sizes of at least 128 bits, it is advised to use different keys for different sessions to mitigate potential attacks.

Uploaded by

Bhavye Nijhawan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

7

RC4 is a stream cipher designed by Ronald Rivest in 1984, widely used in protocols like SSL/TLS. It operates by exclusive-oring plaintext bytes with key bytes generated from a secret key, which can range from 1 to 256 bytes. While RC4 is considered secure with key sizes of at least 128 bits, it is advised to use different keys for different sessions to mitigate potential attacks.

Uploaded by

Bhavye Nijhawan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Module 2

Symmetric Encryption Algorithms


Topic
RC4
RC4
• RC4 (Rivest Cipher) is a stream cipher that was designed in
1984 by Ronald Rivest for RSA Data Security.
• RC4 is used in many data communication and networking
protocols, including SSL/TLS and the IEEE802.11 wireless LAN
standard.
• RC4 is a byte-oriented stream cipher in which a byte (8 bits) of
a plaintext is exclusive-ored with a byte of key to produce a
byte of a ciphertext.
• The secret key, from which the one-byte keys in the key
stream are generated, can contain anywhere from 1 to 256
bytes.
State
• RC4 is based on the concept of a state. At each moment, a
state of 256 bytes is active, from which one of the bytes is
randomly selected to serve as the key for encryption.
• The idea can be shown as an array of bytes:
• S[0] S[1] S[2] … S[255]
• Note that the indices of the elements range between 0 and
255. The contents of each element is also a byte (8 bits) that
can be interpreted as an integer between 0 to 255.
The idea of RC4 stream cipher
Initialization
1. In the first step, the state is initialized to values 0, 1, …, 255.
A key array, K[0], K[1], …, K[255] is also created.
If the secret key has exactly 256 bytes, the bytes are copied to
the K array; otherwise, the bytes are repeated until the K array
is filled.
• for (i = 0 to 255)
• {
• S[i] ← i
• K[i] ← Key [i mod KeyLength]
• }
Cont…
• In the second step, the initialized state goes through a
permutation (swapping the elements) based on the value of
the bytes in K[i].
• The key byte is used only in this step to define which elements
are to be swapped. After this step, the state bytes are
completely shuffled.
Key Stream Generation
• The keys in the key stream, the k’s, are generated, one by one.
• First, the state is permuted based on the values of state
elements and the values of two individual variables, i and j.
• Second, the values of two state elements in positions i and j are
used to define the index of the state element that serves as k.
• The following code is repeated for each byte of the plaintext to
create a new key element in the key stream.
• The variables i and j are initialized to 0 before the first iteration,
but the values are copied from one iteration to the next.
Encryption or Decryption
• After k has been created, the plaintext byte is encrypted with k
to create the ciphertext byte.
• Decryption is the reverse process.
Security Issues
• It is believed that the cipher is secure if the key size is at least
128 bits (16 bytes).
• There are some reported attacks for smaller key sizes (less
than 5 bytes), but the protocols that use RC4 today all use key
sizes that make RC4 secure.
• However, like many other ciphers, it is recommended the
different keys be used for different sessions. This prevents Eve
from using differential cryptanalysis on the cipher.
Example Problem
Initial state permutation

• Repeat the steps until i value reaches the 7th iteration


• After updating the state vector, every time, i value will be
incremented by 1.
• But, j value should not be incremented, every iteration, the
last j value will be used.
Key stream generation

• But here, Every iteration, updated i and j values will be used.


• i and j values will not be incremented

You might also like