|
|
Subscribe / Log in / New account

Python and crypto-strength random numbers by default

By Jake Edge
September 16, 2015

There are various types of random number generators (RNGs) that target different use cases, but a programming language can only have one default. For high-security random numbers (e.g. cryptographic keys and the like), it is a grievous error to use the wrong kind of RNG, while other use cases are typically more forgiving. The Python community is in the middle of a debate about how it should be handling random numbers within the language's standard library.

The random module

On the python-ideas mailing list, Guido van Rossum kicked off the discussion by noting that he had been contacted by OpenBSD founder Theo de Raadt about the random.random() RNG that ships with Python. That RNG is based on the Mersenne Twister (MT) algorithm, which is a pseudo-RNG (PRNG) with an enormously long period. The PRNG can either be seeded by the user (with a call to random.seed()) or, by default, it is seeded with 2500 bytes of entropy from the os.urandom() pool (the strong, non-blocking random pool supplied by the operating system). From a given seed, the same sequence of random numbers will be generated, which makes it deterministic.

Using MT-derived random numbers for cryptographic or other security purposes is definitely not recommended by security experts. Given enough output from the RNG, the seed can be recovered, which means that all further random numbers can be perfectly predicted—generally with disastrous results. But for many uses, such as games, testing, or simulations, the random module provides a simple-to-use way to get perfectly adequate random numbers. The Python documentation for the module clearly indicates that it should not be used for security purposes and suggests either os.urandom() or the random.SystemRandom class.

But Van Rossum noted that "as the meme goes -- nobody reads the docs", so De Raadt's concern is that people will simply reach for the default provided by the language—no matter what they are using the random numbers for. According to Van Rossum, De Raadt is advocating the arc4random() RNG that OpenBSD uses (and, in fact, has switched to by default). Some of that advocacy can be seen in a forwarded email message that Van Rossum posted. Though De Raadt was invited to participate in the thread, "he's too busy" to do so, which left Van Rossum in a bit of a quandary:

The two core Python experts on the random module have given me opinions suggesting that there's not much wrong with MT, so here I am. Who is right? What should we do? Is there anything we need to do?

That set off quite a discussion, which now spans four threads in python-ideas.

Donald Stufft responded that he sees a problem with the current approach, but that he doesn't have any "great solution" for it:

