[BUG] Snapshot 20000224 EGD problems

2000-02-25 Thread Lutz Jaenicke

Hi,

while testing the new EGD support, I found some bugs.
crypto/rand_egd.c:98
The first byte returned is the number of bytes granted. This number can
be 0, when the egd-pool is drained, so that the following read blocks.
To reproduce, run "openssl genrsa -out somekey.pem -rand /var/run/egd-pool 1024"
several times in a fast sequence.
if (read(fd, buf, 1) != 1) goto err;
+   if (buf[0] == 0) goto err;
num = read(fd, buf, 255);
Of course, the returned buf[0] value must match the later returned "num" value,
but what should we do if it does not match instead of using "num" anyway? :-)

apps/app_rand.c, app_RAND_load_files() (is it a bug or a feature? :-)
When specifying a non-existant random-source, like "-rand /does/not/exist"
RAND_EGD() will return "-1", while RAND_load_file() will return "0":
tot+=RAND_egd(n);
tot+=RAND_load_file(n,1024L*1024L);
Hence, "tot" will yield "-1":
ws01 222: ./openssl genrsa -out somekey.pem -rand /does/not/exist
-1 semi-random bytes loaded
Generating RSA private key, 512 bit long modulus
...

Best regards,
Lutz
-- 
Lutz Jaenicke [EMAIL PROTECTED]
BTU Cottbus   http://www.aet.TU-Cottbus.DE/personen/jaenicke/
Lehrstuhl Allgemeine Elektrotechnik  Tel. +49 355 69-4129
Universitaetsplatz 3-4, D-03044 Cottbus  Fax. +49 355 69-4153
__
OpenSSL Project http://www.openssl.org
Development Mailing List   [EMAIL PROTECTED]
Automated List Manager   [EMAIL PROTECTED]



Re: [BUG] Snapshot 20000224 EGD problems

2000-02-25 Thread Bodo Moeller

On Fri, Feb 25, 2000 at 01:20:36PM +0100, Lutz Jaenicke wrote:

   if (read(fd, buf, 1) != 1) goto err;
 + if (buf[0] == 0) goto err;
   num = read(fd, buf, 255);
 Of course, the returned buf[0] value must match the later returned "num" value,
 but what should we do if it does not match instead of using "num" anyway? :-)

Presumably reading should happen in O_NONBLOCK mode to make sure that
bugs such as an incompatible daemon at the Unix socket don't cause
problems?
__
OpenSSL Project http://www.openssl.org
Development Mailing List   [EMAIL PROTECTED]
Automated List Manager   [EMAIL PROTECTED]