Live data from Hacker News

Ask HN: When it is safe to use weak random number generators?

news.ycombinator.com

11–18 of 18 posts

Re: Ask HN: When it is safe to use weak random number generators?

#11
post #10

Erasing a hard disc (i.e. spinning rust, not solid state ones) before retiring it is a proper use case. Linux/Unix example: dd if=/dev/urandom bs=8mb of=/dev/sda Note: this is a trivial example, which could be optimized in various ways, e.g. by generating one 8mb file of randomness and reusing that, especially if your urandom is slow.

Data recovery on overwritten hard drives haven't been feasible since the 90s. A zero-wipe is sufficient!

2008 paper [PDF]: https://www.researchgate.net/profile/Craig-Wright-6/publicat...

Re: Ask HN: When it is safe to use weak random number generators?

#12
post #10

Erasing a hard disc (i.e. spinning rust, not solid state ones) before retiring it is a proper use case. Linux/Unix example: dd if=/dev/urandom bs=8mb of=/dev/sda Note: this is a trivial example, which could be optimized in various ways, e.g. by generating one 8mb file of randomness and reusing that, especially if your urandom is slow.

Data recovery on overwritten hard drives haven't been feasible since the 90s. A zero-wipe is sufficient! 2008 paper [PDF]: https://www.researchgate.net/profile/Craig-Wright-6/publicat...

Thanks, I always thought that these 7-pass DoD methods must be an insane overkill.

Re: Ask HN: When it is safe to use weak random number generators?

#15
Frankly, if you have to ask, just use a (system) CSPRNG.

People massively overblow the impact of the speed difference for most scenarios. Yes, A simulation running on a large scale etc. will probably need a statistically good RNG w/o any security properties but (say) a game generating a seed occasionally will not be bottlenecked by using a CSPRNG. I would say it is worth it just to not have any mental load and slightest change of misuse.

Also, if the salt part is for salting and hashing passwords, forget about the whole idea and use a proper password hash be it Argon2id, scrypt, PBKDF2, whatever. It doesn't really matter which one and ideally a library should have chosen one of the algorithms with good parameters and nonce generation.

(I know Argon2 calls its nonce a salt too but that is irrelevant. It should come from a CSPRNG)

Re: Ask HN: When it is safe to use weak random number generators?

#16
There's no hard, fast rule for when a weak PRNG is bad except in the obvious use cases - salts, etc. There's no reason you can't use a weak random number generator for generating a password. It only becomes a problem when you have a bunch of passwords, stored in the same place, generated with a weak PRNG, AND the adversary knows the PRNG and how they were generated.

It really comes down to threat surface and likelihood of attack. CSPRNGs are cheap enough to run that you can just use one all the time these days with no loss. The problem is the esoteric math they rely on means that you're giving up some control of your threat surface (unless you understand cryptanalysis with modern crypto). So generally, you can just always use a CSPRNG due to cheap execution time, with the understanding you then become vulnerable to attacks like the ECC attack where adversarial mathematicians know more than you about your own security.

Re: Ask HN: When it is safe to use weak random number generators?

#17
It basically boils down to one question:

What are the ramifications of a malicious user being able to predict the RNG results with 100% accuracy?

For generating passwords and encryption keys, obviously predicting RNG is Game Over. For choosing random colors to put on a graph, it's meaningless.

Re: Ask HN: When it is safe to use weak random number generators?

#18
post #8

In video games (and anywhere else where speed matters but quality doesn't). https://doom.fandom.com/wiki/Pseudorandom_number_generator

Unless the video game is poker, in which case it does matter.

https://www.datamation.com/applications/how-to-cheat-at-onli...

Post reply on HN