Re: [PATCH v9 3/3] crypto: Add Inside Secure SafeXcel EIP-93 crypto engine support
From: Christian Marangi
Date: Sat Jan 04 2025 - 11:26:47 EST
On Sat, Dec 21, 2024 at 07:44:30PM +0800, Herbert Xu wrote:
> On Sat, Dec 14, 2024 at 02:27:54PM +0100, Christian Marangi wrote:
> >
> > + ahash_tfm = crypto_alloc_ahash(alg_name, 0, 0);
> > + if (IS_ERR(ahash_tfm))
> > + return PTR_ERR(ahash_tfm);
> > +
> > + req = ahash_request_alloc(ahash_tfm, GFP_ATOMIC);
> > + if (!req) {
> > + ret = -ENOMEM;
> > + goto err_ahash;
> > + }
> > +
> > + rctx = ahash_request_ctx_dma(req);
> > + crypto_init_wait(&wait);
> > + ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
> > + crypto_req_done, &wait);
> > +
> > + /* Hash the key if > SHA256_BLOCK_SIZE */
> > + if (keylen > SHA256_BLOCK_SIZE) {
> > + sg_init_one(&sg[0], key, keylen);
> > +
> > + ahash_request_set_crypt(req, sg, ipad, keylen);
> > + ret = crypto_wait_req(crypto_ahash_digest(req), &wait);
>
> Sleeping in setkey is no longer allowed. I don't think it's
> fatal yet because the main user driving this currently uses
> sync ahashes only. But we should avoid this in all new driver
> code.
>
> Easiest fix would be to allocate a sync ahash:
>
> ahash_tfm = crypto_alloc_ahash(alg_name, 0, CRYPTO_ALG_SYNC);
>
Hi Herbert,
I'm a bit confused by this... I can't find any reference of
CRYPTO_ALG_SYNC, is this something new? Any hint on where to look for
it? Can't find it in include/linux/crypto.h
Following the codeflow of crypto_alloc_ahash is a bit problematic.
--
Ansuel