Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Oct 1995 21:59:11 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        bde@zeta.org.au, mark@grondar.za
Cc:        hackers@FreeBSD.org
Subject:   Re: Creating a /dev/random
Message-ID:  <199510161159.VAA25392@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>> >+			poolsize = read_random(rbuf, CLBYTES);
>> >+			c = min(iov->iov_len, CLBYTES);
>> >+			c = min(c, poolsize);
>> >+			error = uiomove(rbuf, (int)c, uio);
>> 
>> `c' should be calculated before calling rad_random() to avoid wasting
>> randomness.

>Huh? How? :-) Are you suggesting that there should be another call to
>return the number of bytes in the pool _before_ read_random is called?

	intc = imin(iov->iov_len, CLBYTES);
	poolsize = read_random(rbuf, intc);
	intc = imin(intc, poolsize);

It the caller reads 1 byte at a time, then the original version throws
away up to CLBYTES-1 bytes of randomness.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199510161159.VAA25392>