Live data from Hacker News

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

news.ycombinator.com

1–10 of 18 posts

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

#1
Hi

I could not find any definitive material about this topic, but when is it safe to use weak random number generators?

I would say:

  * Generating random passwords - no
  * Generating salt - no
  * Jitter in a Retry Strategy - yes
Anything else?

What rules can we apply here?

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

#2
State your use-case?

"Strong" and "weak" is a sliding scale between indifference and tin-foil paranoia. Plenty of low-end embedded devices have questionable rng's but it's enough for them to make tls requests.

In many modern cryptosystems keys are ephemeral, there's a relatively small window to exploit weak rng's knowing the full state of the system. Long-lived keys are a different story, especially those generated soon after booting.

> Generating salt - no

A salt can be an incrementing number that is publicly known, they are not required to be secret. Using email as a salt is perfectly fine and poses no risk.

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

#3
When there is nothing to be gained from guessing the random number (to the point where you could just hardcode it, then it is safe to use a weak random number generator. Examples would be randomizing background images in a website header or picking a random quote of the day from a list.

If there is a benefit to guessing the random number, then use a secure random number generator. Anything related to passwords, private keys, or anything you expect to be reasonably hard to guess, use a secure number generator.

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

#5
post #3

When there is nothing to be gained from guessing the random number (to the point where you could just hardcode it, then it is safe to use a weak random number generator. Examples would be randomizing background images in a website header or picking a random quote of the day from a list. If there is a benefit to guessing the random number, then use a secure random number generator. Anything related to passwords, priva…

Weak generators can also cause trouble in non-security-related applications. Monte Carlo simulations or integrations run with generators that don't truly randomly sample with respect to the underlying structure of the problem can go quite badly wrong. This usually requires a truly awful generator, but you'd be surprised what can happen. These days there is really no excuse to use anything worse than the Mersenne Twister for mathematical uses.

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

#6
post #4

Noise generation, fuzzing, map/terrain or procedural generation in games, etc where you need randomness and someone replicating the same sequence isn't a threat

Reminds me of how people on the scicraft minecraft server manipulated RNG to get lightning to strike the same spot every game tick. But yeah not really a threat

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

#7
post #3

When there is nothing to be gained from guessing the random number (to the point where you could just hardcode it, then it is safe to use a weak random number generator. Examples would be randomizing background images in a website header or picking a random quote of the day from a list. If there is a benefit to guessing the random number, then use a secure random number generator. Anything related to passwords, priva…

Weak generators can also cause trouble in non-security-related applications. Monte Carlo simulations or integrations run with generators that don't truly randomly sample with respect to the underlying structure of the problem can go quite badly wrong. This usually requires a truly awful generator, but you'd be surprised what can happen. These days there is really no excuse to use anything worse than the Mersenne Twis…

I think what you're talking about would be random numbers with a poor distribution, which is important to distinguish from random numbers with poor unpredictability.

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

#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.
Post reply on HN