summaryrefslogtreecommitdiffstats
path: root/crypto/dh/dh_lib.c
diff options
context:
space:
mode:
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;
}