[Python-checkins] peps: Add FAQ about source of randomness (/dev/urandom versus /dev/random).

steven.daprano python-checkins at python.org
Fri Oct 16 11:40:46 EDT 2015


https://hg.python.org/peps/rev/ee5f38ca28e6
changeset:   6112:ee5f38ca28e6
parent:      6108:ce879f833f82
user:        Steven D'Aprano <steve+python at pearwood.info>
date:        Fri Oct 16 21:43:39 2015 +1100
summary:
  Add FAQ about source of randomness (/dev/urandom versus /dev/random).

files:
  pep-0506.txt |  12 ++++++++++++
  1 files changed, 12 insertions(+), 0 deletions(-)


diff --git a/pep-0506.txt b/pep-0506.txt
--- a/pep-0506.txt
+++ b/pep-0506.txt
@@ -338,6 +338,15 @@
      module, instead it will be given in the documentation as a recipe (à la
      the recipes in the ``itertools`` module) [30]_.
 
+* Q: Will ``secrets`` use /dev/random (which blocks) or /dev/urandom (which
+     doesn't block) on Linux? What about other platforms?
+
+  A: ``secrets`` will be based on ``os.urandom`` and ``random.SystemRandom``,
+     which are interfaces to your operating system's best source of
+     cryptographic randomness. On Linux, that may be ``/dev/urandom`` [31]_,
+     on Windows it may be ``CryptGenRandom()``, but see the documentation
+     and/or source code for the detailed implementation details.
+
 
 References
 ==========
@@ -412,6 +421,9 @@
 
 .. [30] https://mail.python.org/pipermail/python-ideas/2015-September/036488.html
 
+.. [31] http://sockpuppet.org/blog/2014/02/25/safely-generate-random-numbers/
+        http://www.2uo.de/myths-about-urandom/
+
 
 Copyright
 =========

-- 
Repository URL: https://hg.python.org/peps


More information about the Python-checkins mailing list