Re:“RNG broken for last 4 months”
by jackweirdy on Tuesday February 17, 2015 @01:51PM
(#9064186)
I’m curious about that too. How could you unit/regression test `rand`?
[ Parent
| on HN ]
Statistic testing seems like it ought to work. However, I believe there's also the issue of actual uses of the RNG; it's not enough to test the kernel implementation, one must also test that libraries are using the implementation correctly (i.e. not using constant or completely-predictable seed), etc.
So it's not a trivial problem, because (among other reasons) nondeterministic, statistical testing is not well-understood in the testing culture.
Re:“RNG broken for last 4 months”
by tedunangst on Tuesday February 17, 2015 @07:03PM
(#9066105)
Further complication: many RNGs will produce output as a function of their seed state (e.g., rc4 or chacha20). That output will look really good, even with weak seeds. You'll have a hard time detecting that two chacha20 streams were seeded with gettimeofday() for instance, unless you happen to check the exact time used.
You use statistics.
For example, take the birthday paradox problem and check if the collisions are higher than expected.
Re:“RNG broken for last 4 months”
by tedunangst on Tuesday February 17, 2015 @07:01PM
(#9066091)
eh, I'm not sure that works. A random number generator of "return number++" will pass your birthday test.
I just gave an example. I never intended to say you just need this sole solution.
It's also a good lead for a further search query on the topic. Almost all test sets include a birthday test ;) For example this page: https://sites.google.com/site/astudyofentropy/background-inf...
assert(rand() != dummy_random_read_phony())
Re:“RNG broken for last 4 months”
by tedunangst on Tuesday February 17, 2015 @05:49PM
(#9065688)
If dummy_random_read_phony() is rand(), that test will always pass. Almost every implementation of rand() will never return the same result in a row.