Search code examples
randomlinux-kernelkernelrandom-seedentropy

How to fill kernel entropy without X and hardware RNG?


I have a tiny embedded device running Linux but with no hardware RNG driver and without X server (no mouse, no keyboard...).

/dev/random

blocks very quickly.

cat /proc/sys/kernel/random/entropy_avail

reports very low numbers (~10).

The system handles a camera so there is a real source of entropy. How can I input entropy into the kernel?


Solution

  • Take a data stream from your camera, hash it using something decent like BLAKE2b or SHA2, then feed it into /dev/random.

    Once the entropy count is >=256 you are good to go.

    From then only read from /dev/urandom/.

    /dev/urandom will happily spew out cryptographically secure pseudorandom data suitable for key material once the system has 256 bits of entropy available.

    Running out of entropy after you've collected this amount is a myth. Use /dev/urandom, really, it's perfectly fine.