‹ BackHN Continuity

Thread

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

288 points · 220 comments · BruceEel

  1. strenholme · · focus · HN ↗
    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.

    1. stingraycharles · · focus · HN ↗
      Isn’t this effectively what systems like /dev/(u)rand do? Pool multiple random sources together to hedge against these things?

      I fail to see why one should either rely on a single random source nor roll their own.

      1. sltkr · · focus · HN ↗
        Yes, on any modern system you should use the kernel provided random number sources.

        The only legitimate reason to roll your own is when you're developing for an embedded system or a bootloader or something like that where there is no kernel API available.

        1. strenholme · · focus · HN ↗
          The code I wrote has been used by embedded developers in embedded spaces; I remember getting a bug report from someone in China because they used my code in an embedded system before the timestamp was correctly set on said system.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.