Skip to content

crypto: arm32-optimized BLAKE2b and BLAKE2s

Eric Biggers linux-arm-kernel linux-crypto 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest14 patches 10 repliesIn review
  2. v211 patches 6 repliesSuperseded
  3. v15 patches 11 repliesSuperseded

Changes in v3 from the cover letter

- Reworked the shash helpers again. Now they are inline functions, and for BLAKE2s they now share more code with the library API.
- Made the BLAKE2b code be more consistent with the BLAKE2s code.
- Moved the BLAKE2s changes first in the patchset so that the BLAKE2b changes can be made just by syncing the code with BLAKE2s.
- Added a few BLAKE2s cleanups (which get included in BLAKE2b too).
- Improved some comments in the new asm files.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/14crypto: blake2s - define shash_alg structs using macroscrypto/blake2s_generic.c+27 -610 replies
2/14crypto: x86/blake2s - define shash_alg structs using macrosarch/x86/crypto/blake2s-glue.c+23 -610 replies
3/14crypto: blake2s - remove unneeded includescrypto/blake2s_generic.c+0 -20 replies
4/14crypto: blake2s - move update and final logic to internal/blake2s.hinclude/crypto/internal/blake2s.h lib/crypto/blake2s.c+49 -401 reply
5/14crypto: blake2s - share the "shash" API boilerplate codearch/x86/crypto/blake2s-glue.c crypto/blake2s_generic.c include/crypto/internal/blake2s.h+76 -1391 reply
6/14crypto: blake2s - optimize blake2s initializationinclude/crypto/blake2s.h include/crypto/internal/blake2s.h+28 -301 reply
7/14crypto: blake2s - add comment for blake2s_state fieldsinclude/crypto/blake2s.h+1 -01 reply
8/14crypto: blake2s - adjust include guard naminginclude/crypto/blake2s.h include/crypto/internal/blake2s.h+6 -61 reply
9/14crypto: blake2s - include <linux/bug.h> instead of <asm/bug.h>include/crypto/blake2s.h+1 -21 reply
10/14crypto: arm/blake2s - add ARM scalar optimized BLAKE2sarch/arm/crypto/Kconfig arch/arm/crypto/Makefile arch/arm/crypto/blake2s-core.S +1 more+374 -01 reply
11/14wireguard: Kconfig: select CRYPTO_BLAKE2S_ARMdrivers/net/Kconfig+1 -00 replies
12/14crypto: blake2b - sync with blake2s implementationcrypto/blake2b_generic.c include/crypto/blake2b.h include/crypto/internal/blake2b.h+230 -1781 reply
13/14crypto: blake2b - update file commentcrypto/blake2b_generic.c+10 -130 replies
14/14crypto: arm/blake2b - add NEON-accelerated BLAKE2barch/arm/crypto/Kconfig arch/arm/crypto/Makefile arch/arm/crypto/blake2b-neon-core.S +1 more+464 -01 reply

Reviews trailers per patch

All 14 patches have a Reviewed-by or Acked-by.

PatchArd BiesheuvelJason A. DonenfeldDavid Sterba
1/14A-b
2/14A-b
3/14A-b
4/14A-b
5/14A-b
6/14A-b
7/14A-b
8/14A-b
9/14A-b
10/14A-b T-b
11/14A-b R-b
12/14A-b
13/14A-b R-b
14/14A-b T-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v3 thread

Cover letter [PATCH v3 00/14] crypto: arm32-optimized BLAKE2b and BLAKE2s

This patchset adds 32-bit ARM assembly language implementations of BLAKE2b and BLAKE2s.

As a prerequisite to adding these without copy-and-pasting lots of code, this patchset also reworks the existing BLAKE2b and BLAKE2s code to provide helper functions that make implementing "shash" providers for these algorithms much easier. These changes also eliminate unnecessary differences between the BLAKE2b and BLAKE2s code.

