mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: T Pratham <t-pratham@ti.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: "David S. Miller" <davem@davemloft.net>,
	Manorit Chawdhry <m-chawdhry@ti.com>,
	Kamlesh Gurudasani <kamlesh@ti.com>,
	Shiva Tripathi <s-tripathi1@ti.com>,
	Kavitha Malarvizhi <k-malarvizhi@ti.com>,
	"Vishal Mahaveer" <vishalm@ti.com>,
	Praneeth Bajjuri <praneeth@ti.com>,
	<linux-kernel@vger.kernel.org>, <linux-crypto@vger.kernel.org>
Subject: Re: [PATCH v4 1/3] crypto: ti - Add support for SHA224/256/384/512 in DTHEv2 driver
Date: Fri, 5 Jun 2026 16:11:49 +0530	[thread overview]
Message-ID: <e0aec964-3303-4ca2-8d96-6a5d8f5ec9e5@ti.com> (raw)
In-Reply-To: <aiKgs8ipDLPlz6c4@gondor.apana.org.au>

On 6/5/26 15:40, Herbert Xu wrote:
> 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,

.cra_flags sets CRYPTO_AHASH_ALG_BLOCK_ONLY and
CRYPTO_AHASH_ALG_FINAL_NONZERO flags. An update of 64 bytes will do an
update of block size and carry over at least one byte to final. We
always go into this if block when there is non-zero data coming into update.

-- 
Regards
T Pratham <t-pratham@ti.com>

  reply	other threads:[~2026-06-05 10:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-26  9:43 [PATCH v4 0/3] Add support for hashing algorithms in TI DTHE V2 T Pratham
2026-05-26  9:43 ` [PATCH v4 1/3] crypto: ti - Add support for SHA224/256/384/512 in DTHEv2 driver T Pratham
2026-06-05 10:10   ` Herbert Xu
2026-06-05 10:41     ` T Pratham [this message]
2026-06-05 10:59       ` Herbert Xu
2026-06-26 12:57         ` T Pratham
2026-07-13  3:40           ` Herbert Xu
2026-05-26  9:43 ` [PATCH v4 2/3] crypto: ti - Add support for MD5 in DTHEv2 Hashing Engine driver T Pratham
2026-05-26  9:43 ` [PATCH v4 3/3] crypto: ti - Add support for HMAC " T Pratham

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=e0aec964-3303-4ca2-8d96-6a5d8f5ec9e5@ti.com \
    --to=t-pratham@ti.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=k-malarvizhi@ti.com \
    --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=s-tripathi1@ti.com \
    --cc=vishalm@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

all inboxes | Powered by JetHome®