Re: [PATCH v11 3/3] crypto: Add Inside Secure SafeXcel EIP-93 crypto engine support
From: Herbert Xu
Date: Tue Apr 01 2025 - 06:53:35 EST
On Tue, Jan 14, 2025 at 01:36:36PM +0100, Christian Marangi wrote:
>
> +static void eip93_hash_export_sa_state(struct ahash_request *req,
> + struct eip93_hash_export_state *state)
> +{
> + struct eip93_hash_reqctx *rctx = ahash_request_ctx_dma(req);
> + struct sa_state *sa_state = &rctx->sa_state;
> +
> + /*
> + * EIP93 have special handling for state_byte_cnt in sa_state.
> + * Even if a zero packet is passed (and a BADMSG is returned),
> + * state_byte_cnt is incremented to the digest handled (with the hash
> + * primitive). This is problematic with export/import as EIP93
> + * expect 0 state_byte_cnt for the very first iteration.
> + */
> + if (!rctx->len)
> + memset(state->state_len, 0, sizeof(u32) * 2);
I don't understand when this can occur. As far as I can see,
zero-length packets are never passed to the hardware for hashing.
> + else
> + memcpy(state->state_len, sa_state->state_byte_cnt,
> + sizeof(u32) * 2);
I need to know the endianness of state_byte_cnt, which I presume
is the number of bytes that have been hashed into the partial
hash state.
I need this because I'm changing the export format of all ahash
algorithms to match that of the generic implementation. This is
so that you can seamlessly switch between an async ahash and its
sync fallback.
Thanks,
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt