crypto: arm/sha256 - implement library instead of shash
authorEric Biggers <ebiggers@google.com>
Mon, 28 Apr 2025 17:00:27 +0000 (10:00 -0700)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 5 May 2025 10:20:43 +0000 (18:20 +0800)
commitca4477e41c68b58043e67bc78074cd6fcc59ee5e
treed68f227d513b43ab56d3d0374e06820785d28e91
parent950e5c84118c9e5b06bb9a9b64edf989ee4034df
crypto: arm/sha256 - implement library instead of shash

Instead of providing crypto_shash algorithms for the arch-optimized
SHA-256 code, instead implement the SHA-256 library.  This is much
simpler, it makes the SHA-256 library functions be arch-optimized, and
it fixes the longstanding issue where the arch-optimized SHA-256 was
disabled by default.  SHA-256 still remains available through
crypto_shash, but individual architectures no longer need to handle it.

To merge the scalar, NEON, and CE code all into one module cleanly, add
!CPU_V7M as a direct dependency of the CE code.  Previously, !CPU_V7M
was only a direct dependency of the scalar and NEON code.  The result is
still the same because CPU_V7M implies !KERNEL_MODE_NEON, so !CPU_V7M
was already an indirect dependency of the CE code.

To match sha256_blocks_arch(), change the type of the nblocks parameter
of the assembly functions from int to size_t.  The assembly functions
actually already treated it as size_t.

While renaming the assembly files, also fix the naming quirk where
"sha2" meant sha256.  (SHA-512 is also part of SHA-2.)

Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
19 files changed:
arch/arm/configs/exynos_defconfig
arch/arm/configs/milbeaut_m10v_defconfig
arch/arm/configs/multi_v7_defconfig
arch/arm/configs/omap2plus_defconfig
arch/arm/configs/pxa_defconfig
arch/arm/crypto/Kconfig
arch/arm/crypto/Makefile
arch/arm/crypto/sha2-ce-core.S [deleted file]
arch/arm/crypto/sha2-ce-glue.c [deleted file]
arch/arm/crypto/sha256-armv4.pl [deleted file]
arch/arm/crypto/sha256_glue.c [deleted file]
arch/arm/crypto/sha256_glue.h [deleted file]
arch/arm/crypto/sha256_neon_glue.c [deleted file]
arch/arm/lib/crypto/.gitignore
arch/arm/lib/crypto/Kconfig
arch/arm/lib/crypto/Makefile
arch/arm/lib/crypto/sha256-armv4.pl [new file with mode: 0644]
arch/arm/lib/crypto/sha256-ce.S [new file with mode: 0644]
arch/arm/lib/crypto/sha256.c [new file with mode: 0644]