Fix the checks of EVP_PKEY_public_check
authorPeiwei Hu <jlu.hpw@foxmail.com>
Sat, 28 May 2022 15:56:02 +0000 (23:56 +0800)
committerTodd Short <todd.short@me.com>
Thu, 2 Jun 2022 14:36:56 +0000 (10:36 -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)

test/evp_pkey_provided_test.c

index 563e0ad2ed1dedfc2f355796689d38e50882651a..3e2e78ed03c78835d7247be82c0955948e618ca8 100644 (file)
@@ -397,7 +397,7 @@ static int test_fromdata_rsa(void)
             goto err;
 
         if (!TEST_int_gt(EVP_PKEY_check(key_ctx), 0)
-            || !TEST_true(EVP_PKEY_public_check(key_ctx))
+            || !TEST_int_gt(EVP_PKEY_public_check(key_ctx), 0)
             || !TEST_true(EVP_PKEY_private_check(key_ctx))
             || !TEST_int_gt(EVP_PKEY_pairwise_check(key_ctx), 0))
             goto err;
@@ -661,7 +661,7 @@ static int test_fromdata_dh_named_group(void)
             goto err;
 
         if (!TEST_int_gt(EVP_PKEY_check(key_ctx), 0)
-            || !TEST_true(EVP_PKEY_public_check(key_ctx))
+            || !TEST_int_gt(EVP_PKEY_public_check(key_ctx), 0)
             || !TEST_true(EVP_PKEY_private_check(key_ctx))
             || !TEST_int_gt(EVP_PKEY_pairwise_check(key_ctx), 0))
             goto err;
@@ -842,7 +842,7 @@ static int test_fromdata_dh_fips186_4(void)
             goto err;
 
         if (!TEST_int_gt(EVP_PKEY_check(key_ctx), 0)
-            || !TEST_true(EVP_PKEY_public_check(key_ctx))
+            || !TEST_int_gt(EVP_PKEY_public_check(key_ctx), 0)
             || !TEST_true(EVP_PKEY_private_check(key_ctx))
             || !TEST_int_gt(EVP_PKEY_pairwise_check(key_ctx), 0))
             goto err;
@@ -1113,7 +1113,7 @@ static int test_fromdata_ecx(int tst)
                 goto err;
         } else {
             /* The private key check should fail if there is only a public key */
-            if (!TEST_true(EVP_PKEY_public_check(ctx2))
+            if (!TEST_int_gt(EVP_PKEY_public_check(ctx2), 0)
                 || !TEST_false(EVP_PKEY_private_check(ctx2))
                 || !TEST_int_le(EVP_PKEY_check(ctx2), 0))
                 goto err;
@@ -1607,7 +1607,7 @@ static int test_fromdata_dsa_fips186_4(void)
             goto err;
 
         if (!TEST_int_gt(EVP_PKEY_check(key_ctx), 0)
-            || !TEST_true(EVP_PKEY_public_check(key_ctx))
+            || !TEST_int_gt(EVP_PKEY_public_check(key_ctx), 0)
             || !TEST_true(EVP_PKEY_private_check(key_ctx))
             || !TEST_int_gt(EVP_PKEY_pairwise_check(key_ctx), 0))
             goto err;
@@ -1661,7 +1661,7 @@ static int test_check_dsa(void)
 
     if (!TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(NULL, "DSA", NULL))
         || !TEST_int_le(EVP_PKEY_check(ctx), 0)
-        || !TEST_false(EVP_PKEY_public_check(ctx))
+        || !TEST_int_le(EVP_PKEY_public_check(ctx), 0)
         || !TEST_false(EVP_PKEY_private_check(ctx))
         || !TEST_int_le(EVP_PKEY_pairwise_check(ctx), 0))
        goto err;