Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: T Pratham <t-pratham@ti.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Kamlesh Gurudasani <kamlesh@ti.com>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Praneeth Bajjuri <praneeth@ti.com>,
	Manorit Chawdhry <m-chawdhry@ti.com>,
	linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org
Subject: Re: [PATCH v3 2/2] crypto: ti: Add driver for DTHE V2 AES Engine (ECB, CBC)
Date: Fri, 2 May 2025 21:01:17 +0800	[thread overview]
Message-ID: <aBTCHeChXenAQrBH@gondor.apana.org.au> (raw)
In-Reply-To: <20250502121253.456974-4-t-pratham@ti.com>

On Fri, May 02, 2025 at 05:21:17PM +0530, T Pratham wrote:
>
> +static int dthe_aes_crypt(struct skcipher_request *req, int enc)
> +{
> +	struct dthe_tfm_ctx *ctx = crypto_skcipher_ctx(crypto_skcipher_reqtfm(req));
> +	struct dthe_data *dev_data = dthe_get_dev(ctx);
> +	struct crypto_engine *engine;
> +
> +	/*
> +	 * If data is not a multiple of AES_BLOCK_SIZE, need to return -EINVAL
> +	 * If data length input is zero, no need to do any operation.
> +	 */
> +	if (req->cryptlen % AES_BLOCK_SIZE)
> +		return -EINVAL;
> +
> +	if (req->cryptlen == 0)
> +		return 0;
> +
> +	ctx->ctx_info.aes_ctx->enc = enc;

You can't modify crypto_skcipher_ctx as a tfm is shared between
multiple request objects.  If you need to keep track of the operation,
it needs to go into the request context (skcipher_request_ctx).

As a general rule, crypto_skcipher_ctx should only be used to
store key-related information and it can only be modifeid by
setkey.

Anything that is per-op should go into the request context.

> +/**
> + * struct dthe_data - DTHE_V2 driver instance data
> + * @dev: Device pointer
> + * @regs: Base address of the register space
> + * @list: list node for dev
> + * @engine: Crypto engine instance
> + * @dma_aes_rx: AES Rx DMA Channel
> + * @dma_aes_tx: AES Tx DMA Channel
> + * @dma_sha_tx: SHA Tx DMA Channel
> + * @ctx: Transform context struct
> + */
> +struct dthe_data {
> +	struct device *dev;
> +	void __iomem *regs;
> +	struct list_head list;
> +	struct crypto_engine *engine;
> +
> +	struct dma_chan *dma_aes_rx;
> +	struct dma_chan *dma_aes_tx;
> +
> +	struct dma_chan *dma_sha_tx;
> +
> +	struct dthe_tfm_ctx *ctx;

What's this field for? It doesn't seem to be used at all.

Cheers,
-- 
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

  reply	other threads:[~2025-05-02 13:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-02 11:51 [PATCH v3 0/2] Add support for Texas Instruments DTHE V2 crypto accelerator T Pratham
2025-05-02 11:51 ` [PATCH v3 1/2] dt-bindings: crypto: Add binding for TI DTHE V2 T Pratham
2025-05-04 17:17   ` Krzysztof Kozlowski
2025-05-02 11:51 ` [PATCH v3 2/2] crypto: ti: Add driver for DTHE V2 AES Engine (ECB, CBC) T Pratham
2025-05-02 13:01   ` Herbert Xu [this message]
2025-05-05 14:56   ` kernel test robot

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=aBTCHeChXenAQrBH@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=davem@davemloft.net \
    --cc=kamlesh@ti.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m-chawdhry@ti.com \
    --cc=praneeth@ti.com \
    --cc=t-pratham@ti.com \
    --cc=vigneshr@ti.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