diff options
author | Rich Salz <rsalz@openssl.org> | 2017-08-02 14:00:52 -0400 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2017-08-03 10:45:17 -0400 |
commit | ddc6a5c8f5900959bdbdfee79e1625a3f7808acd (patch) | |
tree | 3121037aca10793706bbc4b8800b40ba305a1c06 /crypto/dh | |
parent | ae3947de09522206d61c0206a733517b10a910f8 (diff) |
Add RAND_priv_bytes() for private keys
Add a new global DRBG for private keys used by RAND_priv_bytes.
Add BN_priv_rand() and BN_priv_rand_range() which use RAND_priv_bytes().
Change callers to use the appropriate BN_priv... function.
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/4076)
Diffstat (limited to 'crypto/dh')
-rw-r--r-- | crypto/dh/dh_key.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/crypto/dh/dh_key.c b/crypto/dh/dh_key.c index fce9ff47f3..ce01948602 100644 --- a/crypto/dh/dh_key.c +++ b/crypto/dh/dh_key.c @@ -111,14 +111,14 @@ static int generate_key(DH *dh) if (generate_new_key) { if (dh->q) { do { - if (!BN_rand_range(priv_key, dh->q)) + if (!BN_priv_rand_range(priv_key, dh->q)) goto err; } while (BN_is_zero(priv_key) || BN_is_one(priv_key)); } else { /* secret exponent length */ l = dh->length ? dh->length : BN_num_bits(dh->p) - 1; - if (!BN_rand(priv_key, l, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY)) + if (!BN_priv_rand(priv_key, l, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY)) goto err; } } |