From owner-freebsd-hackers Mon Oct 16 05:34:36 1995 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id FAA06876 for hackers-outgoing; Mon, 16 Oct 1995 05:34:36 -0700 Received: from grunt.grondar.za (grunt.grondar.za [196.7.18.129]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id FAA06870 for ; Mon, 16 Oct 1995 05:34:13 -0700 Received: from grumble.grondar.za (grumble.grondar.za [196.7.18.130]) by grunt.grondar.za (8.6.12/8.6.9) with ESMTP id OAA23686; Mon, 16 Oct 1995 14:33:56 +0200 Received: from localhost (localhost [127.0.0.1]) by grumble.grondar.za (8.6.12/8.6.9) with SMTP id OAA26278; Mon, 16 Oct 1995 14:33:56 +0200 Message-Id: <199510161233.OAA26278@grumble.grondar.za> X-Authentication-Warning: grumble.grondar.za: Host localhost didn't use HELO protocol To: Bruce Evans cc: hackers@FreeBSD.org Subject: Re: Creating a /dev/random Date: Mon, 16 Oct 1995 14:33:55 +0200 From: Mark Murray 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. AHA! The undocumented internals of *iov... Thanks. I just learnt something useful here! M -- Mark Murray 46 Harvey Rd, Claremont, Cape Town 7700, South Africa +27 21 61-3768 GMT+0200 Finger mark@grumble.grondar.za for PGP key