The problem boils down to, are people going to [accidentally] use the default random module when they really should use os.urandom or random.SystemRandom. It is my opinion (and I believe Theo's) that they are going to use the MT backed random functions in random.py when they shouldn't be.

But, as Paul Moore and others pointed out, those with non-security needs for random numbers should be able to expect to access them easily from the standard library. He often uses the random module for games of various sorts, as well as for things like Monte Carlo simulations where millions of results are used. While the reproducibility feature is not particularly important to him, he would expect that a simple API would provide it. People doing crypto or other security programming ought to be looking for an RNG beyond the default:

Anyone doing crypto who doesn't fully appreciate that it's a specialist subject and that they should be looking for a dedicated RNG suitable for crypto, is probably going to make a lot of *other* mistakes as well. Leading them away from this one probably isn't going to be enough to make their code something I'd want to use...

Steven D'Aprano concurred:

Anyone writing crypto code without reading the docs and understanding what they are doing are surely making more mistakes than just using the wrong PRNG. There may be a good argument for adding arc4random support to the stdlib, but making it the default (with the disadvantages discussed, breaking backwards compatibility, surprising non-crypto users, etc.) won't fix the broken crypto code. It will just give people a false sense of security and encourage them to ignore the docs and write broken crypto code.

Part of the problem, of course, is that there is a large body of existing code that expects the random module to behave in a certain way. Some of it requires the reproducibility feature and isn't being used for security purposes. Changing the default would break those programs a few years down the road (if the change follows the normal Python deprecation schedule). As Stephen J. Turnbull put it:

But the people who are "just getting work done" in new programs *won't notice*. I don't think that they care what's under the hood of random.random, as long as (1) the API stays the same, and (2) the documentation clearly indicates where to find PRNGs that support determinism, jumpahead, replicability, and all those other good things, for the needs they doesn't have now but know they probably will have some day. The rub is, as usual, existing applications that would have to be changed for no reason that is relevant to them.

Stufft's proposal

That first thread got rather long, so Stufft attempted something of a reboot in a message that was rather long itself. He had talked to De Raadt to try to better understand his concerns, which Stufft said were not being reflected in the earlier thread. He broke down the users of random numbers into three groups: those who need deterministic output (and reproducibility), those who need cryptographic-strength random numbers (and don't want determinism), and those who aren't sure if their use case is security-sensitive or not. The last group generally doesn't need deterministic output, but currently that's what they get by default. It is Stufft's belief (that is shared with De Raadt, he said) that the members of that group would be better served with a crypto-strength RNG.

Those in group #3 might be told to use os.urandom() (or the random.SystemRandom class that is based on it), but they may end up using the standard random functions due to either the performance of the stronger alternative or bad advice (if, indeed, their need is security-sensitive). In fact, Stufft said, the performance of os.urandom() is one of the main reasons not to make it the default:

The fact that speed is the primary reason not to give people in #3 a cryptographically secure source of random by default is where we come back to the meat of Theo's suggestion. His claim is that invoking os.urandom through any of the interfaces imposes a performance penalty because it has to round trip through the kernel crypto sub system for every request. His suggestion is essentially that we provide an interface to a modern, good, userland  cryptographically secure source of random that is running within the same process as Python itself. One such example of this is the arc4random function (which doesn't actually provide ARC4 on OpenBSD, it provides ChaCha, it's not tied to one specific algorithm) which comes from libc on many platforms. According to Theo, modern userland CSPRNGs [cryptographically secure PRNGs] can create random bytes faster than memcpy which eliminates the argument of speed for why a CSPRNG shouldn't be the "default" source of randomness.

Stufft looked at StackOverflow and other sites with Python code to see what kinds of advice there was about RNG choices. His post had several snippets of code that used the module-level random functions in dubious ways.

That led him to propose that Python change its random-number handling in several ways. It would provide a means to access a fast user-space RNG like arc4random() and add a new class (random.SomeKindOfRandom) that uses it. The proposal would also move the MT-based RNG to a random.DeterministicRandom class and deprecate the module-level functions in the random module. That would mean that users would (eventually) have to choose the kind of randomness they wanted before they would be able to get random numbers. They would call functions like:

    random.SomeKindOfRandom().random()
    random.DeterministicRandom().random()
SystemRandom would still be available for those who wanted that RNG mechanism. Obviously, SomeKindOfRandom would need a better name, though there are objections to the whole idea of doing user-space RNG. Stufft pointed out that security expert Thomas Ptacek is not in favor of user-space RNGs like arc4random().

As might be guessed, Stufft's suggestions were not met with universal acclaim. There were concerns about backward compatibility and for how today's code could be switched, with minimal changes, to run (correctly) in this new world.

But Nick Coghlan strongly objected to the idea of deprecating all of the module-level functions. As he pointed out, nearly all of the module-level functions could provide any kind of random numbers, though they need to have good performance. Making someone choose what type they want, before they can even get a random number is "a *huge* regression in Python's usability for educational use cases". He said that a common "hello world" kind of program for using random numbers in Python is to roll a six-side die:

>>> from random import randint
>>> randint(1, 6)
6

He continued:

Shuffling decks of cards, flipping coins, these are all things used to introduce learners to modelling random events in the real world in software, and we absolutely do *not* want to invalidate the extensive body of educational material that assumes the current module level API for the random module.

He noted that there are calls at the module-level that imply the need for a deterministic RNG (like seed() and others that are stateful) and which can be deprecated to help those who really need them to move to an alternative API. Essentially, he is asking that those who don't care about the RNG wars (and those new to Python in particular) be left out—they can still call the functions they call today.

Breaking compatibility "in the name of the public good" is the wrong approach, Antoine Pitrou said. He and others are tired of seeing security trump all other considerations whenever a topic like this is raised. Since a change like Stufft has suggested can't fix the problem of bad advice on the internet, compromising on a change that maintains compatibility is preferable.

Some people have to support code in 4 different Python versions and further gratuitous breakage in the stdlib doesn't help. Yes, they can change their code. Yes, they can use the "six" module, the "future" module or whatever new bandaid exists on PyPI. Still they must change their code in a way or another because it was deemed "necessary" to break compatibility to solve a concern that doesn't seem grounded in any reasonable analysis.

Python 3 was there to break compatibility. Not Python 3.4. Not Python 3.5. Not Python 3.6.

(in case you're wondering, trying to make all published code on the Internet secure by appropriately changing the interpreter's "behaviour" to match erroneous expectations - even *documented* as erroneous - is *not* reasonable - no matter how hard you try, there will always be occurrences of broken code that people copy and paste around)

Coghlan's proposals

Coghlan started another thread as something of a "pre-PEP" on enhancing the random module. It would create three types of RNGs in Python: seedable, seedless, and system. The seedless version would be the default and guidance would be provided that those who need deterministic random numbers should use the seeded version, while those with strong security needs should use the system RNG.

Coghlan's proposal lays out plans for Python 3.6, which is likely destined for late 2016 (or early 2017), and for 3.7, which is probably due sometime in 2018—a change of this nature for Python can take a while, for sure. Essentially, his idea is to deprecate the stateful methods and module-level functions (seed(), getstate(), and setstate()), except for the SeedableRandom class. Those functions would warn the user, but not actually cause an error—except if the default type has been changed.

The most controversial part of Coghlan's proposal would provide a random.set_default_instance() function to specify which of the three types would be used by the module-level functions. Both Stufft and D'Aprano are concerned that would allow any module to affect all of the random numbers generated from that point on, potentially nullifying the choice another module has made.

Beyond that, though, Moore would like to see some kind of cost/benefit analysis. He is trying to remain open-minded, but is concerned about the disruption for users, particularly those who don't have any security requirements for their use of random numbers. While he recognizes that it is somewhat emotionally stated, the benefits to him seem to be: "Users of code written based on bad advice will be protected from the consequences (as long as the code runs on a sufficiently new version of Python)".

Based on some of that feedback, Coghlan went ahead and drafted PEP 504 that simplifies earlier proposals. It dispenses with the user-space CSPRNG (e.g. arc4random() or something similar) and changes the default to the system RNG (i.e. random.urandom()). If a program uses random.seed() or the other stateful calls (i.e. getstate() or setstate()), the random module will switch to the existing MT-based deterministic PRNG.

He proposes that this be done for 3.6, with a silent-by-default deprecation warning for the fallback to MT. In 3.7 it would instead be a visible-by-default runtime warning. In his announcement of the PEP, he said: "That approach would provide a definite security improvement over the status quo, while restricting the compatibility break to a performance regression in applications that use the module level API without calling seed(), getstate() or setstate()."

Van Rossum's reaction

But it turns out that Van Rossum is not particularly happy with that PEP as the end result of the discussion. He stopped following the "mega-threads", but doesn't see much value in changing things:

I don’t want to change this API and I don’t want to introduce deprecation warnings – the API is fine, and the warnings will be as ineffective as the warnings in the documentation.

I am fine with adding more secure ways of generating random numbers. But we already have random.SystemRandom(), so there doesn’t seem to be a hurry?

Though Stufft reiterated his belief that the existing module "guides you towards using an  insecure source of random numbers rather than a secure one", Van Rossum was not impressed with that argument:

That feels condescending, as does the assumption that (almost) every naive use of randomness is somehow a security vulnerability. The concept of secure vs. insecure sources of randomness isn't *that* hard to grasp.

The discussion is continuing at the time of this writing, but there is a sense that adding access to a fast user-space PRNG, perhaps based on ChaCha20 (like arc4random()), may be in the offing. A change in the default would leave some users and programs behind eventually, but it would seem that most believe users who require deterministic random numbers make up a small minority. Van Rossum, though, seems unconvinced that there is much urgency for a solution. He suggested adding the new method for 3.6, but waiting "a few releases" to decide if any change to the default was warranted. "Security isn't served well by panicky over-reaction", he said.

There is plenty of time left in the 3.6 development schedule, so perhaps other proposals and ideas will eventually win the day. But with Van Rossum firmly opposed to the changes that have been proposed so far, a big change seems unlikely for 3.6. Only time will tell.


Index entries for this article
SecurityPython
SecurityRandom number generation


to post comments

Python and crypto-strength random numbers by default

Posted Sep 16, 2015 17:38 UTC (Wed) by jtaylor (subscriber, #91739) [Link] (1 responses)

I'm curious, has there ever been a documented issue/exploit/breakin caused by the use of a good-but-not-crypto-good random number generation in the real world?
By good I mean for example a properly seeded MT or similar, not hilariously broken stuff like linear congruential with poor parameters or the Debian ssl key bug.

Python and crypto-strength random numbers by default

Posted Sep 16, 2015 18:49 UTC (Wed) by jimparis (guest, #38647) [Link]

This paper describes reverse-engineering a malicious worm by watching a /8 to see which IPs the worm probed. From there, they determined PRNG state and seeds, and used that to deduce everything from the system uptime and disk count of the infected hosts, to tracking down the "patient zero" computer where the worm started:
http://www.icir.org/vern/papers/witty-imc05.pdf

This paper describes PRNG attacks and has some real-world examples of a many PHP applications with PRNGs that were vulnerable in some form. It seems like the most frequent attack is in things like password reset tokens: request a password reset yourself, check your email and figure out the server's PRNG state, request a password reset for your victim, and use the known PRNG state to predict their token:
https://media.blackhat.com/bh-us-12/Briefings/Argyros/BH_...

This page describes an online betting-type game where the attacker was able to predict results from previous ones:
http://jonasnick.github.io/blog/2015/07/08/exploiting-csg...

These slides describe an attack on WPS that involves figuring out the PRNG state (slide 15):
http://www.slideshare.net/0xcite/offline-bruteforce-attac...

Python and crypto-strength random numbers by default

Posted Sep 16, 2015 20:56 UTC (Wed) by fredrik (subscriber, #232) [Link]

I have no opinion on the core topic but want to object to the argument that people don't read the docs.

As a python novice, my impression is that I spend more time reading documentation for python modules than for other languages. Perhaps because I find the documentation for a lot of modules a pleasure to read. They give a swift introduction, offer relevant examples, mention relevant implementation details, and sometimes suggest other modules that perhaps are better suited to some more tangential use case.

So, perhaps an alternative proposal is to ensure that the documentation for random.random() is very entertaining, so entertaining that it competes with 'from __future__ import braces' et.al.

Python and crypto-strength random numbers by default

Posted Sep 16, 2015 22:51 UTC (Wed) by xorbe (guest, #3165) [Link] (1 responses)

One flavor of Python for the kindergarten classroom. One for professional production.

Python and crypto-strength random numbers by default

Posted Sep 17, 2015 14:42 UTC (Thu) by robbe (guest, #16131) [Link]

The former will not care whether their dice rolls can be predicted with some effort (or is gambling allowed in your local kindergärten?). The latter will read the docs. So let's keep things like they are.

Python and crypto-strength random numbers by default

Posted Sep 17, 2015 8:20 UTC (Thu) by hthoma (subscriber, #4743) [Link] (3 responses)

I don't read the documentation either. But if I see an API that has a seed() function, I strongly assume that subsequent calls to random() are deterministic. Just because if it would not be deterministic, then there is no point in having a seed() function at all, IMHO.

Python and crypto-strength random numbers by default

Posted Sep 17, 2015 13:03 UTC (Thu) by njh (subscriber, #4425) [Link] (2 responses)

The tweak that immediately occurred to me would be to change which RNG algorithm is used, based on whether it is explicitly seeded or not.

The article suggest that the existing MT algorithm is seeded from urandom by default, if no seed value is provided.

Why not return values from the MT algorithm if random.random() is called after an explicit seed has been set, but switch to a newer CSPRNG algorithm if random.random() is called without seeding? That would mean that existing Monte Carlo simulation code (and similar) would continue to give results that matched runs from before the change, but stronger random numbers would be produced by default in cases where reproducibility isn't a concern.

Python and crypto-strength random numbers by default

Posted Sep 17, 2015 19:10 UTC (Thu) by droundy (subscriber, #4559) [Link]

This was precisely my thought. It doesn't require changing the documentation at all, as you still should use the explicitly secure one if you need it, to avoid attacks that rely on a module silently degrading random.random. But it "fixes" the vast majority of the naive code out there.

Python and crypto-strength random numbers by default

Posted Sep 17, 2015 21:21 UTC (Thu) by njs (subscriber, #40338) [Link]

> Why not return values from the MT algorithm if random.random() is called after an explicit seed has been set, but switch to a newer CSPRNG algorithm if random.random() is called without seeding?

AFAICT, the only reason not to (besides the usual one that it would take some work to implement and maintain) is that Guido considers it "a hack" :-(

Python and crypto-strength random numbers by default

Posted Sep 17, 2015 12:12 UTC (Thu) by ianmcc (subscriber, #88379) [Link]

I think its a bad idea to try to make the default RNG cryptographically secure. People who don't know what they're doing will misuse it anyway, and if they're too clueless to read the documentation and learn how to do cryptography properly (which probably involves stepping away from the keyboard and using a pre-existing and known good library instead) then they'll surely make lots of other mistakes (from elementary to subtle) with the cryptography too. Indeed, keeping the standard random number generator not suitable for crypto is a good thing, because its an easy-to-spot marker that indicates that there are likely a whole range of insecurities in the code. Like finding brown M&M's in the bowl. http://www.snopes.com/music/artists/vanhalen.asp

For numerical applications (Monte Carlo) you want deterministic random numbers, but seeded non-deterministically (but with the seed stashed away somewhere, so that you can reproduce the calculation later if necessary).

For a game, it would vary - if its a networked multiplayer game then you may well want it to be deterministic, so that multiple clients can do the same 'dice rolls' and stay in sync. If its an online poker game then you definitely want it to be non-deterministic (but you'd probably get the random numbers from a server somewhere anyway).

In all of these cases you'd want to choose very carefully the random number generator and how its used. No 'default' generator will cover all of these cases. The default generator should only be used for 'throwaway' applications, where you need some randomness but don't care whether its deterministic or secure, as long as it meets some minimum level of quality. And for that, MT is already overkill.

Python and crypto-strength random numbers by default

Posted Sep 17, 2015 14:39 UTC (Thu) by ssam (guest, #46587) [Link] (2 responses)

The default implementation should be
def random():
    return 4
If that does not meet your requirements, then you can select the random generator based on what you need.

Python and crypto-strength random numbers by default

Posted Sep 17, 2015 14:56 UTC (Thu) by corbet (editor, #1) [Link] (1 responses)

Cue the obligatory Dilbert link.

Python and crypto-strength random numbers by default

Posted Sep 17, 2015 23:44 UTC (Thu) by xorbe (guest, #3165) [Link]

No, ob XKCD link

https://xkcd.com/221/

Python and crypto-strength random numbers by default

Posted Sep 18, 2015 15:46 UTC (Fri) by diegor (subscriber, #1967) [Link] (1 responses)

It seems to me, that not even OpenBSD replaced the default random generator with a "high-security" generator:

http://www.rocketaware.com/man/man3/random.3.htm

If we follow the Theo's reasoning, we should expect that random() in standard C library was using arc4random.

So I wonder why Theo suggests that python should do it?

Python and crypto-strength random numbers by default

Posted Sep 18, 2015 22:21 UTC (Fri) by wahern (subscriber, #37304) [Link]

It helps if you read a version of the man page from this decade: http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/ma...

OpenBSD changed the behavior starting with OpenBSD 5.7.

Random vs. Cryptographically random are typically separate

Posted Sep 18, 2015 19:20 UTC (Fri) by david.a.wheeler (subscriber, #72896) [Link] (8 responses)

In many languages, "random" and "cryptographically random" are different.

E.G., in Java, SecureRandom provides a cryptographically strong random number generator (RNG), while Random does not. See: http://docs.oracle.com/javase/7/docs/api/java/security/Se...

Random vs. Cryptographically random are typically separate

Posted Sep 18, 2015 22:36 UTC (Fri) by wahern (subscriber, #37304) [Link] (7 responses)

But many people don't think about security consequences, or if they do they arrive at the wrong conclusion. I think the point here is that by making a CSPRNG the default, you mitigate the impact of sloppy analysis. Of course, attempting to second guess programmers this way is often a bad idea. I understand the push back. But in this case, all things considered, it seems like an easy win.

Theo did his homework before arriving at his decision: "I have spent the last week researching all the uses of the srand(), srandom(), and srand48() subsystems in the ports tree." (https://lwn.net/Articles/625562/). So he had a better idea than most about the potential impact.

Random vs. Cryptographically random are typically separate

Posted Sep 19, 2015 0:14 UTC (Sat) by anselm (subscriber, #2796) [Link] (6 responses)

If people are sloppy about random numbers in their cryptographic code, why would anyone want to assume that they are not just as sloppy about the rest of their cryptographic code? Sure, we can arrange for the RNG to get “upgraded” to fix this, but this may end up being the least of our worries.

Random vs. Cryptographically random are typically separate

Posted Sep 19, 2015 2:51 UTC (Sat) by wahern (subscriber, #37304) [Link] (2 responses)

1) Sometimes people don't realize that their code requires cryptographic resilience. Just look at the examples posted above by jimparis. None of those involve obvious cases like generating cipher keys.

2) Similar to #1, sometimes even if your task doesn't require cryptographic resilience it's still a bad idea to use random, et al. The seeding functions often leak state about your process (see jimparis' first 1st). I never use non-CSPRNGs when the results will leak directly or indirectly (e.g. sorting order) over the network. But most people don't even think about this, even experienced engineers. Leaking your PID, system time, etc, is not smart, particularly when it's trivial to avoid doing so.

3) You could make this argument about anything--we can't do it perfectly, so let's do nothing. In this case it's a trivial solution with minimal costs that could offer much benefit. Reasonable people can disagree, of course. But at the end of the day opinions should give way to empirical data. Theo compiled some empirical data and made a decision. Furthermore, implementing this doesn't preclude taking other measures in other contexts.

Random vs. Cryptographically random are typically separate

Posted Sep 19, 2015 11:12 UTC (Sat) by kleptog (subscriber, #1183) [Link]

There's still the documentation question, I see that the warning about it not being cryptographically secure was added in the 2.7 docs, prior to that you had to read the wall of text to discover that. The default behaviour of random() now if you don't seed it is to read 32 bytes of urandom (if available) and use that as seed. If you're not generating lots of random numbers this should be sufficient. You wouldn't want to generate crypto keys that way, but it's not that bad.

Random vs. Cryptographically random are typically separate

Posted Sep 20, 2015 16:57 UTC (Sun) by apoelstra (subscriber, #75205) [Link]

I have a couple more:

4) Failure modes for RNGs are often undetectable by testing. You can (and should) look for really specific failure modes, like always outputting the same value, but in general if you use a bad RNG the rest of your program's performance and correctness will not be affected in the least. Just security.

5) The output of a bad RNG can stick around forever. If you've got a long-lived private key, if it turns out it was generated poorly then you are screwed, even if this was years ago. (Now that I think about it, I have no recollection of what software or version I used to generate my PGP keys. So in principle any RNG failure in the news could be affecting me.) Combine this with #4 and you have a very dangerous situation indeed.

Compare this to other crypto failure modes, like leaving secure data in memory, timing side-channels, etc., which go away once the software is fixed (or even when the software stops running).

Random vs. Cryptographically random are typically separate

Posted Sep 20, 2015 5:29 UTC (Sun) by njs (subscriber, #40338) [Link] (2 responses)

I've come around to feeling that it's unfair to call programmers "sloppy" because they thought that a function called random.random() would return random numbers. Everyone understands how dice and coin flips work, and that's how random number generators are always taught to new programmers, and if random.random() actually worked the way dice and coin flips worked then it would be safe to use for any purpose :-/.

Obviously you and I know that computer "random numbers" are this weird thing that are almost-like-random but with extremely subtle failures that only matter in certain obscure but high-stakes contexts... but it's not really newbie programmers' fault that they don't automatically know this. (Sure, there's a warning in the docs, but if you don't know to look for it...)

Random vs. Cryptographically random are typically separate

Posted Sep 23, 2015 1:35 UTC (Wed) by dvdeug (guest, #10998) [Link] (1 responses)

Computer "numbers" are these weird things that are almost-like-numbers with fairly non-subtle failure modes in many contexts.* A lot of learning computer programming is learning all these details where things don't work the way one would naively expect them to. If they don't understand that random.random uses a deterministic RNG, then they probably have a lot of other problems in programming.

* E.g. exists a, b, i, j such that (a > 0.0) && (b + a == b) or (i > 0) && (j > 0) && (i + j < 0).

Random vs. Cryptographically random are typically separate

Posted Sep 23, 2015 15:26 UTC (Wed) by apoelstra (subscriber, #75205) [Link]

> If they don't understand that random.random uses a deterministic RNG, then they probably have a lot of other problems in programming.

CSPRNGs are also deterministic. Determinism is not what burns cryptographically-inexperienced programmers.

Python and crypto-strength random numbers by default

Posted Sep 19, 2015 5:51 UTC (Sat) by reubenhwk (guest, #75803) [Link] (4 responses)

Why arc4random? Chacha8 is much more secure and faster.

Python and crypto-strength random numbers by default

Posted Sep 19, 2015 5:54 UTC (Sat) by reubenhwk (guest, #75803) [Link] (3 responses)

Nevermind... Got to the end of the article...

Python and crypto-strength random numbers by default

Posted Sep 24, 2015 14:29 UTC (Thu) by dag- (guest, #30207) [Link] (2 responses)

Do you also wonder why one cannot remove a comment (e.g. if there was no reply to it) ?

Yours is an excellent use-case :-)

Python and crypto-strength random numbers by default

Posted Oct 2, 2015 8:07 UTC (Fri) by marcH (subscriber, #57642) [Link] (1 responses)

Because of dangling replies.

Immutability, good. Side-effects, bad.

Python and crypto-strength random numbers by default

Posted Oct 2, 2015 14:47 UTC (Fri) by nybble41 (subscriber, #55106) [Link]

>> Do you also wonder why one cannot remove a comment (e.g. if there was no reply to it) ?

> Because of dangling replies.

Well, dag- did say "if there was no reply to it", which would address the problem of dangling replies.

Even without that restriction, a simple "this comment has been retracted by the author" placeholder message with a link to the original text would seem to me to be a reasonable compromise.


Copyright © 2015, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds