AMD's random number generator can't generate a 0
AMD's random number generator can't generate a 0?

A programmer discovered that AMD processors' RDRAND and RDSEED instructions never produce a zero at the requested bit width, while Intel chips do. He built a test app to visualize the anomaly, reported it to AMD, and got a reply that seemed AI-generated. The thread also debates hardware RNG trust and benchmarks performance across CPUs.
I hope this is not something stupid from AMD that decided zero is not a random number. Maybe some C?O person executed RDRAND, got zero, declared it was broken and made the engineers "fix" it.
- jstanley
This is not the first RNG bug on Zen 2, I recall after I first got mine that some application or other would quit immediately at startup because rdrand always returned -1, i.e. all 1s. It was fixed with a microcode update.
Do we now learn that they fixed "always generate all 1s" with "never generate all 0s"??
EDIT: I've been unable to reproduce the problem on my CPU, FWIW. It's a Ryzen 5 3600.
EDIT2: OK, update, I can reproduce it with rdrand16, rdrand32 is fine but rdrand16 can never generate all 0s. So my CPU does have this problem!
- strenholme
This is why I use, in security critical contents of my software (where the numbers have to be computationally infeasible to produce), a type of random number generator called an XOF (extendable-output function).
It takes entropy from multiple different sources, makes it all input to the XOF, then the XOF uses cryptography to output a stream that has as much entropy as the combined entropy of all of its sources of randomness. So if an XOF, for example, takes 100 runs of rdrand16, along with the system time in microseconds and the number of milliseconds between receiving 100 packets over the network, the XOF will output a completely random stream without artifacts like never returning 0x0000, even if rdrand16 never outputs 0x0000.
- 349ru3h4f03
https://www.amd.com/en/resources/product-security/bulletin/a...
- CodesInChaos
Embarrassing, but probably little practical impact, since these hardware random numbers are typically not used directly and instead seed a CSPRNG.
- matja
I'm getting 16-bit zeros on my Zen 3 chip (+1:3821, 0:3893, -1:3895), I will wait to get some statistically significant samples for the 32-bit values and update the forum thread. Maybe it was fixed after Zen 2?
- 20k
I always wonder how hardware bugs like this happen with the sheer amount of hardware validation that's done. It'd be fascinating to know how it slipped through the cracks, though I know almost nothing about this side of the industry sadly
- fred_is_fred
"Maybe some C?O person executed RDRAND"
is an amusingly gross misunderstanding of what a C?O person does on a daily basis.
- hnacobsxph
Chased a similar bug in a KDF once and only caught it by histogramming the 16 bit draws, statistical suites never flagged it.