Conversation

Oh my. Apparently, AMD CPUs will sometimes return bad results from RDRAND after a suspend. That's bad, but if everyone has been following the cryptographer's advice and _just used getrandom()_ that's not a problem. ... nope! systemd of course didn't!
16
581
Replying to
I think you're misreading the source here. Systemd _does_ call getrandom() if the syscall is available + adds an RDRAND seed on top (if explicitly enabled) and only pads with pseudorandom bytes if getrandom() returns EGAIN (no entropy)
2
1
Replying to and
That kind of over-thinking is what leads to the code this thread is about. I'm sure you don't consider HASH(time, HWID, bit flip) *sufficient*, but some systemd developer will in the EAGAIN branch. The message must be "just use getrandom or urandom", which *is* sufficient.
2
13
I agree most of the time one probably isn't going to do better than `getrandom()`. I think this advice would be more complete if getrandom had a more complete interface to control prediction resistance and to incorporate additional data (e.g. for ECDSA nonces).
1
In my experience, users end up wanting to use the crypto library w/o an OS-provided CSPRNG. This, combined with the limited interface of `getrandom()` does encourage use of an userspace one still. OTOH, `getrandom()` impl is fast on recent kernels, though that's a trade-off.
1
One way to do that is a ChaCha implementation seeded from it (and reseeded on fork if applicable) and optionally reseeded at some interval. An example is the OpenBSD arc4random, but that's a global CSPRNG with a lock around it rather than thread-local. Often not fast enough.
1
RDRAND actually has lower throughput than getrandom anywhere that I've tested, but making a system call to getrandom is quite expensive and that dwarfs the costs. In theory, a proper RDRAND would be useful because CSPRNG state isn't in the address space. In practice, it sucks.
1
Show replies