RC4
Rivest's 1987 byte-oriented stream cipher, once ubiquitous and now prohibited in TLS
Practical attacks exist. Present for compatibility and research only. Reach it with NextSSL(root=True) in Python or the nextssl_root_* functions in C.
About RC4
RC4 is a stream cipher. It uses a 1–256-byte key. Its registry entry cites RFC 6229 and ARC4. It is also known as arc4 and arcfour. NextSSL lists it in the broken tier and exposes it through the root API only (NextSSL(root=True) in Python, nextssl_root_* in C).
Overview
RC4 is a stream cipher designed by Ron Rivest in 1987. It was used in WEP, WPA-TKIP, early TLS and many other systems because of its simplicity and speed, but statistical biases in its output have made it insecure.
RC4 maintains a 256-byte permutation S and two indices. The key-scheduling algorithm initialises S to the identity and swaps entries based on the key. The output generator then repeatedly increments one index, adds the indexed value to the other, swaps the two entries, and outputs the byte at the sum of the two values. No nonce is defined; protocols often concatenated an IV with the key, which proved fatal in WEP.
The algorithm was a trade secret until it was leaked in 1994, which is why it is also known as ARC4 or ARCFOUR. NextSSL includes RC4 for legacy interoperability; RFC 6229 provides test vectors. It is still found in old protocols. Its simplicity made it easy to implement in early hardware and software.
History
1987–2015RC4 designed by Ron Rivest
RC4 source posted anonymously
Fluhrer, Mantin and Shamir break WEP's use of RC4
RC4 prohibited in TLS by RFC 7465
Security notes
RC4 is broken. Its early keystream bytes are biased, related-key weaknesses broke WEP within minutes, and plaintext-recovery attacks against TLS led RFC 7465 to prohibit RC4 in TLS in 2015. Do not use it for new data.
Typical uses
Sizes
| Field | Bytes | Meaning |
|---|---|---|
| key | 1 – 256 | Secret key |
| nonce | 0 | Nonce / IV |
Use it
from nextssl_demo import NextSSL
root = NextSSL(root=True) # tier 'broken' is reachable from the root API only
ct = root.call("stream_apply", "rc4", None, key, nonce, b"secret")[0] # same call decrypts
nextssl_root_stream_apply("rc4", NULL, key, nonce, data, out);
use nextssl_core::Params;
use nextssl_registry::{self as reg, Policy};
let alg = reg::new_streamcipher_in(reg::all(), Policy::Any, "rc4", &Params::new())?;
let ct = alg.apply_keystream(&key, &nonce, b"secret")?;
Calls follow the NextSSL C ABI and its language bindings. Buffer sizes are validated against the sizes above.
Similar names
Looking for something else?More stream ciphers
All 37Frequently asked questions
What is RC4?
RC4 is a stream cipher in the RC4 family. RC4 is a stream cipher designed by Ron Rivest in 1987. It is also known as arc4, arcfour.
What are the RC4 sizes?
In NextSSL, RC4 uses: key 1 to 256 bytes, nonce 0 bytes.
Who designed RC4 and when?
RC4 belongs to the RC4 family, first published in 1987 by Ron Rivest. Its origin: RFC 6229 (test vectors); RFC 7465 (prohibited in TLS).
Which standards define RC4?
RC4 is referenced by RFC 6229, ARC4.
Is RC4 safe to use?
RC4 is in the broken tier. Practical attacks exist. Present for compatibility and research only. It is only reachable through the root API (NextSSL(root=True) in Python, nextssl_root_* in C).
Related families
ARX stream cipher with a one-time Poly1305 MAC; fast and constant-time in software
RC2, RC5 and RC6Ron Rivest's family of block ciphers, from the 1987 RC2 to the AES finalist RC6
AES-CTRCounter mode: turns AES into a fast, parallel stream cipher
ChaChaBernstein's ARX stream cipher; ChaCha20 secures much of today's TLS, SSH and VPN traffic