lib/crypto: sha256: Remove sha256_blocks_simd()
authorEric Biggers <ebiggers@kernel.org>
Mon, 30 Jun 2025 16:06:35 +0000 (09:06 -0700)
committerEric Biggers <ebiggers@kernel.org>
Fri, 4 Jul 2025 17:18:53 +0000 (10:18 -0700)
commit9f97707bdb1e479ea15e14e5525164f5f1128e97
tree1110e97931b1dbeb53243baa9036f038d8845750
parent3135d5be7c27841526d98150c245304ab312e9f4
lib/crypto: sha256: Remove sha256_blocks_simd()

Instead of having both sha256_blocks_arch() and sha256_blocks_simd(),
instead have just sha256_blocks_arch() which uses the most efficient
implementation that is available in the calling context.

This is simpler, as it reduces the API surface.  It's also safer, since
sha256_blocks_arch() just works in all contexts, including contexts
where the FPU/SIMD/vector registers cannot be used.  This doesn't mean
that SHA-256 computations *should* be done in such contexts, but rather
we should just do the right thing instead of corrupting a random task's
registers.  Eliminating this footgun and simplifying the code is well
worth the very small performance cost of doing the check.

Note: in the case of arm and arm64, what used to be sha256_blocks_arch()
is renamed back to its original name of sha256_block_data_order().
sha256_blocks_arch() is now used for the higher-level dispatch function.
This renaming also required an update to lib/crypto/arm64/sha512.h,
since sha2-armv8.pl is shared by both SHA-256 and SHA-512.

Acked-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20250630160645.3198-5-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
13 files changed:
include/crypto/internal/sha2.h
lib/crypto/Kconfig
lib/crypto/arm/Kconfig
lib/crypto/arm/sha256-armv4.pl
lib/crypto/arm/sha256.c
lib/crypto/arm64/Kconfig
lib/crypto/arm64/sha2-armv8.pl
lib/crypto/arm64/sha256.c
lib/crypto/arm64/sha512.h
lib/crypto/riscv/Kconfig
lib/crypto/riscv/sha256.c
lib/crypto/x86/Kconfig
lib/crypto/x86/sha256.c