aboutsummaryrefslogtreecommitdiff
path: root/crypto/cmac/cmac.c
diff options
context:
space:
mode:
authorPeiwei Hu <jlu.hpw@foxmail.com>2022-05-24 22:57:53 +0800
committerTomas Mraz <tomas@openssl.org>2022-05-27 07:58:45 +0200
commitacd6338ff0afa31730a0cff62d993a8ebc63db5c (patch)
tree3e3a9bae859a2359121da6cf75f448d4238c6cdf /crypto/cmac/cmac.c
parentd3c5aff6cbf1ed6c855fb450b2caefbda8b9ce0f (diff)
downloadopenssl-acd6338ff0afa31730a0cff62d993a8ebc63db5c.zip
openssl-acd6338ff0afa31730a0cff62d993a8ebc63db5c.tar.gz
openssl-acd6338ff0afa31730a0cff62d993a8ebc63db5c.tar.bz2
Fix the incorrect checks of EVP_CIPHER_CTX_set_key_length
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18397) (cherry picked from commit 8d9fec1781751d2106d899c6076eeb3da6930bfe)
Diffstat (limited to 'crypto/cmac/cmac.c')
-rw-r--r--crypto/cmac/cmac.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/crypto/cmac/cmac.c b/crypto/cmac/cmac.c
index 218eb94..15968f7 100644
--- a/crypto/cmac/cmac.c
+++ b/crypto/cmac/cmac.c
@@ -137,9 +137,9 @@ int CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen,
/* If anything fails then ensure we can't use this ctx */
ctx->nlast_block = -1;
- if (!EVP_CIPHER_CTX_get0_cipher(ctx->cctx))
+ if (EVP_CIPHER_CTX_get0_cipher(ctx->cctx) == NULL)
return 0;
- if (!EVP_CIPHER_CTX_set_key_length(ctx->cctx, keylen))
+ if (EVP_CIPHER_CTX_set_key_length(ctx->cctx, keylen) <= 0)
return 0;
if (!EVP_EncryptInit_ex(ctx->cctx, NULL, NULL, key, zero_iv))
return 0;