diff options
author | markm <markm@FreeBSD.org> | 2003-11-02 10:55:16 +0000 |
---|---|---|
committer | markm <markm@FreeBSD.org> | 2003-11-02 10:55:16 +0000 |
commit | a3bf188d5b14acb242cc0a64b6bbfe2797f04d04 (patch) | |
tree | f8cbc8e96eb57c0a8f38852165f7e17ba12c50de /sys/dev/random | |
parent | 315c0ec426935ae53905eb509b87fc3e5f7b11af (diff) | |
download | FreeBSD-src-a3bf188d5b14acb242cc0a64b6bbfe2797f04d04.zip FreeBSD-src-a3bf188d5b14acb242cc0a64b6bbfe2797f04d04.tar.gz |
Make sure we get all user-written input. This simplifies the
code considerably.
Submitted by: (forgotten)
[I'll happily acknowledge the submitter if he owns up!]
Diffstat (limited to 'sys/dev/random')
-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 57bb54c..6bbe200 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); } } |