man(7)
π rdrand-gen β man(7)
okay bestie, so this is the man(7) page for rdrand-gen, and it's giving "I asked my CPU for random numbers and it actually delivered." Intel's hardware RNG, straight off the silicon. Let's get into it π
β¨ NAME β¨
rdrand-gen β generate randomness by using RdRand on Intel's CPUs. no cap, that's literally the whole job π²
πΈ SYNOPSIS πΈ
rdrand-gen [--amount NUM] [--method NAME] [--output FILE]
[--threads NUM] [--aes-ctr [--aes-keys FILE]] [--verbose] [--version]
[--help]
π¦ DESCRIPTION π¦
RdRand is an instruction that hands you random numbers from an Intel on-chip hardware random number generator. It's available on Ivy Bridge and later processors, so if your CPU is ancient, sorry bestie, no dice.
The way it works is cascade construction β a HW RNG running at 3Gbps combined with a CSPRNG, with every single component sealed up on the CPU itself. The entropy source is a metastable circuit whose behavior is unpredictable and based on thermal noise π‘οΈβ¨. That entropy gets fed into a 3:1 compression ratio entropy extractor (aka a whitener) based on AES-CBC-MAC. Online statistical tests run right at this stage, and only the high quality random data makes it through as the seed for a cryptographically secure SP800-90 AES-CTR DRBG compliant PRNG. This generator produces a maximum of 512 128-bit AES blocks before it gets reseeded. According to the documentation, 512 blocks is the upper limit for a reseed β but in practice it reseeds much more frequently. lowkey overachiever behavior.
ngl, even though the statistical tests didn't reveal any flaws in RdRand's output, its internal operation cannot be verified β and there's a possibility for a backdoor to be built into it. π¨ Not saying it's there. Just saying nobody can check. iykyk.
So rdrand-gen is a simple application for generating randomness on Intel's CPUs (Ivy Bridge and newer) using the HW RNG on the CPU. It can generate using three methods:
- Default,
get_bytesβ the fastest one. On a laptop with a Core i7, about 200 MiB/s in one thread. It simply pulls randomness out of the HW RNG. β‘ reseed_delayandreseed_skipβ the two slow but more secure methods. Both of these enforce a full regeneration of the CPU's pool before each single value that gets pushed out. π
Here's the tea on those two:
reseed_delayputs in small delays of 20 microseconds β long enough to let the HW reseed RdRand's internal generator with new thermal-noise-based entropy, so two consequent values returned byreseed_delayare guaranteed to be produced with a different seed. π§reseed_skiptakes one of 1025 64bit values (that's the size of the inner pool) and throws away the rest, which forces the HW to reseed. ποΈ
The performance of these reseeding methods is about 1/1000 of the default one. And it differs on every machine β on one machine reseed_skip is faster than reseed_delay, while on another one it can be the other way around. vibe check your own hardware, fr fr.
If aes-ctr is set, then the output of the RdRand instruction is encrypted with AES-CTR from OpenSSL. It can either use a random key, or you can hand it a set of keys and nonces to use via the aes-keys parameter. If AES isn't enabled by that first flag, the keys are ignored. π«π
π the key file syntax, bestie π
On each line is a hexadecimal string containing a key and a nonce. There can be 128 lines at max. The length of a single key is twice that of the nonce, so if K stands for a key character and N for a nonce, a single line in the key file will look like the following:
KKKKNN
24 bytes (48 characters) for a key and a nonce represents a 128bit key. This is also the only currently supported length of the key. π See Examples for a simple way of generating the key file.
π OPTIONS π
--help,-hβ print this help. π«Ά--amount,-n NUMβ generate the given amount of bytes. Suffixes:K,M,G,T. Without the option, or when it's0, generate an unlimited amount. βΎοΈ--method,-m NAMEβ use methodNAME(default isget_bytes, the others arereseed_skipandreseed_delay).--output,-o FILEβ save the generated data to the file. πΎ--threads,-t NUMβ run the generator inNUMthreads (default 2).--aes-ctr,-aβ encrypt the output with AES-CTR. π--aes-keys,-k FILEβ use the given key file for the AES encryption instead of a random one. Works only when-ais set.--verbose,-vβ be verbose (it will print onstderr).--version,-Vβ print version.
heads up: the AES keys in the file for the -k argument have to be 24 bytes long in hexadecimal form.
π EXAMPLES π
Write 10.5MB of random data to the file /tmp/random π
rdrand-gen -n 10.5M -o /tmp/random
Generate 20 random passwords of length 20 built from all letters and digits. Use the secure get_uint64_array_reseed_skip method.
(rdrand-gen -n2k -m reseed_skip | tr -cd '[:alnum:]' | fold -w 20 &&
echo ) | head -20
Create a GPG encrypted keyfile for aespipe.
Encrypt:
tar -cvf - files... | bzip2 | aespipe -w 10 -K keyfile.gpg >archive.aes
Decrypt:
aespipe -d -K keyfile.gpg < /tmp/archive.aes | bzip2 -d -q | tar -tvf -
rdrand-gen -n3705 -m reseed_skip | uuencode -m - | head -n 66 | tail -n
65 | \
gpg --symmetric -a > keyfile.gpg
Test the randomness of the generated data with the dieharder test suite π₯
rdrand-gen | dieharder -g 200 -a
Test the randomness of the generated data with PractRand
rdrand-gen | practrand-RNG_test stdin8 -tlmax 4G
Measure the speed of generation.
rdrand-gen | pv > /dev/null
Create a key file for AES encryption
head -n 3100 /dev/random | xxd -p -c 24 | head -n 129 | tail -n 128 >
keys.txt
Create the keys and pass them to rdrand-gen without saving the keys on disk (iconic, honestly π)
rdrand-gen -a -k <(head -n 3100 /dev/random | \
xxd -p -c 24 | head -n 129 | tail -n 128)
β SEE ALSO β
librdrand(3) librdrand-aes(3)
π BUGS π
No known bugs. (not me being shocked β we love a clean record πβ¨)
π AUTHOR π
Jan Tulak (jan@tulak.me) and Jiri Hladky (hladky.jiri@gmail.com) β absolute legends for building this π«Ά
okay that's the whole page, and yes we ate π this is version 1.2, dated 24 April 2014, and it's the rdrand-gen man page. go forth and generate, bestie πΈπ¦
π¦ where this page comes from
- epel 10: RdRand 2.1.6-1.el10_1 Β· LGPL-2.0-or-later
- epel 9: RdRand 2.1.4-1.el9 Β· LGPLv2+
- fedora 43: RdRand 2.1.6-4.fc43 Β· LGPL-2.0-or-later
- fedora 43: RdRand 2.1.6-4.fc43 Β· LGPL-2.0-or-later
- fedora 44: RdRand 2.1.6-6.fc44 Β· LGPL-2.0-or-later
- fedora 44: RdRand 2.1.6-6.fc44 Β· LGPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms