summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeiwei Hu <jlu.hpw@foxmail.com>2021-11-14 17:57:57 +0800
committerTomas Mraz <tomas@openssl.org>2021-11-22 14:43:44 +0100
commit0650ac437b529274aca094c516a5a0127bbaf48c (patch)
treee336c56a5f94100e8433c8a890e676136c1469e4
parent546b9f6b5cf6d0fde60aa37084eec1bb7d0fbc72 (diff)
Fix EVP_PKEY_decrypt return check
Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17028)
-rw-r--r--test/acvp_test.c2
-rw-r--r--test/evp_extra_test.c4
-rw-r--r--test/threadstest.c5
3 files changed, 6 insertions, 5 deletions
diff --git a/test/acvp_test.c b/test/acvp_test.c
index 89b5400fea..d8425f0d20 100644
--- a/test/acvp_test.c
+++ b/test/acvp_test.c
@@ -1261,7 +1261,7 @@ static int rsa_decryption_primitive_test(int id)
test_output_memory("n", n, n_len);
test_output_memory("e", e, e_len);
- if (!EVP_PKEY_decrypt(ctx, pt, &pt_len, tst->ct, tst->ct_len))
+ if (EVP_PKEY_decrypt(ctx, pt, &pt_len, tst->ct, tst->ct_len) <= 0)
TEST_note("Decryption Failed");
else
test_output_memory("pt", pt, pt_len);
diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c
index 7026753965..444b2796de 100644
--- a/test/evp_extra_test.c
+++ b/test/evp_extra_test.c
@@ -1940,8 +1940,8 @@ static int test_EVP_SM2(void)
if (!TEST_true(EVP_PKEY_CTX_set_params(cctx, sparams)))
goto done;
- if (!TEST_true(EVP_PKEY_decrypt(cctx, plaintext, &ptext_len, ciphertext,
- ctext_len)))
+ if (!TEST_int_gt(EVP_PKEY_decrypt(cctx, plaintext, &ptext_len, ciphertext,
+ ctext_len), 0))
goto done;
if (!TEST_true(EVP_PKEY_CTX_get_params(cctx, gparams)))
diff --git a/test/threadstest.c b/test/threadstest.c
index cfd5991770..73cc072af1 100644
--- a/test/threadstest.c
+++ b/test/threadstest.c
@@ -410,7 +410,7 @@ static void thread_shared_evp_pkey(void)
char *msg = "Hello World";
unsigned char ctbuf[256];
unsigned char ptbuf[256];
- size_t ptlen = sizeof(ptbuf), ctlen = sizeof(ctbuf);
+ size_t ptlen, ctlen = sizeof(ctbuf);
EVP_PKEY_CTX *ctx = NULL;
int success = 0;
int i;
@@ -436,8 +436,9 @@ static void thread_shared_evp_pkey(void)
if (!TEST_ptr(ctx))
goto err;
+ ptlen = sizeof(ptbuf);
if (!TEST_int_ge(EVP_PKEY_decrypt_init(ctx), 0)
- || !TEST_int_ge(EVP_PKEY_decrypt(ctx, ptbuf, &ptlen, ctbuf, ctlen),
+ || !TEST_int_gt(EVP_PKEY_decrypt(ctx, ptbuf, &ptlen, ctbuf, ctlen),
0)
|| !TEST_mem_eq(msg, strlen(msg), ptbuf, ptlen))
goto err;