Precautions against using the PRNG uninitialized: RAND_bytes() now
[openssl.git] / crypto / bn / bn_rand.c
index 91b8e34ae65b364c03ed333c5f181ed6840c7aca..b567b43a6ff96ecd8b925b8a0d791f674db419dd 100644 (file)
@@ -81,9 +81,10 @@ int BN_rand(BIGNUM *rnd, int bits, int top, int bottom)
 
        /* make a random number and set the top and bottom bits */
        time(&tim);
-       RAND_seed(&tim,sizeof(tim));
+       RAND_add(&tim,sizeof(tim),0);
 
-       RAND_bytes(buf,(int)bytes);
+       if (RAND_bytes(buf,(int)bytes) <= 0)
+               goto err;
        if (top)
                {
                if (bit == 0)