From: Eric Biggers <ebiggers@kernel.org>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Linux Crypto Mailing List <linux-crypto@vger.kernel.org>,
linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org,
sparclinux@vger.kernel.org, linux-s390@vger.kernel.org,
x86@kernel.org, Ard Biesheuvel <ardb@kernel.org>,
"Jason A . Donenfeld" <Jason@zx2c4.com>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH 00/12] crypto: sha256 - Use partial block API
Date: Wed, 30 Apr 2025 10:45:43 -0700 [thread overview]
Message-ID: <20250430174543.GB1958@sol.localdomain> (raw)
In-Reply-To: <cover.1745992998.git.herbert@gondor.apana.org.au>
[Added back Cc's that were dropped]
On Wed, Apr 30, 2025 at 02:06:15PM +0800, Herbert Xu wrote:
> This is based on
>
> https://patchwork.kernel.org/project/linux-crypto/list/?series=957785
I'm assuming that you mean that with your diff
https://lore.kernel.org/r/aBGdiv17ztQnhAps@gondor.apana.org.au folded into my
first patch, since otherwise your patch series doesn't apply. But even with
that done, your patch series doesn't build:
In file included from ./include/crypto/hash_info.h:12,
from crypto/hash_info.c:9:
./include/crypto/sha2.h: In function ‘sha256_init’:
./include/crypto/sha2.h:101:32: error: ‘struct sha256_state’ has no member named ‘ctx’
101 | sha256_block_init(&sctx->ctx);
| ^~
> Rather than going through the lib/sha256 partial block handling,
> use the native shash partial block API. Add two extra shash
> algorithms to provide testing coverage for lib/sha256.
>
> Herbert Xu (12):
> crypto: lib/sha256 - Restore lib_sha256 finup code
> crypto: sha256 - Use the partial block API for generic
> crypto: arm/sha256 - Add simd block function
> crypto: arm64/sha256 - Add simd block function
> crypto: mips/sha256 - Export block functions as GPL only
> crypto: powerpc/sha256 - Export block functions as GPL only
> crypto: riscv/sha256 - Add simd block function
> crypto: s390/sha256 - Export block functions as GPL only
> crypto: sparc/sha256 - Export block functions as GPL only
> crypto: x86/sha256 - Add simd block function
> crypto: lib/sha256 - Use generic block helper
> crypto: sha256 - Use the partial block API
>
> arch/arm/lib/crypto/Kconfig | 1 +
> arch/arm/lib/crypto/sha256-armv4.pl | 20 +--
> arch/arm/lib/crypto/sha256.c | 16 +--
> arch/arm64/crypto/sha512-glue.c | 6 +-
> arch/arm64/lib/crypto/Kconfig | 1 +
> arch/arm64/lib/crypto/sha2-armv8.pl | 2 +-
> arch/arm64/lib/crypto/sha256.c | 16 +--
> .../mips/cavium-octeon/crypto/octeon-sha256.c | 4 +-
> arch/powerpc/lib/crypto/sha256.c | 4 +-
> arch/riscv/lib/crypto/Kconfig | 1 +
> arch/riscv/lib/crypto/sha256.c | 17 ++-
> arch/s390/lib/crypto/sha256.c | 4 +-
> arch/sparc/lib/crypto/sha256.c | 4 +-
> arch/x86/lib/crypto/Kconfig | 1 +
> arch/x86/lib/crypto/sha256.c | 16 ++-
> crypto/sha256.c | 134 +++++++++++-------
> include/crypto/internal/sha2.h | 46 ++++++
> include/crypto/sha2.h | 14 +-
> lib/crypto/Kconfig | 8 ++
> lib/crypto/sha256.c | 100 +++----------
> 20 files changed, 232 insertions(+), 183 deletions(-)
The EXPORT_SYMBOL => EXPORT_SYMBOL_GPL changes are fine and should just be one
patch. I was just trying to be consistent with lib/crypto/sha256.c which uses
EXPORT_SYMBOL, but EXPORT_SYMBOL_GPL is fine too.
Everything else in this series is harmful, IMO.
I already covered why crypto_shash should simply use the library and not do
anything special.
As for your sha256_finup "optimization", it's an interesting idea, but
unfortunately it slightly slows down the common case which is count % 64 < 56,
due to the unnecessary copy to the stack and the following zeroization. In the
uncommon case where count % 64 >= 56 you do get to pass nblocks=2 to
sha256_blocks_*(), but ultimately SHA-256 is serialized block-by-block anyway,
so it ends up being only slightly faster in that case, which again is the
uncommon case. So while it's an interesting idea, it doesn't seem to actually
be better. And the fact that that patch is also being used to submit unrelated,
more dubious changes isn't very helpful, of course.
- Eric
next parent reply other threads:[~2025-04-30 17:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1745992998.git.herbert@gondor.apana.org.au>
2025-04-30 17:45 ` Eric Biggers [this message]
2025-05-01 1:21 ` [PATCH 00/12] crypto: sha256 - Use partial block API Herbert Xu
2025-05-01 2:26 ` Eric Biggers
2025-05-01 5:19 ` Herbert Xu
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=20250430174543.GB1958@sol.localdomain \
--to=ebiggers@kernel.org \
--cc=Jason@zx2c4.com \
--cc=ardb@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-s390@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=sparclinux@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=x86@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;
as well as URLs for NNTP newsgroup(s).