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)
This commit is contained in:
parent
546b9f6b5c
commit
0650ac437b
3 changed files with 6 additions and 5 deletions
|
@ -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);
|
||||
|
|
|
@ -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)))
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue