From: Peiwei Hu Date: Sun, 14 Nov 2021 09:57:57 +0000 (+0800) Subject: Fix EVP_PKEY_decrypt return check X-Git-Tag: openssl-3.2.0-alpha1~3310 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0650ac437b529274aca094c516a5a0127bbaf48c;p=thirdparty%2Fopenssl.git Fix EVP_PKEY_decrypt return check Reviewed-by: Paul Dale Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/17028) --- diff --git a/test/acvp_test.c b/test/acvp_test.c index 89b5400feaf..d8425f0d207 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 70267539656..444b2796de0 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 cfd5991770d..73cc072af1d 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;