summaryrefslogtreecommitdiff
path: root/lib/crypto/Makefile
diff options
context:
space:
mode:
authorZhihang Shao <zhihang.shao.iscas@gmail.com>2025-08-29 08:25:13 -0700
committerEric Biggers <ebiggers@kernel.org>2025-08-29 09:49:18 -0700
commitbef9c755986980eecc18e9cecd847bc3c037aebb (patch)
tree25967001759068d69e4e9b6e63af77fff518fcb3 /lib/crypto/Makefile
parentb646b782e522da3509e61f971e5502fccb3a3723 (diff)
lib/crypto: riscv/poly1305: Import OpenSSL/CRYPTOGAMS implementation
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 https://github.com/dot-asm/cryptogams commit 5e3fba73576244708a752fa61a8e93e587f271bb. This patch was tested on SpacemiT X60, with 2~2.5x improvement over generic implementation. Signed-off-by: Chunyan Zhang <zhangchunyan@iscas.ac.cn> Signed-off-by: Zhihang Shao <zhihang.shao.iscas@gmail.com> [EB: ported to lib/crypto/riscv/] Reviewed-by: Ard Biesheuvel <ardb@kernel.org> Link: https://lore.kernel.org/r/20250829152513.92459-4-ebiggers@kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Diffstat (limited to 'lib/crypto/Makefile')
-rw-r--r--lib/crypto/Makefile14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/crypto/Makefile b/lib/crypto/Makefile
index e0536e3b3a04..cd460e5e3dd2 100644
--- a/lib/crypto/Makefile
+++ b/lib/crypto/Makefile
@@ -112,6 +112,19 @@ endif
libpoly1305-$(CONFIG_PPC) += powerpc/poly1305-p10le_64.o
+ifeq ($(CONFIG_RISCV),y)
+libpoly1305-y += riscv/poly1305-core.o
+poly1305-perlasm-flavour-$(CONFIG_32BIT) := 32
+poly1305-perlasm-flavour-$(CONFIG_64BIT) := 64
+quiet_cmd_perlasm_poly1305 = PERLASM $@
+ cmd_perlasm_poly1305 = $(PERL) $< $(poly1305-perlasm-flavour-y) $@
+# Use if_changed instead of cmd, in case the flavour changed.
+$(obj)/riscv/poly1305-core.S: $(src)/riscv/poly1305-riscv.pl FORCE
+ $(call if_changed,perlasm_poly1305)
+targets += riscv/poly1305-core.S
+AFLAGS_riscv/poly1305-core.o += -Dpoly1305_init=poly1305_block_init
+endif
+
ifeq ($(CONFIG_X86),y)
libpoly1305-y += x86/poly1305-x86_64-cryptogams.o
$(obj)/x86/poly1305-x86_64-cryptogams.S: $(src)/x86/poly1305-x86_64-cryptogams.pl
@@ -124,6 +137,7 @@ endif # CONFIG_CRYPTO_LIB_POLY1305_ARCH
clean-files += arm/poly1305-core.S \
arm64/poly1305-core.S \
mips/poly1305-core.S \
+ riscv/poly1305-core.S \
x86/poly1305-x86_64-cryptogams.S
################################################################################