seedrng seeds the Linux kernel random number generator from stored
seed files.
This distribution is a fork of Jason A. Donenfeld's SeedRNG at commit
f68fee4 (Wed Apr 20 2022), with the following changes:
- Added musl libc compatibility
- Manual page for
seedrng(8)inscdoc(5)format - Path definitions moved into
pathnames.h - Added code documentation and technical notes
See the git log for full history.
Original sources:
- git://git.zx2c4.com/seedrng (git)
- https://git.zx2c4.com/seedrng (web)
- C99 compiler
- POSIX
sh(1p),make(1p), and "mandatory utilities" - Linux kernel headers (optional when building with musl)
scdoc(1)to generate manual pages
- Linux kernel with
/dev/randomand/dev/urandomavailable
seedrng is designed for integration with init systems.
It should not be run manually as a standalone tool.
To build and install:
make
make install # as rootConfiguration parameters are defined in config.mk.
Default file paths are specified in pathnames.h.
Run as root (normally via init/shutdown scripts):
seedrngSee seedrng.8.scdoc manual page.
To ensure that the entropy in the seed files either stays the same or
increases over time, seedrng employs the BLAKE2s cryptographic
hash function (with a 32-byte output) when creating new seed files.
The process involves hashing the following data:
HASH( "SeedRNG v1 Old+New Prefix"
|| current_real_time
|| system_boot_time
|| length_of_old_seed
|| old_seed_content
|| length_of_new_seed_data
|| new_seed_data
)
The resulting 32-byte hash is then appended to the newly generated
random data to form the complete new seed. Specifically, if
new_seed represents the newly generated random data of a certain
length, the final new seed stored to disk is constructed as:
final_new_seed = new_seed[:-32] || BLAKE2s_HASH(...)
Where:
||denotes concatenation.BLAKE2s_HASH(...)represents the 32-byte BLAKE2s hash of the concatenated data described above.new_seed[:-32]represents the initial portion of the newly generated random data, with the last 32 bytes reserved for the hash.
This design ensures that the new seed incorporates information about the previous seed, the current system time, the boot time, and the newly generated random data itself, enhancing its robustness and preventing entropy loss.
The absolute file paths used by seedrng for storing the creditable
seed (seed.credit) and the non-creditable seed (seed.no-credit)
are defined as constants in the pathnames.h header file.
The default location for these files is within the /var/lib/seedrng/
directory.
seedrng may be used under any of the following licenses:
- GPL-2.0
- Apache-2.0
- MIT
- BSD-1-Clause
- CC0-1.0