Skip to content

SHA-3 library

Eric Biggers linux-arm-kernel linux-crypto linux-s390 lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest15 patches 19 repliesIn review
  2. v117 patches 17 repliesSuperseded

Changes in v2 from the cover letter

- Added missing selection of CRYPTO_LIB_SHA3 from CRYPTO_SHA3.
- Fixed a bug where incorrect SHAKE output was produced if a zero-length squeeze was followed by a nonzero-length squeeze.
- Improved the SHAKE tests.
- Utilized the one-shot SHA-3 digest instructions on s390.
- Split the s390 changes into several patches.
- Folded some of my patches into David's.
- Dropped some unnecessary changes from the first 2 patches.
- Lots more cleanups, mainly to "lib/crypto: sha3: Add SHA-3 support".

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/15crypto: s390/sha3 - Rename conflicting functionsarch/s390/crypto/sha3_256_s390.c arch/s390/crypto/sha3_512_s390.c+10 -100 replies
2/15crypto: arm64/sha3 - Rename conflicting functionarch/arm64/crypto/sha3-ce-glue.c+6 -60 replies
3/15lib/crypto: sha3: Add SHA-3 supportDocumentation/crypto/index.rst Documentation/crypto/sha3.rst include/crypto/sha3.h +3 more+796 -30 replies
4/15lib/crypto: sha3: Move SHA3 Iota step mapping into round functionlib/crypto/sha3.c+6 -60 replies
5/15lib/crypto: tests: Add SHA3 kunit testsDocumentation/crypto/sha3.rst lib/crypto/tests/Kconfig lib/crypto/tests/Makefile +3 more+596 -10 replies
6/15lib/crypto: tests: Add additional SHAKE testslib/crypto/tests/sha3-testvecs.h lib/crypto/tests/sha3_kunit.c scripts/crypto/gen-hash-testvecs.py+174 -590 replies
7/15lib/crypto: sha3: Add FIPS cryptographic algorithm self-testDocumentation/crypto/sha3.rst lib/crypto/fips.h lib/crypto/sha3.c +1 more+32 -10 replies
8/15crypto: arm64/sha3 - Update sha3_ce_transform() to prepare for libraryarch/arm64/crypto/sha3-ce-core.S arch/arm64/crypto/sha3-ce-glue.c+39 -390 replies
9/15lib/crypto: arm64/sha3: Migrate optimized code into libraryarch/arm64/configs/defconfig arch/arm64/crypto/Kconfig arch/arm64/crypto/Makefile +5 more+73 -1650 replies
10/15lib/crypto: s390/sha3: Add optimized Keccak functionslib/crypto/Kconfig lib/crypto/s390/sha3.h+89 -00 replies
11/15lib/crypto: sha3: Support arch overrides of one-shot digest functionslib/crypto/sha3.c+37 -00 replies
12/15lib/crypto: s390/sha3: Add optimized one-shot SHA-3 digest functionslib/crypto/s390/sha3.h+65 -20 replies
13/15crypto: jitterentropy - Use default sha3 implementationcrypto/jitterentropy-kcapi.c+2 -100 replies
14/15crypto: sha3 - Reimplement using library APIcrypto/Kconfig crypto/Makefile crypto/sha3.c +3 more+176 -2970 replies
15/15crypto: s390/sha3 - Remove superseded SHA-3 codearch/s390/configs/debug_defconfig arch/s390/configs/defconfig arch/s390/crypto/Kconfig +5 more+2 -5080 replies

Reviews trailers per patch

5 of 15 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchArd BiesheuvelHarald Freudenberger
SeriesR-b R-b T-b T-b
1/15
2/15
3/15
4/15
5/15R-b
6/15
7/15
8/15R-b
9/15R-b
10/15
11/15
12/15
13/15R-b
14/15R-b
15/15

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 00/15] SHA-3 library

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 sha3-lib-v2

This series adds SHA-3 support to lib/crypto/. This includes support for the digest algorithms SHA3-224, SHA3-256, SHA3-384, and SHA3-512, and also support for the extendable-output functions SHAKE128 and SHAKE256. The SHAKE128 and SHAKE256 support will be needed by ML-DSA.

