Commit 68546e56 authored by Eric Biggers's avatar Eric Biggers
Browse files

lib/crypto: curve25519: Consolidate into single module

Reorganize the Curve25519 library code:

- Build a single libcurve25519 module, instead of up to three modules:
  libcurve25519, libcurve25519-generic, and an arch-specific module.

- Move the arch-specific Curve25519 code from arch/$(SRCARCH)/crypto/ to
  lib/crypto/$(SRCARCH)/.  Centralize the build rules into
  lib/crypto/Makefile and lib/crypto/Kconfig.

- Include the arch-specific code directly in lib/crypto/curve25519.c via
  a header, rather than using a separate .c file.

- Eliminate the entanglement with CRYPTO.  CRYPTO_LIB_CURVE25519 no
  longer selects CRYPTO, and the arch-specific Curve25519 code no longer
  depends on CRYPTO.

This brings Curve25519 in line with the latest conventions for
lib/crypto/, used by other algorithms.  The exception is that I kept the
generic code in separate translation units for now.  (Some of the
function names collide between the x86 and generic Curve25519 code.  And
the Curve25519 functions are very long anyway, so inlining doesn't
matter as much for Curve25519 as it does for some other algorithms.)

Link: https://lore.kernel.org/r/20250906213523.84915-11-ebiggers@kernel.org


Signed-off-by: default avatarEric Biggers <ebiggers@kernel.org>
parent 8c06b330
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -2,18 +2,6 @@

menu "Accelerated Cryptographic Algorithms for CPU (arm)"

config CRYPTO_CURVE25519_NEON
	tristate
	depends on KERNEL_MODE_NEON
	select CRYPTO_LIB_CURVE25519_GENERIC
	select CRYPTO_ARCH_HAVE_LIB_CURVE25519
	default CRYPTO_LIB_CURVE25519_INTERNAL
	help
	  Curve25519 algorithm

	  Architecture: arm with
	  - NEON (Advanced SIMD) extensions

config CRYPTO_GHASH_ARM_CE
	tristate "Hash functions: GHASH (PMULL/NEON/ARMv8 Crypto Extensions)"
	depends on KERNEL_MODE_NEON
+0 −2
Original line number Diff line number Diff line
@@ -7,7 +7,6 @@ obj-$(CONFIG_CRYPTO_AES_ARM) += aes-arm.o
obj-$(CONFIG_CRYPTO_AES_ARM_BS) += aes-arm-bs.o
obj-$(CONFIG_CRYPTO_BLAKE2B_NEON) += blake2b-neon.o
obj-$(CONFIG_CRYPTO_NHPOLY1305_NEON) += nhpoly1305-neon.o
obj-$(CONFIG_CRYPTO_CURVE25519_NEON) += curve25519-neon.o

obj-$(CONFIG_CRYPTO_AES_ARM_CE) += aes-arm-ce.o
obj-$(CONFIG_CRYPTO_GHASH_ARM_CE) += ghash-arm-ce.o
@@ -18,4 +17,3 @@ blake2b-neon-y := blake2b-neon-core.o blake2b-neon-glue.o
aes-arm-ce-y	:= aes-ce-core.o aes-ce-glue.o
ghash-arm-ce-y	:= ghash-ce-core.o ghash-ce-glue.o
nhpoly1305-neon-y := nh-neon-core.o nhpoly1305-neon-glue.o
curve25519-neon-y := curve25519-core.o curve25519-glue.o
+0 −12
Original line number Diff line number Diff line
@@ -2,18 +2,6 @@

menu "Accelerated Cryptographic Algorithms for CPU (powerpc)"

config CRYPTO_CURVE25519_PPC64
	tristate
	depends on PPC64 && CPU_LITTLE_ENDIAN
	select CRYPTO_LIB_CURVE25519_GENERIC
	select CRYPTO_ARCH_HAVE_LIB_CURVE25519
	default CRYPTO_LIB_CURVE25519_INTERNAL
	help
	  Curve25519 algorithm

	  Architecture: PowerPC64
	  - Little-endian

config CRYPTO_AES_PPC_SPE
	tristate "Ciphers: AES, modes: ECB/CBC/CTR/XTS (SPE)"
	depends on SPE
+0 −2
Original line number Diff line number Diff line
@@ -8,12 +8,10 @@
obj-$(CONFIG_CRYPTO_AES_PPC_SPE) += aes-ppc-spe.o
obj-$(CONFIG_CRYPTO_AES_GCM_P10) += aes-gcm-p10-crypto.o
obj-$(CONFIG_CRYPTO_DEV_VMX_ENCRYPT) += vmx-crypto.o
obj-$(CONFIG_CRYPTO_CURVE25519_PPC64) += curve25519-ppc64le.o

aes-ppc-spe-y := aes-spe-core.o aes-spe-keys.o aes-tab-4k.o aes-spe-modes.o aes-spe-glue.o
aes-gcm-p10-crypto-y := aes-gcm-p10-glue.o aes-gcm-p10.o ghashp10-ppc.o aesp10-ppc.o
vmx-crypto-objs := vmx.o aesp8-ppc.o ghashp8-ppc.o aes.o aes_cbc.o aes_ctr.o aes_xts.o ghash.o
curve25519-ppc64le-y := curve25519-ppc64le-core.o curve25519-ppc64le_asm.o

ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
override flavour := linux-ppc64le
+0 −12
Original line number Diff line number Diff line
@@ -2,18 +2,6 @@

menu "Accelerated Cryptographic Algorithms for CPU (x86)"

config CRYPTO_CURVE25519_X86
	tristate
	depends on 64BIT
	select CRYPTO_LIB_CURVE25519_GENERIC
	select CRYPTO_ARCH_HAVE_LIB_CURVE25519
	default CRYPTO_LIB_CURVE25519_INTERNAL
	help
	  Curve25519 algorithm

	  Architecture: x86_64 using:
	  - ADX (large integer arithmetic)

config CRYPTO_AES_NI_INTEL
	tristate "Ciphers: AES, modes: ECB, CBC, CTS, CTR, XCTR, XTS, GCM (AES-NI/VAES)"
	select CRYPTO_AEAD
Loading