diff options
author | markm <markm@FreeBSD.org> | 2000-07-17 12:23:04 +0000 |
---|---|---|
committer | markm <markm@FreeBSD.org> | 2000-07-17 12:23:04 +0000 |
commit | 8d7820758595ec235d4238e286c63546a533f9d3 (patch) | |
tree | 340bfc3b8cc0e99ad95e3e127e973e17127f38fb /sys/dev/random/yarrow.c | |
parent | 542bea8cf0b0bdbb6b61e4bb41cce819a51347da (diff) | |
download | FreeBSD-src-8d7820758595ec235d4238e286c63546a533f9d3.zip FreeBSD-src-8d7820758595ec235d4238e286c63546a533f9d3.tar.gz |
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.
Diffstat (limited to 'sys/dev/random/yarrow.c')
-rw-r--r-- | sys/dev/random/yarrow.c | 19 |
1 files changed, 19 insertions, 0 deletions
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) { |