# How are AES-256 keys generated using hardware random number generator?

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. Aug 11 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. Aug 11 at 19:52
• @sunknudsen A bit is just a number in base 2.
– user
Aug 11 at 19:57
• @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. Aug 11 at 20:03

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.