public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: linux-crypto@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Ard Biesheuvel <ardb@kernel.org>,
	"Jason A . Donenfeld" <Jason@zx2c4.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Tianjia Zhang <tianjia.zhang@linux.alibaba.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-riscv@lists.infradead.org, x86@kernel.org,
	Eric Biggers <ebiggers@kernel.org>
Subject: [PATCH 00/12] SM3 library
Date: Fri, 20 Mar 2026 21:09:23 -0700	[thread overview]
Message-ID: <20260321040935.410034-1-ebiggers@kernel.org> (raw)

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'

 arch/arm64/configs/defconfig                  |   2 +-
 arch/arm64/crypto/Kconfig                     |  22 --
 arch/arm64/crypto/Makefile                    |   6 -
 arch/arm64/crypto/sm3-ce-glue.c               |  70 ------
 arch/arm64/crypto/sm3-neon-glue.c             |  67 -----
 arch/loongarch/configs/loongson32_defconfig   |   2 +-
 arch/loongarch/configs/loongson64_defconfig   |   2 +-
 arch/m68k/configs/amiga_defconfig             |   2 +-
 arch/m68k/configs/apollo_defconfig            |   2 +-
 arch/m68k/configs/atari_defconfig             |   2 +-
 arch/m68k/configs/bvme6000_defconfig          |   2 +-
 arch/m68k/configs/hp300_defconfig             |   2 +-
 arch/m68k/configs/mac_defconfig               |   2 +-
 arch/m68k/configs/multi_defconfig             |   2 +-
 arch/m68k/configs/mvme147_defconfig           |   2 +-
 arch/m68k/configs/mvme16x_defconfig           |   2 +-
 arch/m68k/configs/q40_defconfig               |   2 +-
 arch/m68k/configs/sun3_defconfig              |   2 +-
 arch/m68k/configs/sun3x_defconfig             |   2 +-
 arch/riscv/crypto/Kconfig                     |  13 -
 arch/riscv/crypto/Makefile                    |   3 -
 arch/s390/configs/debug_defconfig             |   2 +-
 arch/s390/configs/defconfig                   |   2 +-
 arch/x86/crypto/Kconfig                       |  13 -
 arch/x86/crypto/Makefile                      |   3 -
 arch/x86/crypto/sm3_avx_glue.c                | 100 --------
 crypto/Kconfig                                |   2 +-
 crypto/Makefile                               |   2 +-
 crypto/{sm3_generic.c => sm3.c}               |  89 ++++---
 crypto/testmgr.c                              |   2 +
 drivers/crypto/Kconfig                        |   2 +-
 drivers/crypto/starfive/Kconfig               |   2 +-
 drivers/crypto/starfive/jh7110-hash.c         |   8 +-
 include/crypto/sm3.h                          |  85 ++++---
 include/crypto/sm3_base.h                     |  82 -------
 lib/crypto/.kunitconfig                       |   1 +
 lib/crypto/Kconfig                            |  11 +
 lib/crypto/Makefile                           |  15 +-
 .../crypto => lib/crypto/arm64}/sm3-ce-core.S |  11 +-
 .../crypto/arm64}/sm3-neon-core.S             |   9 +-
 lib/crypto/arm64/sm3.h                        |  41 ++++
 .../crypto/riscv}/sm3-riscv64-zvksh-zvkb.S    |   3 +-
 .../crypto/riscv/sm3.h                        |  84 +------
 lib/crypto/sm3.c                              | 148 +++++++++--
 lib/crypto/tests/Kconfig                      |   9 +
 lib/crypto/tests/Makefile                     |   1 +
 lib/crypto/tests/sm3-testvecs.h               | 231 ++++++++++++++++++
 lib/crypto/tests/sm3_kunit.c                  |  31 +++
 .../crypto/x86}/sm3-avx-asm_64.S              |  13 +-
 lib/crypto/x86/sm3.h                          |  39 +++
 scripts/crypto/gen-hash-testvecs.py           |   3 +
 security/integrity/ima/Kconfig                |   2 +-
 52 files changed, 670 insertions(+), 587 deletions(-)
 delete mode 100644 arch/arm64/crypto/sm3-ce-glue.c
 delete mode 100644 arch/arm64/crypto/sm3-neon-glue.c
 delete mode 100644 arch/x86/crypto/sm3_avx_glue.c
 rename crypto/{sm3_generic.c => sm3.c} (30%)
 delete mode 100644 include/crypto/sm3_base.h
 rename {arch/arm64/crypto => lib/crypto/arm64}/sm3-ce-core.S (93%)
 rename {arch/arm64/crypto => lib/crypto/arm64}/sm3-neon-core.S (98%)
 create mode 100644 lib/crypto/arm64/sm3.h
 rename {arch/riscv/crypto => lib/crypto/riscv}/sm3-riscv64-zvksh-zvkb.S (97%)
 rename arch/riscv/crypto/sm3-riscv64-glue.c => lib/crypto/riscv/sm3.h (18%)
 create mode 100644 lib/crypto/tests/sm3-testvecs.h
 create mode 100644 lib/crypto/tests/sm3_kunit.c
 rename {arch/x86/crypto => lib/crypto/x86}/sm3-avx-asm_64.S (98%)
 create mode 100644 lib/crypto/x86/sm3.h


base-commit: 6bc9effb4cbf9b6eba0f51aba1c8893dfd4c8100
-- 
2.53.0



             reply	other threads:[~2026-03-21  4:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-21  4:09 Eric Biggers [this message]
2026-03-21  4:09 ` [PATCH 01/12] crypto: sm3 - Fold sm3_init() into its caller Eric Biggers
2026-03-21  4:09 ` [PATCH 02/12] crypto: sm3 - Remove sm3_zero_message_hash and SM3_T[1-2] Eric Biggers
2026-03-21  4:09 ` [PATCH 03/12] crypto: sm3 - Rename CRYPTO_SM3_GENERIC to CRYPTO_SM3 Eric Biggers
2026-03-21  4:09 ` [PATCH 04/12] lib/crypto: sm3: Add SM3 library API Eric Biggers
2026-03-21  4:09 ` [PATCH 05/12] lib/crypto: tests: Add KUnit tests for SM3 Eric Biggers
2026-03-21  4:09 ` [PATCH 06/12] crypto: sm3 - Replace with wrapper around library Eric Biggers
2026-03-21  4:09 ` [PATCH 07/12] lib/crypto: arm64/sm3: Migrate optimized code into library Eric Biggers
2026-03-21  4:09 ` [PATCH 08/12] lib/crypto: riscv/sm3: " Eric Biggers
2026-03-21  4:09 ` [PATCH 09/12] lib/crypto: x86/sm3: " Eric Biggers
2026-03-21  4:09 ` [PATCH 10/12] crypto: sm3 - Remove sm3_base.h Eric Biggers
2026-03-21  4:09 ` [PATCH 11/12] crypto: sm3 - Remove the original "sm3_block_generic()" Eric Biggers
2026-03-21  4:09 ` [PATCH 12/12] crypto: sm3 - Remove 'struct sm3_state' Eric Biggers
2026-03-23 14:13 ` [PATCH 00/12] SM3 library Ard Biesheuvel
2026-03-24 23:27 ` Eric Biggers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260321040935.410034-1-ebiggers@kernel.org \
    --to=ebiggers@kernel.org \
    --cc=Jason@zx2c4.com \
    --cc=ardb@kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=tianjia.zhang@linux.alibaba.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox