Practical Seed-Recovery for the PCG Pseudo-Random Number Generator Charles Bouillaguet, Florette Martinez and Julia Sauvage November 2, 2020 Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 1 / 31
Introduction What? Cryptanalysis of the Permuted Congruential Generator (PCG). Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 2 / 31
Why? Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 3 / 31
Why? Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 4 / 31
Why? Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 5 / 31
Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 6 / 31
Introduction What? Cryptanalysis of the Permuted Congruential Generator (PCG). Results Practical seed-recovery / prediction. How? "Guess-and-Determine" attack. Most expensive part : many small CVP problems. Actually done in ≤ 20 000 CPU-hours. Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 7 / 31
Permuted Congruencial Generators (PCG) Conventional (non-crypto) pseudo-random generators Designed in 2014 by Melissa O’Neil PCG64 Internal state : 128-bit state and 128-bit increment 64-bit outputs 256-bit seed (or 128-bit with default increment) Default pseudo-random generator in NumPy 128 0 Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 8 / 31
Permuted Congruencial Generators (PCG) Conventional (non-crypto) pseudo-random generators Designed in 2014 by Melissa O’Neil PCG64 Internal state : 128-bit state and 128-bit increment 64-bit outputs 256-bit seed (or 128-bit with default increment) Default pseudo-random generator in NumPy × a + c mod 2 128 128 128 S i + 1 S i 128 0 Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 8 / 31
Permuted Congruencial Generators (PCG) Conventional (non-crypto) pseudo-random generators Designed in 2014 by Melissa O’Neil PCG64 Internal state : 128-bit state and 128-bit increment 64-bit outputs 256-bit seed (or 128-bit with default increment) Default pseudo-random generator in NumPy × a + c mod 2 128 128 128 S i + 1 S i 128 0 64 64 � Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 8 / 31
Permuted Congruencial Generators (PCG) Conventional (non-crypto) pseudo-random generators Designed in 2014 by Melissa O’Neil PCG64 Internal state : 128-bit state and 128-bit increment 64-bit outputs 256-bit seed (or 128-bit with default increment) Default pseudo-random generator in NumPy × a + c mod 2 128 128 128 S i + 1 S i 128 122 0 64 64 � 6 r i ≫ 64 X i Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 8 / 31
Attack Outline Guess some bits in a few successive states. Least-significant bits Rotations ⇒ Turn it into a (regular) truncated congruential generator . Reconstruct hidden information using lattice techniques. Discard bad guesses. Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 9 / 31
Attack Outline Guess some bits in a few successive states. Least-significant bits Rotations ⇒ Turn it into a (regular) truncated congruential generator . Reconstruct hidden information using lattice techniques. Easy case ( c known): full state Hard case ( c unknown): only partial information Discard bad guesses. Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 9 / 31
Easy Case: Known increment If the increment (c) is known ... ... Get rid of it! S ′ 0 ← S 0 S ′ 1 ← S 1 − c S ′ 2 ← S 2 − ( a + 1 ) c 3 ← S 3 − ( a 2 + a + 1 ) c S ′ . . . Yields S ′ : sequence of states with c = 0 → Geometric sequence . Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 10 / 31
Attack Details 64 bits 64 bits S 0 S 1 S 2 Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 11 / 31
Attack Details 6 ℓ bits r 0 w S 0 r 1 S 1 r 2 S 2 Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 11 / 31
Attack Details 6 ℓ bits r 0 w S 0 × a + c mod 2 ℓ r 1 w 1 S 1 × a + c mod 2 ℓ r 2 w 2 S 2 Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 11 / 31
Attack Details 6 ℓ bits r 0 w S 0 r 1 w 1 S 1 r 2 w 2 S 2 Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 11 / 31
Attack Details 6 ℓ bits r 0 w S 0 ????????????????? r 1 w 1 S 1 ????????????????? r 2 w 2 S 2 ????????????????? ℓ bits 6 Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 11 / 31
Attack Details ????????????????? ????????????????? ????????????????? ℓ bits 6 64 bits Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 11 / 31
Remove the “Constant Component” ????????????????? T 0 − 0 × a mod 2 64 ????????????????? T 1 − c × a mod 2 64 ????????????????? T 2 ( a + 1 ) c − Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 12 / 31
Truncated Linear Congruential Generators Internal state : 2 k -bit state. Multiplier a : known constant. Initial state: unknown 2 k -bit seed. × a mod 2 k k 0 T i discarded Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 13 / 31
Reconstructing Truncated Geometric Sequences Sequence u i + 1 = a × u i mod 2 k . T = Truncated version (low-order bits unknown). L = lattice spawned by the rows of a 2 a n − 1 1 a . . . 2 k 0 0 0 . . . 2 k 0 0 . . . 0 u i . . . . . . . . . . . . . . . T i ????????? 2 k 0 0 0 . . . Main Idea u = ( u 0 , u 1 , . . . , u n − 1 ) belongs to the lattice L . T (truncated geometric series) is an approximation of u . ⇒ T is close to a point of L . ⇒ Closest point to T in L � u . Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 14 / 31
Lattices and Basis reduction Lattice : subgroup of R n isomorphic to Z m Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 15 / 31
Lattices and Basis reduction Lattice : subgroup of R n isomorphic to Z m Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 15 / 31
CVP problem and Babai rounding Closest Vector Problem Standard NP-hard problem on lattices. Given arbitrary x ∈ Z n , find closest lattice point. Babai Rounding Algorithm Approximately solves CVP. H − 1 × x � � BabaiRounding ( x , L ) = H × round Where H is a “good” (LLL-reduced) basis of the lattice L . FAST (two matrix-vector products + rounding) Exponentially bad approximation (in the lattice dimension). → Often exact in small dimension though. Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 16 / 31
Lattices and Basis reduction Lattice : subgroup of R n isomorphic to Z m Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 17 / 31
Lattices and Basis reduction Lattice : subgroup of R n isomorphic to Z m Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 17 / 31
Implementation (Easy case, known increment) Summary Observe 3 outputs X 0 , X 1 , X 2 (192 bits). Guess 37 bits: n = 3 successive rotations (6 bits each), ℓ = 19 least significant bits of S 0 , Solve 2 37 instances of CVP in dimension 3 (Babai Rounding). Reconstruct initial state, check outputs. Caveat Attack proved correct for ℓ = 20, works fine for ℓ = 19... Concretely... 25 CPU cycles per guess, 23 CPU-minutes in total. Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 18 / 31
Issue with c unknown Summary so far (the Easy Case ) The increment (c) is known : Remove it, get truncated geometric sequence, CVP. Now the Hard Case The increment (c) is unknown : How to get truncated geometric sequence? (∆ S i + 1 = a × ∆ S i mod 2 128 ) . Use ∆ S i = S i + 1 − S i Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 19 / 31
Issue with c unknown Summary so far (the Easy Case ) The increment (c) is known : Remove it, get truncated geometric sequence, CVP. Now the Hard Case The increment (c) is unknown : How to get truncated geometric sequence? (∆ S i + 1 = a × ∆ S i mod 2 128 ) . Use ∆ S i = S i + 1 − S i Same attack as before, but... Must guess one more rotation. Must guess least-significant bits of c . Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 19 / 31
Attack Details S 0 S 1 S 2 S 3 S 4 Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 20 / 31
Attack Details 6 ℓ bits r 0 w S 0 r 1 S 1 r 2 S 2 r 3 S 3 r 4 S 4 Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 20 / 31
Attack Details 6 ℓ bits r 0 w S 0 × a + c mod 2 ℓ r 1 w 1 S 1 × a + c mod 2 ℓ r 2 w 2 S 2 × a + c mod 2 ℓ r 3 w 3 S 3 × a + c mod 2 ℓ r 4 w 4 S 4 Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 20 / 31
Attack Details 6 ℓ bits r 0 w S 0 r 1 w 1 S 1 r 2 w 2 S 2 r 3 w 3 S 3 r 4 w 4 S 4 Bouillaguet, Martinez, Sauvage (SU) Seed-Recovery for PCG November 2, 2020 20 / 31
Recommend
More recommend