News for hackers. Stuff that matters.
Re:Pseudo-Random vs. True Random (2012) by tptacek on Wednesday July 15, 2020 @12:11AM (#23841237)
For security, you don't care whether random numbers are "truly random" or not; you care whether they're cryptographically secure. Your mental model should be of a stream cipher, which is a tool that stretches a short secret into a very long secret. The question you should ask yourself is, "have I fed this generator 16-32 bytes of unguessable material, and does it use cryptographically sound tools to spool out random bytes from that seed?"

Your kernel arranges to do this for you, and, for security-sensitive applications, is the RNG you should use to the exclusion of all others, "true" or not.

Re:Pseudo-Random vs. True Random (2012) by tialaramex on Wednesday July 15, 2020 @01:38AM (#23841732)
I feel like the question you've suggested people ask themselves is a bit over-complicated. Maybe the right way to phrase the question is instead just:

Can somebody else guess these numbers?

It doesn't actually matter whether bad guys can guess your numbers because you use Python's non-cryptographic PRNG or because you mistakenly overwrote the genuinely random numbers you had with zeroes, or they've planted a physical device inside your computer stealing the random numbers used, it only matters that they can guess the numbers.

Re:Pseudo-Random vs. True Random (2012) by ChrisSD on Wednesday July 15, 2020 @01:59AM (#23841841)
Put more simply: It's the unpredictability of the output that's important.

It doesn't matter if it's "true" randomness or not. Unless of course you're looking to leverage the theoretical strengths of a one time pad.

Re:Pseudo-Random vs. True Random (2012) by SAI_Peregrinus on Wednesday July 15, 2020 @09:36AM (#23844993)
It's also quite possible there is no such thing as "true" randomness. If one of the deterministic interpretations of quantum mechanics is correct and there's no other source of randomness in the laws of physics, then TRNGs are just looking at the output of chaotic systems, just like PRNGs are.

Random.org's atmospheric noise source isn't even quantum-mechanical, it's classical deterministic chaos. It's a PRNG with an enormous state.

Re:Pseudo-Random vs. True Random (2012) by tialaramex on Wednesday July 15, 2020 @05:49PM (#23852480)
One of the unknown corner cases in this space is that it implies hidden state. We've ruled out Local Hidden State with physics experiments, but you can't rule out Global Hidden State that way. There could be in this sense say, a 1MB global "random seed" for our universe.

In this model you can build Quantum Computers but when you build a really big one to, for example, attack traditional public key cryptography with Shor's algorithm it mysteriously doesn't work. This is because without you knowing it your Quantum Computer is using the global hidden state as scratch storage and it ran out.

Almost everything about this scenario is terrible news, but on the bright side you can't attack modern cryptography with a Quantum Computer because it won't work.

Re:Pseudo-Random vs. True Random (2012) by irjustin on Wednesday July 15, 2020 @09:02PM (#23854521)
I'm not sure why you're being downvoted. It's not an unreasonable question/thought.

The heisenberg uncertainty principle says we cannot know both position and momentum perfectly at the same time where I believe your comment is originating from?

In theory, if we perfectly know the quantum information then a system's state is perfectly reproducible (probably not us... ultra aliens?) since no quantum information is ever lost (probably...). To my best understanding, this is the idea of the holographic principle[0].

[0] https://www.youtube.com/watch?v=klpDHn8viX8

Re:Pseudo-Random vs. True Random (2012) by SAI_Peregrinus on Thursday July 16, 2020 @08:38AM (#23858346)
No, just interpretations of QM, Heisenberg doesn't change anything here.

Wikipedia has a nice table[0]. Any deterministic interpretation says that the results of experiment are all entirely predetermined by the entire past history of the universe. This includes Heisenberg's principle, since what you choose to measure is also deterministic, and thus the imprecision is predetermined.

There's nothing in the laws of physics that rules out these interpretations. Thus, we can't definitively say that TRNGs exist in this universe. We also can't say that they don't, of course, since all the interpretations of QM make the same observable predictions and thus are equally likely to be correct.

[0]https://en.wikipedia.org/wiki/Interpretations_of_quantum_mec...

Re:Pseudo-Random vs. True Random (2012) by crmrc114 on Monday July 13, 2020 @02:14PM (#23823770)
I was wondering how I would quickly check the randomness of a RNG. When I noticed a couple websites had randomly generated bmps. I guess with the human brain being an awesome visual pattern detector this is a quick and easy test. Anyhow I stumbled on this page from 2012 and figured I would share.
Re:Pseudo-Random vs. True Random (2012) by merricksb on Tuesday July 14, 2020 @09:59AM (#23832023)
If interested, see this past HN discussion from time of publication:

https://news.ycombinator.com/item?id=5850067

Re:Pseudo-Random vs. True Random (2012) by McGlockenshire on Wednesday July 15, 2020 @02:29AM (#23842003)
FWIW, the information in this article is out of date.

For example, as the article picks on PHP, PHP now uses the Mersenne Twister for regular rand(), and gives access to a CSPRNG through random_int() and random_bytes(). By "now" here I mean as of five years ago.

It's still important for developers to understand the "P" in PRNG, but at least we have less possible foot-shooting by default in PHP now. (Evergreen statement!)

Re:Pseudo-Random vs. True Random (2012) by ggm on Wednesday July 15, 2020 @12:56AM (#23841488)
How many gates would it cost, to include the various quantum like random sources as hardware on-die?

Open gate transistors, thermal effects, radiative effects...

(Not that there are not risks, and it is a mistake to assume on-die is not risky)

Re:Pseudo-Random vs. True Random (2012) by jesboat on Wednesday July 15, 2020 @01:05AM (#23841548)
They already do. http://en.wikipedia.org/wiki/RdRand has been around on x86 for a while.

Unfortunately, they're essentially unauditable and sometimes frightfully broken, eg https://arstechnica.com/gadgets/2019/10/how-a-months-old-amd...

Fun times

Re:Pseudo-Random vs. True Random (2012) by ggm on Wednesday July 15, 2020 @01:13AM (#23841595)
So Linus is fine with it, and FreeBSD fed it into yarrow/fortuna which is the kernel boot time initialized entropy pool.
Re:Pseudo-Random vs. True Random (2012) by ChrisSD on Wednesday July 15, 2020 @01:52AM (#23841805)
Putting it into a pool is fine. It can be XORed with other sources.

And if at boot time there's no stored entropy and no other sources, then it's better than nothing until more sources become available.

Re:Pseudo-Random vs. True Random (2012) by hellofunk on Wednesday July 15, 2020 @06:40AM (#23843414)
There are many applications for which you definitely do not want a true random number. Sometimes you want your random numbers to exist in a uniform distribution, for example.
Re:Pseudo-Random vs. True Random (2012) by gopiandcode on Wednesday July 15, 2020 @06:53AM (#23843505)
This is incorrect.

True random (vs pseudo-random) relates to whether the past outcomes of the generator provide any information about the future invocations. There is nothing stating that a true random generator can not conform to some distribution

There are cases where you might not want a true random generator, although this relates more to the importance of unpredictability versus the performance requirements for your domain.

Re:Pseudo-Random vs. True Random (2012) by Spivak on Wednesday July 15, 2020 @10:19AM (#23845544)
Or maybe a more succinct way of putting it. You can sample random numbers from any distribution. There's nothing special about the uniform distribution except that it's one that people want most of the time.
Re:Pseudo-Random vs. True Random (2012) by 082349872349872 on Wednesday July 15, 2020 @01:52AM (#23841803)
On the other hand, if one is chipping for spread spectrum, a PRNG is much more useful than a TRNG.
Re:Pseudo-Random vs. True Random (2012) by greencar on Wednesday July 15, 2020 @11:27AM (#23846613)
If you cross your eyes a little the second one shows a schooner
Re:Pseudo-Random vs. True Random (2012) by andyljones on Wednesday July 15, 2020 @02:43AM (#23842061)
The link at the bottom of the post to the actual explanation is broken. Here's a web archive version:

https://web.archive.org/web/20191106104440/http://cod.ifies....

TL;DR the default Windows random number generator is (was?) an LCG[1], and that's what PHP calls into by default.

[1] https://en.wikipedia.org/wiki/Linear_congruential_generator

Re:Pseudo-Random vs. True Random (2012) by acqq on Wednesday July 15, 2020 @03:18AM (#23842236)
I'd expect it's fixed since PHP 7.1.0:

https://www.php.net/manual/en/function.rand.php

"Note: As of PHP 7.1.0, rand() uses the same random number generator as mt_rand(). To preserve backwards compatibility rand() allows max to be smaller than min as opposed to returning FALSE as mt_rand()."

Maybe somebody could run the code from the OP on Windows with a newer PHP and check?