Skip to content

RISC-V: provide some accelerated cryptography implementations using vector extensions

Jerry Shih linux-crypto linux-riscv lkml 4 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest11 patches 0 repliesNew
  2. v312 patches 8 repliesSuperseded
  3. v213 patches 27 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v112 patches37 repliesSuperseded

Changes in v4 from the cover letter

- Check the assembler capability for using the vector crypto asm mnemonics.
- Use asm mnemonics for the instructions in vector crypto 1.0 extension.
- Revert the usage of simd skcipher interface for AES-CBC/CTR/ECB/XTS and Chacha20.

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/11RISC-V: add helper function to read the vector VLENarch/riscv/include/asm/vector.h+11 -00 replies
2/11RISC-V: hook new crypto subdir into build-systemarch/riscv/Kbuild arch/riscv/crypto/Kconfig arch/riscv/crypto/Makefile +1 more+13 -00 replies
3/11RISC-V: add TOOLCHAIN_HAS_VECTOR_CRYPTO in kconfigarch/riscv/Kconfig+8 -00 replies
4/11RISC-V: crypto: add Zvkned accelerated AES implementationarch/riscv/crypto/Kconfig arch/riscv/crypto/Makefile arch/riscv/crypto/aes-riscv64-glue.c +2 more+630 -00 replies
5/11RISC-V: crypto: add accelerated AES-CBC/CTR/ECB/XTS implementationsarch/riscv/crypto/Kconfig arch/riscv/crypto/Makefile arch/riscv/crypto/aes-riscv64-block-mode-glue.c +3 more+2601 -00 replies
6/11RISC-V: crypto: add Zvkg accelerated GCM GHASH implementationarch/riscv/crypto/Kconfig arch/riscv/crypto/Makefile arch/riscv/crypto/ghash-riscv64-glue.c +1 more+292 -00 replies
7/11RISC-V: crypto: add Zvknha/b accelerated SHA224/256 implementationsarch/riscv/crypto/Kconfig arch/riscv/crypto/Makefile arch/riscv/crypto/sha256-riscv64-glue.c +1 more+480 -00 replies
8/11RISC-V: crypto: add Zvknhb accelerated SHA384/512 implementationsarch/riscv/crypto/Kconfig arch/riscv/crypto/Makefile arch/riscv/crypto/sha512-riscv64-glue.c +1 more+422 -00 replies
9/11RISC-V: crypto: add Zvksed accelerated SM4 implementationarch/riscv/crypto/Kconfig arch/riscv/crypto/Makefile arch/riscv/crypto/sm4-riscv64-glue.c +1 more+413 -00 replies
10/11RISC-V: crypto: add Zvksh accelerated SM3 implementationarch/riscv/crypto/Kconfig arch/riscv/crypto/Makefile arch/riscv/crypto/sm3-riscv64-glue.c +1 more+370 -00 replies
11/11RISC-V: crypto: add Zvkb accelerated ChaCha20 implementationarch/riscv/crypto/Kconfig arch/riscv/crypto/Makefile arch/riscv/crypto/chacha-riscv64-glue.c +1 more+449 -00 replies

Reviews trailers per patch

2 of 11 patches have a Reviewed-by or Acked-by.

PatchEric Biggers
1/11R-b
2/11R-b
3/11
4/11
5/11
6/11
7/11
8/11
9/11
10/11
11/11

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

Read the v4 thread

Cover letter [PATCH v4 00/11] RISC-V: provide some accelerated cryptography implementations using vector extensions

This series provides cryptographic implementations using the vector crypto extensions[1] including:
1. AES cipher
2. AES with CBC/CTR/ECB/XTS block modes
3. ChaCha20 stream cipher
4. GHASH for GCM
5. SHA-224/256 and SHA-384/512 hash
6. SM3 hash
7. SM4 cipher

This patch set is based on Heiko Stuebner's work at:

The implementations reuse the perl-asm scripts from OpenSSL[2] with some changes adapting for the kernel crypto framework.
The perl-asm scripts generate the RISC-V RVV 1.0 and the vector crypto 1.0 instructions into .S files.

All changes pass the kernel run-time crypto self tests and the extra tests with vector-crypto-enabled qemu.

This series depend on:
1. kernel riscv/for-next(6.7-rc1)

2. support kernel-mode vector

Here is a branch on github applying with all dependent patches:

And here is the previous v3 link:

Updated patches (on current order): 4, 5, 6, 7, 8, 9, 10, 11 New patch: 3
Unchanged patch: 1, 2
Deleted patch: 3, 5 in v3

Changelog v4:
- Check the assembler capability for using the vector crypto asm mnemonics.
- Use asm mnemonics for the instructions in vector crypto 1.0 extension.
- Revert the usage of simd skcipher interface for AES-CBC/CTR/ECB/XTS and Chacha20.

Changelog v3:
- Use asm mnemonics for the instructions in RVV 1.0 extension.
- Use SYM_TYPED_FUNC_START for indirect-call asm symbols.
- Update aes xts_crypt() implementation.
- Update crypto function names with the prefix/suffix of riscv64 or the specific extensions to avoid the collision with functions in crypto/ or lib/crypto/.

