I know about key derivation functions such as PBKDF2 which derive keys from passwords.

That said, I am having hard time wrapping my mind around how AES-256 keys are generated using hardware random number generators.

From Wikipedia:

In computing, a hardware random number generator (HRNG) or true random number generator (TRNG) is a device that generates random numbers from a physical process, rather than by means of an algorithm.

How do we go from these “numbers“ to a key such as the following?

10110100 01010001 10011110 10001001 10001011 10001100 10100011 10001101 00100000 00001110 00000010 01000111 01010010 11111000 10111010 01001011 01001111 00100110 10001110 11101000 01110100 11010000 10101111 11110010 01101010 11110101 01011010 00000101 10011001 00011011 01110101 00001101

In the context of brute forcing AES-256 keys (which is impossible to my knowledge), what would one iterate through?

  • I'm not sure what your problem is. A hardware random generator returns a sequence of random bits (ok, typically 8 bits are returned to the application at once, i.e. a byte). One just reads as much bits as needed to build the key, i.e. 256 bits (32 byte) for AES 256. This can be simplified by calling function like getrandom which fill a buffer of a given size with random data. Commented Aug 11, 2021 at 19:50
  • Thanks @SteffenUllrich. So why is it called a random number generator and not a random bits generator? Trying to better understand the relationship between numbers and keys. Likely naive questions, but somehow I am having a hard time deeply understanding these concepts.
    – sunknudsen
    Commented Aug 11, 2021 at 19:52
  • 2
    @sunknudsen A bit is just a number in base 2.
    – user
    Commented Aug 11, 2021 at 19:57
  • 2
    @sunknudsen: A RNG produces a sequence of bits. Each sequence of bits can be interpreted as a number and that's what many want mathematicians usually work with and hence probably the name. But it can also just be treated as random data, like part of an image, a random pattern ... Never though that the term could be confusing and never thought too much about that "number" part, but looks like it actually can be interpreted in a very narrow sense. Commented Aug 11, 2021 at 20:03

1 Answer 1


Almost all random number generators, whether software or hardware, end up producing blocks of bits. For software, this is because it is wildly inefficient to produce single bits, and so algorithms generally produce large numbers of bits at once.

For hardware, this is because the hardware used is often imperfect and may have a slight bias, or it could end up being broken altogether and descend into either a large bias or just a single output. As a result, a hardware RNG will contain code to process blocks of bits, perform statistical tests on them to determine if they are likely to be the result of a large bias or a malfunction, and if they pass the tests, run them through some sort of conditioning algorithm which condenses a large number of bits into a smaller number of less biased bits. This can be done using something like AES with CBC mode, a hash function, or simpler approaches, like Von Neumann debiasing.

In any event, using any sort of RNG to generate a symmetric key like for AES-256, the bits or bytes are produced by the RNG, and then the proper amount (in this case, 256 bits or 32 bytes) are taken and used for the key. It really doesn't matter whether we prefer to write the RNG output or the key as individual bits, as bytes, or as larger numbers, provided we agree on the bit and byte ordering to be used. Thus, the word "number" is only used in the most generic sense as meaning some integral quality in some base we'd like to use.

Another term for a cryptographically secure pseudorandom number generator (CSPRNG) is a DRBG (a deterministic random bit generator). The latter is less commonly used, but it is notably used for several designs specified by NIST. In fact, the CTR DRBG is used in Intel chips for the RDRAND and RDSEED instructions. A hardware RNG is used to generate a set of bits, which are then tested and debiased, and those bits are then used to seed a CTR DRBG instance in hardware. But either way, the two terms are mostly equivalent.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .