]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
crypto: tegra - Set IV to NULL explicitly for AES ECB
authorAkhil R <akhilrajeev@nvidia.com>
Mon, 24 Feb 2025 09:16:08 +0000 (14:46 +0530)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sat, 8 Mar 2025 08:22:24 +0000 (16:22 +0800)
It may happen that the variable req->iv may have stale values or
zero sized buffer by default and may end up getting used during
encryption/decryption. This inturn may corrupt the results or break the
operation. Set the req->iv variable to NULL explicitly for algorithms
like AES-ECB where IV is not used.

Fixes: 0880bb3b00c8 ("crypto: tegra - Add Tegra Security Engine driver")
Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/tegra/tegra-se-aes.c

index c3afa8344e4ad540e18eb9dadd82463412807d4a..a1b469c3a55ba307421a7955d82a0191abd6c57e 100644 (file)
@@ -446,6 +446,9 @@ static int tegra_aes_crypt(struct skcipher_request *req, bool encrypt)
        if (!req->cryptlen)
                return 0;
 
+       if (ctx->alg == SE_ALG_ECB)
+               req->iv = NULL;
+
        rctx->encrypt = encrypt;
        rctx->config = tegra234_aes_cfg(ctx->alg, encrypt);
        rctx->crypto_config = tegra234_aes_crypto_cfg(ctx->alg, encrypt);