Subject: CVS commit: syssrc
To: None <source-changes@netbsd.org>
From: Bill Sommerfeld <sommerfeld@netbsd.org>
List: source-changes
Date: 06/05/2000 16:42:35
Module Name:	syssrc
Committed By:	sommerfeld
Date:		Mon Jun  5 23:42:35 UTC 2000

Modified Files:
	syssrc/sys/dev: rnd.c rndpool.c
	syssrc/sys/sys: rnd.h

Log Message:
/dev/random code cleanups:
 - Add comments about which spls apply to which data structures.
 - Consistently protect the rnd_samples queue (the queue of
unprocessed samples) at splhigh().
 - allow MD code to supply cpu_timestamp() and cpu_havetimestamp() for
an optional higher-resolution clock/roulette wheel source.
 - Collect more statistics on the pool state (keeping track of where
collected bits are going, in addition to where they came from).
 - Add RNDGETPOOLSTAT ioctl to get the additional stats.
 - Flush a few unused rndpool calls.
 - XXX XXX Cryptographic changes:
  - 32-bit rotate is:
	((val << rp->rotate) | (val >> (32 - rp->rotate))),
    not
	(val << rp->rotate) | (val >> rp->rotate)
    or
	((val << rp->rotate) | (val >> (31 - rp->rotate)))
  - Avoid overloading of rp->rotate and double-rotation of data
(which limited pool mixing somewhat; "rotate" never got above 7).
  - Be more paranoid (but probably not paranoid enough) about mixing
output back into the pool.  This is an improvement, but it needs
revisiting soon.

We should follow the spirit of some of the recommendations in
the Schneier PRNG papers:

http://www.counterpane.com/yarrow-notes.html
http://www.counterpane.com/pseudorandom_number.html

including:
 - two (or more) stage operation for better isolation between inputs
and outputs.
 - use of keyed one-way functions (probably better even than
invertible keyed functions like 3DES) at key points in the data flow,
so that breaking the PRNG is clearly as hard as breaking the function.


To generate a diff of this commit:
cvs rdiff -r1.18 -r1.19 syssrc/sys/dev/rnd.c
cvs rdiff -r1.8 -r1.9 syssrc/sys/dev/rndpool.c
cvs rdiff -r1.11 -r1.12 syssrc/sys/sys/rnd.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.