Skip to content

Commit

Permalink
EVP_DigestVerifyFinal: fix test function and invocation
Browse files Browse the repository at this point in the history
Signed-off-by: Peiwei Hu <[email protected]>

Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from openssl#17029)
  • Loading branch information
PeiweiHu authored and t8m committed Nov 16, 2021
1 parent 6d77473 commit e2e5e72
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion demos/signature/EVP_Signature_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ static int demo_verify(OSSL_LIB_CTX *libctx, const char *sig_name,
fprintf(stderr, "EVP_DigestVerifyUpdate(hamlet_2) failed.\n");
goto cleanup;
}
if (!EVP_DigestVerifyFinal(verify_context, sig_value, sig_len)) {
if (EVP_DigestVerifyFinal(verify_context, sig_value, sig_len) <= 0) {
fprintf(stderr, "EVP_DigestVerifyFinal failed.\n");
goto cleanup;
}
Expand Down
16 changes: 8 additions & 8 deletions test/evp_extra_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1273,11 +1273,11 @@ static int test_EVP_DigestSignInit(int tst)
sizeof(kMsg))))
goto out;
}
if (!TEST_true(EVP_DigestVerifyFinal(md_ctx_verify, sig, sig_len)))
if (!TEST_int_gt(EVP_DigestVerifyFinal(md_ctx_verify, sig, sig_len), 0))
goto out;

/* Multiple calls to EVP_DigestVerifyFinal should work */
if (!TEST_true(EVP_DigestVerifyFinal(md_ctx_verify, sig, sig_len)))
if (!TEST_int_gt(EVP_DigestVerifyFinal(md_ctx_verify, sig, sig_len), 0))
goto out;
} else {
/*
Expand Down Expand Up @@ -1323,15 +1323,15 @@ static int test_EVP_DigestVerifyInit(void)

if (!TEST_true(EVP_DigestVerifyInit(md_ctx, NULL, EVP_sha256(), NULL, pkey))
|| !TEST_true(EVP_DigestVerifyUpdate(md_ctx, kMsg, sizeof(kMsg)))
|| !TEST_true(EVP_DigestVerifyFinal(md_ctx, kSignature,
sizeof(kSignature))))
|| !TEST_int_gt(EVP_DigestVerifyFinal(md_ctx, kSignature,
sizeof(kSignature)), 0))
goto out;

/* test with reinitialization */
if (!TEST_true(EVP_DigestVerifyInit(md_ctx, NULL, NULL, NULL, NULL))
|| !TEST_true(EVP_DigestVerifyUpdate(md_ctx, kMsg, sizeof(kMsg)))
|| !TEST_true(EVP_DigestVerifyFinal(md_ctx, kSignature,
sizeof(kSignature))))
|| !TEST_int_gt(EVP_DigestVerifyFinal(md_ctx, kSignature,
sizeof(kSignature)), 0))
goto out;
ret = 1;

Expand Down Expand Up @@ -1786,7 +1786,7 @@ static int test_EVP_SM2_verify(void)
if (!TEST_true(EVP_DigestVerifyUpdate(mctx, msg, strlen(msg))))
goto done;

if (!TEST_true(EVP_DigestVerifyFinal(mctx, signature, sizeof(signature))))
if (!TEST_int_gt(EVP_DigestVerifyFinal(mctx, signature, sizeof(signature)), 0))
goto done;
rc = 1;

Expand Down Expand Up @@ -1896,7 +1896,7 @@ static int test_EVP_SM2(void)
if (!TEST_true(EVP_DigestVerifyUpdate(md_ctx_verify, kMsg, sizeof(kMsg))))
goto done;

if (!TEST_true(EVP_DigestVerifyFinal(md_ctx_verify, sig, sig_len)))
if (!TEST_int_gt(EVP_DigestVerifyFinal(md_ctx_verify, sig, sig_len), 0))
goto done;

/* now check encryption/decryption */
Expand Down

0 comments on commit e2e5e72

Please sign in to comment.