xref: /linux/lib/crypto/Makefile (revision 70cb6ca58fddb02e269fe743ba75d53d577b5b1c)
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
11aacb37f5SEric Biggersobj-$(CONFIG_CRYPTO_HASH_INFO)			+= hash_info.o
12aacb37f5SEric Biggers
137033b937SEric Biggersobj-$(CONFIG_CRYPTO_LIB_UTILS)			+= libcryptoutils.o
146e78ad0bSEric Biggerslibcryptoutils-y				:= memneq.o utils.o
157033b937SEric Biggers
165fb8ef25SArd Biesheuvel# chacha is used by the /dev/random driver which is always builtin
175fb8ef25SArd Biesheuvelobj-y						+= chacha.o
185fb8ef25SArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_CHACHA_GENERIC)		+= libchacha.o
195fb8ef25SArd Biesheuvel
20e59c1c98SArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_AES)			+= libaes.o
21e59c1c98SArd Biesheuvellibaes-y					:= aes.o
22e59c1c98SArd Biesheuvel
23f1354404SArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_AESCFB)			+= libaescfb.o
24f1354404SArd Biesheuvellibaescfb-y					:= aescfb.o
25f1354404SArd Biesheuvel
26520af5daSArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_AESGCM)			+= libaesgcm.o
27520af5daSArd Biesheuvellibaesgcm-y					:= aesgcm.o
28520af5daSArd Biesheuvel
29dc51f257SArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_ARC4)			+= libarc4.o
30dc51f257SArd Biesheuvellibarc4-y					:= arc4.o
3104007b0eSArd Biesheuvel
3261c581a4SArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_GF128MUL)		+= gf128mul.o
3361c581a4SArd Biesheuvel
346048fdccSJason A. Donenfeld# blake2s is used by the /dev/random driver which is always builtin
356048fdccSJason A. Donenfeldobj-y						+= libblake2s.o
366048fdccSJason A. Donenfeldlibblake2s-y					:= blake2s.o
376048fdccSJason A. Donenfeldlibblake2s-$(CONFIG_CRYPTO_LIB_BLAKE2S_GENERIC)	+= blake2s-generic.o
3840b99697SEric Biggerslibblake2s-$(CONFIG_CRYPTO_SELFTESTS)		+= blake2s-selftest.o
3966d7fb94SJason A. Donenfeld
40ed20078bSArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_CHACHA20POLY1305)	+= libchacha20poly1305.o
41ed20078bSArd Biesheuvellibchacha20poly1305-y				+= chacha20poly1305.o
4240b99697SEric Biggerslibchacha20poly1305-$(CONFIG_CRYPTO_SELFTESTS)	+= chacha20poly1305-selftest.o
43ed20078bSArd Biesheuvel
44a8bdf2c4SHerbert Xuobj-$(CONFIG_CRYPTO_LIB_CURVE25519_GENERIC)	+= libcurve25519-generic.o
45a8bdf2c4SHerbert Xulibcurve25519-generic-y				:= curve25519-fiat32.o
46a8bdf2c4SHerbert Xulibcurve25519-generic-$(CONFIG_ARCH_SUPPORTS_INT128)	:= curve25519-hacl64.o
47a8bdf2c4SHerbert Xulibcurve25519-generic-y				+= curve25519-generic.o
482f13daeeSNathan Chancellor# clang versions prior to 18 may blow out the stack with KASAN
492f13daeeSNathan Chancellorifeq ($(call clang-min-version, 180000),)
502f13daeeSNathan ChancellorKASAN_SANITIZE_curve25519-hacl64.o := n
512f13daeeSNathan Chancellorendif
52a8bdf2c4SHerbert Xu
53a8bdf2c4SHerbert Xuobj-$(CONFIG_CRYPTO_LIB_CURVE25519)		+= libcurve25519.o
540ed42a6fSJason A. Donenfeldlibcurve25519-y					+= curve25519.o
5540b99697SEric Biggerslibcurve25519-$(CONFIG_CRYPTO_SELFTESTS)	+= curve25519-selftest.o
560ed42a6fSJason A. Donenfeld
5704007b0eSArd Biesheuvelobj-$(CONFIG_CRYPTO_LIB_DES)			+= libdes.o
5804007b0eSArd Biesheuvellibdes-y					:= des.o
5901d3aee8SHans de Goede
609b9d4ef0SHerbert Xuobj-$(CONFIG_CRYPTO_LIB_POLY1305)		+= libpoly1305.o
611c08a104SJason A. Donenfeldlibpoly1305-y					+= poly1305.o
6248ea8c6eSArd Biesheuvel
639b9d4ef0SHerbert Xuobj-$(CONFIG_CRYPTO_LIB_POLY1305_GENERIC)	+= libpoly1305-generic.o
649b9d4ef0SHerbert Xulibpoly1305-generic-y				:= poly1305-donna32.o
659b9d4ef0SHerbert Xulibpoly1305-generic-$(CONFIG_ARCH_SUPPORTS_INT128) := poly1305-donna64.o
669b9d4ef0SHerbert Xulibpoly1305-generic-y				+= poly1305-generic.o
679b9d4ef0SHerbert Xu
6890860aefSEric Biggers################################################################################
6990860aefSEric Biggers
70ec8f7f48SEric Biggersobj-$(CONFIG_CRYPTO_LIB_SHA1) += libsha1.o
71ec8f7f48SEric Biggerslibsha1-y := sha1.o
7290860aefSEric Biggersifeq ($(CONFIG_CRYPTO_LIB_SHA1_ARCH),y)
7390860aefSEric BiggersCFLAGS_sha1.o += -I$(src)/$(SRCARCH)
74*70cb6ca5SEric Biggersifeq ($(CONFIG_ARM),y)
75*70cb6ca5SEric Biggerslibsha1-y += arm/sha1-armv4-large.o
76*70cb6ca5SEric Biggerslibsha1-$(CONFIG_KERNEL_MODE_NEON) += arm/sha1-armv7-neon.o \
77*70cb6ca5SEric Biggers				      arm/sha1-ce-core.o
78*70cb6ca5SEric Biggersendif
7990860aefSEric Biggersendif # CONFIG_CRYPTO_LIB_SHA1_ARCH
80463f7408SEric Biggers
81e96cb950SEric Biggers################################################################################
82e96cb950SEric Biggers
8301d3aee8SHans de Goedeobj-$(CONFIG_CRYPTO_LIB_SHA256) += libsha256.o
8401d3aee8SHans de Goedelibsha256-y := sha256.o
85e96cb950SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_SHA256_ARCH),y)
86e96cb950SEric BiggersCFLAGS_sha256.o += -I$(src)/$(SRCARCH)
8766d7fb94SJason A. Donenfeld
88e96cb950SEric Biggersifeq ($(CONFIG_ARM),y)
89e96cb950SEric Biggerslibsha256-y += arm/sha256-ce.o arm/sha256-core.o
90e96cb950SEric Biggers$(obj)/arm/sha256-core.S: $(src)/arm/sha256-armv4.pl
91e96cb950SEric Biggers	$(call cmd,perlasm)
92e96cb950SEric Biggersclean-files += arm/sha256-core.S
93e96cb950SEric BiggersAFLAGS_arm/sha256-core.o += $(aflags-thumb2-y)
94e96cb950SEric Biggersendif
95e96cb950SEric Biggers
96e96cb950SEric Biggersifeq ($(CONFIG_ARM64),y)
97e96cb950SEric Biggerslibsha256-y += arm64/sha256-core.o
98e96cb950SEric Biggers$(obj)/arm64/sha256-core.S: $(src)/arm64/sha2-armv8.pl
99e96cb950SEric Biggers	$(call cmd,perlasm_with_args)
100e96cb950SEric Biggersclean-files += arm64/sha256-core.S
101e96cb950SEric Biggerslibsha256-$(CONFIG_KERNEL_MODE_NEON) += arm64/sha256-ce.o
102e96cb950SEric Biggersendif
103e96cb950SEric Biggers
104e96cb950SEric Biggerslibsha256-$(CONFIG_PPC) += powerpc/sha256-spe-asm.o
105e96cb950SEric Biggerslibsha256-$(CONFIG_RISCV) += riscv/sha256-riscv64-zvknha_or_zvknhb-zvkb.o
106e96cb950SEric Biggerslibsha256-$(CONFIG_SPARC) += sparc/sha256_asm.o
107e96cb950SEric Biggerslibsha256-$(CONFIG_X86) += x86/sha256-ssse3-asm.o \
108e96cb950SEric Biggers			   x86/sha256-avx-asm.o \
109e96cb950SEric Biggers			   x86/sha256-avx2-asm.o \
110e96cb950SEric Biggers			   x86/sha256-ni-asm.o
111e96cb950SEric Biggersendif # CONFIG_CRYPTO_LIB_SHA256_ARCH
112e96cb950SEric Biggers
113e96cb950SEric Biggers################################################################################
114950e5c84SEric Biggers
115b693c703SEric Biggersobj-$(CONFIG_CRYPTO_LIB_SHA512) += libsha512.o
116b693c703SEric Biggerslibsha512-y := sha512.o
117b693c703SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_SHA512_ARCH),y)
118b693c703SEric BiggersCFLAGS_sha512.o += -I$(src)/$(SRCARCH)
11924c91b62SEric Biggers
12024c91b62SEric Biggersifeq ($(CONFIG_ARM),y)
12124c91b62SEric Biggerslibsha512-y += arm/sha512-core.o
12224c91b62SEric Biggers$(obj)/arm/sha512-core.S: $(src)/arm/sha512-armv4.pl
12324c91b62SEric Biggers	$(call cmd,perlasm)
12424c91b62SEric Biggersclean-files += arm/sha512-core.S
12524c91b62SEric BiggersAFLAGS_arm/sha512-core.o += $(aflags-thumb2-y)
12624c91b62SEric Biggersendif
12724c91b62SEric Biggers
12860e3f1e9SEric Biggersifeq ($(CONFIG_ARM64),y)
12960e3f1e9SEric Biggerslibsha512-y += arm64/sha512-core.o
13061f86c70SEric Biggers$(obj)/arm64/sha512-core.S: $(src)/arm64/sha2-armv8.pl
13160e3f1e9SEric Biggers	$(call cmd,perlasm_with_args)
13260e3f1e9SEric Biggersclean-files += arm64/sha512-core.S
13360e3f1e9SEric Biggerslibsha512-$(CONFIG_KERNEL_MODE_NEON) += arm64/sha512-ce-core.o
13460e3f1e9SEric Biggersendif
135b59059a2SEric Biggers
136b59059a2SEric Biggerslibsha512-$(CONFIG_RISCV) += riscv/sha512-riscv64-zvknhb-zvkb.o
13702b35babSEric Biggerslibsha512-$(CONFIG_SPARC) += sparc/sha512_asm.o
138484c1811SEric Biggerslibsha512-$(CONFIG_X86) += x86/sha512-ssse3-asm.o \
139484c1811SEric Biggers			   x86/sha512-avx-asm.o \
140484c1811SEric Biggers			   x86/sha512-avx2-asm.o
141b693c703SEric Biggersendif # CONFIG_CRYPTO_LIB_SHA512_ARCH
142b693c703SEric Biggers
143e96cb950SEric Biggers################################################################################
144e96cb950SEric Biggers
1452a598d0bSHerbert Xuobj-$(CONFIG_MPILIB) += mpi/
1464964a1d9SEric Biggers
147ac90aad0SEric Biggersobj-$(CONFIG_CRYPTO_SELFTESTS_FULL)		+= simd.o
148f4065b2fSHerbert Xu
149f4065b2fSHerbert Xuobj-$(CONFIG_CRYPTO_LIB_SM3)			+= libsm3.o
150f4065b2fSHerbert Xulibsm3-y					:= sm3.o
1514a32e5dcSEric Biggers
1524a32e5dcSEric Biggersobj-$(CONFIG_ARM) += arm/
15361f86c70SEric Biggersobj-$(CONFIG_ARM64) += arm64/
1547e54e993SEric Biggersobj-$(CONFIG_MIPS) += mips/
155676d45abSEric Biggersobj-$(CONFIG_PPC) += powerpc/
156daed4fcfSEric Biggersobj-$(CONFIG_RISCV) += riscv/
157b8456f7aSEric Biggersobj-$(CONFIG_S390) += s390/
15874750aa7SEric Biggersobj-$(CONFIG_X86) += x86/
159