From owner-freebsd-hackers Mon Oct 16 05:02:30 1995 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id FAA05977 for hackers-outgoing; Mon, 16 Oct 1995 05:02:30 -0700 Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id FAA05972 for ; Mon, 16 Oct 1995 05:02:23 -0700 Received: (from bde@localhost) by godzilla.zeta.org.au (8.6.9/8.6.9) id VAA25392; Mon, 16 Oct 1995 21:59:11 +1000 Date: Mon, 16 Oct 1995 21:59:11 +1000 From: Bruce Evans Message-Id: <199510161159.VAA25392@godzilla.zeta.org.au> To: bde@zeta.org.au, mark@grondar.za Subject: Re: Creating a /dev/random Cc: hackers@FreeBSD.org Sender: owner-hackers@FreeBSD.org Precedence: bulk >> >+ 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