diff options
author | bde <bde@FreeBSD.org> | 1995-12-22 15:20:50 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1995-12-22 15:20:50 +0000 |
commit | df04a23d594d29e3266a8642fa96b392acadc778 (patch) | |
tree | 0601cd14819da9b547adaf27ffbc3798b54a84fe /sys | |
parent | 207137fc89d6a138131b839574913f20b9c8e82c (diff) | |
download | FreeBSD-src-df04a23d594d29e3266a8642fa96b392acadc778.zip FreeBSD-src-df04a23d594d29e3266a8642fa96b392acadc778.tar.gz |
Fixed arg order in an outb() call. add_timer_randomness() clobbered
part of the DMA channel 0 address and wasn't random in the intended
way.
Submitted by: KATO Takenori <kato@eclogite.eps.nagoya-u.ac.jp>
Disable interrupts while reading the clock. This probably isn't
important (allowing interrupts probably increased randomness in
the usual case).
Removed __i386__ ifdef. This file is in an i386 directory and has
other i386 dependencies.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/i386/isa/random.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sys/i386/isa/random.c b/sys/i386/isa/random.c index 89a7453..99c5de4 100644 --- a/sys/i386/isa/random.c +++ b/sys/i386/isa/random.c @@ -1,7 +1,7 @@ /* * random.c -- A strong random number generator * - * $Id: random.c,v 1.2 1995/11/04 16:00:50 markm Exp $ + * $Id: random.c,v 1.3 1995/11/20 12:12:02 phk Exp $ * * Version 0.92, last modified 21-Sep-95 * @@ -303,6 +303,7 @@ add_timer_randomness(struct random_bucket *r, struct timer_rand_state *state, { int delta, delta2; int nbits; + u_int8_t timer_high, timer_low; /* * Calculate number of bits of randomness we probably @@ -321,19 +322,21 @@ add_timer_randomness(struct random_bucket *r, struct timer_rand_state *state, add_entropy(r, (u_int8_t *) &ticks, sizeof(ticks), nbits, delay); -#if defined (__i386__) /* * On a 386, read the high resolution timer. We assume that * this gives us 2 bits of randomness. XXX This needs * investigation. */ - outb(TIMER_LATCH|TIMER_SEL0, TIMER_MODE); /* latch the count ASAP */ - add_entropy_byte(r, inb(TIMER_CNTR0), 1); - add_entropy_byte(r, inb(TIMER_CNTR0), 1); + disable_intr(); + outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH); + timer_low = inb(TIMER_CNTR0); + timer_high = inb(TIMER_CNTR0); + enable_intr(); + add_entropy_byte(r, timer_low, 1); + add_entropy_byte(r, timer_high, 1); r->entropy_count += 2; if (r->entropy_count > r->bit_length) r->entropy_count = r->bit_length; -#endif } void |