lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aBTCHeChXenAQrBH@gondor.apana.org.au>
Date: Fri, 2 May 2025 21:01:17 +0800
From: Herbert Xu <herbert@...dor.apana.org.au>
To: T Pratham <t-pratham@...com>
Cc: "David S. Miller" <davem@...emloft.net>,
	Kamlesh Gurudasani <kamlesh@...com>,
	Vignesh Raghavendra <vigneshr@...com>,
	Praneeth Bajjuri <praneeth@...com>,
	Manorit Chawdhry <m-chawdhry@...com>, linux-kernel@...r.kernel.org,
	linux-crypto@...r.kernel.org
Subject: Re: [PATCH v3 2/2] crypto: ti: Add driver for DTHE V2 AES Engine
 (ECB, CBC)

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@...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

Powered by Openwall GNU/*/Linux Powered by OpenVZ