Stream Ciphers
Starting the day with some déjà vu
Everyone remember the one-time pad from last time?
What does it use as…
What constraints apply when using it?
Is it…
Why can’t we just use it for everything and skip the rest of cryptography?
secrets module, right?“Anyone who considers arithmetical methods of producing random digits is, of course, in a state of sin.” – John von Neumann
/dev/randomCloudflare’s wall of lava lamps at 101 Townsend Street, San Francisco. Photo: HaeB, CC BY-SA 4.0
Let’s make this concrete with a tiny (insecure!) PRG
Suppose \(G : \{0,1\}^4 \to \{0,1\}^8\) and our seed is \(s = 1011\)
The PRG stretches the seed: \(G(s) = G(1011) = 10110011\)
We want to encrypt the message \(m = 01001110\)
Encrypt: \(c = G(s) \oplus m = 10110011 \oplus 01001110 = 11111101\)
Decrypt: \(m = G(s) \oplus c = 10110011 \oplus 11111101 = 01001110\) ✓
The seed is 4 bits but we encrypted an 8-bit message!
Of course, 4-bit seeds are trivially brute-forced
Prove it or it didn’t happen.
Theorem: Let \(G\) be a secure PRG. Then the stream cipher \(\mathcal{E}\) built from \(G\) is semantically secure.
More precisely: for every efficient SS adversary \(\mathcal{A}\) attacking \(\mathcal{E}\), there exists an efficient PRG adversary \(\mathcal{B}\) attacking \(G\) such that:
In words: anyone who can break the stream cipher can also break the PRG
How do we prove this? We need a new technique…
Making generators from generators.
Let’s try this with \(n = 2\) and tiny 4-bit outputs
\(H_0 = (G(s_1),\; G(s_2)) = (1011,\; 0110)\) – both from the PRG
\(H_1 = (r_1,\; G(s_2))\;\, = (1100,\; 0110)\) – first slot replaced with random
\(H_2 = (r_1,\; r_2)\;\;\;\;\;\, = (1100,\; 0011)\) – both truly random
Can you tell \(H_0\) from \(H_2\)?
If not, you shouldn’t be able to spot any single step either
From state-of-the-art to cautionary tale.
"expand 32-byte k" (128-bit constant, four 32-bit words)A user’s guide.
/dev/random and /dev/urandom on LinuxCan you really trust your standard library?
java.util.Random has always used a linear congruential generator (LCG), and still does
RandomGenerator with better algorithms, but you have to opt in100,000 consecutive triples from RANDU plotted in 3D. The points fall on just 15 parallel planes. Image: Luis Sanchez, CC BY-SA 3.0
PRGs aren’t just for encryption.
What did we learn?
Ask now, catch me after class, or email eoin@eoin.ai