xref: /linux/lib/crypto/Makefile (revision 293c7cd5c6c00f3b6fa0072fc4b017a3a13ad1e7)
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 Biggersobj-$(CONFIG_KUNIT)				+= tests/
124dcf6cadSEric Biggers
13aacb37f5SEric Biggersobj-$(CONFIG_CRYPTO_HASH_INFO)			+= hash_info.o
14aacb37f5SEric Biggers
157033b937SEric Biggersobj-$(CONFIG_CRYPTO_LIB_UTILS)			+= libcryptoutils.o
166e78ad0bSEric Biggerslibcryptoutils-y				:= memneq.o utils.o
177033b937SEric Biggers
18a22fd0e3SEric Biggers################################################################################
19a22fd0e3SEric Biggers
20e59c1c98SArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_AES) += libaes.o
21e59c1c98SArd Biesheuvellibaes-y := aes.o
22a22fd0e3SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_AES_ARCH),y)
23a22fd0e3SEric BiggersCFLAGS_aes.o += -I$(src)/$(SRCARCH)
24fa229775SEric Biggers
25fa229775SEric Biggerslibaes-$(CONFIG_ARM) += arm/aes-cipher-core.o
26fa229775SEric Biggers
272b1ef7aeSEric Biggersifeq ($(CONFIG_ARM64),y)
282b1ef7aeSEric Biggerslibaes-y += arm64/aes-cipher-core.o
292b1ef7aeSEric Biggerslibaes-$(CONFIG_KERNEL_MODE_NEON) += arm64/aes-ce-core.o
302b1ef7aeSEric Biggersendif
312b1ef7aeSEric Biggers
320892c91bSEric Biggersifeq ($(CONFIG_PPC),y)
330892c91bSEric Biggersifeq ($(CONFIG_SPE),y)
340892c91bSEric Biggerslibaes-y += powerpc/aes-spe-core.o \
350892c91bSEric Biggers	    powerpc/aes-spe-keys.o \
360892c91bSEric Biggers	    powerpc/aes-spe-modes.o \
370892c91bSEric Biggers	    powerpc/aes-tab-4k.o
387cf2082eSEric Biggerselse
397cf2082eSEric Biggerslibaes-y += powerpc/aesp8-ppc.o
407cf2082eSEric Biggersaes-perlasm-flavour-y := linux-ppc64
417cf2082eSEric Biggersaes-perlasm-flavour-$(CONFIG_PPC64_ELF_ABI_V2) := linux-ppc64-elfv2
427cf2082eSEric Biggersaes-perlasm-flavour-$(CONFIG_CPU_LITTLE_ENDIAN) := linux-ppc64le
437cf2082eSEric Biggersquiet_cmd_perlasm_aes = PERLASM $@
447cf2082eSEric Biggers      cmd_perlasm_aes = $(PERL) $< $(aes-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
54*293c7cd5SEric Biggerslibaes-$(CONFIG_SPARC) += sparc/aes_asm.o
55a22fd0e3SEric Biggersendif # CONFIG_CRYPTO_LIB_AES_ARCH
56a22fd0e3SEric Biggers
57a22fd0e3SEric Biggers################################################################################
58e59c1c98SArd Biesheuvel
59f1354404SArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_AESCFB)			+= libaescfb.o
60f1354404SArd Biesheuvellibaescfb-y					:= aescfb.o
61f1354404SArd Biesheuvel
62520af5daSArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_AESGCM)			+= libaesgcm.o
63520af5daSArd Biesheuvellibaesgcm-y					:= aesgcm.o
64520af5daSArd Biesheuvel
65dc51f257SArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_ARC4)			+= libarc4.o
66dc51f257SArd Biesheuvellibarc4-y					:= arc4.o
6704007b0eSArd Biesheuvel
6861c581a4SArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_GF128MUL)		+= gf128mul.o
6961c581a4SArd Biesheuvel
7039ee3970SEric Biggers################################################################################
7139ee3970SEric Biggers
7223a16c95SEric Biggersobj-$(CONFIG_CRYPTO_LIB_BLAKE2B) += libblake2b.o
7323a16c95SEric Biggerslibblake2b-y := blake2b.o
7423a16c95SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_BLAKE2B_ARCH),y)
7523a16c95SEric BiggersCFLAGS_blake2b.o += -I$(src)/$(SRCARCH)
76ba6617bdSEric Biggerslibblake2b-$(CONFIG_ARM) += arm/blake2b-neon-core.o
7723a16c95SEric Biggersendif # CONFIG_CRYPTO_LIB_BLAKE2B_ARCH
7823a16c95SEric Biggers
7923a16c95SEric Biggers################################################################################
8023a16c95SEric Biggers
816048fdccSJason A. Donenfeld# blake2s is used by the /dev/random driver which is always builtin
8239ee3970SEric Biggersobj-y += blake2s.o
8339ee3970SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_BLAKE2S_ARCH),y)
8439ee3970SEric BiggersCFLAGS_blake2s.o += -I$(src)/$(SRCARCH)
8539ee3970SEric Biggersobj-$(CONFIG_ARM) += arm/blake2s-core.o
8639ee3970SEric Biggersobj-$(CONFIG_X86) += x86/blake2s-core.o
8739ee3970SEric Biggersendif
8866d7fb94SJason A. Donenfeld
8913cecc52SEric Biggers################################################################################
9013cecc52SEric Biggers
9113cecc52SEric Biggers# chacha20_block() is used by the /dev/random driver which is always builtin
9213cecc52SEric Biggersobj-y += chacha-block-generic.o
9313cecc52SEric Biggers
9413cecc52SEric Biggersobj-$(CONFIG_CRYPTO_LIB_CHACHA) += libchacha.o
9513cecc52SEric Biggerslibchacha-y := chacha.o
9613cecc52SEric Biggers
9713cecc52SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_CHACHA_ARCH),y)
9813cecc52SEric BiggersCFLAGS_chacha.o += -I$(src)/$(SRCARCH)
9913cecc52SEric Biggers
10013cecc52SEric Biggersifeq ($(CONFIG_ARM),y)
10113cecc52SEric Biggerslibchacha-y += arm/chacha-scalar-core.o
10213cecc52SEric Biggerslibchacha-$(CONFIG_KERNEL_MODE_NEON) += arm/chacha-neon-core.o
10313cecc52SEric Biggersendif
10413cecc52SEric Biggers
10513cecc52SEric Biggerslibchacha-$(CONFIG_ARM64) += arm64/chacha-neon-core.o
10613cecc52SEric Biggers
10713cecc52SEric Biggersifeq ($(CONFIG_MIPS),y)
10813cecc52SEric Biggerslibchacha-y += mips/chacha-core.o
10913cecc52SEric BiggersAFLAGS_mips/chacha-core.o += -O2 # needed to fill branch delay slots
11013cecc52SEric Biggersendif
11113cecc52SEric Biggers
11213cecc52SEric Biggerslibchacha-$(CONFIG_PPC) += powerpc/chacha-p10le-8x.o
11313cecc52SEric Biggerslibchacha-$(CONFIG_RISCV) += riscv/chacha-riscv64-zvkb.o
11413cecc52SEric Biggerslibchacha-$(CONFIG_S390) += s390/chacha-s390.o
11513cecc52SEric Biggerslibchacha-$(CONFIG_X86) += x86/chacha-ssse3-x86_64.o \
11613cecc52SEric Biggers			   x86/chacha-avx2-x86_64.o \
11713cecc52SEric Biggers			   x86/chacha-avx512vl-x86_64.o
11813cecc52SEric Biggersendif # CONFIG_CRYPTO_LIB_CHACHA_ARCH
11913cecc52SEric Biggers
12013cecc52SEric Biggers################################################################################
12113cecc52SEric Biggers
122ed20078bSArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_CHACHA20POLY1305)	+= libchacha20poly1305.o
123ed20078bSArd Biesheuvellibchacha20poly1305-y				+= chacha20poly1305.o
12440b99697SEric Biggerslibchacha20poly1305-$(CONFIG_CRYPTO_SELFTESTS)	+= chacha20poly1305-selftest.o
125ed20078bSArd Biesheuvel
12668546e56SEric Biggers################################################################################
12768546e56SEric Biggers
12868546e56SEric Biggersobj-$(CONFIG_CRYPTO_LIB_CURVE25519) += libcurve25519.o
12968546e56SEric Biggerslibcurve25519-y := curve25519.o
13068546e56SEric Biggers
13168546e56SEric Biggers# Disable GCOV in odd or sensitive code
13268546e56SEric BiggersGCOV_PROFILE_curve25519.o := n
13368546e56SEric Biggers
13468546e56SEric Biggersifeq ($(CONFIG_ARCH_SUPPORTS_INT128),y)
13568546e56SEric Biggerslibcurve25519-$(CONFIG_CRYPTO_LIB_CURVE25519_GENERIC) += curve25519-hacl64.o
13668546e56SEric Biggerselse
13768546e56SEric Biggerslibcurve25519-$(CONFIG_CRYPTO_LIB_CURVE25519_GENERIC) += curve25519-fiat32.o
13868546e56SEric Biggersendif
1392f13daeeSNathan Chancellor# clang versions prior to 18 may blow out the stack with KASAN
1402b81082aSNathan Chancellorifeq ($(CONFIG_CC_IS_CLANG)_$(call clang-min-version, 180000),y_)
1412f13daeeSNathan ChancellorKASAN_SANITIZE_curve25519-hacl64.o := n
1422f13daeeSNathan Chancellorendif
143a8bdf2c4SHerbert Xu
14468546e56SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_CURVE25519_ARCH),y)
14568546e56SEric BiggersCFLAGS_curve25519.o += -I$(src)/$(SRCARCH)
14668546e56SEric Biggerslibcurve25519-$(CONFIG_ARM) += arm/curve25519-core.o
14768546e56SEric Biggerslibcurve25519-$(CONFIG_PPC) += powerpc/curve25519-ppc64le_asm.o
14868546e56SEric Biggersendif
14968546e56SEric Biggers
15068546e56SEric Biggers################################################################################
1510ed42a6fSJason A. Donenfeld
15204007b0eSArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_DES)			+= libdes.o
15304007b0eSArd Biesheuvellibdes-y					:= des.o
15401d3aee8SHans de Goede
155e1644613SEric Biggers################################################################################
156e1644613SEric Biggers
157e1644613SEric Biggersobj-$(CONFIG_CRYPTO_LIB_MD5) += libmd5.o
158e1644613SEric Biggerslibmd5-y := md5.o
159e1644613SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_MD5_ARCH),y)
160e1644613SEric BiggersCFLAGS_md5.o += -I$(src)/$(SRCARCH)
16109371e13SEric Biggerslibmd5-$(CONFIG_PPC) += powerpc/md5-asm.o
162a1848f6eSEric Biggerslibmd5-$(CONFIG_SPARC) += sparc/md5_asm.o
163e1644613SEric Biggersendif # CONFIG_CRYPTO_LIB_MD5_ARCH
164e1644613SEric Biggers
165e1644613SEric Biggers################################################################################
166e1644613SEric Biggers
16764edcceaSEric Biggersobj-$(CONFIG_CRYPTO_LIB_MLDSA) += libmldsa.o
16864edcceaSEric Biggerslibmldsa-y := mldsa.o
16964edcceaSEric Biggers
17064edcceaSEric Biggers################################################################################
17164edcceaSEric Biggers
17214e15c71SEric Biggersobj-$(CONFIG_CRYPTO_LIB_NH) += libnh.o
17314e15c71SEric Biggerslibnh-y := nh.o
17414e15c71SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_NH_ARCH),y)
17514e15c71SEric BiggersCFLAGS_nh.o += -I$(src)/$(SRCARCH)
17629e39a11SEric Biggerslibnh-$(CONFIG_ARM) += arm/nh-neon-core.o
177b4a8528dSEric Biggerslibnh-$(CONFIG_ARM64) += arm64/nh-neon-core.o
178a229d832SEric Biggerslibnh-$(CONFIG_X86) += x86/nh-sse2.o x86/nh-avx2.o
17914e15c71SEric Biggersendif
18014e15c71SEric Biggers
18114e15c71SEric Biggers################################################################################
18214e15c71SEric Biggers
1839b9d4ef0SHerbert Xuobj-$(CONFIG_CRYPTO_LIB_POLY1305) += libpoly1305.o
184b646b782SEric Biggerslibpoly1305-y := poly1305.o
185b646b782SEric Biggersifeq ($(CONFIG_ARCH_SUPPORTS_INT128),y)
186b646b782SEric Biggerslibpoly1305-$(CONFIG_CRYPTO_LIB_POLY1305_GENERIC) += poly1305-donna64.o
187b646b782SEric Biggerselse
188b646b782SEric Biggerslibpoly1305-$(CONFIG_CRYPTO_LIB_POLY1305_GENERIC) += poly1305-donna32.o
189b646b782SEric Biggersendif
19048ea8c6eSArd Biesheuvel
191b646b782SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_POLY1305_ARCH),y)
192b646b782SEric BiggersCFLAGS_poly1305.o += -I$(src)/$(SRCARCH)
193b646b782SEric Biggers
194b646b782SEric Biggersifeq ($(CONFIG_ARM),y)
195b646b782SEric Biggerslibpoly1305-y += arm/poly1305-core.o
196b646b782SEric Biggers$(obj)/arm/poly1305-core.S: $(src)/arm/poly1305-armv4.pl
197b646b782SEric Biggers	$(call cmd,perlasm)
198b646b782SEric Biggers# massage the perlasm code a bit so we only get the NEON routine if we need it
199b646b782SEric Biggerspoly1305-aflags-$(CONFIG_CPU_V7) := -U__LINUX_ARM_ARCH__ -D__LINUX_ARM_ARCH__=5
200b646b782SEric Biggerspoly1305-aflags-$(CONFIG_KERNEL_MODE_NEON) := -U__LINUX_ARM_ARCH__ -D__LINUX_ARM_ARCH__=7
201b646b782SEric BiggersAFLAGS_arm/poly1305-core.o += $(poly1305-aflags-y) $(aflags-thumb2-y)
202b646b782SEric Biggersendif
203b646b782SEric Biggers
204b646b782SEric Biggersifeq ($(CONFIG_ARM64),y)
205b646b782SEric Biggerslibpoly1305-y += arm64/poly1305-core.o
206b646b782SEric Biggers$(obj)/arm64/poly1305-core.S: $(src)/arm64/poly1305-armv8.pl
207b646b782SEric Biggers	$(call cmd,perlasm_with_args)
208b646b782SEric Biggersendif
209b646b782SEric Biggers
210b646b782SEric Biggersifeq ($(CONFIG_MIPS),y)
211b646b782SEric Biggerslibpoly1305-y += mips/poly1305-core.o
212b646b782SEric Biggerspoly1305-perlasm-flavour-$(CONFIG_32BIT) := o32
213b646b782SEric Biggerspoly1305-perlasm-flavour-$(CONFIG_64BIT) := 64
214b646b782SEric Biggersquiet_cmd_perlasm_poly1305 = PERLASM $@
215b646b782SEric Biggers      cmd_perlasm_poly1305 = $(PERL) $< $(poly1305-perlasm-flavour-y) $@
216b646b782SEric Biggers# Use if_changed instead of cmd, in case the flavour changed.
217b646b782SEric Biggers$(obj)/mips/poly1305-core.S: $(src)/mips/poly1305-mips.pl FORCE
218b646b782SEric Biggers	$(call if_changed,perlasm_poly1305)
219b646b782SEric Biggerstargets += mips/poly1305-core.S
220b646b782SEric Biggersendif
221b646b782SEric Biggers
222b646b782SEric Biggerslibpoly1305-$(CONFIG_PPC) += powerpc/poly1305-p10le_64.o
223b646b782SEric Biggers
224bef9c755SZhihang Shaoifeq ($(CONFIG_RISCV),y)
225bef9c755SZhihang Shaolibpoly1305-y += riscv/poly1305-core.o
226bef9c755SZhihang Shaopoly1305-perlasm-flavour-$(CONFIG_32BIT) := 32
227bef9c755SZhihang Shaopoly1305-perlasm-flavour-$(CONFIG_64BIT) := 64
228bef9c755SZhihang Shaoquiet_cmd_perlasm_poly1305 = PERLASM $@
229bef9c755SZhihang Shao      cmd_perlasm_poly1305 = $(PERL) $< $(poly1305-perlasm-flavour-y) $@
230bef9c755SZhihang Shao# Use if_changed instead of cmd, in case the flavour changed.
231bef9c755SZhihang Shao$(obj)/riscv/poly1305-core.S: $(src)/riscv/poly1305-riscv.pl FORCE
232bef9c755SZhihang Shao	$(call if_changed,perlasm_poly1305)
233bef9c755SZhihang Shaotargets += riscv/poly1305-core.S
234bef9c755SZhihang ShaoAFLAGS_riscv/poly1305-core.o += -Dpoly1305_init=poly1305_block_init
235bef9c755SZhihang Shaoendif
236bef9c755SZhihang Shao
237b646b782SEric Biggersifeq ($(CONFIG_X86),y)
238b646b782SEric Biggerslibpoly1305-y += x86/poly1305-x86_64-cryptogams.o
239b646b782SEric Biggers$(obj)/x86/poly1305-x86_64-cryptogams.S: $(src)/x86/poly1305-x86_64-cryptogams.pl
240b646b782SEric Biggers	$(call cmd,perlasm)
241b646b782SEric Biggersendif
242b646b782SEric Biggers
243b646b782SEric Biggersendif # CONFIG_CRYPTO_LIB_POLY1305_ARCH
244b646b782SEric Biggers
245b646b782SEric Biggers# clean-files must be defined unconditionally
246b646b782SEric Biggersclean-files += arm/poly1305-core.S \
247b646b782SEric Biggers	       arm64/poly1305-core.S \
248b646b782SEric Biggers	       mips/poly1305-core.S \
249bef9c755SZhihang Shao	       riscv/poly1305-core.S \
250b646b782SEric Biggers	       x86/poly1305-x86_64-cryptogams.S
2519b9d4ef0SHerbert Xu
25290860aefSEric Biggers################################################################################
25390860aefSEric Biggers
2543d176751SEric Biggersobj-$(CONFIG_CRYPTO_LIB_POLYVAL) += libpolyval.o
2553d176751SEric Biggerslibpolyval-y := polyval.o
2563d176751SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_POLYVAL_ARCH),y)
2573d176751SEric BiggersCFLAGS_polyval.o += -I$(src)/$(SRCARCH)
25837919e23SEric Biggerslibpolyval-$(CONFIG_ARM64) += arm64/polyval-ce-core.o
2594d8da355SEric Biggerslibpolyval-$(CONFIG_X86) += x86/polyval-pclmul-avx.o
2603d176751SEric Biggersendif
2613d176751SEric Biggers
2623d176751SEric Biggers################################################################################
2633d176751SEric Biggers
264ec8f7f48SEric Biggersobj-$(CONFIG_CRYPTO_LIB_SHA1) += libsha1.o
265ec8f7f48SEric Biggerslibsha1-y := sha1.o
26690860aefSEric Biggersifeq ($(CONFIG_CRYPTO_LIB_SHA1_ARCH),y)
26790860aefSEric BiggersCFLAGS_sha1.o += -I$(src)/$(SRCARCH)
26870cb6ca5SEric Biggersifeq ($(CONFIG_ARM),y)
26970cb6ca5SEric Biggerslibsha1-y += arm/sha1-armv4-large.o
27070cb6ca5SEric Biggerslibsha1-$(CONFIG_KERNEL_MODE_NEON) += arm/sha1-armv7-neon.o \
27170cb6ca5SEric Biggers				      arm/sha1-ce-core.o
27270cb6ca5SEric Biggersendif
27300d549bbSEric Biggerslibsha1-$(CONFIG_ARM64) += arm64/sha1-ce-core.o
2746b9ae8cfSEric Biggersifeq ($(CONFIG_PPC),y)
2756b9ae8cfSEric Biggerslibsha1-y += powerpc/sha1-powerpc-asm.o
2766b9ae8cfSEric Biggerslibsha1-$(CONFIG_SPE) += powerpc/sha1-spe-asm.o
2776b9ae8cfSEric Biggersendif
278c7510599SEric Biggerslibsha1-$(CONFIG_SPARC) += sparc/sha1_asm.o
279f3d6cb3dSEric Biggerslibsha1-$(CONFIG_X86) += x86/sha1-ssse3-and-avx.o \
280f3d6cb3dSEric Biggers			 x86/sha1-avx2-asm.o \
281f3d6cb3dSEric Biggers			 x86/sha1-ni-asm.o
28290860aefSEric Biggersendif # CONFIG_CRYPTO_LIB_SHA1_ARCH
283463f7408SEric Biggers
284e96cb950SEric Biggers################################################################################
285e96cb950SEric Biggers
28601d3aee8SHans de Goedeobj-$(CONFIG_CRYPTO_LIB_SHA256) += libsha256.o
28701d3aee8SHans de Goedelibsha256-y := sha256.o
288e96cb950SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_SHA256_ARCH),y)
289e96cb950SEric BiggersCFLAGS_sha256.o += -I$(src)/$(SRCARCH)
29066d7fb94SJason A. Donenfeld
291e96cb950SEric Biggersifeq ($(CONFIG_ARM),y)
292e96cb950SEric Biggerslibsha256-y += arm/sha256-ce.o arm/sha256-core.o
293e96cb950SEric Biggers$(obj)/arm/sha256-core.S: $(src)/arm/sha256-armv4.pl
294e96cb950SEric Biggers	$(call cmd,perlasm)
295e96cb950SEric BiggersAFLAGS_arm/sha256-core.o += $(aflags-thumb2-y)
296e96cb950SEric Biggersendif
297e96cb950SEric Biggers
298e96cb950SEric Biggersifeq ($(CONFIG_ARM64),y)
299e96cb950SEric Biggerslibsha256-y += arm64/sha256-core.o
300e96cb950SEric Biggers$(obj)/arm64/sha256-core.S: $(src)/arm64/sha2-armv8.pl
301e96cb950SEric Biggers	$(call cmd,perlasm_with_args)
302e96cb950SEric Biggerslibsha256-$(CONFIG_KERNEL_MODE_NEON) += arm64/sha256-ce.o
303e96cb950SEric Biggersendif
304e96cb950SEric Biggers
305e96cb950SEric Biggerslibsha256-$(CONFIG_PPC) += powerpc/sha256-spe-asm.o
306e96cb950SEric Biggerslibsha256-$(CONFIG_RISCV) += riscv/sha256-riscv64-zvknha_or_zvknhb-zvkb.o
307e96cb950SEric Biggerslibsha256-$(CONFIG_SPARC) += sparc/sha256_asm.o
308e96cb950SEric Biggerslibsha256-$(CONFIG_X86) += x86/sha256-ssse3-asm.o \
309e96cb950SEric Biggers			   x86/sha256-avx-asm.o \
310e96cb950SEric Biggers			   x86/sha256-avx2-asm.o \
311e96cb950SEric Biggers			   x86/sha256-ni-asm.o
312e96cb950SEric Biggersendif # CONFIG_CRYPTO_LIB_SHA256_ARCH
313e96cb950SEric Biggers
314e96cb950SEric Biggers################################################################################
315950e5c84SEric Biggers
316b693c703SEric Biggersobj-$(CONFIG_CRYPTO_LIB_SHA512) += libsha512.o
317b693c703SEric Biggerslibsha512-y := sha512.o
318b693c703SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_SHA512_ARCH),y)
319b693c703SEric BiggersCFLAGS_sha512.o += -I$(src)/$(SRCARCH)
32024c91b62SEric Biggers
32124c91b62SEric Biggersifeq ($(CONFIG_ARM),y)
32224c91b62SEric Biggerslibsha512-y += arm/sha512-core.o
32324c91b62SEric Biggers$(obj)/arm/sha512-core.S: $(src)/arm/sha512-armv4.pl
32424c91b62SEric Biggers	$(call cmd,perlasm)
32524c91b62SEric BiggersAFLAGS_arm/sha512-core.o += $(aflags-thumb2-y)
32624c91b62SEric Biggersendif
32724c91b62SEric Biggers
32860e3f1e9SEric Biggersifeq ($(CONFIG_ARM64),y)
32960e3f1e9SEric Biggerslibsha512-y += arm64/sha512-core.o
33061f86c70SEric Biggers$(obj)/arm64/sha512-core.S: $(src)/arm64/sha2-armv8.pl
33160e3f1e9SEric Biggers	$(call cmd,perlasm_with_args)
33260e3f1e9SEric Biggerslibsha512-$(CONFIG_KERNEL_MODE_NEON) += arm64/sha512-ce-core.o
33360e3f1e9SEric Biggersendif
334b59059a2SEric Biggers
335b59059a2SEric Biggerslibsha512-$(CONFIG_RISCV) += riscv/sha512-riscv64-zvknhb-zvkb.o
33602b35babSEric Biggerslibsha512-$(CONFIG_SPARC) += sparc/sha512_asm.o
337484c1811SEric Biggerslibsha512-$(CONFIG_X86) += x86/sha512-ssse3-asm.o \
338484c1811SEric Biggers			   x86/sha512-avx-asm.o \
339484c1811SEric Biggers			   x86/sha512-avx2-asm.o
340b693c703SEric Biggersendif # CONFIG_CRYPTO_LIB_SHA512_ARCH
341b693c703SEric Biggers
342e96cb950SEric Biggers################################################################################
343e96cb950SEric Biggers
34405934472SDavid Howellsobj-$(CONFIG_CRYPTO_LIB_SHA3) += libsha3.o
34505934472SDavid Howellslibsha3-y := sha3.o
34605934472SDavid Howells
3471e29a750SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_SHA3_ARCH),y)
3481e29a750SEric BiggersCFLAGS_sha3.o += -I$(src)/$(SRCARCH)
3491e29a750SEric Biggerslibsha3-$(CONFIG_ARM64) += arm64/sha3-ce-core.o
3501e29a750SEric Biggersendif # CONFIG_CRYPTO_LIB_SHA3_ARCH
3511e29a750SEric Biggers
35205934472SDavid Howells################################################################################
35305934472SDavid Howells
3542a598d0bSHerbert Xuobj-$(CONFIG_MPILIB) += mpi/
3554964a1d9SEric Biggers
356ac90aad0SEric Biggersobj-$(CONFIG_CRYPTO_SELFTESTS_FULL)		+= simd.o
357f4065b2fSHerbert Xu
358f4065b2fSHerbert Xuobj-$(CONFIG_CRYPTO_LIB_SM3)			+= libsm3.o
359f4065b2fSHerbert Xulibsm3-y					:= sm3.o
3604a32e5dcSEric Biggers
361fd7e5de4STal Zussman# clean-files must be defined unconditionally
362fd7e5de4STal Zussmanclean-files += arm/sha256-core.S arm/sha512-core.S
363fd7e5de4STal Zussmanclean-files += arm64/sha256-core.S arm64/sha512-core.S
364