Use scalar ALU and vector ALU together for chacha20 stream cipher
authorJerry Shih <bignose1007@gmail.com>
Sat, 9 Mar 2024 07:03:56 +0000 (15:03 +0800)
committerTomas Mraz <tomas@openssl.org>
Wed, 17 Apr 2024 14:55:03 +0000 (16:55 +0200)
commitda8b6308bd7ad5b7c779aa2d9123bf5faacaec7f
tree988c7558b2b03f0b6d01cb69c72962fb71526f0f
parent96939f1e2c6ac1264142ef62c9925786f5723649
Use scalar ALU and vector ALU together for chacha20 stream cipher

Fixes #24070

Use scalar ALU for 1 chacha block with rvv ALU simultaneously.
The tail elements(non-multiple of block length) will be handled by
the scalar logic.

Use rvv path if the input length > chacha_block_size.

And we have about 1.2x improvement comparing with the original code.

Reviewed-by: Hongren Zheng <i@zenithal.me>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24097)
crypto/chacha/asm/chacha-riscv64-zbb-zvkb.pl [moved from crypto/chacha/asm/chacha-riscv64-zvkb.pl with 53% similarity]
crypto/chacha/build.info
crypto/chacha/chacha_riscv.c
crypto/perlasm/riscv.pm