Re: [PATCH v3 05/10] crypto: riscv - add vector crypto accelerated ChaCha20

From: Jerry Shih
Date: Fri Apr 12 2024 - 04:08:17 EST


On Apr 12, 2024, at 15:59, Yangyu Chen <cyy@xxxxxxxxxxxx> wrote:
> On 2024/1/22 08:19, Eric Biggers wrote:> From: Jerry Shih <jerry.shih@xxxxxxxxxx>
>>
>> Add an implementation of ChaCha20 using the Zvkb extension. The
>> assembly code is derived from OpenSSL code (openssl/openssl#21923) that
>> was dual-licensed so that it could be reused in the kernel.
>> Nevertheless, the assembly has been significantly reworked for
>> integration with the kernel, for example by using a regular .S file
>> instead of the so-called perlasm, using the assembler instead of bare
>> '.inst', and reducing code duplication.
>>
>> Signed-off-by: Jerry Shih <jerry.shih@xxxxxxxxxx>
>> Co-developed-by: Eric Biggers <ebiggers@xxxxxxxxxx>
>> Signed-off-by: Eric Biggers <ebiggers@xxxxxxxxxx>
>> ---
>
> Hi, Jerry Shih and Eric Biggers,
>
> Since this implementation is derived from OpenSSL, I have an issue on
> OpenSSL about this chacha20 implementation using Zvkb [1] and see a fixes
> PR by Jerry Shih [2].
>
> I wonder will kernel need to port those fixes to handle the non-multiple
> block length of the chacha20 cipher? If yes, we should port it immediately
> to catch up with the v6.9 release if we can.
>
> [1] https://github.com/openssl/openssl/issues/24070
> [2] https://github.com/openssl/openssl/pull/24097
>
> Thanks,
> Yangyu Chen
>

There is no non-multiple block size issue here. It's already handled by the gluing part.

https://github.com/torvalds/linux/blob/586b5dfb51b962c1b6c06495715e4c4f76a7fc5a/arch/riscv/crypto/chacha-riscv64-glue.c#L45-L53

-Jerry