FreeBSD/sys/dev/random/yarrow.c
/*-
 * Main read from Yarrow.
 * The supplied buf MUST be a multiple (>=0) of RANDOM_BLOCKSIZE in size.
 * Lots of code presumes this for efficiency, both here and in other
 * routines. You are NOT allowed to break this!
 */
Main read from Yarrow.
The supplied buf MUST be a multiple (>=0) of RANDOM_BLOCKSIZE in size.
Lots of code presumes this for efficiency, both here and in other
routines. You are NOT allowed to break this!
Main read from Yarrow . The supplied buf MUST be a multiple ( > = 0 ) of RANDOM_BLOCKSIZE in size . Lots of code presumes this for efficiency both here and in other routines . You are NOT allowed to break this!
void
random_yarrow_read(uint8_t *buf, u_int bytecount)
{
	u_int blockcount, i;
	KASSERT((bytecount % RANDOM_BLOCKSIZE) == 0, ("%s(): bytecount (= %d) must be a multiple of %d", __func__, bytecount, RANDOM_BLOCKSIZE ));
	RANDOM_RESEED_LOCK();
	blockcount = howmany(bytecount, RANDOM_BLOCKSIZE);
	for (i = 0; i < blockcount; i++) {
		if (yarrow_state.ys_outputblocks++ >= yarrow_state.ys_gengateinterval) {
			random_yarrow_generator_gate();
			yarrow_state.ys_outputblocks = 0;
		}
		uint128_increment(&yarrow_state.ys_counter);
		randomdev_encrypt(&yarrow_state.ys_key, &yarrow_state.ys_counter, buf, RANDOM_BLOCKSIZE);
		buf += RANDOM_BLOCKSIZE;
	}
	RANDOM_RESEED_UNLOCK();
}
void random_yarrow_read ( uint8_t * buf , u_int bytecount ) { u_int blockcount , i ; KASSERT ( ( bytecount % RANDOM_BLOCKSIZE ) == 0 , ( " " , __func__ , bytecount , RANDOM_BLOCKSIZE ) ) ; RANDOM_RESEED_LOCK ( ) ; blockcount = howmany ( bytecount , RANDOM_BLOCKSIZE ) ; for ( i = 0 ; i < blockcount ; i ++ ) { if ( yarrow_state . ys_outputblocks ++ >= yarrow_state . ys_gengateinterval ) { random_yarrow_generator_gate ( ) ; yarrow_state . ys_outputblocks = 0 ; } uint128_increment ( & yarrow_state . ys_counter ) ; randomdev_encrypt ( & yarrow_state . ys_key , & yarrow_state . ys_counter , buf , RANDOM_BLOCKSIZE ) ; buf += RANDOM_BLOCKSIZE ; } RANDOM_RESEED_UNLOCK ( ) ; }
Main read from Yarrow.
Main read from Yarrow .