diff options
| author | Eric Biggers <ebiggers@kernel.org> | 2025-06-30 19:03:08 +0300 |
|---|---|---|
| committer | Eric Biggers <ebiggers@kernel.org> | 2025-06-30 19:26:19 +0300 |
| commit | 485deceec03997eabd884d4da89217af73d1ab8d (patch) | |
| tree | 1199e20158088d4a2e0cc559aea76aca483d2602 | |
| parent | 23e8b4371dbd5907d633262f36903144a378a114 (diff) | |
| download | linux-485deceec03997eabd884d4da89217af73d1ab8d.tar.xz | |
crypto: riscv/sha512 - Stop depending on sha512_generic_block_fn
sha512_generic_block_fn() will no longer be available when the SHA-512
support in the old-school crypto API is changed to just wrap the SHA-512
library. Replace the use of sha512_generic_block_fn() in
sha512-riscv64-glue.c with temporary code that uses the library's
__sha512_update(). This is just a temporary workaround to keep the
kernel building and functional at each commit; this code gets superseded
when the RISC-V optimized SHA-512 is migrated to lib/crypto/ anyway.
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20250630160320.2888-5-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
| -rw-r--r-- | arch/riscv/crypto/Kconfig | 1 | ||||
| -rw-r--r-- | arch/riscv/crypto/sha512-riscv64-glue.c | 8 |
2 files changed, 8 insertions, 1 deletions
diff --git a/arch/riscv/crypto/Kconfig b/arch/riscv/crypto/Kconfig index cd9b776602f8..53e4e1eacf55 100644 --- a/arch/riscv/crypto/Kconfig +++ b/arch/riscv/crypto/Kconfig @@ -31,6 +31,7 @@ config CRYPTO_GHASH_RISCV64 config CRYPTO_SHA512_RISCV64 tristate "Hash functions: SHA-384 and SHA-512" depends on 64BIT && RISCV_ISA_V && TOOLCHAIN_HAS_VECTOR_CRYPTO + select CRYPTO_LIB_SHA512 select CRYPTO_SHA512 help SHA-384 and SHA-512 secure hash algorithm (FIPS 180) diff --git a/arch/riscv/crypto/sha512-riscv64-glue.c b/arch/riscv/crypto/sha512-riscv64-glue.c index 4634fca78ae2..b3dbc71de07b 100644 --- a/arch/riscv/crypto/sha512-riscv64-glue.c +++ b/arch/riscv/crypto/sha512-riscv64-glue.c @@ -38,7 +38,13 @@ static void sha512_block(struct sha512_state *state, const u8 *data, sha512_transform_zvknhb_zvkb(state, data, num_blocks); kernel_vector_end(); } else { - sha512_generic_block_fn(state, data, num_blocks); + struct __sha512_ctx ctx = {}; + + static_assert(sizeof(ctx.state) == sizeof(state->state)); + memcpy(&ctx.state, state->state, sizeof(ctx.state)); + __sha512_update(&ctx, data, + (size_t)num_blocks * SHA512_BLOCK_SIZE); + memcpy(state->state, &ctx.state, sizeof(state->state)); } } |
