summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-06-07 09:21:42 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-06-07 09:21:42 (GMT)
commitdddf4849ec1750ca02d03b9772eff7141ba626f3 (patch)
tree1add3bb9de96020956ebf0327c163df13af1bb25 /Doc
parent6827fd867b9609c405cd25568aa91df1b0d011b4 (diff)
downloadcpython-dddf4849ec1750ca02d03b9772eff7141ba626f3.zip
cpython-dddf4849ec1750ca02d03b9772eff7141ba626f3.tar.gz
cpython-dddf4849ec1750ca02d03b9772eff7141ba626f3.tar.bz2
os.urandom() doesn't block on Linux anymore
Issue #26839: On Linux, os.urandom() now calls getrandom() with GRND_NONBLOCK to fall back on reading /dev/urandom if the urandom entropy pool is not initialized yet. Patch written by Colm Buckley.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/os.rst13
1 files changed, 10 insertions, 3 deletions
diff --git a/Doc/library/os.rst b/Doc/library/os.rst
index e6b6465..785b080 100644
--- a/Doc/library/os.rst
+++ b/Doc/library/os.rst
@@ -3733,14 +3733,21 @@ Miscellaneous Functions
This function returns random bytes from an OS-specific randomness source. The
returned data should be unpredictable enough for cryptographic applications,
- though its exact quality depends on the OS implementation. On a Unix-like
- system this will query ``/dev/urandom``, and on Windows it will use
- ``CryptGenRandom()``. If a randomness source is not found,
+ though its exact quality depends on the OS implementation.
+
+ On Linux, ``getrandom()`` syscall is used if available and the urandom
+ entropy pool is initialized (``getrandom()`` does not block).
+ On a Unix-like system this will query ``/dev/urandom``. On Windows, it
+ will use ``CryptGenRandom()``. If a randomness source is not found,
:exc:`NotImplementedError` will be raised.
For an easy-to-use interface to the random number generator
provided by your platform, please see :class:`random.SystemRandom`.
+ .. versionchanged:: 3.5.2
+ On Linux, if ``getrandom()`` blocks (the urandom entropy pool is not
+ initialized yet), fall back on reading ``/dev/urandom``.
+
.. versionchanged:: 3.5
On Linux 3.17 and newer, the ``getrandom()`` syscall is now used
when available. On OpenBSD 5.6 and newer, the C ``getentropy()``