diff options
author | Richard Levitte <levitte@openssl.org> | 2020-12-04 08:55:19 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2020-12-05 11:06:05 +0100 |
commit | ecfbe2f0461b399b6bf99bdaa95c460ece8e693e (patch) | |
tree | ce456497034af6245bd9591b9d97d15cb34021a2 /crypto/dsa/dsa_lib.c | |
parent | 76191c7999e0d1f709ea468950457f71cea378c4 (diff) |
DSA: Make DSA_bits() and DSA_size() check that there are key parameters
Without these check, a DSA structure without key parameters will cause
these functions to crash. This is also the case in pre-3.0 OpenSSL,
but since we now extract these data early, to cache them in the
EVP_PKEY structure, the same crash happens earlier and much more
internally.
The added checks are of the same kind as DSA_security_bits() already
does.
Fixes #13610
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/13611)
Diffstat (limited to 'crypto/dsa/dsa_lib.c')
-rw-r--r-- | crypto/dsa/dsa_lib.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/crypto/dsa/dsa_lib.c b/crypto/dsa/dsa_lib.c index 983a463ff5..4a9f572edd 100644 --- a/crypto/dsa/dsa_lib.c +++ b/crypto/dsa/dsa_lib.c @@ -335,7 +335,9 @@ int DSA_security_bits(const DSA *d) int DSA_bits(const DSA *dsa) { - return BN_num_bits(dsa->params.p); + if (dsa->params.p != NULL) + return BN_num_bits(dsa->params.p); + return -1; } FFC_PARAMS *dsa_get0_params(DSA *dsa) |