Fix the checks of EVP_PKEY_param_check
authorPeiwei Hu <jlu.hpw@foxmail.com>
Sat, 28 May 2022 16:05:28 +0000 (00:05 +0800)
committerTodd Short <todd.short@me.com>
Thu, 2 Jun 2022 14:54:17 +0000 (10:54 -0400)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/18424)

(cherry picked from commit e85bef981c037a6ebc0ca39f61c11bd79ed89fb3)

apps/dhparam.c
apps/ecparam.c

index 53d2c7c34d56efc45fbf14a711e681cbb4b218cd..2742389bb377b804ed42996a5bb4240914dbb6b5 100644 (file)
@@ -318,7 +318,7 @@ int dhparam_main(int argc, char **argv)
             BIO_printf(bio_err, "Error, failed to check DH parameters\n");
             goto end;
         }
-        if (!EVP_PKEY_param_check(ctx)) {
+        if (EVP_PKEY_param_check(ctx) <= 0) {
             BIO_printf(bio_err, "Error, invalid parameters generated\n");
             goto end;
         }
index e93ecaea6a183556d0c1fe7303c9ac728950c4f6..5d869cfd14f70fc565ab071c08cd9db8d3ae0499 100644 (file)
@@ -284,7 +284,7 @@ int ecparam_main(int argc, char **argv)
                 goto end;
         }
         pctx = EVP_PKEY_CTX_new_from_pkey(NULL, params_key, NULL);
-        if (pctx == NULL || !EVP_PKEY_param_check(pctx)) {
+        if (pctx == NULL || EVP_PKEY_param_check(pctx) <= 0) {
             BIO_printf(bio_err, "failed\n");
             goto end;
         }