Changelog v2:
- Do not turn on the RISC-V accelerated crypto kconfig options by default.
- Assume RISC-V vector extension could support unaligned access in kernel.
- Turn to use simd skcipher interface for AES-CBC/CTR/ECB/XTS and Chacha20.
- Rename crypto file and driver names to make the most important extension at first place.

Heiko Stuebner (2):
RISC-V: add helper function to read the vector VLEN
RISC-V: hook new crypto subdir into build-system

Jerry Shih (9):
RISC-V: add TOOLCHAIN_HAS_VECTOR_CRYPTO in kconfig
RISC-V: crypto: add Zvkned accelerated AES implementation
RISC-V: crypto: add accelerated AES-CBC/CTR/ECB/XTS implementations
RISC-V: crypto: add Zvkg accelerated GCM GHASH implementation
RISC-V: crypto: add Zvknha/b accelerated SHA224/256 implementations
RISC-V: crypto: add Zvknhb accelerated SHA384/512 implementations
RISC-V: crypto: add Zvksed accelerated SM4 implementation
RISC-V: crypto: add Zvksh accelerated SM3 implementation
RISC-V: crypto: add Zvkb accelerated ChaCha20 implementation

 arch/riscv/Kbuild                             |    1 +
 arch/riscv/Kconfig                            |    8 +
 arch/riscv/crypto/Kconfig                     |  110 ++
 arch/riscv/crypto/Makefile                    |   68 +
 .../crypto/aes-riscv64-block-mode-glue.c      |  459 +++++++
 arch/riscv/crypto/aes-riscv64-glue.c          |  137 ++
 arch/riscv/crypto/aes-riscv64-glue.h          |   18 +
 .../crypto/aes-riscv64-zvkned-zvbb-zvkg.pl    |  949 +++++++++++++
 arch/riscv/crypto/aes-riscv64-zvkned-zvkb.pl  |  415 ++++++
 arch/riscv/crypto/aes-riscv64-zvkned.pl       | 1199 +++++++++++++++++
 arch/riscv/crypto/chacha-riscv64-glue.c       |  109 ++
 arch/riscv/crypto/chacha-riscv64-zvkb.pl      |  321 +++++
 arch/riscv/crypto/ghash-riscv64-glue.c        |  175 +++
 arch/riscv/crypto/ghash-riscv64-zvkg.pl       |  100 ++
 arch/riscv/crypto/sha256-riscv64-glue.c       |  145 ++
 .../sha256-riscv64-zvknha_or_zvknhb-zvkb.pl   |  317 +++++
 arch/riscv/crypto/sha512-riscv64-glue.c       |  139 ++
 .../crypto/sha512-riscv64-zvknhb-zvkb.pl      |  265 ++++
 arch/riscv/crypto/sm3-riscv64-glue.c          |  124 ++
 arch/riscv/crypto/sm3-riscv64-zvksh.pl        |  227 ++++
 arch/riscv/crypto/sm4-riscv64-glue.c          |  121 ++
 arch/riscv/crypto/sm4-riscv64-zvksed.pl       |  268 ++++
 arch/riscv/include/asm/vector.h               |   11 +
 crypto/Kconfig                                |    3 +
 24 files changed, 5689 insertions(+)
 create mode 100644 arch/riscv/crypto/Kconfig
 create mode 100644 arch/riscv/crypto/Makefile
 create mode 100644 arch/riscv/crypto/aes-riscv64-block-mode-glue.c
 create mode 100644 arch/riscv/crypto/aes-riscv64-glue.c
 create mode 100644 arch/riscv/crypto/aes-riscv64-glue.h
 create mode 100644 arch/riscv/crypto/aes-riscv64-zvkned-zvbb-zvkg.pl
 create mode 100644 arch/riscv/crypto/aes-riscv64-zvkned-zvkb.pl
 create mode 100644 arch/riscv/crypto/aes-riscv64-zvkned.pl
 create mode 100644 arch/riscv/crypto/chacha-riscv64-glue.c
 create mode 100644 arch/riscv/crypto/chacha-riscv64-zvkb.pl
 create mode 100644 arch/riscv/crypto/ghash-riscv64-glue.c
 create mode 100644 arch/riscv/crypto/ghash-riscv64-zvkg.pl
 create mode 100644 arch/riscv/crypto/sha256-riscv64-glue.c
 create mode 100644 arch/riscv/crypto/sha256-riscv64-zvknha_or_zvknhb-zvkb.pl
 create mode 100644 arch/riscv/crypto/sha512-riscv64-glue.c
 create mode 100644 arch/riscv/crypto/sha512-riscv64-zvknhb-zvkb.pl
 create mode 100644 arch/riscv/crypto/sm3-riscv64-glue.c
 create mode 100644 arch/riscv/crypto/sm3-riscv64-zvksh.pl
 create mode 100644 arch/riscv/crypto/sm4-riscv64-glue.c
 create mode 100644 arch/riscv/crypto/sm4-riscv64-zvksed.pl

--
2.28.0