diff options
| author | Peter Wemm <peter@FreeBSD.org> | 1996-09-27 13:25:13 +0000 |
|---|---|---|
| committer | Peter Wemm <peter@FreeBSD.org> | 1996-09-27 13:25:13 +0000 |
| commit | 983febf3dc5da745ca8a0a4cf20daa837f28bdfa (patch) | |
| tree | 1616561a31008878272d60e47169e5d4e4965d79 /sys/kern/kern_random.c | |
| parent | 78a660dc2345ce368555cbdf48538b3fd0147be3 (diff) | |
Notes
Diffstat (limited to 'sys/kern/kern_random.c')
| -rw-r--r-- | sys/kern/kern_random.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/sys/kern/kern_random.c b/sys/kern/kern_random.c index 7a6ea06808c5..31b456316afc 100644 --- a/sys/kern/kern_random.c +++ b/sys/kern/kern_random.c @@ -1,7 +1,7 @@ /* * random_machdep.c -- A strong random number generator * - * $Id: random_machdep.c,v 1.9 1996/06/17 16:47:43 bde Exp $ + * $Id: random_machdep.c,v 1.10 1996/08/02 21:16:27 bde Exp $ * * Version 0.95, last modified 18-Oct-95 * @@ -44,6 +44,8 @@ #include <sys/param.h> #include <sys/systm.h> #include <sys/kernel.h> +#include <sys/select.h> +#include <sys/fcntl.h> #include <machine/clock.h> #include <machine/random.h> @@ -85,6 +87,7 @@ struct random_bucket { u_int entropy_count; int input_rotate; u_int32_t *pool; + struct selinfo rsel; }; /* There is one of these per entropy source */ @@ -118,6 +121,8 @@ rand_initialize(void) random_state.entropy_count = 0; random_state.pool = random_pool; random_wait = NULL; + random_state.rsel.si_flags = 0; + random_state.rsel.si_pid = 0; } /* @@ -225,6 +230,9 @@ add_timer_randomness(struct random_bucket *r, struct timer_rand_state *state, /* Prevent overflow */ if (r->entropy_count > POOLBITS) r->entropy_count = POOLBITS; + + if (r->entropy_count >= 8) + selwakeup(&random_state.rsel); } void @@ -479,3 +487,24 @@ write_random(const char *buf, u_int nbytes) return nbytes; } #endif /* notused */ + +int +random_select(dev_t dev, int rw, struct proc *p) +{ + int s, ret; + + if (rw == FWRITE) + return 1; /* heh. */ + + s = splhigh(); + if (random_state.entropy_count >= 8) + ret = 1; + else { + selrecord(p, &random_state.rsel); + ret = 0; + } + splx(s); + + return ret; +} + |
