Python: module gdata.Crypto.Util.randpool

gdata.Crypto.Util.randpool | index /usr/local/google/home/afshar/src/external-gdata-release/google3/src/gdata/Crypto/Util/randpool.py

`# randpool.py : Cryptographically strong random number generation
#
# Part of the Python Cryptography Toolkit
#
# Distribute and use freely; there are no restrictions on further
# dissemination and usage except those imposed by the laws of your
# country of residence. This software is provided "as is" without
# warranty of fitness for use or suitability for any purpose, express
# or implied. Use at your own risk or not at all.
#`

Modules
`` |  |
array os | termios time | types warnings |

Classes
`` |  | KeyboardEntry RandomPool PersistentRandomPool KeyboardRandomPool
class KeyboardEntry
`` |  | Methods defined here: __init__(self, fd=0) close(self, delay=0) getch(self)
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`

Data
`` |  | STIRNUM = 3 __revision__ = '$Id: randpool.py,v 1.14 2004/05/06 12:56:54 akuchling Exp $' winrandom = None