Esempio n. 1
0
 def random_data(self, bytes):
     current_time = maybe_monotonic_time()
     if self.last_reseed is not None and self.last_reseed > current_time:
         warnings.warn('Clock rewind detected. Resetting last_reseed.',
                       ClockRewindWarning)
         self.last_reseed = None
     if self.pools[0].length >= self.min_pool_size and (
             self.last_reseed is None
             or current_time > self.last_reseed + self.reseed_interval):
         self._reseed(current_time)
     return self.generator.pseudo_random_data(bytes)
Esempio n. 2
0
 def random_data(self, bytes):
     current_time = maybe_monotonic_time()
     if (self.last_reseed is not None and self.last_reseed > current_time): # Avoid float comparison to None to make Py3k happy
         warnings.warn("Clock rewind detected. Resetting last_reseed.", ClockRewindWarning)
         self.last_reseed = None
     if (self.pools[0].length >= self.min_pool_size and
         (self.last_reseed is None or
          current_time > self.last_reseed + self.reseed_interval)):
         self._reseed(current_time)
     # The following should fail if we haven't seeded the pool yet.
     return self.generator.pseudo_random_data(bytes)
Esempio n. 3
0
 def random_data(self, bytes):
     current_time = maybe_monotonic_time()
     if (self.last_reseed is not None and self.last_reseed > current_time): # Avoid float comparison to None to make Py3k happy
         warnings.warn("Clock rewind detected. Resetting last_reseed.", ClockRewindWarning)
         self.last_reseed = None
     if (self.pools[0].length >= self.min_pool_size and
         (self.last_reseed is None or
          current_time > self.last_reseed + self.reseed_interval)):
         self._reseed(current_time)
     # The following should fail if we haven't seeded the pool yet.
     return self.generator.pseudo_random_data(bytes)
Esempio n. 4
0
    def _reseed(self, current_time=None):
        if current_time is None:
            current_time = maybe_monotonic_time()
        seed = []
        self.reseed_count += 1
        self.last_reseed = current_time
        for i in which_pools(self.reseed_count):
            seed.append(self.pools[i].digest())
            self.pools[i].reset()

        seed = b("").join(seed)
        self.generator.reseed(seed)
Esempio n. 5
0
    def _reseed(self, current_time=None):
        if current_time is None:
            current_time = maybe_monotonic_time()
        seed = []
        self.reseed_count += 1
        self.last_reseed = current_time
        for i in which_pools(self.reseed_count):
            seed.append(self.pools[i].digest())
            self.pools[i].reset()

        seed = b("").join(seed)
        self.generator.reseed(seed)