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 11*4dcf6cadSEric Biggersobj-$(CONFIG_KUNIT) += tests/ 12*4dcf6cadSEric 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 629b9d4ef0SHerbert Xuobj-$(CONFIG_CRYPTO_LIB_POLY1305) += libpoly1305.o 631c08a104SJason A. Donenfeldlibpoly1305-y += poly1305.o 6448ea8c6eSArd Biesheuvel 659b9d4ef0SHerbert Xuobj-$(CONFIG_CRYPTO_LIB_POLY1305_GENERIC) += libpoly1305-generic.o 669b9d4ef0SHerbert Xulibpoly1305-generic-y := poly1305-donna32.o 679b9d4ef0SHerbert Xulibpoly1305-generic-$(CONFIG_ARCH_SUPPORTS_INT128) := poly1305-donna64.o 689b9d4ef0SHerbert Xulibpoly1305-generic-y += poly1305-generic.o 699b9d4ef0SHerbert Xu 7090860aefSEric Biggers################################################################################ 7190860aefSEric Biggers 72ec8f7f48SEric Biggersobj-$(CONFIG_CRYPTO_LIB_SHA1) += libsha1.o 73ec8f7f48SEric Biggerslibsha1-y := sha1.o 7490860aefSEric Biggersifeq ($(CONFIG_CRYPTO_LIB_SHA1_ARCH),y) 7590860aefSEric BiggersCFLAGS_sha1.o += -I$(src)/$(SRCARCH) 7670cb6ca5SEric Biggersifeq ($(CONFIG_ARM),y) 7770cb6ca5SEric Biggerslibsha1-y += arm/sha1-armv4-large.o 7870cb6ca5SEric Biggerslibsha1-$(CONFIG_KERNEL_MODE_NEON) += arm/sha1-armv7-neon.o \ 7970cb6ca5SEric Biggers arm/sha1-ce-core.o 8070cb6ca5SEric Biggersendif 8100d549bbSEric Biggerslibsha1-$(CONFIG_ARM64) += arm64/sha1-ce-core.o 826b9ae8cfSEric Biggersifeq ($(CONFIG_PPC),y) 836b9ae8cfSEric Biggerslibsha1-y += powerpc/sha1-powerpc-asm.o 846b9ae8cfSEric Biggerslibsha1-$(CONFIG_SPE) += powerpc/sha1-spe-asm.o 856b9ae8cfSEric Biggersendif 86c7510599SEric Biggerslibsha1-$(CONFIG_SPARC) += sparc/sha1_asm.o 87f3d6cb3dSEric Biggerslibsha1-$(CONFIG_X86) += x86/sha1-ssse3-and-avx.o \ 88f3d6cb3dSEric Biggers x86/sha1-avx2-asm.o \ 89f3d6cb3dSEric Biggers x86/sha1-ni-asm.o 9090860aefSEric Biggersendif # CONFIG_CRYPTO_LIB_SHA1_ARCH 91463f7408SEric Biggers 92e96cb950SEric Biggers################################################################################ 93e96cb950SEric Biggers 9401d3aee8SHans de Goedeobj-$(CONFIG_CRYPTO_LIB_SHA256) += libsha256.o 9501d3aee8SHans de Goedelibsha256-y := sha256.o 96e96cb950SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_SHA256_ARCH),y) 97e96cb950SEric BiggersCFLAGS_sha256.o += -I$(src)/$(SRCARCH) 9866d7fb94SJason A. Donenfeld 99e96cb950SEric Biggersifeq ($(CONFIG_ARM),y) 100e96cb950SEric Biggerslibsha256-y += arm/sha256-ce.o arm/sha256-core.o 101e96cb950SEric Biggers$(obj)/arm/sha256-core.S: $(src)/arm/sha256-armv4.pl 102e96cb950SEric Biggers $(call cmd,perlasm) 103e96cb950SEric Biggersclean-files += arm/sha256-core.S 104e96cb950SEric BiggersAFLAGS_arm/sha256-core.o += $(aflags-thumb2-y) 105e96cb950SEric Biggersendif 106e96cb950SEric Biggers 107e96cb950SEric Biggersifeq ($(CONFIG_ARM64),y) 108e96cb950SEric Biggerslibsha256-y += arm64/sha256-core.o 109e96cb950SEric Biggers$(obj)/arm64/sha256-core.S: $(src)/arm64/sha2-armv8.pl 110e96cb950SEric Biggers $(call cmd,perlasm_with_args) 111e96cb950SEric Biggersclean-files += arm64/sha256-core.S 112e96cb950SEric Biggerslibsha256-$(CONFIG_KERNEL_MODE_NEON) += arm64/sha256-ce.o 113e96cb950SEric Biggersendif 114e96cb950SEric Biggers 115e96cb950SEric Biggerslibsha256-$(CONFIG_PPC) += powerpc/sha256-spe-asm.o 116e96cb950SEric Biggerslibsha256-$(CONFIG_RISCV) += riscv/sha256-riscv64-zvknha_or_zvknhb-zvkb.o 117e96cb950SEric Biggerslibsha256-$(CONFIG_SPARC) += sparc/sha256_asm.o 118e96cb950SEric Biggerslibsha256-$(CONFIG_X86) += x86/sha256-ssse3-asm.o \ 119e96cb950SEric Biggers x86/sha256-avx-asm.o \ 120e96cb950SEric Biggers x86/sha256-avx2-asm.o \ 121e96cb950SEric Biggers x86/sha256-ni-asm.o 122e96cb950SEric Biggersendif # CONFIG_CRYPTO_LIB_SHA256_ARCH 123e96cb950SEric Biggers 124e96cb950SEric Biggers################################################################################ 125950e5c84SEric Biggers 126b693c703SEric Biggersobj-$(CONFIG_CRYPTO_LIB_SHA512) += libsha512.o 127b693c703SEric Biggerslibsha512-y := sha512.o 128b693c703SEric Biggersifeq ($(CONFIG_CRYPTO_LIB_SHA512_ARCH),y) 129b693c703SEric BiggersCFLAGS_sha512.o += -I$(src)/$(SRCARCH) 13024c91b62SEric Biggers 13124c91b62SEric Biggersifeq ($(CONFIG_ARM),y) 13224c91b62SEric Biggerslibsha512-y += arm/sha512-core.o 13324c91b62SEric Biggers$(obj)/arm/sha512-core.S: $(src)/arm/sha512-armv4.pl 13424c91b62SEric Biggers $(call cmd,perlasm) 13524c91b62SEric Biggersclean-files += arm/sha512-core.S 13624c91b62SEric BiggersAFLAGS_arm/sha512-core.o += $(aflags-thumb2-y) 13724c91b62SEric Biggersendif 13824c91b62SEric Biggers 13960e3f1e9SEric Biggersifeq ($(CONFIG_ARM64),y) 14060e3f1e9SEric Biggerslibsha512-y += arm64/sha512-core.o 14161f86c70SEric Biggers$(obj)/arm64/sha512-core.S: $(src)/arm64/sha2-armv8.pl 14260e3f1e9SEric Biggers $(call cmd,perlasm_with_args) 14360e3f1e9SEric Biggersclean-files += arm64/sha512-core.S 14460e3f1e9SEric Biggerslibsha512-$(CONFIG_KERNEL_MODE_NEON) += arm64/sha512-ce-core.o 14560e3f1e9SEric Biggersendif 146b59059a2SEric Biggers 147b59059a2SEric Biggerslibsha512-$(CONFIG_RISCV) += riscv/sha512-riscv64-zvknhb-zvkb.o 14802b35babSEric Biggerslibsha512-$(CONFIG_SPARC) += sparc/sha512_asm.o 149484c1811SEric Biggerslibsha512-$(CONFIG_X86) += x86/sha512-ssse3-asm.o \ 150484c1811SEric Biggers x86/sha512-avx-asm.o \ 151484c1811SEric Biggers x86/sha512-avx2-asm.o 152b693c703SEric Biggersendif # CONFIG_CRYPTO_LIB_SHA512_ARCH 153b693c703SEric Biggers 154e96cb950SEric Biggers################################################################################ 155e96cb950SEric Biggers 1562a598d0bSHerbert Xuobj-$(CONFIG_MPILIB) += mpi/ 1574964a1d9SEric Biggers 158ac90aad0SEric Biggersobj-$(CONFIG_CRYPTO_SELFTESTS_FULL) += simd.o 159f4065b2fSHerbert Xu 160f4065b2fSHerbert Xuobj-$(CONFIG_CRYPTO_LIB_SM3) += libsm3.o 161f4065b2fSHerbert Xulibsm3-y := sm3.o 1624a32e5dcSEric Biggers 1634a32e5dcSEric Biggersobj-$(CONFIG_ARM) += arm/ 16461f86c70SEric Biggersobj-$(CONFIG_ARM64) += arm64/ 1657e54e993SEric Biggersobj-$(CONFIG_MIPS) += mips/ 166676d45abSEric Biggersobj-$(CONFIG_PPC) += powerpc/ 167daed4fcfSEric Biggersobj-$(CONFIG_RISCV) += riscv/ 168b8456f7aSEric Biggersobj-$(CONFIG_S390) += s390/ 16974750aa7SEric Biggersobj-$(CONFIG_X86) += x86/ 170