diff options
author | Peiwei Hu <jlu.hpw@foxmail.com> | 2021-11-14 17:57:57 +0800 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2021-11-22 15:21:51 +0100 |
commit | 0cc5074e93dfcb4d44ece4cd21d3175a5a51f6f5 (patch) | |
tree | 34b52664781f564776aac017433b6269d507324b /test | |
parent | 12cdadb9f43e6e989bea7e9384884c5deca340a5 (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)
(cherry picked from commit 0650ac437b529274aca094c516a5a0127bbaf48c)
Diffstat (limited to 'test')
-rw-r--r-- | test/acvp_test.c | 2 | ||||
-rw-r--r-- | test/evp_extra_test.c | 4 | ||||
-rw-r--r-- | test/threadstest.c | 5 |
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 965de2e2c8..8efe051f20 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 505dd79e95..b7e781fb6b 100644 --- a/test/threadstest.c +++ b/test/threadstest.c @@ -293,7 +293,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; @@ -319,8 +319,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; |