diff options
author | markm <markm@FreeBSD.org> | 2000-07-09 11:52:12 +0000 |
---|---|---|
committer | markm <markm@FreeBSD.org> | 2000-07-09 11:52:12 +0000 |
commit | 89ca69193464a4d38b274170f31e1230f83f97d2 (patch) | |
tree | 23899ac28a165c102257976c1b1732610ec89d7c /sys/dev/random/yarrow.c | |
parent | be58a54d861ad1db0bee83f025d12336bae99471 (diff) | |
download | FreeBSD-src-89ca69193464a4d38b274170f31e1230f83f97d2.zip FreeBSD-src-89ca69193464a4d38b274170f31e1230f83f97d2.tar.gz |
Yarrow tweaks; separate the fast and slow reseed tasks so that they don't
stomp on each other; provide constant names (as enums) for the harvester
to use (makes it more self-documenting).
Diffstat (limited to 'sys/dev/random/yarrow.c')
-rw-r--r-- | sys/dev/random/yarrow.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/sys/dev/random/yarrow.c b/sys/dev/random/yarrow.c index ab4a69c..dab10b5 100644 --- a/sys/dev/random/yarrow.c +++ b/sys/dev/random/yarrow.c @@ -47,17 +47,20 @@ static void generator_gate(void); static void reseed(int); -static void random_harvest_internal(struct timespec *nanotime, u_int64_t entropy, u_int bits, u_int frac, u_int source); +static void random_harvest_internal(struct timespec *nanotime, u_int64_t entropy, u_int bits, u_int frac, enum esource source); /* Structure holding the entropy state */ struct random_state random_state; /* When enough entropy has been harvested, asynchronously "stir" it in */ -static struct task regate_task; +static struct task regate_task[2]; -static struct context { +struct context { u_int pool; -} context = { 0 }; +} context[2] = { + { 0 }, + { 1 } + }; static void regate(void *context, int pending) @@ -80,7 +83,8 @@ random_init(void) random_state.pool[1].thresh = 160; random_state.slowoverthresh = 2; random_state.which = FAST; - TASK_INIT(®ate_task, 0, ®ate, (void *)&context); + TASK_INIT(®ate_task[FAST], FAST, ®ate, (void *)&context[FAST]); + TASK_INIT(®ate_task[SLOW], SLOW, ®ate, (void *)&context[SLOW]); random_init_harvester(random_harvest_internal); } @@ -286,7 +290,7 @@ generator_gate(void) static void random_harvest_internal(struct timespec *nanotime, u_int64_t entropy, - u_int bits, u_int frac, u_int origin) + u_int bits, u_int frac, enum esource origin) { u_int insert; int which; /* fast or slow */ @@ -324,16 +328,15 @@ random_harvest_internal(struct timespec *nanotime, u_int64_t entropy, source->bits += source->frac / 1024; source->frac %= 1024; } - context.pool = which; if (source->bits >= pool->thresh) { - /* XXX Needs to be multiply queued? */ - taskqueue_enqueue(taskqueue_swi, ®ate_task); + /* XXX Slowoverthresh nees to be considered */ + taskqueue_enqueue(taskqueue_swi, ®ate_task[which]); } /* bump the insertion point */ source->current = insert; - /* toggle the pool for next time */ + /* toggle the pool for next insertion */ random_state.which = !random_state.which; } |