STINNER Victor <victor.stin...@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 <rep...@bugs.python.org>
<http://bugs.python.org/issue12049>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to