Simplify BN_rand_range
[openssl.git] / crypto / dsa / dsa_key.c
index e974861c5c638bfe0caf1e78d1efebe7d8052b68..af3c56d770ecb2480b996875df3b5624dd205f26 100644 (file)
@@ -56,6 +56,7 @@
  * [including the GNU Public Licence.]
  */
 
+#ifndef NO_SHA
 #include <stdio.h>
 #include <time.h>
 #include "cryptlib.h"
@@ -83,7 +84,8 @@ int DSA_generate_key(DSA *dsa)
        i=BN_num_bits(dsa->q);
        for (;;)
                {
-               BN_rand(priv_key,i,1,0);
+               if (!BN_rand(priv_key,i,0,0))
+                       goto err;
                if (BN_cmp(priv_key,dsa->q) >= 0)
                        BN_sub(priv_key,priv_key,dsa->q);
                if (!BN_is_zero(priv_key)) break;
@@ -108,4 +110,4 @@ err:
        if (ctx != NULL) BN_CTX_free(ctx);
        return(ok);
        }
-
+#endif