summaryrefslogtreecommitdiffstats
path: root/crypto/bn/bn_rand.c
diff options
context:
space:
mode:
authorBodo Möller <bodo@openssl.org>2000-07-02 19:42:19 +0000
committerBodo Möller <bodo@openssl.org>2000-07-02 19:42:19 +0000
commit904cb691f38a88ca4c6e5db2153afbb3bac193fc (patch)
tree9ce728bdf89e3860b9a5b51842b1a7a987c74841 /crypto/bn/bn_rand.c
parent3f2599d97d6ffe26e81eb46c43c7f0905c8fb762 (diff)
Return bignum '0' when BN_rand is asked for a 0 bit random number.
Diffstat (limited to 'crypto/bn/bn_rand.c')
-rw-r--r--crypto/bn/bn_rand.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/crypto/bn/bn_rand.c b/crypto/bn/bn_rand.c
index b1163f7ec4..21ecbc04ed 100644
--- a/crypto/bn/bn_rand.c
+++ b/crypto/bn/bn_rand.c
@@ -68,6 +68,12 @@ static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom)
int ret=0,bit,bytes,mask;
time_t tim;
+ if (bits == 0)
+ {
+ BN_zero(rnd);
+ return 1;
+ }
+
bytes=(bits+7)/8;
bit=(bits-1)%8;
mask=0xff<<bit;