The architecture-optimized SHA-3 code for arm64 and s390 is migrated into lib/crypto/. (The existing s390 code couldn't really be reused, so really I rewrote it from scratch.) This makes the SHA-3 library functions be accelerated on these architectures.

Finally, the sha3-224, sha3-256, sha3-384, and sha3-512 crypto_shash algorithms are reimplemented on top of the library API.

If the s390 folks could re-test the s390 optimized SHA-3 code (by enabling CRYPTO_LIB_SHA3_KUNIT_TEST and CRYPTO_LIB_BENCHMARK), that would be helpful. QEMU doesn't support the instructions it uses. Also, it would be helpful to provide the benchmark output from just before "lib/crypto: s390/sha3: Add optimized Keccak function", just after it, and after "lib/crypto: s390/sha3: Add optimized one-shot SHA-3 digest functions". Then we can verify that each change is useful.

Changed in v2:
- Added missing selection of CRYPTO_LIB_SHA3 from CRYPTO_SHA3.
- Fixed a bug where incorrect SHAKE output was produced if a zero-length squeeze was followed by a nonzero-length squeeze.
- Improved the SHAKE tests.
- Utilized the one-shot SHA-3 digest instructions on s390.
- Split the s390 changes into several patches.
- Folded some of my patches into David's.
- Dropped some unnecessary changes from the first 2 patches.
- Lots more cleanups, mainly to "lib/crypto: sha3: Add SHA-3 support".

Changed in v1 (vs. first 5 patches of David's v6 patchset):
- Migrated the arm64 and s390 code into lib/crypto/
- Simplified the library API
- Added FIPS test
- Many other fixes and improvements

The first 5 patches are derived from David's v6 patchset
(https://lore.kernel.org/linux-crypto/[email protected]/).
Earlier changelogs can be found there.

David Howells (5):
crypto: s390/sha3 - Rename conflicting functions
crypto: arm64/sha3 - Rename conflicting function lib/crypto: sha3: Add SHA-3 support
lib/crypto: sha3: Move SHA3 Iota step mapping into round function lib/crypto: tests: Add SHA3 kunit tests

Eric Biggers (10):
lib/crypto: tests: Add additional SHAKE tests
lib/crypto: sha3: Add FIPS cryptographic algorithm self-test
crypto: arm64/sha3 - Update sha3_ce_transform() to prepare for library lib/crypto: arm64/sha3: Migrate optimized code into library lib/crypto: s390/sha3: Add optimized Keccak functions lib/crypto: sha3: Support arch overrides of one-shot digest functions lib/crypto: s390/sha3: Add optimized one-shot SHA-3 digest functions
crypto: jitterentropy - Use default sha3 implementation
crypto: sha3 - Reimplement using library API
crypto: s390/sha3 - Remove superseded SHA-3 code

 Documentation/crypto/index.rst                |   1 +
 Documentation/crypto/sha3.rst                 | 130 ++++++
 arch/arm64/configs/defconfig                  |   2 +-
 arch/arm64/crypto/Kconfig                     |  11 -
 arch/arm64/crypto/Makefile                    |   3 -
 arch/arm64/crypto/sha3-ce-glue.c              | 151 -------
 arch/s390/configs/debug_defconfig             |   3 +-
 arch/s390/configs/defconfig                   |   3 +-
 arch/s390/crypto/Kconfig                      |  20 -
 arch/s390/crypto/Makefile                     |   2 -
 arch/s390/crypto/sha.h                        |  51 ---
 arch/s390/crypto/sha3_256_s390.c              | 157 -------
 arch/s390/crypto/sha3_512_s390.c              | 157 -------
 arch/s390/crypto/sha_common.c                 | 117 -----
 crypto/Kconfig                                |   1 +
 crypto/Makefile                               |   2 +-
 crypto/jitterentropy-kcapi.c                  |  12 +-
 crypto/sha3.c                                 | 166 +++++++
 crypto/sha3_generic.c                         | 290 ------------
 crypto/testmgr.c                              |   8 +
 include/crypto/sha3.h                         | 306 ++++++++++++-
 lib/crypto/Kconfig                            |  13 +
 lib/crypto/Makefile                           |  10 +
 .../crypto/arm64}/sha3-ce-core.S              |  67 +--
 lib/crypto/arm64/sha3.h                       |  62 +++
 lib/crypto/fips.h                             |   7 +
 lib/crypto/s390/sha3.h                        | 151 +++++++
 lib/crypto/sha3.c                             | 411 +++++++++++++++++
 lib/crypto/tests/Kconfig                      |  11 +
 lib/crypto/tests/Makefile                     |   1 +
 lib/crypto/tests/sha3-testvecs.h              | 249 +++++++++++
 lib/crypto/tests/sha3_kunit.c                 | 422 ++++++++++++++++++
 scripts/crypto/gen-fips-testvecs.py           |   4 +
 scripts/crypto/gen-hash-testvecs.py           |  27 +-
 34 files changed, 2012 insertions(+), 1016 deletions(-)
 create mode 100644 Documentation/crypto/sha3.rst
 delete mode 100644 arch/arm64/crypto/sha3-ce-glue.c
 delete mode 100644 arch/s390/crypto/sha.h
 delete mode 100644 arch/s390/crypto/sha3_256_s390.c
 delete mode 100644 arch/s390/crypto/sha3_512_s390.c
 delete mode 100644 arch/s390/crypto/sha_common.c
 create mode 100644 crypto/sha3.c
 delete mode 100644 crypto/sha3_generic.c
 rename {arch/arm64/crypto => lib/crypto/arm64}/sha3-ce-core.S (84%)
 create mode 100644 lib/crypto/arm64/sha3.h
 create mode 100644 lib/crypto/s390/sha3.h
 create mode 100644 lib/crypto/sha3.c
 create mode 100644 lib/crypto/tests/sha3-testvecs.h
 create mode 100644 lib/crypto/tests/sha3_kunit.c

base-commit: e3068492d0016d0ea9a1ff07dbfa624d2ec773ca

Signature · 1 line
2.51.1.dirty