[issue18811] add ssl-based generator to random module

2013-08-23 Thread Antoine Pitrou
Antoine Pitrou added the comment: > How about we generalize SystemRandom so users can implement a custom > RNG class wby providing a method rng(amount) -> bytes? We may make it easier to implement custom Random implementations with user-defined random generators, but they needn't be *SystemRand

[issue18811] add ssl-based generator to random module

2013-08-23 Thread Charles-François Natali
Charles-François Natali added the comment: > How about we generalize SystemRandom so users can implement > a custom RNG class wby providing a method rng(amount) -> bytes? The random module already makes it easy: """ Class Random can also be subclassed if you want to use a different basic gener

[issue18811] add ssl-based generator to random module

2013-08-23 Thread Christian Heimes
Christian Heimes added the comment: I don't get it either. urandom is perfectly fine. I showed that urandom is just a bit slower than SSL_rand(). How about we generalize SystemRandom so users can implement a custom RNG class wby providing a method rng(amount) -> bytes? Antoine Pitrou schrie

[issue18811] add ssl-based generator to random module

2013-08-23 Thread Antoine Pitrou
Antoine Pitrou added the comment: Seriously, why are we obsessed with performance when talking about a security feature? Did anyone *actually* complain about urandom() being too slow (ok, someone complained about it eating file descriptors... :-))? The question is whether OpenSSL's random gene

[issue18811] add ssl-based generator to random module

2013-08-22 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- assignee: -> rhettinger nosy: +rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue18811] add ssl-based generator to random module

2013-08-22 Thread Christian Heimes
Changes by Christian Heimes : Removed file: http://bugs.python.org/file31419/prng.py ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue18811] add ssl-based generator to random module

2013-08-22 Thread Christian Heimes
Christian Heimes added the comment: Improved benchmark script: Loops: 50 1 4 8 16 32 64 128 urandom (fd)0.091 0.185 0.306 0.544 1.060 1.989 3.876 urandom (fd, no buf)0.504 0.502 0.502 0.806 1.398 2.324 4.086 o

[issue18811] add ssl-based generator to random module

2013-08-22 Thread STINNER Victor
STINNER Victor added the comment: Use time.perf_counter() for benchmarkks!!! It would be interesting to compare performances on other platforms: Windows, Solaris, Mac OS X, ... -- ___ Python tracker __

[issue18811] add ssl-based generator to random module

2013-08-22 Thread Charles-François Natali
Charles-François Natali added the comment: > It doesn't look like OpenSSL's PRNG is much faster than /dev/urandom if > Python keeps a persistent fd: > > $ python3.3 prng.py > loops: 100 > bytes: 16 > /dev/urandom (fd)1.2181 > os.urandom() 3.2892 > RAND_pseudo_bytes

[issue18811] add ssl-based generator to random module

2013-08-22 Thread Christian Heimes
Christian Heimes added the comment: I'm -1 It doesn't look like OpenSSL's PRNG is much faster than /dev/urandom if Python keeps a persistent fd: $ python3.3 prng.py loops: 100 bytes: 16 /dev/urandom (fd)1.2181 os.urandom() 3.2892 RAND_pseudo_bytes1.2924 RAND_by

[issue18811] add ssl-based generator to random module

2013-08-22 Thread Charles-François Natali
New submission from Charles-François Natali: Now that the ssl module exposes RAND_bytes() (issue #12049), it might be interesting to implement a SSLRandom generator to the random module, to have a cryptographically strong generator without the os.urandom() overhead. Thoughts? -- messa