diff options
author | Ulf Möller <ulf@openssl.org> | 2000-01-27 19:31:26 +0000 |
---|---|---|
committer | Ulf Möller <ulf@openssl.org> | 2000-01-27 19:31:26 +0000 |
commit | 38e33cef15e7965ad9fd9db4b08fb2f5dc1bc573 (patch) | |
tree | 27216af3df8adcdc381475ca7011f43fcf34e7fe /crypto/bn/bn_rand.c | |
parent | 0c23524963064a3bf8206b28c97f88e157d29fa7 (diff) |
Document DSA and SHA.
New function BN_pseudo_rand().
Use BN_prime_checks_size(BN_num_bits(w)) rounds of Miller-Rabin when
generating DSA primes (why not use BN_is_prime()?)
Diffstat (limited to 'crypto/bn/bn_rand.c')
-rw-r--r-- | crypto/bn/bn_rand.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/crypto/bn/bn_rand.c b/crypto/bn/bn_rand.c index b567b43a6f..dd6f6c9e44 100644 --- a/crypto/bn/bn_rand.c +++ b/crypto/bn/bn_rand.c @@ -62,7 +62,7 @@ #include "bn_lcl.h" #include <openssl/rand.h> -int BN_rand(BIGNUM *rnd, int bits, int top, int bottom) +static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom) { unsigned char *buf=NULL; int ret=0,bit,bytes,mask; @@ -83,8 +83,17 @@ int BN_rand(BIGNUM *rnd, int bits, int top, int bottom) time(&tim); RAND_add(&tim,sizeof(tim),0); - if (RAND_bytes(buf,(int)bytes) <= 0) - goto err; + if (pseudorand) + { + if (RAND_pseudo_bytes(buf, bytes) == -1) + goto err; + } + else + { + if (RAND_bytes(buf, bytes) <= 0) + goto err; + } + if (top) { if (bit == 0) @@ -116,3 +125,12 @@ err: return(ret); } +int BN_rand(BIGNUM *rnd, int bits, int top, int bottom) + { + return bnrand(1, rnd, bits, top, bottom); + } + +int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom) + { + return bnrand(0, rnd, bits, top, bottom); + } |