From 904cb691f38a88ca4c6e5db2153afbb3bac193fc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bodo=20M=C3=B6ller?= Date: Sun, 2 Jul 2000 19:42:19 +0000 Subject: [PATCH] Return bignum '0' when BN_rand is asked for a 0 bit random number. --- crypto/bn/bn_rand.c | 6 ++++++ 1 file changed, 6 insertions(+) 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<