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) 7470cb6ca5SEric Biggersifeq ($(CONFIG_ARM),y) 7570cb6ca5SEric Biggerslibsha1-y += arm/sha1-armv4-large.o 7670cb6ca5SEric Biggerslibsha1-$(CONFIG_KERNEL_MODE_NEON) += arm/sha1-armv7-neon.o \ 7770cb6ca5SEric Biggers arm/sha1-ce-core.o 7870cb6ca5SEric Biggersendif 7900d549bbSEric Biggerslibsha1-$(CONFIG_ARM64) += arm64/sha1-ce-core.o 806b9ae8cfSEric Biggersifeq ($(CONFIG_PPC),y) 816b9ae8cfSEric Biggerslibsha1-y += powerpc/sha1-powerpc-asm.o 826b9ae8cfSEric Biggerslibsha1-$(CONFIG_SPE) += powerpc/sha1-spe-asm.o 836b9ae8cfSEric Biggersendif 84*c7510599SEric Biggerslibsha1-$(CONFIG_SPARC) += sparc/sha1_asm.o 8590860aefSEric Biggersendif # CONFIG_CRYPTO_LIB_SHA1_ARCH 86463f7408SEric Biggers 87e96cb950SEric Biggers################################################################################ 88e96cb950SEric Biggers 8901d3aee8SHans de Goedeobj-$(CONFIG_CRYPTO_LIB_SHA256) += libsha256.o 9001d3aee8SHans de Goedelibsha256-y := sha256.o 91e96cb950SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_SHA256_ARCH),y) 92e96cb950SEric BiggersCFLAGS_sha256.o += -I$(src)/$(SRCARCH) 9366d7fb94SJason A. Donenfeld 94e96cb950SEric Biggersifeq ($(CONFIG_ARM),y) 95e96cb950SEric Biggerslibsha256-y += arm/sha256-ce.o arm/sha256-core.o 96e96cb950SEric Biggers$(obj)/arm/sha256-core.S: $(src)/arm/sha256-armv4.pl 97e96cb950SEric Biggers $(call cmd,perlasm) 98e96cb950SEric Biggersclean-files += arm/sha256-core.S 99e96cb950SEric BiggersAFLAGS_arm/sha256-core.o += $(aflags-thumb2-y) 100e96cb950SEric Biggersendif 101e96cb950SEric Biggers 102e96cb950SEric Biggersifeq ($(CONFIG_ARM64),y) 103e96cb950SEric Biggerslibsha256-y += arm64/sha256-core.o 104e96cb950SEric Biggers$(obj)/arm64/sha256-core.S: $(src)/arm64/sha2-armv8.pl 105e96cb950SEric Biggers $(call cmd,perlasm_with_args) 106e96cb950SEric Biggersclean-files += arm64/sha256-core.S 107e96cb950SEric Biggerslibsha256-$(CONFIG_KERNEL_MODE_NEON) += arm64/sha256-ce.o 108e96cb950SEric Biggersendif 109e96cb950SEric Biggers 110e96cb950SEric Biggerslibsha256-$(CONFIG_PPC) += powerpc/sha256-spe-asm.o 111e96cb950SEric Biggerslibsha256-$(CONFIG_RISCV) += riscv/sha256-riscv64-zvknha_or_zvknhb-zvkb.o 112e96cb950SEric Biggerslibsha256-$(CONFIG_SPARC) += sparc/sha256_asm.o 113e96cb950SEric Biggerslibsha256-$(CONFIG_X86) += x86/sha256-ssse3-asm.o \ 114e96cb950SEric Biggers x86/sha256-avx-asm.o \ 115e96cb950SEric Biggers x86/sha256-avx2-asm.o \ 116e96cb950SEric Biggers x86/sha256-ni-asm.o 117e96cb950SEric Biggersendif # CONFIG_CRYPTO_LIB_SHA256_ARCH 118e96cb950SEric Biggers 119e96cb950SEric Biggers################################################################################ 120950e5c84SEric Biggers 121b693c703SEric Biggersobj-$(CONFIG_CRYPTO_LIB_SHA512) += libsha512.o 122b693c703SEric Biggerslibsha512-y := sha512.o 123b693c703SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_SHA512_ARCH),y) 124b693c703SEric BiggersCFLAGS_sha512.o += -I$(src)/$(SRCARCH) 12524c91b62SEric Biggers 12624c91b62SEric Biggersifeq ($(CONFIG_ARM),y) 12724c91b62SEric Biggerslibsha512-y += arm/sha512-core.o 12824c91b62SEric Biggers$(obj)/arm/sha512-core.S: $(src)/arm/sha512-armv4.pl 12924c91b62SEric Biggers $(call cmd,perlasm) 13024c91b62SEric Biggersclean-files += arm/sha512-core.S 13124c91b62SEric BiggersAFLAGS_arm/sha512-core.o += $(aflags-thumb2-y) 13224c91b62SEric Biggersendif 13324c91b62SEric Biggers 13460e3f1e9SEric Biggersifeq ($(CONFIG_ARM64),y) 13560e3f1e9SEric Biggerslibsha512-y += arm64/sha512-core.o 13661f86c70SEric Biggers$(obj)/arm64/sha512-core.S: $(src)/arm64/sha2-armv8.pl 13760e3f1e9SEric Biggers $(call cmd,perlasm_with_args) 13860e3f1e9SEric Biggersclean-files += arm64/sha512-core.S 13960e3f1e9SEric Biggerslibsha512-$(CONFIG_KERNEL_MODE_NEON) += arm64/sha512-ce-core.o 14060e3f1e9SEric Biggersendif 141b59059a2SEric Biggers 142b59059a2SEric Biggerslibsha512-$(CONFIG_RISCV) += riscv/sha512-riscv64-zvknhb-zvkb.o 14302b35babSEric Biggerslibsha512-$(CONFIG_SPARC) += sparc/sha512_asm.o 144484c1811SEric Biggerslibsha512-$(CONFIG_X86) += x86/sha512-ssse3-asm.o \ 145484c1811SEric Biggers x86/sha512-avx-asm.o \ 146484c1811SEric Biggers x86/sha512-avx2-asm.o 147b693c703SEric Biggersendif # CONFIG_CRYPTO_LIB_SHA512_ARCH 148b693c703SEric Biggers 149e96cb950SEric Biggers################################################################################ 150e96cb950SEric Biggers 1512a598d0bSHerbert Xuobj-$(CONFIG_MPILIB) += mpi/ 1524964a1d9SEric Biggers 153ac90aad0SEric Biggersobj-$(CONFIG_CRYPTO_SELFTESTS_FULL) += simd.o 154f4065b2fSHerbert Xu 155f4065b2fSHerbert Xuobj-$(CONFIG_CRYPTO_LIB_SM3) += libsm3.o 156f4065b2fSHerbert Xulibsm3-y := sm3.o 1574a32e5dcSEric Biggers 1584a32e5dcSEric Biggersobj-$(CONFIG_ARM) += arm/ 15961f86c70SEric Biggersobj-$(CONFIG_ARM64) += arm64/ 1607e54e993SEric Biggersobj-$(CONFIG_MIPS) += mips/ 161676d45abSEric Biggersobj-$(CONFIG_PPC) += powerpc/ 162daed4fcfSEric Biggersobj-$(CONFIG_RISCV) += riscv/ 163b8456f7aSEric Biggersobj-$(CONFIG_S390) += s390/ 16474750aa7SEric Biggersobj-$(CONFIG_X86) += x86/ 165