xref: /linux/lib/crypto/Makefile (revision a5210135489ae7bc1ef1cb4a8157361dd7b468cd)
1dc51f257SArd Biesheuvel# SPDX-License-Identifier: GPL-2.0
2dc51f257SArd Biesheuvel
324c91b62SEric Biggersaflags-thumb2-$(CONFIG_THUMB2_KERNEL)  := -U__thumb2__ -D__thumb2__=1
424c91b62SEric Biggers
524c91b62SEric Biggersquiet_cmd_perlasm = PERLASM $@
624c91b62SEric Biggers      cmd_perlasm = $(PERL) $(<) > $(@)
724c91b62SEric Biggers
860e3f1e9SEric Biggersquiet_cmd_perlasm_with_args = PERLASM $@
960e3f1e9SEric Biggers      cmd_perlasm_with_args = $(PERL) $(<) void $(@)
1060e3f1e9SEric Biggers
114dcf6cadSEric Biggersppc64-perlasm-flavour-y := linux-ppc64
124dcf6cadSEric Biggersppc64-perlasm-flavour-$(CONFIG_PPC64_ELF_ABI_V2) := linux-ppc64-elfv2
13aacb37f5SEric Biggersppc64-perlasm-flavour-$(CONFIG_CPU_LITTLE_ENDIAN) := linux-ppc64le
14aacb37f5SEric Biggers
157033b937SEric Biggersobj-$(CONFIG_KUNIT)				+= tests/
166e78ad0bSEric Biggers
177033b937SEric Biggersobj-$(CONFIG_CRYPTO_HASH_INFO)			+= hash_info.o
18a22fd0e3SEric Biggers
19a22fd0e3SEric Biggersobj-$(CONFIG_CRYPTO_LIB_UTILS)			+= libcryptoutils.o
20e59c1c98SArd Biesheuvellibcryptoutils-y				:= memneq.o utils.o
21e59c1c98SArd Biesheuvel
22a22fd0e3SEric Biggers################################################################################
23a22fd0e3SEric Biggers
24fa229775SEric Biggersobj-$(CONFIG_CRYPTO_LIB_AES) += libaes.o
25fa229775SEric Biggerslibaes-y := aes.o
26fa229775SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_AES_ARCH),y)
272b1ef7aeSEric BiggersCFLAGS_aes.o += -I$(src)/$(SRCARCH)
282b1ef7aeSEric Biggers
292b1ef7aeSEric Biggerslibaes-$(CONFIG_ARM) += arm/aes-cipher-core.o
302b1ef7aeSEric Biggerslibaes-$(CONFIG_ARM64) += arm64/aes-cipher-core.o \
312b1ef7aeSEric Biggers			  arm64/aes-ce-core.o \
320892c91bSEric Biggers			  arm64/aes-ce.o \
330892c91bSEric Biggers			  arm64/aes-neon.o
340892c91bSEric Biggers
350892c91bSEric Biggersifeq ($(CONFIG_PPC),y)
360892c91bSEric Biggersifeq ($(CONFIG_SPE),y)
370892c91bSEric Biggerslibaes-y += powerpc/aes-spe-core.o \
387cf2082eSEric Biggers	    powerpc/aes-spe-keys.o \
397cf2082eSEric Biggers	    powerpc/aes-spe-modes.o \
407cf2082eSEric Biggers	    powerpc/aes-tab-4k.o
417cf2082eSEric Biggerselse
427cf2082eSEric Biggerslibaes-y += powerpc/aesp8-ppc.o
437cf2082eSEric Biggersquiet_cmd_perlasm_aes = PERLASM $@
447cf2082eSEric Biggers      cmd_perlasm_aes = $(PERL) $< $(ppc64-perlasm-flavour-y) $@
457cf2082eSEric Biggers# Use if_changed instead of cmd, in case the flavour changed.
467cf2082eSEric Biggers$(obj)/powerpc/aesp8-ppc.S: $(src)/powerpc/aesp8-ppc.pl FORCE
477cf2082eSEric Biggers	$(call if_changed,perlasm_aes)
487cf2082eSEric Biggerstargets += powerpc/aesp8-ppc.S
497cf2082eSEric BiggersOBJECT_FILES_NON_STANDARD_powerpc/aesp8-ppc.o := y
507cf2082eSEric Biggersendif # !CONFIG_SPE
510892c91bSEric Biggersendif # CONFIG_PPC
520892c91bSEric Biggers
53a4e573dbSEric Biggerslibaes-$(CONFIG_RISCV) += riscv/aes-riscv64-zvkned.o
54293c7cd5SEric Biggerslibaes-$(CONFIG_SPARC) += sparc/aes_asm.o
5524eb22d8SEric Biggerslibaes-$(CONFIG_X86) += x86/aes-aesni.o
56a22fd0e3SEric Biggersendif # CONFIG_CRYPTO_LIB_AES_ARCH
57a22fd0e3SEric Biggers
58*d5b66179SEric Biggers# clean-files must be defined unconditionally
59*d5b66179SEric Biggersclean-files += powerpc/aesp8-ppc.S
60*d5b66179SEric Biggers
61a22fd0e3SEric Biggers################################################################################
62e59c1c98SArd Biesheuvel
63f1354404SArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_AESCFB)			+= libaescfb.o
64f1354404SArd Biesheuvellibaescfb-y					:= aescfb.o
65f1354404SArd Biesheuvel
66520af5daSArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_AESGCM)			+= libaesgcm.o
67520af5daSArd Biesheuvellibaesgcm-y					:= aesgcm.o
68520af5daSArd Biesheuvel
69dc51f257SArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_ARC4)			+= libarc4.o
70dc51f257SArd Biesheuvellibarc4-y					:= arc4.o
7104007b0eSArd Biesheuvel
7261c581a4SArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_GF128MUL)		+= gf128mul.o
7361c581a4SArd Biesheuvel
7439ee3970SEric Biggers################################################################################
7539ee3970SEric Biggers
7623a16c95SEric Biggersobj-$(CONFIG_CRYPTO_LIB_BLAKE2B) += libblake2b.o
7723a16c95SEric Biggerslibblake2b-y := blake2b.o
7823a16c95SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_BLAKE2B_ARCH),y)
7923a16c95SEric BiggersCFLAGS_blake2b.o += -I$(src)/$(SRCARCH)
80ba6617bdSEric Biggerslibblake2b-$(CONFIG_ARM) += arm/blake2b-neon-core.o
8123a16c95SEric Biggersendif # CONFIG_CRYPTO_LIB_BLAKE2B_ARCH
8223a16c95SEric Biggers
8323a16c95SEric Biggers################################################################################
8423a16c95SEric Biggers
856048fdccSJason A. Donenfeld# blake2s is used by the /dev/random driver which is always builtin
8639ee3970SEric Biggersobj-y += blake2s.o
8739ee3970SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_BLAKE2S_ARCH),y)
8839ee3970SEric BiggersCFLAGS_blake2s.o += -I$(src)/$(SRCARCH)
8939ee3970SEric Biggersobj-$(CONFIG_ARM) += arm/blake2s-core.o
9039ee3970SEric Biggersobj-$(CONFIG_X86) += x86/blake2s-core.o
9139ee3970SEric Biggersendif
9266d7fb94SJason A. Donenfeld
9313cecc52SEric Biggers################################################################################
9413cecc52SEric Biggers
9513cecc52SEric Biggers# chacha20_block() is used by the /dev/random driver which is always builtin
9613cecc52SEric Biggersobj-y += chacha-block-generic.o
9713cecc52SEric Biggers
9813cecc52SEric Biggersobj-$(CONFIG_CRYPTO_LIB_CHACHA) += libchacha.o
9913cecc52SEric Biggerslibchacha-y := chacha.o
10013cecc52SEric Biggers
10113cecc52SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_CHACHA_ARCH),y)
10213cecc52SEric BiggersCFLAGS_chacha.o += -I$(src)/$(SRCARCH)
10313cecc52SEric Biggers
10413cecc52SEric Biggersifeq ($(CONFIG_ARM),y)
10513cecc52SEric Biggerslibchacha-y += arm/chacha-scalar-core.o
10613cecc52SEric Biggerslibchacha-$(CONFIG_KERNEL_MODE_NEON) += arm/chacha-neon-core.o
10713cecc52SEric Biggersendif
10813cecc52SEric Biggers
10913cecc52SEric Biggerslibchacha-$(CONFIG_ARM64) += arm64/chacha-neon-core.o
11013cecc52SEric Biggers
11113cecc52SEric Biggersifeq ($(CONFIG_MIPS),y)
11213cecc52SEric Biggerslibchacha-y += mips/chacha-core.o
11313cecc52SEric BiggersAFLAGS_mips/chacha-core.o += -O2 # needed to fill branch delay slots
11413cecc52SEric Biggersendif
11513cecc52SEric Biggers
11613cecc52SEric Biggerslibchacha-$(CONFIG_PPC) += powerpc/chacha-p10le-8x.o
11713cecc52SEric Biggerslibchacha-$(CONFIG_RISCV) += riscv/chacha-riscv64-zvkb.o
11813cecc52SEric Biggerslibchacha-$(CONFIG_S390) += s390/chacha-s390.o
11913cecc52SEric Biggerslibchacha-$(CONFIG_X86) += x86/chacha-ssse3-x86_64.o \
12013cecc52SEric Biggers			   x86/chacha-avx2-x86_64.o \
12113cecc52SEric Biggers			   x86/chacha-avx512vl-x86_64.o
12213cecc52SEric Biggersendif # CONFIG_CRYPTO_LIB_CHACHA_ARCH
12313cecc52SEric Biggers
12413cecc52SEric Biggers################################################################################
12513cecc52SEric Biggers
126ed20078bSArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_CHACHA20POLY1305)	+= libchacha20poly1305.o
127ed20078bSArd Biesheuvellibchacha20poly1305-y				+= chacha20poly1305.o
12840b99697SEric Biggers
129ed20078bSArd Biesheuvel################################################################################
13068546e56SEric Biggers
13168546e56SEric Biggersobj-$(CONFIG_CRYPTO_LIB_CURVE25519) += libcurve25519.o
13268546e56SEric Biggerslibcurve25519-y := curve25519.o
13368546e56SEric Biggers
13468546e56SEric Biggers# Disable GCOV in odd or sensitive code
13568546e56SEric BiggersGCOV_PROFILE_curve25519.o := n
13668546e56SEric Biggers
13768546e56SEric Biggersifeq ($(CONFIG_ARCH_SUPPORTS_INT128),y)
13868546e56SEric Biggerslibcurve25519-$(CONFIG_CRYPTO_LIB_CURVE25519_GENERIC) += curve25519-hacl64.o
13968546e56SEric Biggerselse
14068546e56SEric Biggerslibcurve25519-$(CONFIG_CRYPTO_LIB_CURVE25519_GENERIC) += curve25519-fiat32.o
14168546e56SEric Biggersendif
14268546e56SEric Biggers# clang versions prior to 18 may blow out the stack with KASAN
1432f13daeeSNathan Chancellorifeq ($(CONFIG_CC_IS_CLANG)_$(call clang-min-version, 180000),y_)
1442b81082aSNathan ChancellorKASAN_SANITIZE_curve25519-hacl64.o := n
1452f13daeeSNathan Chancellorendif
1462f13daeeSNathan Chancellor
147a8bdf2c4SHerbert Xuifeq ($(CONFIG_CRYPTO_LIB_CURVE25519_ARCH),y)
14868546e56SEric BiggersCFLAGS_curve25519.o += -I$(src)/$(SRCARCH)
14968546e56SEric Biggerslibcurve25519-$(CONFIG_ARM) += arm/curve25519-core.o
15068546e56SEric Biggerslibcurve25519-$(CONFIG_PPC) += powerpc/curve25519-ppc64le_asm.o
15168546e56SEric Biggersendif
15268546e56SEric Biggers
15368546e56SEric Biggers################################################################################
15468546e56SEric Biggers
1550ed42a6fSJason A. Donenfeldobj-$(CONFIG_CRYPTO_LIB_DES)			+= libdes.o
15604007b0eSArd Biesheuvellibdes-y					:= des.o
15704007b0eSArd Biesheuvel
15801d3aee8SHans de Goede################################################################################
159e1644613SEric Biggers
160e1644613SEric Biggersobj-$(CONFIG_CRYPTO_LIB_GF128HASH) += libgf128hash.o
161e1644613SEric Biggerslibgf128hash-y := gf128hash.o
162e1644613SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_GF128HASH_ARCH),y)
163e1644613SEric BiggersCFLAGS_gf128hash.o += -I$(src)/$(SRCARCH)
164e1644613SEric Biggerslibgf128hash-$(CONFIG_ARM) += arm/ghash-neon-core.o
16509371e13SEric Biggerslibgf128hash-$(CONFIG_ARM64) += arm64/ghash-neon-core.o \
166a1848f6eSEric Biggers				arm64/polyval-ce-core.o
167e1644613SEric Biggers
168e1644613SEric Biggersifeq ($(CONFIG_PPC),y)
169e1644613SEric Biggerslibgf128hash-y += powerpc/ghashp8-ppc.o
170e1644613SEric Biggersquiet_cmd_perlasm_ghash = PERLASM $@
17164edcceaSEric Biggers      cmd_perlasm_ghash = $(PERL) $< $(ppc64-perlasm-flavour-y) $@
17264edcceaSEric Biggers$(obj)/powerpc/ghashp8-ppc.S: $(src)/powerpc/ghashp8-ppc.pl FORCE
17364edcceaSEric Biggers	$(call if_changed,perlasm_ghash)
17464edcceaSEric Biggerstargets += powerpc/ghashp8-ppc.S
17564edcceaSEric BiggersOBJECT_FILES_NON_STANDARD_powerpc/ghashp8-ppc.o := y
17614e15c71SEric Biggersendif
17714e15c71SEric Biggers
17814e15c71SEric Biggerslibgf128hash-$(CONFIG_RISCV) += riscv/ghash-riscv64-zvkg.o
17914e15c71SEric Biggerslibgf128hash-$(CONFIG_X86) += x86/ghash-pclmul.o \
18029e39a11SEric Biggers			      x86/polyval-pclmul-avx.o
181b4a8528dSEric Biggersendif # CONFIG_CRYPTO_LIB_GF128HASH_ARCH
182a229d832SEric Biggers
18314e15c71SEric Biggers# clean-files must be defined unconditionally
18414e15c71SEric Biggersclean-files += powerpc/ghashp8-ppc.S
18514e15c71SEric Biggers
18614e15c71SEric Biggers################################################################################
1879b9d4ef0SHerbert Xu
188b646b782SEric Biggersobj-$(CONFIG_CRYPTO_LIB_MD5) += libmd5.o
189b646b782SEric Biggerslibmd5-y := md5.o
190b646b782SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_MD5_ARCH),y)
191b646b782SEric BiggersCFLAGS_md5.o += -I$(src)/$(SRCARCH)
192b646b782SEric Biggerslibmd5-$(CONFIG_PPC) += powerpc/md5-asm.o
193b646b782SEric Biggersendif # CONFIG_CRYPTO_LIB_MD5_ARCH
19448ea8c6eSArd Biesheuvel
195b646b782SEric Biggers################################################################################
196b646b782SEric Biggers
197b646b782SEric Biggersobj-$(CONFIG_CRYPTO_LIB_MLDSA) += libmldsa.o
198b646b782SEric Biggerslibmldsa-y := mldsa.o
199b646b782SEric Biggers
200b646b782SEric Biggers################################################################################
201b646b782SEric Biggers
202b646b782SEric Biggersobj-$(CONFIG_CRYPTO_LIB_NH) += libnh.o
203b646b782SEric Biggerslibnh-y := nh.o
204b646b782SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_NH_ARCH),y)
205b646b782SEric BiggersCFLAGS_nh.o += -I$(src)/$(SRCARCH)
206b646b782SEric Biggerslibnh-$(CONFIG_ARM) += arm/nh-neon-core.o
207b646b782SEric Biggerslibnh-$(CONFIG_ARM64) += arm64/nh-neon-core.o
208b646b782SEric Biggerslibnh-$(CONFIG_X86) += x86/nh-sse2.o x86/nh-avx2.o
209b646b782SEric Biggersendif
210b646b782SEric Biggers
211b646b782SEric Biggers################################################################################
212b646b782SEric Biggers
213b646b782SEric Biggersobj-$(CONFIG_CRYPTO_LIB_POLY1305) += libpoly1305.o
214b646b782SEric Biggerslibpoly1305-y := poly1305.o
215b646b782SEric Biggersifeq ($(CONFIG_ARCH_SUPPORTS_INT128),y)
216b646b782SEric Biggerslibpoly1305-$(CONFIG_CRYPTO_LIB_POLY1305_GENERIC) += poly1305-donna64.o
217b646b782SEric Biggerselse
218b646b782SEric Biggerslibpoly1305-$(CONFIG_CRYPTO_LIB_POLY1305_GENERIC) += poly1305-donna32.o
219b646b782SEric Biggersendif
220b646b782SEric Biggers
221b646b782SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_POLY1305_ARCH),y)
222b646b782SEric BiggersCFLAGS_poly1305.o += -I$(src)/$(SRCARCH)
223b646b782SEric Biggers
224b646b782SEric Biggersifeq ($(CONFIG_ARM),y)
225b646b782SEric Biggerslibpoly1305-y += arm/poly1305-core.o
226b646b782SEric Biggers$(obj)/arm/poly1305-core.S: $(src)/arm/poly1305-armv4.pl
227b646b782SEric Biggers	$(call cmd,perlasm)
228bef9c755SZhihang Shao# massage the perlasm code a bit so we only get the NEON routine if we need it
229bef9c755SZhihang Shaopoly1305-aflags-$(CONFIG_CPU_V7) := -U__LINUX_ARM_ARCH__ -D__LINUX_ARM_ARCH__=5
230bef9c755SZhihang Shaopoly1305-aflags-$(CONFIG_KERNEL_MODE_NEON) := -U__LINUX_ARM_ARCH__ -D__LINUX_ARM_ARCH__=7
231bef9c755SZhihang ShaoAFLAGS_arm/poly1305-core.o += $(poly1305-aflags-y) $(aflags-thumb2-y)
232bef9c755SZhihang Shaoendif
233bef9c755SZhihang Shao
234bef9c755SZhihang Shaoifeq ($(CONFIG_ARM64),y)
235bef9c755SZhihang Shaolibpoly1305-y += arm64/poly1305-core.o
236bef9c755SZhihang Shao$(obj)/arm64/poly1305-core.S: $(src)/arm64/poly1305-armv8.pl
237bef9c755SZhihang Shao	$(call cmd,perlasm_with_args)
238bef9c755SZhihang Shaoendif
239bef9c755SZhihang Shao
240bef9c755SZhihang Shaoifeq ($(CONFIG_MIPS),y)
241b646b782SEric Biggerslibpoly1305-y += mips/poly1305-core.o
242b646b782SEric Biggerspoly1305-perlasm-flavour-$(CONFIG_32BIT) := o32
243b646b782SEric Biggerspoly1305-perlasm-flavour-$(CONFIG_64BIT) := 64
244b646b782SEric Biggersquiet_cmd_perlasm_poly1305 = PERLASM $@
245b646b782SEric Biggers      cmd_perlasm_poly1305 = $(PERL) $< $(poly1305-perlasm-flavour-y) $@
246b646b782SEric Biggers# Use if_changed instead of cmd, in case the flavour changed.
247b646b782SEric Biggers$(obj)/mips/poly1305-core.S: $(src)/mips/poly1305-mips.pl FORCE
248b646b782SEric Biggers	$(call if_changed,perlasm_poly1305)
249b646b782SEric Biggerstargets += mips/poly1305-core.S
250b646b782SEric Biggersendif
251b646b782SEric Biggers
252b646b782SEric Biggerslibpoly1305-$(CONFIG_PPC) += powerpc/poly1305-p10le_64.o
253bef9c755SZhihang Shao
254b646b782SEric Biggersifeq ($(CONFIG_RISCV),y)
2559b9d4ef0SHerbert Xulibpoly1305-y += riscv/poly1305-core.o
25690860aefSEric Biggerspoly1305-perlasm-flavour-$(CONFIG_32BIT) := 32
25790860aefSEric Biggerspoly1305-perlasm-flavour-$(CONFIG_64BIT) := 64
2583d176751SEric Biggersquiet_cmd_perlasm_poly1305 = PERLASM $@
2593d176751SEric Biggers      cmd_perlasm_poly1305 = $(PERL) $< $(poly1305-perlasm-flavour-y) $@
2603d176751SEric Biggers# Use if_changed instead of cmd, in case the flavour changed.
2613d176751SEric Biggers$(obj)/riscv/poly1305-core.S: $(src)/riscv/poly1305-riscv.pl FORCE
26237919e23SEric Biggers	$(call if_changed,perlasm_poly1305)
2634d8da355SEric Biggerstargets += riscv/poly1305-core.S
2643d176751SEric BiggersAFLAGS_riscv/poly1305-core.o += -Dpoly1305_init=poly1305_block_init
2653d176751SEric Biggersendif
2663d176751SEric Biggers
2673d176751SEric Biggersifeq ($(CONFIG_X86),y)
268ec8f7f48SEric Biggerslibpoly1305-y += x86/poly1305-x86_64-cryptogams.o
269ec8f7f48SEric Biggers$(obj)/x86/poly1305-x86_64-cryptogams.S: $(src)/x86/poly1305-x86_64-cryptogams.pl
27090860aefSEric Biggers	$(call cmd,perlasm)
27190860aefSEric Biggersendif
27270cb6ca5SEric Biggers
27370cb6ca5SEric Biggersendif # CONFIG_CRYPTO_LIB_POLY1305_ARCH
27470cb6ca5SEric Biggers
27570cb6ca5SEric Biggers# clean-files must be defined unconditionally
27670cb6ca5SEric Biggersclean-files += arm/poly1305-core.S \
27700d549bbSEric Biggers	       arm64/poly1305-core.S \
2786b9ae8cfSEric Biggers	       mips/poly1305-core.S \
2796b9ae8cfSEric Biggers	       riscv/poly1305-core.S \
2806b9ae8cfSEric Biggers	       x86/poly1305-x86_64-cryptogams.S
2816b9ae8cfSEric Biggers
282c7510599SEric Biggers################################################################################
283f3d6cb3dSEric Biggers
284f3d6cb3dSEric Biggersobj-$(CONFIG_CRYPTO_LIB_SHA1) += libsha1.o
285f3d6cb3dSEric Biggerslibsha1-y := sha1.o
28690860aefSEric Biggersifeq ($(CONFIG_CRYPTO_LIB_SHA1_ARCH),y)
287463f7408SEric BiggersCFLAGS_sha1.o += -I$(src)/$(SRCARCH)
288e96cb950SEric Biggersifeq ($(CONFIG_ARM),y)
289e96cb950SEric Biggerslibsha1-y += arm/sha1-armv4-large.o
29001d3aee8SHans de Goedelibsha1-$(CONFIG_KERNEL_MODE_NEON) += arm/sha1-armv7-neon.o \
29101d3aee8SHans de Goede				      arm/sha1-ce-core.o
292e96cb950SEric Biggersendif
293e96cb950SEric Biggerslibsha1-$(CONFIG_ARM64) += arm64/sha1-ce-core.o
29466d7fb94SJason A. Donenfeldifeq ($(CONFIG_PPC),y)
295e96cb950SEric Biggerslibsha1-y += powerpc/sha1-powerpc-asm.o
296e96cb950SEric Biggerslibsha1-$(CONFIG_SPE) += powerpc/sha1-spe-asm.o
297e96cb950SEric Biggersendif
298e96cb950SEric Biggerslibsha1-$(CONFIG_SPARC) += sparc/sha1_asm.o
299e96cb950SEric Biggerslibsha1-$(CONFIG_X86) += x86/sha1-ssse3-and-avx.o \
300e96cb950SEric Biggers			 x86/sha1-avx2-asm.o \
301e96cb950SEric Biggers			 x86/sha1-ni-asm.o
302e96cb950SEric Biggersendif # CONFIG_CRYPTO_LIB_SHA1_ARCH
303e96cb950SEric Biggers
304e96cb950SEric Biggers################################################################################
305e96cb950SEric Biggers
306e96cb950SEric Biggersobj-$(CONFIG_CRYPTO_LIB_SHA256) += libsha256.o
307e96cb950SEric Biggerslibsha256-y := sha256.o
308e96cb950SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_SHA256_ARCH),y)
309e96cb950SEric BiggersCFLAGS_sha256.o += -I$(src)/$(SRCARCH)
310e96cb950SEric Biggers
311e96cb950SEric Biggersifeq ($(CONFIG_ARM),y)
312e96cb950SEric Biggerslibsha256-y += arm/sha256-ce.o arm/sha256-core.o
313e96cb950SEric Biggers$(obj)/arm/sha256-core.S: $(src)/arm/sha256-armv4.pl
314e96cb950SEric Biggers	$(call cmd,perlasm)
315e96cb950SEric BiggersAFLAGS_arm/sha256-core.o += $(aflags-thumb2-y)
316e96cb950SEric Biggersendif
317e96cb950SEric Biggers
318e96cb950SEric Biggersifeq ($(CONFIG_ARM64),y)
319950e5c84SEric Biggerslibsha256-y += arm64/sha256-ce.o arm64/sha256-core.o
320b693c703SEric Biggers$(obj)/arm64/sha256-core.S: $(src)/arm64/sha2-armv8.pl
321b693c703SEric Biggers	$(call cmd,perlasm_with_args)
322b693c703SEric Biggersendif
323b693c703SEric Biggers
32424c91b62SEric Biggerslibsha256-$(CONFIG_PPC) += powerpc/sha256-spe-asm.o
32524c91b62SEric Biggerslibsha256-$(CONFIG_RISCV) += riscv/sha256-riscv64-zvknha_or_zvknhb-zvkb.o
32624c91b62SEric Biggerslibsha256-$(CONFIG_SPARC) += sparc/sha256_asm.o
32724c91b62SEric Biggerslibsha256-$(CONFIG_X86) += x86/sha256-ssse3-asm.o \
32824c91b62SEric Biggers			   x86/sha256-avx-asm.o \
32924c91b62SEric Biggers			   x86/sha256-avx2-asm.o \
33024c91b62SEric Biggers			   x86/sha256-ni-asm.o
33124c91b62SEric Biggersendif # CONFIG_CRYPTO_LIB_SHA256_ARCH
33260e3f1e9SEric Biggers
33360e3f1e9SEric Biggers################################################################################
33461f86c70SEric Biggers
33560e3f1e9SEric Biggersobj-$(CONFIG_CRYPTO_LIB_SHA512) += libsha512.o
33660e3f1e9SEric Biggerslibsha512-y := sha512.o
33760e3f1e9SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_SHA512_ARCH),y)
338b59059a2SEric BiggersCFLAGS_sha512.o += -I$(src)/$(SRCARCH)
339b59059a2SEric Biggers
34002b35babSEric Biggersifeq ($(CONFIG_ARM),y)
341484c1811SEric Biggerslibsha512-y += arm/sha512-core.o
342484c1811SEric Biggers$(obj)/arm/sha512-core.S: $(src)/arm/sha512-armv4.pl
343484c1811SEric Biggers	$(call cmd,perlasm)
344b693c703SEric BiggersAFLAGS_arm/sha512-core.o += $(aflags-thumb2-y)
345b693c703SEric Biggersendif
346e96cb950SEric Biggers
347e96cb950SEric Biggersifeq ($(CONFIG_ARM64),y)
34805934472SDavid Howellslibsha512-y += arm64/sha512-ce-core.o arm64/sha512-core.o
34905934472SDavid Howells$(obj)/arm64/sha512-core.S: $(src)/arm64/sha2-armv8.pl
35005934472SDavid Howells	$(call cmd,perlasm_with_args)
3511e29a750SEric Biggersendif
3521e29a750SEric Biggers
3531e29a750SEric Biggerslibsha512-$(CONFIG_RISCV) += riscv/sha512-riscv64-zvknhb-zvkb.o
3541e29a750SEric Biggerslibsha512-$(CONFIG_SPARC) += sparc/sha512_asm.o
3551e29a750SEric Biggerslibsha512-$(CONFIG_X86) += x86/sha512-ssse3-asm.o \
35605934472SDavid Howells			   x86/sha512-avx-asm.o \
35705934472SDavid Howells			   x86/sha512-avx2-asm.o
3582a598d0bSHerbert Xuendif # CONFIG_CRYPTO_LIB_SHA512_ARCH
3594964a1d9SEric Biggers
360ac90aad0SEric Biggers################################################################################
361f4065b2fSHerbert Xu
362f4065b2fSHerbert Xuobj-$(CONFIG_CRYPTO_LIB_SHA3) += libsha3.o
363f4065b2fSHerbert Xulibsha3-y := sha3.o
3644a32e5dcSEric Biggers
365fd7e5de4STal Zussmanifeq ($(CONFIG_CRYPTO_LIB_SHA3_ARCH),y)
366fd7e5de4STal ZussmanCFLAGS_sha3.o += -I$(src)/$(SRCARCH)
367fd7e5de4STal Zussmanlibsha3-$(CONFIG_ARM64) += arm64/sha3-ce-core.o
368endif # CONFIG_CRYPTO_LIB_SHA3_ARCH
369
370################################################################################
371
372obj-$(CONFIG_CRYPTO_LIB_SM3) += libsm3.o
373libsm3-y := sm3.o
374ifeq ($(CONFIG_CRYPTO_LIB_SM3_ARCH),y)
375CFLAGS_sm3.o += -I$(src)/$(SRCARCH)
376libsm3-$(CONFIG_ARM64) += arm64/sm3-ce-core.o \
377			  arm64/sm3-neon-core.o
378libsm3-$(CONFIG_RISCV) += riscv/sm3-riscv64-zvksh-zvkb.o
379libsm3-$(CONFIG_X86) += x86/sm3-avx-asm_64.o
380endif # CONFIG_CRYPTO_LIB_SM3_ARCH
381
382################################################################################
383
384obj-$(CONFIG_MPILIB) += mpi/
385
386obj-$(CONFIG_CRYPTO_SELFTESTS_FULL)		+= simd.o
387
388# clean-files must be defined unconditionally
389clean-files += arm/sha256-core.S arm/sha512-core.S
390clean-files += arm64/sha256-core.S arm64/sha512-core.S
391