random: Initialise the kernel's PRNG earlier

Since more processes depend on good randomness, we need to
make sure that the kernel's PRNG is initialized as early as
possible.

For systems without a HWRNG, we will need to fall back to our
noisy loop and wait until we have enough randomness.

This patch also removes saving and restoring the seed. This
is no longer useful because the kernel's PRNG only takes any
input after it has successfully been seeded from other sources.

Hence adding this seed does not increase its randomness.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
This commit is contained in:
Michael Tremer
2020-04-29 19:33:04 +00:00
committed by Arne Fitzenreiter
parent 65cb935200
commit 97b1857ba4
6 changed files with 6 additions and 35 deletions

View File

@@ -22,29 +22,10 @@ case "$1" in
sync
rm -f /var/tmp/random-tmpfile
done;
boot_mesg "\rInitializing kernel random number generator..."
if [ -f /var/tmp/random-seed ]; then
/bin/cat /var/tmp/random-seed >/dev/urandom
fi
touch /var/tmp/random-seed
chmod 600 /var/tmp/random-seed
/bin/dd if=/dev/urandom of=/var/tmp/random-seed \
count=1 bs=$poolsize &>/dev/null
evaluate_retval
;;
stop)
boot_mesg "Saving random seed..."
touch /var/tmp/random-seed
chmod 600 /var/tmp/random-seed
/bin/dd if=/dev/urandom of=/var/tmp/random-seed \
count=1 bs=$poolsize &>/dev/null
evaluate_retval
;;
*)
echo "Usage: $0 {start|stop}"
echo "Usage: $0 {start}"
exit 1
;;
esac