diff options
Diffstat (limited to 'crypto/openssl/crypto/bn/bn_rand.c')
-rw-r--r-- | crypto/openssl/crypto/bn/bn_rand.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/crypto/openssl/crypto/bn/bn_rand.c b/crypto/openssl/crypto/bn/bn_rand.c index 91b8e34..943712c 100644 --- a/crypto/openssl/crypto/bn/bn_rand.c +++ b/crypto/openssl/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; @@ -81,9 +81,19 @@ 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); + + if (pseudorand) + { + if (RAND_pseudo_bytes(buf, bytes) == -1) + goto err; + } + else + { + if (RAND_bytes(buf, bytes) <= 0) + goto err; + } - RAND_bytes(buf,(int)bytes); if (top) { if (bit == 0) @@ -115,3 +125,12 @@ err: return(ret); } +int BN_rand(BIGNUM *rnd, int bits, int top, int bottom) + { + return bnrand(0, rnd, bits, top, bottom); + } + +int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom) + { + return bnrand(1, rnd, bits, top, bottom); + } |