[issue27266] Add block keyword-only optional parameter to os.urandom()

STINNER Victor report at bugs.python.org
Wed Jun 8 06:03:36 EDT 2016


STINNER Victor added the comment:

> Is there a way to read from /dev/urandom without blocking? If not, _PyOS_URandom() may use arc4random() on FreeBSD if block is false. I suggest to enhance _PyOS_URandom() after the Python 3.5.2 release.

See the issue #22542 "Use arc4random under OpenBSD for os.urandom() if /dev/urandom is not present".

It looks like arc4random() is now initialized with getentropy(KEYSZ+IVSZ) (32+8 = 40 bytes) on OpenBSD:
http://bxr.su/OpenBSD/lib/libc/crypt/arc4random.c

getentropy() is non-blocking. By the way, os.urandom() is now implemented with getentropy() on OpenBSD.

----------

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


More information about the Python-bugs-list mailing list