Models plaintext as a bit stream, combined with a random keystream via a reversible operation, bitwise XOR.
Both encryption and decryption must generate the identical keystream .
- 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.
Stream Encryption Scheme
A stream cipher is already a complete encryption scheme. It needs no mode of operation.
- Arbitrary length
The keystream is generated to any length and XORed with the plaintext bit by bit. No padding, and ciphertext length equals plaintext length. - Randomisation
The keystream generator takes an initialization vector alongside the key, so the same plaintext under the same key gives different ciphertext for different IVs.
Keystream Generator
A function that generates a stream of pseudorandom bits from a short secret key. Used in practical stream ciphers.
A secure keystream generator must satisfy:
- Long period
The period of the repetition of the sequence, where , must be large for all . - 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.
Malleability
An encryption scheme is malleable iff an attacker can transform a ciphertext of an unknown message into a ciphertext of a related message , without knowing or the key.
The XOR-combiner stream cipher is malleable. Given , the attacker chooses a mask and sends .
The plaintext changes by exactly , an attacker-chosen relation, with no other change. Flipping bit of flips bit of the plaintext.
Malleability here follows from 2 properties together, not from the keystream being random or pseudorandom.
- The combiner is XOR, which is linear and known to the attacker.
- No integrity check covers the ciphertext.
Removing either property breaks the attack. A self-synchronising stream cipher feeds past ciphertext bits into the keystream, so a flipped bit garbles a run of following plaintext instead of one clean bit.
A scheme is non-malleable iff any tampering with the ciphertext makes it decrypt to a value unrelated to , or makes decryption reject.
Breaking the Cipher
Reusing a keystream across 2 messages and produces ciphertexts and .
The keystream cancels. An attacker holding and recovers without . Plaintext redundancy separates it into and . Knowing one plaintext gives the other directly.
Knowing one plaintext also recovers the keystream, . Any further message under the same can then be forged. The attacker picks and sends , which decrypts to , an existential forgery.
Examples
One-Time Pad
To encrypt a message (of length ), a keystream (of length ) is generated that is random and never reused. The message bits are XORed with the keystream bits to produce the ciphertext.
Impractical as it requires a key as long as the message and never reused, but applications need a short key and reuse it across many messages.