[PATCH 00/12] SM3 library
Ard Biesheuvel
ardb at kernel.org
Mon Mar 23 07:13:29 PDT 2026
On Sat, 21 Mar 2026, at 05:09, Eric Biggers wrote:
> This series is targeting libcrypto-next. It can also be retrieved from:
>
> git fetch
> https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git
> sm3-lib-v1
>
> This series cleans up the kernel's existing SM3 hashing code:
>
> - First, it updates lib/crypto/sm3.c to implement the full SM3 instead
> of just SM3's compression function.
>
> - Next, it adds a KUnit test suite for the new library API.
>
> - Next, it replaces the "sm3-generic" crypto_shash with a wrapper around
> the new library API.
>
> - Finally, it accelerates the API using the existing SM3 assembly code
> for arm64, riscv, and x86. The architecture-specific crypto_shash
> glue code for SM3 is no longer needed and is removed.
>
> This should look quite boring. It's the same cleanup that I've already
> done for the other hash functions.
>
> Note: I don't recommend using SM3. There also don't appear to be any
> immediate candidate users of the SM3 library other than crypto_shash.
>
> Still, this seems like the clear way to go. It's simpler, and it gets
> the hash algorithms integrated in a consistent way. We won't have to
> keep track of two quite different ways of doing things. With KUnit the
> code becomes much easier to test and benchmark, as well.
>
> Eric Biggers (12):
> crypto: sm3 - Fold sm3_init() into its caller
> crypto: sm3 - Remove sm3_zero_message_hash and SM3_T[1-2]
> crypto: sm3 - Rename CRYPTO_SM3_GENERIC to CRYPTO_SM3
> lib/crypto: sm3: Add SM3 library API
> lib/crypto: tests: Add KUnit tests for SM3
> crypto: sm3 - Replace with wrapper around library
> lib/crypto: arm64/sm3: Migrate optimized code into library
> lib/crypto: riscv/sm3: Migrate optimized code into library
> lib/crypto: x86/sm3: Migrate optimized code into library
> crypto: sm3 - Remove sm3_base.h
> crypto: sm3 - Remove the original "sm3_block_generic()"
> crypto: sm3 - Remove 'struct sm3_state'
>
Acked-by: Ard Biesheuvel <ardb at kernel.org>
More information about the linux-riscv
mailing list