Re: [PATCH RFC 1/2] crypto: ti: Add support for SHA224/256/384/512 in DTHE V2 driver

From: Herbert Xu
Date: Wed Apr 02 2025 - 10:00:36 EST


On Wed, Apr 02, 2025 at 07:01:25PM +0530, T Pratham wrote:
>
> How are you planning to restore such states in import if the export is
> to be made compatible with sha512_state? Do you have any pointers for me
> on how to change the import/export before sending the next revision of
> my driver?

In struct sha512_state buflen is simply stored in the lower bits of
count[0]. So when you import count[0] you can derive buflen from it
as

buflen = count[0] & (SHA512_BLOCK_SIZE - 1);

Of course when you're exporting don't forget to put buflen into
the lower bits of count[0] before you write it out.

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