def reseed(self, ticks=None): """Use entropy to generate new seed for PRNG""" if ticks is None: ticks = self.RESEED_TIME v0 = self.fast.accumulate() v_i = hash(v0 + v0 + chr(0) * 4) # now compute Vp_t for i in range(1, ticks): # XXX how many bits should I extend i to? istr = struct.pack('i', i)[0] prev = v_i v_i = hash(v_i + v0 + istr) zap(prev) zap(self.key) self.key = hash_ex(hash(v_i + self.key), self.KEY_SIZE) self.cipher = DES3.new(self.key, DES3.ECB) self.counter = bytes_to_long(self.cipher.encrypt('\000' * 8))
def reset(self): """Reset the estimates to zero""" self.estBits = 0 # the user's estimate self.zEstBits = 0 # the zlib estimate zap(self.input) self.input = ''