[PATCH] crypto: riscv/poly1305 - import OpenSSL/CRYPTOGAMS implementation
Eric Biggers
ebiggers at kernel.org
Thu Jun 5 08:01:39 PDT 2025
On Thu, Jun 05, 2025 at 10:56:34PM +0800, zhihang.shao.iscas at gmail.com wrote:
> From: Zhihang Shao <zhihang.shao.iscas at gmail.com>
>
> This is a straight import of the OpenSSL/CRYPTOGAMS Poly1305
> implementation for riscv authored by Andy Polyakov.
> The file 'poly1305-riscv.pl' is taken straight from this upstream
> GitHub repository [0] at commit 33fe84bc21219a16825459b37c825bf4580a0a7b,
> and this commit fixed a bug in riscv 64bit implementation.
> Also, this patch passed extra run-time self tests.
>
> [0] https://github.com/dot-asm/cryptogams
>
> Signed-off-by: Zhihang Shao <zhihang.shao.iscas at gmail.com>
> ---
> arch/riscv/crypto/Kconfig | 10 +
> arch/riscv/crypto/Makefile | 17 +
> arch/riscv/crypto/poly1305-glue.c | 202 +++++++
> arch/riscv/crypto/poly1305-riscv.pl | 797 ++++++++++++++++++++++++++++
> drivers/net/Kconfig | 1 +
> lib/crypto/Kconfig | 2 +-
> 6 files changed, 1028 insertions(+), 1 deletion(-)
> create mode 100644 arch/riscv/crypto/poly1305-glue.c
> create mode 100644 arch/riscv/crypto/poly1305-riscv.pl
>
> diff --git a/arch/riscv/crypto/Kconfig b/arch/riscv/crypto/Kconfig
> index c67095a3d669..228bb3c6940d 100644
> --- a/arch/riscv/crypto/Kconfig
> +++ b/arch/riscv/crypto/Kconfig
> @@ -38,6 +38,16 @@ config CRYPTO_GHASH_RISCV64
> Architecture: riscv64 using:
> - Zvkg vector crypto extension
>
> +config CRYPTO_POLY1305_RISCV
> + tristate "Hash functions: Poly1305"
> + select CRYPTO_HASH
> + select CRYPTO_ARCH_HAVE_LIB_POLY1305
> + help
> + Poly1305 authenticator algorithm (RFC7539)
> +
> + Architecture: riscv using:
> + - V vector extension
> +
> config CRYPTO_SHA256_RISCV64
> tristate "Hash functions: SHA-224 and SHA-256"
> depends on 64BIT && RISCV_ISA_V && TOOLCHAIN_HAS_VECTOR_CRYPTO
> diff --git a/arch/riscv/crypto/Makefile b/arch/riscv/crypto/Makefile
> index 247c7bc7288c..0c96bd9a61b3 100644
> --- a/arch/riscv/crypto/Makefile
> +++ b/arch/riscv/crypto/Makefile
> @@ -10,6 +10,10 @@ chacha-riscv64-y := chacha-riscv64-glue.o chacha-riscv64-zvkb.o
> obj-$(CONFIG_CRYPTO_GHASH_RISCV64) += ghash-riscv64.o
> ghash-riscv64-y := ghash-riscv64-glue.o ghash-riscv64-zvkg.o
>
> +obj-$(CONFIG_CRYPTO_POLY1305_RISCV) += poly1305-riscv.o
> +poly1305-riscv-y := poly1305-core.o poly1305-glue.o
> +AFLAGS_poly1305-core.o += -Dpoly1305_init=poly1305_init_riscv
> +
> obj-$(CONFIG_CRYPTO_SHA256_RISCV64) += sha256-riscv64.o
> sha256-riscv64-y := sha256-riscv64-glue.o sha256-riscv64-zvknha_or_zvknhb-zvkb.o
Please rebase onto mainline and port your change to arch/riscv/lib/crypto/.
Poly1305 is now available only through the library API, not the crypto_shash
API.
- Eric
More information about the linux-riscv
mailing list