Go back

Stream Ciphers

Topics

1. Introduction

Stream ciphers are symmetric encryption algorithms that encrypt data one bit or byte at a time using a keystream generated by a pseudorandom bit generator (PRBG). They are efficient and well-suited for high-speed or resource-constrained environments, but their security relies heavily on the properties of the keystream.

2. Pseudorandom Bit Generators (PRBGs)

Idea: as noted, the one-time pad is a perfect secracy (semantically secure against ciphertext-only attacks by an adversary with infinite computational resources. However, it needs a key as long as the message. So what if we generate a long key from a short key?
A PRBG expands a short, random seed into a long pseudorandom output called a keystream. This keystream is XORed with the plaintext in a manner similar to a one-time pad, but is generated deterministically.

Definition

A pseudorandom bit generator (PRBG) is a deterministic algorithm that takes as input a short random seed, and outputs a longer pseudorandom sequence, also known as a keystream

Key Properties:

Stream cipher

We can use a pseudorandom bit generator to construct a stream cipher.
The seed is the secret key shared by Alice and Bob.
Note that unlike the one-time pad, a stream cipher will not have perfect secrecy.
Instead, security depends on the quality of the PRBG.

Components of a PRBG

A pseudorandom bit generator consists of:

Stream Cipher Architectures

One-Input PRBGs

Early stream ciphers used a single key as input. This meant one key produced one keystream, and reusing the key for multiple messages was insecure.

PRBG is deterministic, so each key produces a single output sequence.
So the same key should not be used to encrypt multiple messages.

Two-Input PRBGs

Modern designs include an Initialization Vector (IV) alongside the key, allowing the same key to produce many different keystreams. The IV is public and transmitted with ciphertext.

Now the key is kept private, but the IV can be made public.
So, one can generate multiple (different) output sequences from the same key but different IV's.
Pros: Can safely reuse keys with different IVs
Cons: Adds communication overhead (must send IV)

3. Linear Feedback Shift Registers (LFSRs)

LFSRs are simple, fast hardware-friendly components used in many stream ciphers. They use a recurrence relation to generate sequences from an initial state vector.

Example recurrence: st+6 = st+5 ⊕ st+4 ⊕ st+1 ⊕ st

As such, any infinite periodic sequence (st) can be defined via a recurrence relation with a first few inital state vector (s0, s1, ..., sn-1).

However, LFSRs have low linear complexity and are predictable, and hence a deterministic PRBG produces a periodic sequence.

Attack on small period: If the period of the keystream is less than the length of a ciphertext, then at least two secions of the message were encrypted using the same portion of the keystream. By XORing these two sections, the keystream cancels out and one obtains the XOR of the plaintext strings. It is then possible to attack such a sum by exploiting the redundancy of the plaintext.

Building a PRBG from a LFSR

A single LFSR on its own is not good.
Knowing the output leads to knowing the intermediate state so one can predict all future sequence.

Typically there are three ways of using LFSRs:

4. A5/1

A stream cipher used in GSM mobile telephony. It combines three LFSRs irregularly clocked based on a majority rule.

Vulnerabilities: A5/1 was reverse-engineered and cracked with precomputation attacks using rainbow tables and GPU hardware.

5. RC4

Designed by Ron Rivest (1987). Widely adopted in SSL/TLS and WEP. Simple and fast but now deprecated.

Key Scheduling Algorithm:

Keystream Generation:

Flaws: Biased outputs in early bytes, exploitable with millions of packets. RC4 is officially deprecated as of the 2010s.

6. Salsa20 and ChaCha

Modern stream ciphers by Daniel J. Bernstein. Salsa20 (2005), ChaCha (2008).

Characteristics: Fast in software, strong resistance to cryptanalysis, used in TLS, SSH, QUIC, IPsec

7. Wireless Security and WEP Case Study

WEP used RC4 with a 24-bit IV and a shared key. It aimed to provide confidentiality, integrity, and access control—but failed.

Key Flaws:

FMS Attack:

The Fluhrer-Mantin-Shamir attack (2001) shows how key recovery is possible with 5 million packets. Used widely in tools like aircrack-ng.

Conclusion

Stream ciphers are efficient and powerful but require careful design and implementation. Legacy systems like WEP have shown that weak key handling and poor initialization can completely undermine security.

Modern alternatives like ChaCha20 and AES-CTR are recommended today.