RC4: Design, Vulnerabilities, and Deprecation
What You'll Learn
You'll discover how RC4's internal design works, understand its critical vulnerabilities, and learn why this once-popular stream cipher is now forbidden in modern security protocols.
RC4's Internal Design
RC4 (Rivest Cipher 4) was designed in 1987 as a simple, fast stream cipher. It consists of two main parts:
Internal State: RC4 maintains a 256-byte array (called "S") and two index pointers. During initialization, your secret key scrambles this array through the Key Scheduling Algorithm (KSA).
PRGA (Pseudo-Random Generation Algorithm): After initialization, RC4 generates keystream bytes one at a time by swapping values in the S array and outputting bytes based on those swaps. You XOR these keystream bytes with your plaintext to encrypt.
Think of it like shuffling a deck of 256 cards based on your secret key, then repeatedly drawing cards in a specific pattern to generate random numbers for encryption.
Critical Vulnerabilities
RC4 suffers from devastating statistical biases:
- Key scheduling bias: The first bytes of keystream are not truly random, leaking information about the key
- Distinguishing attacks: Certain byte patterns appear more frequently than they should in random data
- Related-key attacks: Using similar keys can reveal patterns
- Invariance weakness: Some states produce predictable output sequences
These aren't theoretical—they've been exploited in real attacks against WEP (WiFi), TLS, and other protocols.
Why It's Deprecated
Starting in 2015, major standards bodies and browsers banned RC4. The biases allow attackers to recover passwords, session cookies, and encrypted data after observing enough traffic. Modern protocols now require AES-based alternatives.
Key Takeaway: RC4's simplicity made it popular, but its statistical biases and weak key scheduling created exploitable vulnerabilities—never use RC4 in new systems, and migrate away from it in legacy applications.