crypto: arm64/sha256 - implement library instead of shash
authorEric Biggers <ebiggers@google.com>
Mon, 28 Apr 2025 17:00:29 +0000 (10:00 -0700)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 5 May 2025 10:20:43 +0000 (18:20 +0800)
commit6e36be511d2846f40c0095c408797ceef17db4f5
tree882e488dc2db524a8dfaed6abaeabce99c2fe8a4
parent642cfc0680ff9aae73cd87d6fffcc84d9434938b
crypto: arm64/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.

Remove support for SHA-256 finalization from the ARMv8 CE assembly code,
since the library does not yet support architecture-specific overrides
of the finalization.  (Support for that has been omitted for now, for
simplicity and because usually it isn't performance-critical.)

To match sha256_blocks_arch(), change the type of the nblocks parameter
of the assembly functions from int or 'unsigned int' to size_t.  Update
the ARMv8 CE assembly function accordingly.  The scalar and NEON
assembly functions actually already treated it as size_t.

While renaming the assembly files, also fix the naming quirks where
"sha2" meant sha256, and "sha512" meant both sha256 and sha512.

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>
13 files changed:
arch/arm64/configs/defconfig
arch/arm64/crypto/Kconfig
arch/arm64/crypto/Makefile
arch/arm64/crypto/sha2-ce-core.S [deleted file]
arch/arm64/crypto/sha2-ce-glue.c [deleted file]
arch/arm64/crypto/sha256-glue.c [deleted file]
arch/arm64/crypto/sha512-armv8.pl [deleted file]
arch/arm64/lib/crypto/.gitignore
arch/arm64/lib/crypto/Kconfig
arch/arm64/lib/crypto/Makefile
arch/arm64/lib/crypto/sha2-armv8.pl [new file with mode: 0644]
arch/arm64/lib/crypto/sha256-ce.S [new file with mode: 0644]
arch/arm64/lib/crypto/sha256.c [new file with mode: 0644]