summaryrefslogtreecommitdiffstats
path: root/crypto/dh/dh_lib.c
diff options
context:
space:
mode:
authorShane Lontis <shane.lontis@oracle.com>2020-03-06 22:47:58 +0100
committerShane Lontis <shane.lontis@oracle.com>2020-03-06 22:47:58 +0100
commit55f02cb6849f0366dd8b787dbe8e74b56c15bfd1 (patch)
tree121d16aadaf60b03ed5036d4750190ac3dbdf6e5 /crypto/dh/dh_lib.c
parentClarify the usage of EVP_PKEY_get_raw_[private|public]_key() (diff)
downloadopenssl-55f02cb6849f0366dd8b787dbe8e74b56c15bfd1.tar.xz
openssl-55f02cb6849f0366dd8b787dbe8e74b56c15bfd1.zip
Change DH_get_nid() to set the value of q if it is not already set
Fixes #11108. It only sets q if a valid named group is found. The function signature was recently changed to pass a non const DH pointer in order to allow the nid to be cached internally. As an extension of this the value of q can now also be set as q is always known for named groups. The length field is also set if q is set. Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/11114)
Diffstat (limited to 'crypto/dh/dh_lib.c')
-rw-r--r--crypto/dh/dh_lib.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/crypto/dh/dh_lib.c b/crypto/dh/dh_lib.c
index d7fe850f58..29152dca4d 100644
--- a/crypto/dh/dh_lib.c
+++ b/crypto/dh/dh_lib.c
@@ -211,11 +211,16 @@ int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g)
ffc_params_set0_pqg(&dh->params, p, q, g);
dh->params.nid = NID_undef;
- DH_get_nid(dh); /* Check if this is a named group and cache it */
-
- if (q != NULL)
- dh->length = BN_num_bits(q);
-
+ /*
+ * Check if this is a named group. If it finds a named group then the
+ * 'q' and 'length' value are either already set or are set by the
+ * call.
+ */
+ if (DH_get_nid(dh) == NID_undef) {
+ /* If its not a named group then set the 'length' if q is not NULL */
+ if (q != NULL)
+ dh->length = BN_num_bits(q);
+ }
dh->dirty_cnt++;
return 1;
}