From: Akhil R <akhilrajeev@nvidia.com>
To: <herbert@gondor.apana.org.au>, <davem@davemloft.net>,
<thierry.reding@gmail.com>, <jonathanh@nvidia.com>,
<linux-crypto@vger.kernel.org>, <linux-tegra@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Cc: <akhilrajeev@nvidia.com>
Subject: [PATCH 7/7] crypto: tegra: Set IV to NULL explicitly for AES ECB
Date: Tue, 17 Dec 2024 21:42:07 +0530 [thread overview]
Message-ID: <20241217161207.72921-8-akhilrajeev@nvidia.com> (raw)
In-Reply-To: <20241217161207.72921-1-akhilrajeev@nvidia.com>
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>
---
drivers/crypto/tegra/tegra-se-aes.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/crypto/tegra/tegra-se-aes.c b/drivers/crypto/tegra/tegra-se-aes.c
index cdcf05e235ca..be0a0b51f5a5 100644
--- a/drivers/crypto/tegra/tegra-se-aes.c
+++ b/drivers/crypto/tegra/tegra-se-aes.c
@@ -443,6 +443,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);
--
2.43.2
prev parent reply other threads:[~2024-12-17 16:15 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-17 16:12 [PATCH 0/7] Tegra Security Engine driver improvements Akhil R
2024-12-17 16:12 ` [PATCH 1/7] crypto: tegra: Use separate buffer for setkey Akhil R
2024-12-28 11:36 ` Herbert Xu
2024-12-31 4:25 ` Akhil R
2025-01-02 0:58 ` Herbert Xu
2025-01-06 4:11 ` Akhil R
2024-12-17 16:12 ` [PATCH 2/7] crypto: tegra: Do not use fixed size buffers Akhil R
2024-12-17 16:12 ` [PATCH 3/7] crypto: tegra: check retrun value for hash do_one_req Akhil R
2024-12-17 16:12 ` [PATCH 4/7] crypto: tegra: Transfer HASH init function to crypto engine Akhil R
2024-12-17 16:12 ` [PATCH 5/7] crypto: tegra: Fix HASH intermediate result handling Akhil R
2024-12-17 16:12 ` [PATCH 6/7] crypto: tegra: Fix CMAC " Akhil R
2024-12-17 16:12 ` Akhil R [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241217161207.72921-8-akhilrajeev@nvidia.com \
--to=akhilrajeev@nvidia.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=jonathanh@nvidia.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=thierry.reding@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox