summaryrefslogtreecommitdiff
path: root/providers/fips
diff options
context:
space:
mode:
authorPeiwei Hu <jlu.hpw@foxmail.com>2022-05-21 16:17:23 +0800
committerTomas Mraz <tomas@openssl.org>2022-05-24 08:57:37 +0200
commitd649c51a5388912277dffb56d921eb720db54be1 (patch)
treef98696e10572ae47f0733c4a73fcbaee39b6c892 /providers/fips
parent36c269c3023f5eb626ec79777ed8b285ef939be2 (diff)
downloadopenssl-new-d649c51a5388912277dffb56d921eb720db54be1.tar.gz
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 'providers/fips')
-rw-r--r--providers/fips/self_test_kats.c8
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;
}