Re: [PATCH v2 2/6] crypto: hisilicon/sec - add ahash alg features for Kunpeng920

From: Herbert Xu
Date: Fri Oct 01 2021 - 01:57:54 EST


On Fri, Sep 24, 2021 at 05:27:12PM +0800, Kai Ye wrote:
>
> +static int sec_ahash_import(struct ahash_request *req, const void *in)
> +{
> + /*
> + * Import partial state of the transformation. This function loads the
> + * entire state of the ongoing transformation from a provided block of
> + * data so the transformation can continue from this point onward.
> + */
> + struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
> + struct sec_req *sreq = ahash_request_ctx(req);
> + struct sec_ctx *ctx = crypto_ahash_ctx(tfm);
> + const struct sec_ahash_req *state = in;
> +
> + sreq->ctx = ctx;
> + memcpy(&sreq->hash_req, state, sizeof(struct sec_ahash_req));
> +
> + return 0;
> +}

It's still not clear how this function actually works.

Could you please explain how can this work in the following scenario?

x = export_state

reboot_machine

import_state(x)

How do you restore all the internal state so that further data
can be hashed onto the existing hash state after a reboot?

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