[Python-Dev] writing to /dev/*random [was: BDFL ruling request: should we block ...]
Stephen J. Turnbull
stephen at xemacs.org
Sat Jun 11 20:16:44 EDT 2016
This is related to David Mertz's request for backward compatible
initialization, not to the bdfl decision.
Steven D'Aprano writes:
> I don't think that's something which the Python interpreter ought to do
> for you, but you can write to /dev/urandom or /dev/random (both keep
> their own, separate, entropy pools):
>
> open("/dev/urandom", "w").write("hello world")
This fails for unprivileged users on Mac. I'm not sure what happens
on Linux; it appears to succeed, but the result wasn't what I
expected.
Also, when entropy gets low, it's not clear how additional entropy is
allocated between the /dev/random and /dev/urandom pools.
> But of course there's the question of where you're going to get a
> source of noise to write to the file. While it's (probably?)
> harmless to write a hard-coded string to it, I don't think its
> going to give you much entropy.
Use a Raspberry-Pi, or other advanced expensive<wink/> hardware.
There's no real excuse for not having a hardware generator if the Pi
has one! I would guess you can probably get something with a USB
interface for $20 or so.
http://scruss.com/blog/2013/06/07/well-that-was-unexpected-the-raspberry-pis-hardware-random-number-generator/
More information about the Python-Dev
mailing list