Question 2
Weak PRG
The PRG described below uses a 56-bit secret seed. Running the program generates the following first nine outputs of the PRG:
output #1: 210205973 output #2: 22795300 output #3: 58776750 output #4: 121262470 output #5: 264731963 output #6: 140842553 output #7: 242590528 output #8: 195244728 output #9: 86752752
Show that this PRG is insecure by computing the next output. What is the next output (output #10) of the PRG? Note that you are not given the seed.
Hint: there is an algorithm that takes time approximately 2^28 to predict the next output.
Here is the Python script that implements the PRG:
import random P = 295075153L # about 2^28 class WeakPrng(object): def __init__(self, p): # generate seed with 56 bits of entropy self.p = p self.x = random.randint(0, p) self.y = random.randint(0, p) def next(self): # x_{i+1} = 2*x_{i}+5 (mod p) self.x = (2*self.x + 5) % self.p # y_{i+1} = 3*y_{i}+7 (mod p) self.y = (3*self.y + 7) % self.p # z_{i+1} = x_{i+1} xor y_{i+1} return (self.x ^ self.y) prng = WeakPrng(P) for i in range(1, 10): print "output #%d: %d" % (i, prng.next())