diff options
author | Sahana Prasad <sahana@redhat.com> | 2021-01-25 14:44:29 +0100 |
---|---|---|
committer | Dmitry Belyavskiy <beldmit@gmail.com> | 2021-02-18 12:04:35 +0100 |
commit | 5d8ffebbcdf4992d3c428201b1f3330020bbe92e (patch) | |
tree | 553c8a5bb0c77b9dad2a01b0e076c506af84da46 /crypto/dh/dh_lib.c | |
parent | 0b3139e815d3d14c4d7506488add6e02a2b682ec (diff) |
DH: Make DH_bits(), DH_size(), and DH_security_bits() check that there are key parameters
Fixes #13569
Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/13955)
Diffstat (limited to 'crypto/dh/dh_lib.c')
-rw-r--r-- | crypto/dh/dh_lib.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/crypto/dh/dh_lib.c b/crypto/dh/dh_lib.c index e8a66878ab..46aba02bad 100644 --- a/crypto/dh/dh_lib.c +++ b/crypto/dh/dh_lib.c @@ -187,12 +187,16 @@ void *DH_get_ex_data(const DH *d, int idx) int DH_bits(const DH *dh) { - return BN_num_bits(dh->params.p); + if (dh->params.p != NULL) + return BN_num_bits(dh->params.p); + return -1; } int DH_size(const DH *dh) { - return BN_num_bytes(dh->params.p); + if (dh->params.p != NULL) + return BN_num_bytes(dh->params.p); + return -1; } int DH_security_bits(const DH *dh) @@ -204,7 +208,9 @@ int DH_security_bits(const DH *dh) N = dh->length; else N = -1; - return BN_security_bits(BN_num_bits(dh->params.p), N); + if (dh->params.p != NULL) + return BN_security_bits(BN_num_bits(dh->params.p), N); + return -1; } void DH_get0_pqg(const DH *dh, |