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:58:20 +0200 |
commit | 4aa3eb454e89fd78884faa168a90ccf19d0bca3a (patch) | |
tree | c7286d9a8738993b053fd792fa1d88a028525649 /providers/fips | |
parent | 5aa6e627953a4b3e96ea1f37b5ed71c9bb8c1e1b (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)
(cherry picked from commit d649c51a5388912277dffb56d921eb720db54be1)
Diffstat (limited to 'providers/fips')
-rw-r--r-- | providers/fips/self_test_kats.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/providers/fips/self_test_kats.c b/providers/fips/self_test_kats.c index 94a0cf842c..3a7d095c7b 100644 --- a/providers/fips/self_test_kats.c +++ b/providers/fips/self_test_kats.c @@ -72,10 +72,10 @@ static int cipher_init(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, in_tag = (unsigned char *)t->tag; return EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, enc) - && EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, t->iv_len, NULL) + && (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, t->iv_len, NULL) > 0) && (in_tag == NULL || EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, t->tag_len, - in_tag)) + in_tag) > 0) && EVP_CipherInit_ex(ctx, NULL, NULL, t->key, t->iv, enc) && EVP_CIPHER_CTX_set_padding(ctx, pad) && EVP_CipherUpdate(ctx, NULL, &tmp, t->aad, t->aad_len); @@ -117,8 +117,8 @@ static int self_test_cipher(const ST_KAT_CIPHER *t, OSSL_SELF_TEST *st, if (t->tag != NULL) { unsigned char tag[16] = { 0 }; - if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, t->tag_len, - tag) + if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, t->tag_len, + tag) <= 0 || memcmp(tag, t->tag, t->tag_len) != 0) goto err; } |