[issue12049] expose RAND_bytes() function of OpenSSL

STINNER Victor report at bugs.python.org
Wed May 11 22:53:03 CEST 2011


STINNER Victor <victor.stinner at haypocalc.com> added the comment:

ssl_rand.patch adds RAND_bytes() and RAND_pseudo_bytes() functions to the ssl module.

I moved /dev/urandom to /dev/urandom.xxx and /dev/random to /dev/random.xxx to test RAND_bytes() error path. In this case, RAND_pseudo_bytes() generates non-cryptographic pseudo-random bytes.

RAND_pseudo_bytes() returns a tuple (bytes, is_cryptographic).

In test_ssl, I used the assertion that RAND_pseudo_bytes() only generates cryptographic numbers if RAND_status() is 1. If the assertion is wrong, the test can be changed to just test the type of is_crytographic.

RAND_bytes() and RAND_pseudo_bytes() raise a SSLError on error using ERR_get_errno() as the error code, whereas other ssl functions uses a value of the py_ssl_error enum. I don't know if it is the good choise.

----------
keywords: +patch
Added file: http://bugs.python.org/file21974/ssl_rand_bytes.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12049>
_______________________________________


More information about the Python-bugs-list mailing list