Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do PRNG need to be thread safe?

As long as concurrent calls don't cause seg-v's or return the same value, what reasons are there for preventing race conditions and data corruption in PRNGs when those error's primary effects are unpredictable results and that is the point of a PRNG?


Edit: are there any PRNG that wouldn't suffer under race conditions and data corruption?

like image 311
BCS Avatar asked Jan 23 '23 19:01

BCS


2 Answers

when those error's primary effects are unpredictable results and that is the point of a PRNG?

"Random" is not the same as unpredictable - Random implies a certain distribution that is very important to maintain should you want real random numbers. If your random numbers are predictable in any way it can be a security issue, or at least a program bug

like image 130
Ana Betts Avatar answered Jan 26 '23 08:01

Ana Betts


PRNGs are meticulously constructed tools -- frankly, if race conditions and threading bugs were a good PRNG, the implementation would be written that way.

The problem with adding threading bugs to increase randomness is that it's an unstudied change to the generator. Existing secure algorithms and implementations have been exhaustively tested; if you want to try an unsafe variant, you'll need to do the statistical grunt work to show that it's at least as random as a normal PRNG.

like image 41
ojrac Avatar answered Jan 26 '23 07:01

ojrac