mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] crypto: tegra: Fix IV usage for AES ECB
@ 2025-03-26 14:51 Akhil R
  2025-04-07  5:20 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Akhil R @ 2025-03-26 14:51 UTC (permalink / raw)
  To: herbert, davem, thierry.reding, jonathanh, linux-crypto,
	linux-tegra, linux-kernel
  Cc: Akhil R

Modifying the crypto_request turns out to be not the right way to handle
the stale value issue with the IV. Though the IV is not used for AES ECB,
it eventually get used in algorithms like LRW in the next step after
AES ECB encryption/decryption. Setting req->iv to NULL breaks the
implementation of such algorithms. Hence modify only the local reqctx
to check for IV.

Fixes: bde558220866 ("crypto: tegra - Set IV to NULL explicitly for AES ECB")
Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
---
 drivers/crypto/tegra/tegra-se-aes.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/crypto/tegra/tegra-se-aes.c b/drivers/crypto/tegra/tegra-se-aes.c
index ca9d0cca1f74..0e07d0523291 100644
--- a/drivers/crypto/tegra/tegra-se-aes.c
+++ b/drivers/crypto/tegra/tegra-se-aes.c
@@ -269,7 +269,7 @@ static int tegra_aes_do_one_req(struct crypto_engine *engine, void *areq)
 	unsigned int cmdlen, key1_id, key2_id;
 	int ret;
 
-	rctx->iv = (u32 *)req->iv;
+	rctx->iv = (ctx->alg == SE_ALG_ECB) ? NULL : (u32 *)req->iv;
 	rctx->len = req->cryptlen;
 	key1_id = ctx->key1_id;
 	key2_id = ctx->key2_id;
@@ -498,9 +498,6 @@ 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;
 
 	return crypto_transfer_skcipher_request_to_engine(ctx->se->engine, req);
-- 
2.43.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] crypto: tegra: Fix IV usage for AES ECB
  2025-03-26 14:51 [PATCH] crypto: tegra: Fix IV usage for AES ECB Akhil R
@ 2025-04-07  5:20 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2025-04-07  5:20 UTC (permalink / raw)
  To: Akhil R
  Cc: davem, thierry.reding, jonathanh, linux-crypto, linux-tegra,
	linux-kernel

On Wed, Mar 26, 2025 at 08:21:10PM +0530, Akhil R wrote:
> Modifying the crypto_request turns out to be not the right way to handle
> the stale value issue with the IV. Though the IV is not used for AES ECB,
> it eventually get used in algorithms like LRW in the next step after
> AES ECB encryption/decryption. Setting req->iv to NULL breaks the
> implementation of such algorithms. Hence modify only the local reqctx
> to check for IV.
> 
> Fixes: bde558220866 ("crypto: tegra - Set IV to NULL explicitly for AES ECB")
> Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
> ---
>  drivers/crypto/tegra/tegra-se-aes.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-04-07  5:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-26 14:51 [PATCH] crypto: tegra: Fix IV usage for AES ECB Akhil R
2025-04-07  5:20 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®