The new BLAKE2b implementation is NEON-accelerated, while the new BLAKE2s implementation uses scalar instructions since NEON doesn't work very well for it. The BLAKE2b implementation is faster and is expected to be useful as a replacement for SHA-1 in dm-verity, while the BLAKE2s implementation would be useful for WireGuard which uses BLAKE2s.

Both new implementations are wired up to the shash API, while the new BLAKE2s implementation is also wired up to the library API.

See the individual commits for full details, including benchmarks.

This patchset was tested on a Raspberry Pi 2 (which uses a Cortex-A7 processor) with CONFIG_CRYPTO_MANAGER_EXTRA_TESTS=y, plus other tests.

This patchset applies to mainline commit 614cb5894306.

Changed since v2:
- Reworked the shash helpers again. Now they are inline functions, and for BLAKE2s they now share more code with the library API.
- Made the BLAKE2b code be more consistent with the BLAKE2s code.
- Moved the BLAKE2s changes first in the patchset so that the BLAKE2b changes can be made just by syncing the code with BLAKE2s.
- Added a few BLAKE2s cleanups (which get included in BLAKE2b too).
- Improved some comments in the new asm files.

Changed since v1:
- Added ARM scalar implementation of BLAKE2s.
- Adjusted the BLAKE2b helper functions to be consistent with what I decided to do for BLAKE2s.
- Fixed build error in blake2b-neon-core.S in some configurations.

Eric Biggers (14):
crypto: blake2s - define shash_alg structs using macros
crypto: x86/blake2s - define shash_alg structs using macros
crypto: blake2s - remove unneeded includes
crypto: blake2s - move update and final logic to internal/blake2s.h
crypto: blake2s - share the "shash" API boilerplate code
crypto: blake2s - optimize blake2s initialization
crypto: blake2s - add comment for blake2s_state fields
crypto: blake2s - adjust include guard naming
crypto: blake2s - include <linux/bug.h> instead of <asm/bug.h>
crypto: arm/blake2s - add ARM scalar optimized BLAKE2s
wireguard: Kconfig: select CRYPTO_BLAKE2S_ARM
crypto: blake2b - sync with blake2s implementation
crypto: blake2b - update file comment
crypto: arm/blake2b - add NEON-accelerated BLAKE2b

 arch/arm/crypto/Kconfig             |  19 ++
 arch/arm/crypto/Makefile            |   4 +
 arch/arm/crypto/blake2b-neon-core.S | 347 ++++++++++++++++++++++++++++
 arch/arm/crypto/blake2b-neon-glue.c | 105 +++++++++
 arch/arm/crypto/blake2s-core.S      | 285 +++++++++++++++++++++++
 arch/arm/crypto/blake2s-glue.c      |  78 +++++++
 arch/x86/crypto/blake2s-glue.c      | 150 +++---------
 crypto/blake2b_generic.c            | 249 +++++---------------
 crypto/blake2s_generic.c            | 158 +++----------
 drivers/net/Kconfig                 |   1 +
 include/crypto/blake2b.h            |  67 ++++++
 include/crypto/blake2s.h            |  63 ++---
 include/crypto/internal/blake2b.h   | 115 +++++++++
 include/crypto/internal/blake2s.h   | 109 ++++++++-
 lib/crypto/blake2s.c                |  48 +---
 15 files changed, 1278 insertions(+), 520 deletions(-)
 create mode 100644 arch/arm/crypto/blake2b-neon-core.S
 create mode 100644 arch/arm/crypto/blake2b-neon-glue.c
 create mode 100644 arch/arm/crypto/blake2s-core.S
 create mode 100644 arch/arm/crypto/blake2s-glue.c
 create mode 100644 include/crypto/blake2b.h
 create mode 100644 include/crypto/internal/blake2b.h

base-commit: 614cb5894306cfa2c7d9b6168182876ff5948735

Signature · 1 line
2.29.2