Stream Ciphers

3 min read Last updated Sun Jul 05 2026 05:11:45 GMT+0000 (Coordinated Universal Time)

Kerckhoffs’s principle: a cryptosystem must remain secure even if everything about the system, except the key, is public knowledge.

Since security depends only on the key, the key space must be large enough to make an exhaustive key search infeasible.

Stream Cipher

Models plaintext as a bit stream, combined with a random keystream via a reversible operation, bitwise XOR.

ci=miki,mi=cikic_i = m_i \oplus k_i, \quad m_i = c_i \oplus k_i

Both encryption and decryption must generate the identical keystream kik_i.

  • No error propagation
    A bit error in a transmitted ciphertext bit corrupts only the corresponding decrypted plaintext bit.
  • Efficient for real-time data (audio, video streaming) when the keystream generation algorithm is fast.

One-Time Pad

A keystream that is different for every message and as long as the message is perfectly secure.

Keystream Generator

Practical stream ciphers use a keystream generator: a short secret key expands into a stream of pseudorandom bits k0,k1,k2,k_0, k_1, k_2, \dots.

A secure keystream generator must satisfy:

  • Long period
    The period NN of the repetition of the sequence, where ki=ki+Nk_i = k_{i+N}, must be large for all ii.
  • Pseudo-randomness
    The sequence must pass statistical random number tests.
  • Unpredictability
    Computationally infeasible to determine the full keystream from any part of it, of any length.

Attacking a Stream Cipher

Reusing a key produces related ciphertexts for different messages.

c1c2=(m1k)(m2k)=m1m2c_1 \oplus c_2 = (m_1 \oplus k) \oplus (m_2 \oplus k) = m_1 \oplus m_2

An attacker who captures ciphertext streams can construct a new ciphertext, without knowing the key, that decrypts predictably. This is an existential forgery attack.

Lorenz Cipher

A stream cipher, manufactured by C. Lorenz AG, that encrypts a Baudot-coded plaintext bit stream into 5 ciphertext bit streams.

Encryption XORs the 5-bit Baudot code with a 5-bit random sequence, generated by 12 shift registers in 3 groups:

  • 5 χ\chi registers, lengths 41, 31, 29, 26, 23.
  • 5 ψ\psi registers, lengths 43, 47, 51, 53, 59.
  • 2 μ\mu registers, lengths 61, 37.

At each clock tick tt:

  • K=(χiψi)K = (\chi_i \oplus \psi_i) for i=1,,5i = 1, \dots, 5.
  • tt+1t \leftarrow t + 1, and the χ\chi registers advance.
  • μ(1)\mu^{(1)} advances every tick, and conditionally triggers μ(2)\mu^{(2)} to advance.
  • μ(2)\mu^{(2)} conditionally triggers the ψ\psi registers to advance.
  • Output KK.

Key space:

241+31+29+26+23+43+47+51+53+59+61+37=25012^{41+31+29+26+23+43+47+51+53+59+61+37} = 2^{501}
Was this helpful?