From 8d7820758595ec235d4238e286c63546a533f9d3 Mon Sep 17 00:00:00 2001 From: markm Date: Mon, 17 Jul 2000 12:23:04 +0000 Subject: Add randomness write functionality. This does absolutely nothing for entropy estimation, but causes an immediate reseed after the input (read in sizeof(u_int64_t) chunks) is "harvested". This will be used in the reboot "reseeder", coming in another commit. This can be used very effectively at any time you think your randomness is compromised; something like # (ps -gauxwww; netstat -an; dmesg; vmstat -c10 1) > /dev/random will give the attacker something to think about. --- sys/dev/random/yarrow.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'sys/dev/random/yarrow.c') diff --git a/sys/dev/random/yarrow.c b/sys/dev/random/yarrow.c index c6ae448..e5174d9 100644 --- a/sys/dev/random/yarrow.c +++ b/sys/dev/random/yarrow.c @@ -274,6 +274,25 @@ read_random(char *buf, u_int count) return retval; } +void +write_random(char *buf, u_int count) +{ + u_int i; + intrmask_t mask; + struct timespec nanotime; + + /* The reseed task must not be jumped on */ + mask = splsofttq(); + for (i = 0; i < count/sizeof(u_int64_t); i++) { + getnanotime(&nanotime); + random_harvest_internal(&nanotime, + *(u_int64_t *)&buf[i*sizeof(u_int64_t)], + 0, 0, RANDOM_WRITE); + } + reseed(FAST); + splx(mask); +} + static void generator_gate(void) { -- cgit v1.1