Reject obviously invalid DSA parameters during signing
authorMatt Caswell <matt@openssl.org>
Fri, 3 May 2019 14:56:08 +0000 (15:56 +0100)
committerMatt Caswell <matt@openssl.org>
Tue, 7 May 2019 15:47:30 +0000 (16:47 +0100)
Fixes #8875

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8876)

crypto/dsa/dsa_ossl.c

index 37c654d20ccd5cc5ce7b59a684d8b5dd78dbb260..b66d5ad0c901d09b9bfa05b4e1d3ea223070f709 100644 (file)
@@ -190,6 +190,12 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in,
         return 0;
     }
 
+    /* Reject obviously invalid parameters */
+    if (BN_is_zero(dsa->p) || BN_is_zero(dsa->q) || BN_is_zero(dsa->g)) {
+        DSAerr(DSA_F_DSA_SIGN_SETUP, DSA_R_INVALID_PARAMETERS);
+        return 0;
+    }
+
     k = BN_new();
     l = BN_new();
     if (k == NULL || l == NULL)