Simplify BN_rand_range
[openssl.git] / crypto / dsa / dsa_key.c
index 2c70248687a0a42e3907297988534ba4cce37e4d..af3c56d770ecb2480b996875df3b5624dd205f26 100644 (file)
@@ -1,5 +1,5 @@
 /* crypto/dsa/dsa_key.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
  * This package is an SSL implementation written
  * [including the GNU Public Licence.]
  */
 
+#ifndef NO_SHA
 #include <stdio.h>
 #include <time.h>
 #include "cryptlib.h"
-#include "sha.h"
-#include "bn.h"
-#include "dsa.h"
-#include "rand.h"
+#include <openssl/sha.h>
+#include <openssl/bn.h>
+#include <openssl/dsa.h>
+#include <openssl/rand.h>
 
-int DSA_generate_key(dsa)
-DSA *dsa;
+int DSA_generate_key(DSA *dsa)
        {
        int ok=0;
        unsigned int i;
@@ -84,7 +84,8 @@ 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;
@@ -109,4 +110,4 @@ err:
        if (ctx != NULL) BN_CTX_free(ctx);
        return(ok);
        }
-
+#endif