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

From: Herbert Xu
Date: Sat Nov 13 2021 - 01:01:37 EST


On Fri, Oct 22, 2021 at 05:10:51PM +0800, Kai Ye wrote:
>
> +static int sec_ahash_export(struct ahash_request *req, void *out)
> +{
> + /*
> + * This function dumps the
> + * entire state of the ongoing transformation into a provided block of
> + * data so it can be @import'ed back later on.
> + */
> + struct sec_req *sreq = ahash_request_ctx(req);
> + struct sec_auth_ctx *a_ctx = &sreq->ctx->a_ctx;
> + u8 mac_len = a_ctx->mac_len;
> +
> + memcpy(out, &sreq->hash_req, sizeof(struct sec_ahash_req));

So this structure seems to contain a bunch of metadata but not
the actual hash state.

> + /* Export the partial hash data */
> + memcpy(out + sizeof(struct sec_ahash_req), a_ctx->metamac, mac_len);

This looks like it could be the hash state, but mac_len is clamped
at digest size so it's way too small to contain the entire hash
state.

How is this supposed to work?

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