From: Eric Biggers <ebiggers@kernel.org>
To: Corentin Labbe <clabbe@baylibre.com>
Cc: herbert@gondor.apana.org.au, catalin.marinas@arm.com,
linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com,
linux-crypto@vger.kernel.org, will@kernel.org,
davem@davemloft.net, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] crypto: arm64: CE: implement export/import
Date: Wed, 19 Feb 2020 10:16:54 -0800 [thread overview]
Message-ID: <20200219181654.GB2312@sol.localdomain> (raw)
In-Reply-To: <1582128037-18644-1-git-send-email-clabbe@baylibre.com>
On Wed, Feb 19, 2020 at 04:00:37PM +0000, Corentin Labbe wrote:
> When an ahash algorithm fallback to another ahash and that fallback is
> shaXXX-CE, doing export/import lead to error like this:
> alg: ahash: sha1-sun8i-ce export() overran state buffer on test vector 0, cfg=\"import/export\"
>
> This is due to the descsize of shaxxx-ce larger than struct shaxxx_state off by an u32.
> For fixing this, let's implement export/import which rip the finalize
> variant instead of using generic export/import.
>
> Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
> ---
> arch/arm64/crypto/sha1-ce-glue.c | 20 ++++++++++++++++++++
> arch/arm64/crypto/sha2-ce-glue.c | 23 +++++++++++++++++++++++
> 2 files changed, 43 insertions(+)
>
> diff --git a/arch/arm64/crypto/sha1-ce-glue.c b/arch/arm64/crypto/sha1-ce-glue.c
> index 63c875d3314b..dc44d48415cd 100644
> --- a/arch/arm64/crypto/sha1-ce-glue.c
> +++ b/arch/arm64/crypto/sha1-ce-glue.c
> @@ -91,12 +91,32 @@ static int sha1_ce_final(struct shash_desc *desc, u8 *out)
> return sha1_base_finish(desc, out);
> }
>
> +static int sha1_ce_export(struct shash_desc *desc, void *out)
> +{
> + struct sha1_ce_state *sctx = shash_desc_ctx(desc);
> +
> + memcpy(out, sctx, sizeof(struct sha1_state));
> + return 0;
> +}
> +
> +static int sha1_ce_import(struct shash_desc *desc, const void *in)
> +{
> + struct sha1_ce_state *sctx = shash_desc_ctx(desc);
> +
> + memcpy(sctx, in, sizeof(struct sha1_state));
> + sctx->finalize = 0;
> + return 0;
> +}
Can you use '&sctx->sst' instead of 'sctx' so that we aren't relying on the
'struct sha1_state' being located at the beginning of the struct?
Likewise for SHA-2.
- Eric
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-02-19 18:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-19 16:00 [PATCH] crypto: arm64: CE: implement export/import Corentin Labbe
2020-02-19 18:16 ` Eric Biggers [this message]
2020-02-21 19:55 ` LABBE Corentin
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=20200219181654.GB2312@sol.localdomain \
--to=ebiggers@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=clabbe@baylibre.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@googlegroups.com \
--cc=will@kernel.org \
/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