Do not match RFC 5114 groups without q as it is significant
authorTomas Mraz <tomas@openssl.org>
Mon, 15 Feb 2021 14:26:14 +0000 (15:26 +0100)
committerMatt Caswell <matt@openssl.org>
Tue, 16 Feb 2021 10:12:02 +0000 (10:12 +0000)
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14189)

crypto/ffc/ffc_dh.c

index 313466b0eac3345f2d725d0964027eb2ff1a6b57..948c61d988ba9eff1b8e4c87d73dbefd4f856573 100644 (file)
@@ -110,7 +110,9 @@ const DH_NAMED_GROUP *ossl_ffc_numbers_to_dh_named_group(const BIGNUM *p,
         if (BN_cmp(p, dh_named_groups[i].p) == 0
             && BN_cmp(g, dh_named_groups[i].g) == 0
             /* Verify q is correct if it exists */
-            && (q == NULL || BN_cmp(q, dh_named_groups[i].q) == 0))
+            && ((q != NULL && BN_cmp(q, dh_named_groups[i].q) == 0)
+                /* Do not match RFC 5114 groups without q */
+                || (q == NULL && dh_named_groups[i].uid > 3)))
             return &dh_named_groups[i];
     }
     return NULL;