[Python-ideas] Should our default random number generator be secure?

Brett Cannon brett at python.org
Thu Sep 10 17:46:28 CEST 2015

On Thu, 10 Sep 2015 at 01:26 M.-A. Lemburg <mal at egenix.com> wrote:

> Reading this thread is fun, but it doesn't seem to be getting
> anywhere - perhaps that's part of the fun ;-)
> Realistically, I see two options:
>  1. Someone goes and implements the OpenBSD random function in C
>     and put a package up on PyPI, updating it whenever OpenBSD
>     thinks that a new algorithm is needed or a security issue
>     has to be fixed (from my experience with other crypto software
>     like OpenSSL, this should be on the order of every 2-6 months ;-))
>  2. Ditto, but we put the module in the stdlib and then run around
>     issuing patch level security releases every 2-6 months.

I see a third: rename random.random() to be be something that gets the
point across it is not crypto secure and then stop at that. I don't think
the stdlib should get into the game of trying to provide a RNG that we
claim is cryptographically secure as that will change suddenly when a
weakness is discovered (this is one of the key reasons we chose not to
consider adding requests to the stdlib, for instance).

Theo's key issue is misuse of random.random(), not the lack of a
crypto-appropriate RNG in the stdlib (that just happens to be his solution
because he has an RNG that he is partially in charge of). So that means
either we take a "consenting adults" approach and say we can't prevent
people from using code without reading the docs or we try to rename the
function. But then again that won't help with all of the other functions in
the random module that implicitly use random.random() (if that even
matters; not sure if the helper functions in the module have any crypto use
that would lead to their misuse).

Oh, and there is always the nuclear 4th option and we just deprecate the
random module. ;)


> Replacing our deterministic default PRNG with a non-deterministic
> one doesn't really fly, since we'd break an important feature
> of random.random(). You may remember that we already ran a similar
> stunt with the string hash function, with very mixed results.
> Calling the result of such a switch-over "secure" is even
> worse, since it's a promise we cannot keep (probably not even
> fully define). Better leave the promise at "insecure" - that's
> something we can promise forever and don't have to define :-)
> Regardless of what we end up with, I think Python land can do
> better than name it "arc4random". We're great at bike shedding,
> so how about we start the fun with "randomYMMV" :-)
> Overall, I think having more options for good PRNGs is great.
> Whether this "arc4random" is any good remains to be seen, but
> given that OpenBSD developed it, chances are higher than
> usual.
> --
> Marc-Andre Lemburg
> eGenix.com
> Professional Python Services directly from the Source  (#1, Sep 10 2015)
> >>> Python Projects, Coaching and Consulting ...  http://www.egenix.com/
> >>> mxODBC Plone/Zope Database Adapter ...       http://zope.egenix.com/
> >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
> ________________________________________________________________________
> 2015-09-18: PyCon UK 2015 ...                               8 days to go
> ::::: Try our mxODBC.Connect Python Database Interface for free ! ::::::
>    eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
>     D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
>            Registered at Amtsgericht Duesseldorf: HRB 46611
>                http://www.egenix.com/company/contact/
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150910/15dc229c/attachment-0001.html>

More information about the Python-ideas mailing list