Re: [PATCH v3 1/3] crypto: ti - Add support for SHA224/256/384/512 in DTHEv2 driver

From: Herbert Xu

Date: Sat Mar 14 2026 - 00:00:10 EST


On Thu, Feb 26, 2026 at 06:41:01PM +0530, T Pratham wrote:
>
> +static int dthe_hash_export(struct ahash_request *req, void *out)
> +{
> + struct dthe_hash_req_ctx *rctx = ahash_request_ctx(req);
> + struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
> + struct dthe_tfm_ctx *ctx = crypto_ahash_ctx(tfm);
> + union {
> + u8 *u8;
> + u64 *u64;
> + } p = { .u8 = out };
> +
> + memcpy(out, rctx->phash, ctx->phash_size);
> + p.u8 += ctx->phash_size;
> + put_unaligned(rctx->digestcnt[0], p.u64++);
> + if (ctx->phash_size >= SHA512_DIGEST_SIZE)
> + put_unaligned(rctx->digestcnt[1], p.u64++);
> +
> + return 0;
> +}

The hash state must always be exported, even right after initialisation.
So you need to export the initial SHA stats if phash_available is
false.

Cheers,
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt