[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aYWsJAmf05EdotTX@gondor.apana.org.au>
Date: Fri, 6 Feb 2026 16:53:56 +0800
From: Herbert Xu <herbert@...dor.apana.org.au>
To: T Pratham <t-pratham@...com>
Cc: "David S. Miller" <davem@...emloft.net>,
Manorit Chawdhry <m-chawdhry@...com>,
Kamlesh Gurudasani <kamlesh@...com>,
Shiva Tripathi <s-tripathi1@...com>,
Kavitha Malarvizhi <k-malarvizhi@...com>,
Vishal Mahaveer <vishalm@...com>,
Praneeth Bajjuri <praneeth@...com>, linux-crypto@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v8 1/3] crypto: ti - Add support for AES-CTR in DTHEv2
driver
On Tue, Jan 20, 2026 at 08:14:06PM +0530, T Pratham wrote:
>
> + /*
> + * CTR mode can operate on any input length, but the hardware
> + * requires input length to be a multiple of the block size.
> + * We need to handle the padding in the driver.
> + */
> + if (ctx->aes_mode == DTHE_AES_CTR && req->cryptlen % AES_BLOCK_SIZE) {
> + struct scatterlist *sg;
> + int i = 0;
> + unsigned int curr_len = 0;
> +
> + len -= req->cryptlen % AES_BLOCK_SIZE;
> + src_nents = sg_nents_for_len(req->src, len);
> + dst_nents = sg_nents_for_len(req->dst, len);
> +
> + /*
> + * Need to truncate the src and dst to len, else DMA complains.
> + * Lengths restored at end
> + */
> + for_each_sg(req->src, sg, src_nents - 1, i) {
> + curr_len += sg->length;
> + }
> + curr_len += sg->length;
> + src_bkup_len = sg->length;
> + sg->length -= curr_len % AES_BLOCK_SIZE;
Please don't modify the SG lists since they may be used elsewhere.
There is no harm in mapping a bit more data than what you will
end up using.
Just truncate the length written to the hardware instead.
Thanks,
--
Email: Herbert Xu <herbert@...dor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Powered by blists - more mailing lists