################################################################################
# Curve25519 implementation: X25519 and ED25519

leancrypto-$(CONFIG_LEANCRYPTO_CURVE25519)				       \
				+= ../curve25519/src/ed25519.o		       \
				   ../curve25519/src/ed25519_ref10.o	       \
				   ../curve25519/src/x25519.o		       \
				   ../curve25519/src/x25519_scalarmult_c.o

ifdef CONFIG_X86_64
leancrypto-$(CONFIG_LEANCRYPTO_CURVE25519)				       \
				+= ../curve25519/src/avx/curve25519_avx.o      \
				   ../curve25519/src/avx/curve25519_avx_asm.o  \
				   ../curve25519/src/avx/fe51_invert.o	       \
				   ../curve25519/src/avx/fe_frombytes_avx.o
else ifdef CONFIG_ARM64
asflags-$(CONFIG_LEANCRYPTO_CURVE25519)					       \
				+= -march=armv8-a+simd			       \
				   -funsafe-math-optimizations
leancrypto-$(CONFIG_LEANCRYPTO_CURVE25519)				       \
				+= ../curve25519/src/armv8/curve25519_armv8.o  \
				   ../curve25519/src/armv8/X25519-AArch64.o
else ifdef CONFIG_ARM
asflags-$(CONFIG_LEANCRYPTO_CURVE25519)					       \
				+= -mfpu=neon-vfpv4			       \
				   -mthumb				       \
				   -march=armv7-a+vfpv4			       \
				   -mfloat-abi=softfp			       \
				   -funsafe-math-optimizations
leancrypto-$(CONFIG_LEANCRYPTO_CURVE25519)				       \
				+= ../curve25519/src/armv7/curve25519_armv7.o  \
				   ../curve25519/src/armv7/x25519-cortex-m4-gcc.o
else
leancrypto-$(CONFIG_LEANCRYPTO_CURVE25519)				       \
				+= ../curve25519/src/x25519_scalarmult.o
endif

ifdef CONFIG_LEANCRYPTO_CURVE25519
ccflags-y			+= -DLC_CURVE25519
obj-$(CONFIG_LEANCRYPTO_TEST_MODULES)	+= ed25519_tester.o
obj-$(CONFIG_LEANCRYPTO_TEST_MODULES)	+= x25519_c_tester.o
obj-$(CONFIG_LEANCRYPTO_TEST_MODULES)	+= x25519_common_tester.o

ed25519_tester-y		+= ../curve25519/tests/ed25519_tester.o	       \
				   ../drng/src/selftest_rng.o
x25519_c_tester-y		+= ../curve25519/tests/x25519_c_tester.o       \
				   ../drng/src/selftest_rng.o
x25519_common_tester-y		+= ../curve25519/tests/x25519_common_tester.o

ifdef CONFIG_X86_64
obj-$(CONFIG_LEANCRYPTO_TEST_MODULES)	+= x25519_avx_tester.o
x25519_avx_tester-y		+= ../curve25519/tests/x25519_c_tester.o       \
				   ../drng/src/selftest_rng.o
endif

endif
