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

From: Herbert Xu

Date: Fri Jun 05 2026 - 06:25:46 EST


On Tue, May 26, 2026 at 03:13:51PM +0530, T Pratham wrote:
>
> +static int dthe_hash_final(struct ahash_request *req)
> +{
> + struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
> + struct dthe_tfm_ctx *ctx = crypto_ahash_ctx(tfm);
> + struct dthe_hash_req_ctx *rctx = ahash_request_ctx(req);
> + struct dthe_data *dev_data = dthe_get_dev(ctx);
> + struct crypto_engine *engine = dev_data->hash_engine;
> +
> + /**
> + * We are always buffering data in update, except when nbytes = 0.
> + * So, either we get the buffered data here (nbytes > 0) or
> + * it is the case that we got zero message to begin with
> + */
> + if (req->nbytes > 0) {
> + rctx->flags = DTHE_HASH_OP_FINUP;
> +
> + return crypto_transfer_hash_request_to_engine(engine, req);
> + }
> +
> + dthe_hash_write_zero_message(ctx->hash_mode, req->result);

This doesn't look right. If I do an update of 64 bytes, and then
call final with req->nbytes == 0, this will give me a zero-length
hash.

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