diff options
author | Matt Caswell <matt@openssl.org> | 2016-04-25 17:06:56 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-06-27 15:00:08 +0100 |
commit | ad64a69e02f7dda422d0f4f53dce7b1278715380 (patch) | |
tree | 5c76fd6da6b731a05cbd8559db71e8c821b44f36 /crypto/bn | |
parent | f3dbce6634dee43dcb0243544db05e101104fe6b (diff) |
Change usage of RAND_pseudo_bytes to RAND_bytes
RAND_pseudo_bytes() allows random data to be returned even in low entropy
conditions. Sometimes this is ok. Many times it is not. For the avoidance
of any doubt, replace existing usage of RAND_pseudo_bytes() with
RAND_bytes().
Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'crypto/bn')
-rw-r--r-- | crypto/bn/bn_rand.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/crypto/bn/bn_rand.c b/crypto/bn/bn_rand.c index f9fb2e9e45..2266d22b66 100644 --- a/crypto/bn/bn_rand.c +++ b/crypto/bn/bn_rand.c @@ -145,13 +145,9 @@ static int bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom) time(&tim); RAND_add(&tim, sizeof(tim), 0.0); - if (pseudorand) { - if (RAND_pseudo_bytes(buf, bytes) == -1) - goto err; - } else { - if (RAND_bytes(buf, bytes) <= 0) - goto err; - } + /* We ignore the value of pseudorand and always call RAND_bytes */ + if (RAND_bytes(buf, bytes) <= 0) + goto err; #if 1 if (pseudorand == 2) { |