xref: /linux/lib/crypto/Makefile (revision 09371e1349c9bb34ac030973c7867016a8a8914d)
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
185fb8ef25SArd Biesheuvel# chacha is used by the /dev/random driver which is always builtin
195fb8ef25SArd Biesheuvelobj-y						+= chacha.o
205fb8ef25SArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_CHACHA_GENERIC)		+= libchacha.o
215fb8ef25SArd Biesheuvel
22e59c1c98SArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_AES)			+= libaes.o
23e59c1c98SArd Biesheuvellibaes-y					:= aes.o
24e59c1c98SArd Biesheuvel
25f1354404SArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_AESCFB)			+= libaescfb.o
26f1354404SArd Biesheuvellibaescfb-y					:= aescfb.o
27f1354404SArd Biesheuvel
28520af5daSArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_AESGCM)			+= libaesgcm.o
29520af5daSArd Biesheuvellibaesgcm-y					:= aesgcm.o
30520af5daSArd Biesheuvel
31dc51f257SArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_ARC4)			+= libarc4.o
32dc51f257SArd Biesheuvellibarc4-y					:= arc4.o
3304007b0eSArd Biesheuvel
3461c581a4SArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_GF128MUL)		+= gf128mul.o
3561c581a4SArd Biesheuvel
366048fdccSJason A. Donenfeld# blake2s is used by the /dev/random driver which is always builtin
376048fdccSJason A. Donenfeldobj-y						+= libblake2s.o
386048fdccSJason A. Donenfeldlibblake2s-y					:= blake2s.o
396048fdccSJason A. Donenfeldlibblake2s-$(CONFIG_CRYPTO_LIB_BLAKE2S_GENERIC)	+= blake2s-generic.o
4040b99697SEric Biggerslibblake2s-$(CONFIG_CRYPTO_SELFTESTS)		+= blake2s-selftest.o
4166d7fb94SJason A. Donenfeld
42ed20078bSArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_CHACHA20POLY1305)	+= libchacha20poly1305.o
43ed20078bSArd Biesheuvellibchacha20poly1305-y				+= chacha20poly1305.o
4440b99697SEric Biggerslibchacha20poly1305-$(CONFIG_CRYPTO_SELFTESTS)	+= chacha20poly1305-selftest.o
45ed20078bSArd Biesheuvel
46a8bdf2c4SHerbert Xuobj-$(CONFIG_CRYPTO_LIB_CURVE25519_GENERIC)	+= libcurve25519-generic.o
47a8bdf2c4SHerbert Xulibcurve25519-generic-y				:= curve25519-fiat32.o
48a8bdf2c4SHerbert Xulibcurve25519-generic-$(CONFIG_ARCH_SUPPORTS_INT128)	:= curve25519-hacl64.o
49a8bdf2c4SHerbert Xulibcurve25519-generic-y				+= curve25519-generic.o
502f13daeeSNathan Chancellor# clang versions prior to 18 may blow out the stack with KASAN
512f13daeeSNathan Chancellorifeq ($(call clang-min-version, 180000),)
522f13daeeSNathan ChancellorKASAN_SANITIZE_curve25519-hacl64.o := n
532f13daeeSNathan Chancellorendif
54a8bdf2c4SHerbert Xu
55a8bdf2c4SHerbert Xuobj-$(CONFIG_CRYPTO_LIB_CURVE25519)		+= libcurve25519.o
560ed42a6fSJason A. Donenfeldlibcurve25519-y					+= curve25519.o
5740b99697SEric Biggerslibcurve25519-$(CONFIG_CRYPTO_SELFTESTS)	+= curve25519-selftest.o
580ed42a6fSJason A. Donenfeld
5904007b0eSArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_DES)			+= libdes.o
6004007b0eSArd Biesheuvellibdes-y					:= des.o
6101d3aee8SHans de Goede
62e1644613SEric Biggers################################################################################
63e1644613SEric Biggers
64e1644613SEric Biggersobj-$(CONFIG_CRYPTO_LIB_MD5) += libmd5.o
65e1644613SEric Biggerslibmd5-y := md5.o
66e1644613SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_MD5_ARCH),y)
67e1644613SEric BiggersCFLAGS_md5.o += -I$(src)/$(SRCARCH)
68*09371e13SEric Biggerslibmd5-$(CONFIG_PPC) += powerpc/md5-asm.o
69e1644613SEric Biggersendif # CONFIG_CRYPTO_LIB_MD5_ARCH
70e1644613SEric Biggers
71e1644613SEric Biggers################################################################################
72e1644613SEric Biggers
739b9d4ef0SHerbert Xuobj-$(CONFIG_CRYPTO_LIB_POLY1305)		+= libpoly1305.o
741c08a104SJason A. Donenfeldlibpoly1305-y					+= poly1305.o
7548ea8c6eSArd Biesheuvel
769b9d4ef0SHerbert Xuobj-$(CONFIG_CRYPTO_LIB_POLY1305_GENERIC)	+= libpoly1305-generic.o
779b9d4ef0SHerbert Xulibpoly1305-generic-y				:= poly1305-donna32.o
789b9d4ef0SHerbert Xulibpoly1305-generic-$(CONFIG_ARCH_SUPPORTS_INT128) := poly1305-donna64.o
799b9d4ef0SHerbert Xulibpoly1305-generic-y				+= poly1305-generic.o
809b9d4ef0SHerbert Xu
8190860aefSEric Biggers################################################################################
8290860aefSEric Biggers
83ec8f7f48SEric Biggersobj-$(CONFIG_CRYPTO_LIB_SHA1) += libsha1.o
84ec8f7f48SEric Biggerslibsha1-y := sha1.o
8590860aefSEric Biggersifeq ($(CONFIG_CRYPTO_LIB_SHA1_ARCH),y)
8690860aefSEric BiggersCFLAGS_sha1.o += -I$(src)/$(SRCARCH)
8770cb6ca5SEric Biggersifeq ($(CONFIG_ARM),y)
8870cb6ca5SEric Biggerslibsha1-y += arm/sha1-armv4-large.o
8970cb6ca5SEric Biggerslibsha1-$(CONFIG_KERNEL_MODE_NEON) += arm/sha1-armv7-neon.o \
9070cb6ca5SEric Biggers				      arm/sha1-ce-core.o
9170cb6ca5SEric Biggersendif
9200d549bbSEric Biggerslibsha1-$(CONFIG_ARM64) += arm64/sha1-ce-core.o
936b9ae8cfSEric Biggersifeq ($(CONFIG_PPC),y)
946b9ae8cfSEric Biggerslibsha1-y += powerpc/sha1-powerpc-asm.o
956b9ae8cfSEric Biggerslibsha1-$(CONFIG_SPE) += powerpc/sha1-spe-asm.o
966b9ae8cfSEric Biggersendif
97c7510599SEric Biggerslibsha1-$(CONFIG_SPARC) += sparc/sha1_asm.o
98f3d6cb3dSEric Biggerslibsha1-$(CONFIG_X86) += x86/sha1-ssse3-and-avx.o \
99f3d6cb3dSEric Biggers			 x86/sha1-avx2-asm.o \
100f3d6cb3dSEric Biggers			 x86/sha1-ni-asm.o
10190860aefSEric Biggersendif # CONFIG_CRYPTO_LIB_SHA1_ARCH
102463f7408SEric Biggers
103e96cb950SEric Biggers################################################################################
104e96cb950SEric Biggers
10501d3aee8SHans de Goedeobj-$(CONFIG_CRYPTO_LIB_SHA256) += libsha256.o
10601d3aee8SHans de Goedelibsha256-y := sha256.o
107e96cb950SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_SHA256_ARCH),y)
108e96cb950SEric BiggersCFLAGS_sha256.o += -I$(src)/$(SRCARCH)
10966d7fb94SJason A. Donenfeld
110e96cb950SEric Biggersifeq ($(CONFIG_ARM),y)
111e96cb950SEric Biggerslibsha256-y += arm/sha256-ce.o arm/sha256-core.o
112e96cb950SEric Biggers$(obj)/arm/sha256-core.S: $(src)/arm/sha256-armv4.pl
113e96cb950SEric Biggers	$(call cmd,perlasm)
114e96cb950SEric BiggersAFLAGS_arm/sha256-core.o += $(aflags-thumb2-y)
115e96cb950SEric Biggersendif
116e96cb950SEric Biggers
117e96cb950SEric Biggersifeq ($(CONFIG_ARM64),y)
118e96cb950SEric Biggerslibsha256-y += arm64/sha256-core.o
119e96cb950SEric Biggers$(obj)/arm64/sha256-core.S: $(src)/arm64/sha2-armv8.pl
120e96cb950SEric Biggers	$(call cmd,perlasm_with_args)
121e96cb950SEric Biggerslibsha256-$(CONFIG_KERNEL_MODE_NEON) += arm64/sha256-ce.o
122e96cb950SEric Biggersendif
123e96cb950SEric Biggers
124e96cb950SEric Biggerslibsha256-$(CONFIG_PPC) += powerpc/sha256-spe-asm.o
125e96cb950SEric Biggerslibsha256-$(CONFIG_RISCV) += riscv/sha256-riscv64-zvknha_or_zvknhb-zvkb.o
126e96cb950SEric Biggerslibsha256-$(CONFIG_SPARC) += sparc/sha256_asm.o
127e96cb950SEric Biggerslibsha256-$(CONFIG_X86) += x86/sha256-ssse3-asm.o \
128e96cb950SEric Biggers			   x86/sha256-avx-asm.o \
129e96cb950SEric Biggers			   x86/sha256-avx2-asm.o \
130e96cb950SEric Biggers			   x86/sha256-ni-asm.o
131e96cb950SEric Biggersendif # CONFIG_CRYPTO_LIB_SHA256_ARCH
132e96cb950SEric Biggers
133e96cb950SEric Biggers################################################################################
134950e5c84SEric Biggers
135b693c703SEric Biggersobj-$(CONFIG_CRYPTO_LIB_SHA512) += libsha512.o
136b693c703SEric Biggerslibsha512-y := sha512.o
137b693c703SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_SHA512_ARCH),y)
138b693c703SEric BiggersCFLAGS_sha512.o += -I$(src)/$(SRCARCH)
13924c91b62SEric Biggers
14024c91b62SEric Biggersifeq ($(CONFIG_ARM),y)
14124c91b62SEric Biggerslibsha512-y += arm/sha512-core.o
14224c91b62SEric Biggers$(obj)/arm/sha512-core.S: $(src)/arm/sha512-armv4.pl
14324c91b62SEric Biggers	$(call cmd,perlasm)
14424c91b62SEric BiggersAFLAGS_arm/sha512-core.o += $(aflags-thumb2-y)
14524c91b62SEric Biggersendif
14624c91b62SEric Biggers
14760e3f1e9SEric Biggersifeq ($(CONFIG_ARM64),y)
14860e3f1e9SEric Biggerslibsha512-y += arm64/sha512-core.o
14961f86c70SEric Biggers$(obj)/arm64/sha512-core.S: $(src)/arm64/sha2-armv8.pl
15060e3f1e9SEric Biggers	$(call cmd,perlasm_with_args)
15160e3f1e9SEric Biggerslibsha512-$(CONFIG_KERNEL_MODE_NEON) += arm64/sha512-ce-core.o
15260e3f1e9SEric Biggersendif
153b59059a2SEric Biggers
154b59059a2SEric Biggerslibsha512-$(CONFIG_RISCV) += riscv/sha512-riscv64-zvknhb-zvkb.o
15502b35babSEric Biggerslibsha512-$(CONFIG_SPARC) += sparc/sha512_asm.o
156484c1811SEric Biggerslibsha512-$(CONFIG_X86) += x86/sha512-ssse3-asm.o \
157484c1811SEric Biggers			   x86/sha512-avx-asm.o \
158484c1811SEric Biggers			   x86/sha512-avx2-asm.o
159b693c703SEric Biggersendif # CONFIG_CRYPTO_LIB_SHA512_ARCH
160b693c703SEric Biggers
161e96cb950SEric Biggers################################################################################
162e96cb950SEric Biggers
1632a598d0bSHerbert Xuobj-$(CONFIG_MPILIB) += mpi/
1644964a1d9SEric Biggers
165ac90aad0SEric Biggersobj-$(CONFIG_CRYPTO_SELFTESTS_FULL)		+= simd.o
166f4065b2fSHerbert Xu
167f4065b2fSHerbert Xuobj-$(CONFIG_CRYPTO_LIB_SM3)			+= libsm3.o
168f4065b2fSHerbert Xulibsm3-y					:= sm3.o
1694a32e5dcSEric Biggers
1704a32e5dcSEric Biggersobj-$(CONFIG_ARM) += arm/
17161f86c70SEric Biggersobj-$(CONFIG_ARM64) += arm64/
1727e54e993SEric Biggersobj-$(CONFIG_MIPS) += mips/
173676d45abSEric Biggersobj-$(CONFIG_PPC) += powerpc/
174daed4fcfSEric Biggersobj-$(CONFIG_RISCV) += riscv/
175b8456f7aSEric Biggersobj-$(CONFIG_S390) += s390/
17674750aa7SEric Biggersobj-$(CONFIG_X86) += x86/
177fd7e5de4STal Zussman
178fd7e5de4STal Zussman# clean-files must be defined unconditionally
179fd7e5de4STal Zussmanclean-files += arm/sha256-core.S arm/sha512-core.S
180fd7e5de4STal Zussmanclean-files += arm64/sha256-core.S arm64/sha512-core.S
181