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.
This commit is contained in:
parent
526d7a354a
commit
aa67202b2b
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* random.c -- A strong random number generator
|
* 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
|
* 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 delta, delta2;
|
||||||
int nbits;
|
int nbits;
|
||||||
|
u_int8_t timer_high, timer_low;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calculate number of bits of randomness we probably
|
* 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);
|
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
|
* On a 386, read the high resolution timer. We assume that
|
||||||
* this gives us 2 bits of randomness. XXX This needs
|
* this gives us 2 bits of randomness. XXX This needs
|
||||||
* investigation.
|
* investigation.
|
||||||
*/
|
*/
|
||||||
outb(TIMER_LATCH|TIMER_SEL0, TIMER_MODE); /* latch the count ASAP */
|
disable_intr();
|
||||||
add_entropy_byte(r, inb(TIMER_CNTR0), 1);
|
outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
|
||||||
add_entropy_byte(r, inb(TIMER_CNTR0), 1);
|
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;
|
r->entropy_count += 2;
|
||||||
if (r->entropy_count > r->bit_length)
|
if (r->entropy_count > r->bit_length)
|
||||||
r->entropy_count = r->bit_length;
|
r->entropy_count = r->bit_length;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user