minor change for the prng
authorUlf Möller <ulf@openssl.org>
Fri, 14 Jan 2000 02:31:32 +0000 (02:31 +0000)
committerUlf Möller <ulf@openssl.org>
Fri, 14 Jan 2000 02:31:32 +0000 (02:31 +0000)
crypto/rand/md_rand.c
rsaref/rsaref.c

index d727fff9243d6efc57b74994ab3fc5b458fe1690..5eef93d4bdbcfcd127a939523fa48417b79b4f58 100644 (file)
@@ -360,15 +360,13 @@ static int ssleay_rand_bytes(unsigned char *buf, int num)
                 */
                if ((fh = fopen(DEVRANDOM, "r")) != NULL)
                        {
                 */
                if ((fh = fopen(DEVRANDOM, "r")) != NULL)
                        {
-                       unsigned char tmpbuf[32];
+                       unsigned char tmpbuf[ENTROPY_NEEDED];
+                       int i;
 
 
-                       fread((unsigned char *)tmpbuf,1,32,fh);
-                       /* we don't care how many bytes we read,
-                        * we will just copy the 'stack' if there is
-                        * nothing else :-) */
+                       i=fread((unsigned char *)tmpbuf,1,ENTROPY_NEEDED,fh);
                        fclose(fh);
                        fclose(fh);
-                       RAND_seed(tmpbuf,32);
-                       memset(tmpbuf,0,32);
+                       RAND_seed(tmpbuf,i);
+                       memset(tmpbuf,0,i);
                        }
 #endif
 #ifdef PURIFY
                        }
 #endif
 #ifdef PURIFY
index 55cebc8fcb3c984c474d752b4cfde01db5aea62a..ae70feb3e9b0e246d07d0891ef0087cb34c96d61 100644 (file)
@@ -279,7 +279,8 @@ int RSA_ref_public_encrypt(int len, unsigned char *from, unsigned char *to,
        R_GetRandomBytesNeeded((unsigned int *)&i,&rnd);
        while (i > 0)
                {
        R_GetRandomBytesNeeded((unsigned int *)&i,&rnd);
        while (i > 0)
                {
-               RAND_bytes(buf,16);
+               if (RAND_bytes(buf,16) <= 0)
+                       goto err;
                R_RandomUpdate(&rnd,buf,(unsigned int)((i>16)?16:i));
                i-=16;
                }
                R_RandomUpdate(&rnd,buf,(unsigned int)((i>16)?16:i));
                i-=16;
                }