| |
- KeyboardEntry
- RandomPool
-
- PersistentRandomPool
-
- KeyboardRandomPool
class KeyboardRandomPool(PersistentRandomPool) |
| |
- Method resolution order:
- KeyboardRandomPool
- PersistentRandomPool
- RandomPool
Methods defined here:
- __init__(self, *args, **kwargs)
- randomize(self, N=0)
- Adds N bits of entropy to random pool. If N is 0, fill up pool.
Methods inherited from PersistentRandomPool:
- save(self)
Methods inherited from RandomPool:
- addEvent(self, event, s='')
- add_event(self, s='')
- add_event(s:string)
Add an event to the random pool. The current time is stored
between calls and used to estimate the entropy. The optional
's' parameter is a string that will also be XORed into the pool.
Returns the estimated number of additional bits of entropy gain.
- getBytes(self, N)
- # Deprecated method names: remove in PCT 2.1 or later.
- get_bytes(self, N)
- get_bytes(N:int) : string
Return N bytes of random data.
- stir(self, s='')
- stir(s:string)
Mix up the randomness pool. This will call add_event() twice,
but out of paranoia the entropy attribute will not be
increased. The optional 's' parameter is a string that will
be hashed with the randomness pool.
- stir_n(self, N=3)
- stir_n(N)
stirs the random pool N times
|
class PersistentRandomPool(RandomPool) |
| |
Methods defined here:
- __init__(self, filename=None, *args, **kwargs)
- save(self)
Methods inherited from RandomPool:
- addEvent(self, event, s='')
- add_event(self, s='')
- add_event(s:string)
Add an event to the random pool. The current time is stored
between calls and used to estimate the entropy. The optional
's' parameter is a string that will also be XORed into the pool.
Returns the estimated number of additional bits of entropy gain.
- getBytes(self, N)
- # Deprecated method names: remove in PCT 2.1 or later.
- get_bytes(self, N)
- get_bytes(N:int) : string
Return N bytes of random data.
- randomize(self, N=0)
- randomize(N:int)
use the class entropy source to get some entropy data.
This is overridden by KeyboardRandomize().
- stir(self, s='')
- stir(s:string)
Mix up the randomness pool. This will call add_event() twice,
but out of paranoia the entropy attribute will not be
increased. The optional 's' parameter is a string that will
be hashed with the randomness pool.
- stir_n(self, N=3)
- stir_n(N)
stirs the random pool N times
|
class RandomPool |
|
randpool.py : Cryptographically strong random number generation.
The implementation here is similar to the one in PGP. To be
cryptographically strong, it must be difficult to determine the RNG's
output, whether in the future or the past. This is done by using
a cryptographic hash function to "stir" the random data.
Entropy is gathered in the same fashion as PGP; the highest-resolution
clock around is read and the data is added to the random number pool.
A conservative estimate of the entropy is then kept.
If a cryptographically secure random source is available (/dev/urandom
on many Unixes, Windows CryptGenRandom on most Windows), then use
it.
Instance Attributes:
bits : int
Maximum size of pool in bits
bytes : int
Maximum size of pool in bytes
entropy : int
Number of bits of entropy in this pool.
Methods:
add_event([s]) : add some entropy to the pool
get_bytes(int) : get N bytes of random data
randomize([N]) : get N bytes of randomness from external source |
|
Methods defined here:
- __init__(self, numbytes=160, cipher=None, hash=None)
- addEvent(self, event, s='')
- add_event(self, s='')
- add_event(s:string)
Add an event to the random pool. The current time is stored
between calls and used to estimate the entropy. The optional
's' parameter is a string that will also be XORed into the pool.
Returns the estimated number of additional bits of entropy gain.
- getBytes(self, N)
- # Deprecated method names: remove in PCT 2.1 or later.
- get_bytes(self, N)
- get_bytes(N:int) : string
Return N bytes of random data.
- randomize(self, N=0)
- randomize(N:int)
use the class entropy source to get some entropy data.
This is overridden by KeyboardRandomize().
- stir(self, s='')
- stir(s:string)
Mix up the randomness pool. This will call add_event() twice,
but out of paranoia the entropy attribute will not be
increased. The optional 's' parameter is a string that will
be hashed with the randomness pool.
- stir_n(self, N=3)
- stir_n(N)
stirs the random pool N times
| |