keystream
A stream of random-looking bytes made from a key and a nonce, which a stream cipher combines with the message using XOR to encrypt it.
In more detail
Decryption makes the same keystream and applies XOR again, which restores the plaintext. The keystream must never repeat: if two messages share it, combining their ciphertexts removes it and exposes the messages. Counter mode, GCM and ChaCha20 all work this way.
Example
keystream = bytes(c ^ p for c, p in zip(c1, known))Related terms
- XOR — Exclusive or: a bit operation that outputs 1 when two bits differ and 0 when they match.
- CTR mode — Counter mode: a way of using a block cipher that encrypts a running counter to make keystream, then combines that with the message using XOR.
- nonce reuse — The mistake of encrypting two messages with the same key and the same nonce, which can expose both messages and allow forgeries.
- cipher — An algorithm for encrypting and decrypting data, such as AES; a mode, such as GCM, says how it is applied to data longer than one block.
Taught in
- Symmetric Encryption: AES-GCM & ChaCha20 — Cybersecurity Fundamentals, GRC & Cryptography