Let's say I'm naive and want to generate a random integer in the range
[0, m), so I do the following:
k = cryptographically_secure_rng() % m
cryptographically_secure_rng returns a random integer in the range
m <= n.
Now in general
k isn't distributed uniformly anymore.
It seems to me that for any reasonably nontrivial value of
n, this can't possibly cut the attacker's time by more than half -- and in general, it would seem to cut it by a much smaller fraction.
Yet my impression from security/crypto is that such a naive RNG would be catastrophic for the security of the system.
So my question is:
How bad is this from the standpoint of an attacker trying to attack a system by exploiting this function?
Could such a bias be abused and amplified (e.g. exponentially) to attack a system?
If so, in what kind of a system might this occur, and how?
If not, then is the problem worth worrying about, and why?