diff options
| author | Mark Murray <markm@FreeBSD.org> | 2003-11-02 10:55:16 +0000 |
|---|---|---|
| committer | Mark Murray <markm@FreeBSD.org> | 2003-11-02 10:55:16 +0000 |
| commit | f757589236b4ab8b41b811afee170c30f6157e70 (patch) | |
| tree | f8cbc8e96eb57c0a8f38852165f7e17ba12c50de /sys/dev/random/randomdev.c | |
| parent | 9712142383d79449ae34fe9c26506af44f2b1a19 (diff) | |
Notes
Diffstat (limited to 'sys/dev/random/randomdev.c')
| -rw-r--r-- | sys/dev/random/randomdev.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/sys/dev/random/randomdev.c b/sys/dev/random/randomdev.c index 57bb54c8fc69..6bbe2007c24a 100644 --- a/sys/dev/random/randomdev.c +++ b/sys/dev/random/randomdev.c @@ -406,27 +406,18 @@ static void random_write_internal(void *buf, int count) { int i; + u_int chunk; /* Break the input up into HARVESTSIZE chunks. * The writer has too much control here, so "estimate" the * the entropy as zero. */ for (i = 0; i < count; i += HARVESTSIZE) { + chunk = HARVESTSIZE; + if (i + chunk >= count) + chunk = (u_int)(count - i); random_harvest_internal(get_cyclecount(), (char *)buf + i, - HARVESTSIZE, 0, 0, RANDOM_WRITE); - } - - /* Maybe the loop iterated at least once */ - if (i > count) - i -= HARVESTSIZE; - - /* Get the last bytes even if the input length is not - * a multiple of HARVESTSIZE. - */ - count %= HARVESTSIZE; - if (count) { - random_harvest_internal(get_cyclecount(), (char *)buf + i, - (u_int)count, 0, 0, RANDOM_WRITE); + chunk, 0, 0, RANDOM_WRITE); } } |
