diff options
author | Peiwei Hu <jlu.hpw@foxmail.com> | 2022-05-21 16:17:23 +0800 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2022-05-24 08:57:37 +0200 |
commit | d649c51a5388912277dffb56d921eb720db54be1 (patch) | |
tree | f98696e10572ae47f0733c4a73fcbaee39b6c892 /test/evp_test.c | |
parent | 36c269c3023f5eb626ec79777ed8b285ef939be2 (diff) |
Fix check of EVP_CIPHER_CTX_ctrl
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18368)
Diffstat (limited to 'test/evp_test.c')
-rw-r--r-- | test/evp_test.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/test/evp_test.c b/test/evp_test.c index 6427137b37..4198787bb9 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -769,8 +769,8 @@ static int cipher_test_enc(EVP_TEST *t, int enc, } if (expected->iv) { if (expected->aead) { - if (!EVP_CIPHER_CTX_ctrl(ctx_base, EVP_CTRL_AEAD_SET_IVLEN, - expected->iv_len, 0)) { + if (EVP_CIPHER_CTX_ctrl(ctx_base, EVP_CTRL_AEAD_SET_IVLEN, + expected->iv_len, 0) <= 0) { t->err = "INVALID_IV_LENGTH"; goto err; } @@ -793,8 +793,8 @@ static int cipher_test_enc(EVP_TEST *t, int enc, tag = expected->tag; } if (tag || expected->aead != EVP_CIPH_GCM_MODE) { - if (!EVP_CIPHER_CTX_ctrl(ctx_base, EVP_CTRL_AEAD_SET_TAG, - expected->tag_len, tag)) + if (EVP_CIPHER_CTX_ctrl(ctx_base, EVP_CTRL_AEAD_SET_TAG, + expected->tag_len, tag) <= 0) goto err; } } @@ -802,7 +802,7 @@ static int cipher_test_enc(EVP_TEST *t, int enc, if (expected->rounds > 0) { int rounds = (int)expected->rounds; - if (!EVP_CIPHER_CTX_ctrl(ctx_base, EVP_CTRL_SET_RC5_ROUNDS, rounds, NULL)) { + if (EVP_CIPHER_CTX_ctrl(ctx_base, EVP_CTRL_SET_RC5_ROUNDS, rounds, NULL) <= 0) { t->err = "INVALID_ROUNDS"; goto err; } @@ -815,7 +815,7 @@ static int cipher_test_enc(EVP_TEST *t, int enc, if (expected->key_bits > 0) { int bits = (int)expected->key_bits; - if (!EVP_CIPHER_CTX_ctrl(ctx_base, EVP_CTRL_SET_RC2_KEY_BITS, bits, NULL)) { + if (EVP_CIPHER_CTX_ctrl(ctx_base, EVP_CTRL_SET_RC2_KEY_BITS, bits, NULL) <= 0) { t->err = "INVALID KEY BITS"; goto err; } @@ -856,9 +856,9 @@ static int cipher_test_enc(EVP_TEST *t, int enc, ERR_pop_to_mark(); if (expected->mac_key != NULL - && !EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_MAC_KEY, + && EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_MAC_KEY, (int)expected->mac_key_len, - (void *)expected->mac_key)) { + (void *)expected->mac_key) <= 0) { t->err = "SET_MAC_KEY_ERROR"; goto err; } @@ -934,8 +934,8 @@ static int cipher_test_enc(EVP_TEST *t, int enc, OPENSSL_free(tls_aad); } else if (!enc && (expected->aead == EVP_CIPH_OCB_MODE || expected->tag_late)) { - if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, - expected->tag_len, expected->tag)) { + if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, + expected->tag_len, expected->tag) <= 0) { t->err = "TAG_SET_ERROR"; goto err; } @@ -997,8 +997,8 @@ static int cipher_test_enc(EVP_TEST *t, int enc, t->err = "TAG_LENGTH_INTERNAL_ERROR"; goto err; } - if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, - expected->tag_len, rtag)) { + if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, + expected->tag_len, rtag) <= 0) { t->err = "TAG_RETRIEVE_ERROR"; goto err; } |