1# SPDX-License-Identifier: GPL-2.0 2# 3# Cryptographic API 4# 5 6obj-$(CONFIG_CRYPTO) += crypto.o 7crypto-y := api.o cipher.o compress.o 8 9obj-$(CONFIG_CRYPTO_ENGINE) += crypto_engine.o 10obj-$(CONFIG_CRYPTO_FIPS) += fips.o 11 12crypto_algapi-$(CONFIG_PROC_FS) += proc.o 13crypto_algapi-y := algapi.o scatterwalk.o $(crypto_algapi-y) 14obj-$(CONFIG_CRYPTO_ALGAPI2) += crypto_algapi.o 15 16obj-$(CONFIG_CRYPTO_AEAD2) += aead.o 17obj-$(CONFIG_CRYPTO_AEAD2) += geniv.o 18 19obj-$(CONFIG_CRYPTO_SKCIPHER2) += skcipher.o 20obj-$(CONFIG_CRYPTO_SEQIV) += seqiv.o 21obj-$(CONFIG_CRYPTO_ECHAINIV) += echainiv.o 22 23crypto_hash-y += ahash.o 24crypto_hash-y += shash.o 25obj-$(CONFIG_CRYPTO_HASH2) += crypto_hash.o 26 27obj-$(CONFIG_CRYPTO_AKCIPHER2) += akcipher.o 28obj-$(CONFIG_CRYPTO_KPP2) += kpp.o 29 30dh_generic-y := dh.o 31dh_generic-y += dh_helper.o 32obj-$(CONFIG_CRYPTO_DH) += dh_generic.o 33 34$(obj)/rsapubkey.asn1.o: $(obj)/rsapubkey.asn1.c $(obj)/rsapubkey.asn1.h 35$(obj)/rsaprivkey.asn1.o: $(obj)/rsaprivkey.asn1.c $(obj)/rsaprivkey.asn1.h 36$(obj)/rsa_helper.o: $(obj)/rsapubkey.asn1.h $(obj)/rsaprivkey.asn1.h 37 38rsa_generic-y := rsapubkey.asn1.o 39rsa_generic-y += rsaprivkey.asn1.o 40rsa_generic-y += rsa.o 41rsa_generic-y += rsa_helper.o 42rsa_generic-y += rsa-pkcs1pad.o 43obj-$(CONFIG_CRYPTO_RSA) += rsa_generic.o 44 45$(obj)/sm2signature.asn1.o: $(obj)/sm2signature.asn1.c $(obj)/sm2signature.asn1.h 46$(obj)/sm2.o: $(obj)/sm2signature.asn1.h 47 48sm2_generic-y += sm2signature.asn1.o 49sm2_generic-y += sm2.o 50 51obj-$(CONFIG_CRYPTO_SM2) += sm2_generic.o 52 53$(obj)/ecdsasignature.asn1.o: $(obj)/ecdsasignature.asn1.c $(obj)/ecdsasignature.asn1.h 54$(obj)/ecdsa.o: $(obj)/ecdsasignature.asn1.h 55ecdsa_generic-y += ecdsa.o 56ecdsa_generic-y += ecdsasignature.asn1.o 57obj-$(CONFIG_CRYPTO_ECDSA) += ecdsa_generic.o 58 59crypto_acompress-y := acompress.o 60crypto_acompress-y += scompress.o 61obj-$(CONFIG_CRYPTO_ACOMP2) += crypto_acompress.o 62 63cryptomgr-y := algboss.o testmgr.o 64 65obj-$(CONFIG_CRYPTO_MANAGER2) += cryptomgr.o 66obj-$(CONFIG_CRYPTO_USER) += crypto_user.o 67crypto_user-y := crypto_user_base.o 68crypto_user-$(CONFIG_CRYPTO_STATS) += crypto_user_stat.o 69obj-$(CONFIG_CRYPTO_CMAC) += cmac.o 70obj-$(CONFIG_CRYPTO_HMAC) += hmac.o 71obj-$(CONFIG_CRYPTO_VMAC) += vmac.o 72obj-$(CONFIG_CRYPTO_XCBC) += xcbc.o 73obj-$(CONFIG_CRYPTO_NULL2) += crypto_null.o 74obj-$(CONFIG_CRYPTO_MD4) += md4.o 75obj-$(CONFIG_CRYPTO_MD5) += md5.o 76obj-$(CONFIG_CRYPTO_RMD160) += rmd160.o 77obj-$(CONFIG_CRYPTO_SHA1) += sha1_generic.o 78obj-$(CONFIG_CRYPTO_SHA256) += sha256_generic.o 79obj-$(CONFIG_CRYPTO_SHA512) += sha512_generic.o 80obj-$(CONFIG_CRYPTO_SHA3) += sha3_generic.o 81obj-$(CONFIG_CRYPTO_SM3) += sm3_generic.o 82obj-$(CONFIG_CRYPTO_STREEBOG) += streebog_generic.o 83obj-$(CONFIG_CRYPTO_WP512) += wp512.o 84CFLAGS_wp512.o := $(call cc-option,-fno-schedule-insns) # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149 85obj-$(CONFIG_CRYPTO_BLAKE2B) += blake2b_generic.o 86obj-$(CONFIG_CRYPTO_GF128MUL) += gf128mul.o 87obj-$(CONFIG_CRYPTO_ECB) += ecb.o 88obj-$(CONFIG_CRYPTO_CBC) += cbc.o 89obj-$(CONFIG_CRYPTO_CFB) += cfb.o 90obj-$(CONFIG_CRYPTO_PCBC) += pcbc.o 91obj-$(CONFIG_CRYPTO_CTS) += cts.o 92obj-$(CONFIG_CRYPTO_LRW) += lrw.o 93obj-$(CONFIG_CRYPTO_XTS) += xts.o 94obj-$(CONFIG_CRYPTO_CTR) += ctr.o 95obj-$(CONFIG_CRYPTO_XCTR) += xctr.o 96obj-$(CONFIG_CRYPTO_HCTR2) += hctr2.o 97obj-$(CONFIG_CRYPTO_KEYWRAP) += keywrap.o 98obj-$(CONFIG_CRYPTO_ADIANTUM) += adiantum.o 99obj-$(CONFIG_CRYPTO_NHPOLY1305) += nhpoly1305.o 100obj-$(CONFIG_CRYPTO_GCM) += gcm.o 101obj-$(CONFIG_CRYPTO_CCM) += ccm.o 102obj-$(CONFIG_CRYPTO_CHACHA20POLY1305) += chacha20poly1305.o 103obj-$(CONFIG_CRYPTO_AEGIS128) += aegis128.o 104aegis128-y := aegis128-core.o 105 106ifeq ($(ARCH),arm) 107CFLAGS_aegis128-neon-inner.o += -ffreestanding -march=armv8-a -mfloat-abi=softfp 108CFLAGS_aegis128-neon-inner.o += -mfpu=crypto-neon-fp-armv8 109aegis128-$(CONFIG_CRYPTO_AEGIS128_SIMD) += aegis128-neon.o aegis128-neon-inner.o 110endif 111ifeq ($(ARCH),arm64) 112aegis128-cflags-y := -ffreestanding -mcpu=generic+crypto 113aegis128-cflags-$(CONFIG_CC_IS_GCC) += -ffixed-q16 -ffixed-q17 -ffixed-q18 \ 114 -ffixed-q19 -ffixed-q20 -ffixed-q21 \ 115 -ffixed-q22 -ffixed-q23 -ffixed-q24 \ 116 -ffixed-q25 -ffixed-q26 -ffixed-q27 \ 117 -ffixed-q28 -ffixed-q29 -ffixed-q30 \ 118 -ffixed-q31 119CFLAGS_aegis128-neon-inner.o += $(aegis128-cflags-y) 120CFLAGS_REMOVE_aegis128-neon-inner.o += -mgeneral-regs-only 121aegis128-$(CONFIG_CRYPTO_AEGIS128_SIMD) += aegis128-neon.o aegis128-neon-inner.o 122endif 123 124obj-$(CONFIG_CRYPTO_PCRYPT) += pcrypt.o 125obj-$(CONFIG_CRYPTO_CRYPTD) += cryptd.o 126obj-$(CONFIG_CRYPTO_DES) += des_generic.o 127obj-$(CONFIG_CRYPTO_FCRYPT) += fcrypt.o 128obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish_generic.o 129obj-$(CONFIG_CRYPTO_BLOWFISH_COMMON) += blowfish_common.o 130obj-$(CONFIG_CRYPTO_TWOFISH) += twofish_generic.o 131obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o 132obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o 133CFLAGS_serpent_generic.o := $(call cc-option,-fsched-pressure) # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149 134obj-$(CONFIG_CRYPTO_AES) += aes_generic.o 135CFLAGS_aes_generic.o := $(call cc-option,-fno-code-hoisting) # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83356 136obj-$(CONFIG_CRYPTO_SM4) += sm4_generic.o 137obj-$(CONFIG_CRYPTO_AES_TI) += aes_ti.o 138obj-$(CONFIG_CRYPTO_CAMELLIA) += camellia_generic.o 139obj-$(CONFIG_CRYPTO_CAST_COMMON) += cast_common.o 140obj-$(CONFIG_CRYPTO_CAST5) += cast5_generic.o 141obj-$(CONFIG_CRYPTO_CAST6) += cast6_generic.o 142obj-$(CONFIG_CRYPTO_ARC4) += arc4.o 143obj-$(CONFIG_CRYPTO_TEA) += tea.o 144obj-$(CONFIG_CRYPTO_KHAZAD) += khazad.o 145obj-$(CONFIG_CRYPTO_ANUBIS) += anubis.o 146obj-$(CONFIG_CRYPTO_SEED) += seed.o 147obj-$(CONFIG_CRYPTO_CHACHA20) += chacha_generic.o 148obj-$(CONFIG_CRYPTO_POLY1305) += poly1305_generic.o 149obj-$(CONFIG_CRYPTO_DEFLATE) += deflate.o 150obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o 151obj-$(CONFIG_CRYPTO_CRC32C) += crc32c_generic.o 152obj-$(CONFIG_CRYPTO_CRC32) += crc32_generic.o 153obj-$(CONFIG_CRYPTO_CRCT10DIF) += crct10dif_common.o crct10dif_generic.o 154obj-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o 155obj-$(CONFIG_CRYPTO_LZO) += lzo.o lzo-rle.o 156obj-$(CONFIG_CRYPTO_LZ4) += lz4.o 157obj-$(CONFIG_CRYPTO_LZ4HC) += lz4hc.o 158obj-$(CONFIG_CRYPTO_XXHASH) += xxhash_generic.o 159obj-$(CONFIG_CRYPTO_842) += 842.o 160obj-$(CONFIG_CRYPTO_RNG2) += rng.o 161obj-$(CONFIG_CRYPTO_ANSI_CPRNG) += ansi_cprng.o 162obj-$(CONFIG_CRYPTO_DRBG) += drbg.o 163obj-$(CONFIG_CRYPTO_JITTERENTROPY) += jitterentropy_rng.o 164CFLAGS_jitterentropy.o = -O0 165KASAN_SANITIZE_jitterentropy.o = n 166UBSAN_SANITIZE_jitterentropy.o = n 167jitterentropy_rng-y := jitterentropy.o jitterentropy-kcapi.o 168obj-$(CONFIG_CRYPTO_TEST) += tcrypt.o 169obj-$(CONFIG_CRYPTO_GHASH) += ghash-generic.o 170obj-$(CONFIG_CRYPTO_POLYVAL) += polyval-generic.o 171obj-$(CONFIG_CRYPTO_USER_API) += af_alg.o 172obj-$(CONFIG_CRYPTO_USER_API_HASH) += algif_hash.o 173obj-$(CONFIG_CRYPTO_USER_API_SKCIPHER) += algif_skcipher.o 174obj-$(CONFIG_CRYPTO_USER_API_RNG) += algif_rng.o 175obj-$(CONFIG_CRYPTO_USER_API_AEAD) += algif_aead.o 176obj-$(CONFIG_CRYPTO_ZSTD) += zstd.o 177obj-$(CONFIG_CRYPTO_OFB) += ofb.o 178obj-$(CONFIG_CRYPTO_ECC) += ecc.o 179obj-$(CONFIG_CRYPTO_ESSIV) += essiv.o 180obj-$(CONFIG_CRYPTO_CURVE25519) += curve25519-generic.o 181 182ecdh_generic-y += ecdh.o 183ecdh_generic-y += ecdh_helper.o 184obj-$(CONFIG_CRYPTO_ECDH) += ecdh_generic.o 185 186$(obj)/ecrdsa_params.asn1.o: $(obj)/ecrdsa_params.asn1.c $(obj)/ecrdsa_params.asn1.h 187$(obj)/ecrdsa_pub_key.asn1.o: $(obj)/ecrdsa_pub_key.asn1.c $(obj)/ecrdsa_pub_key.asn1.h 188$(obj)/ecrdsa.o: $(obj)/ecrdsa_params.asn1.h $(obj)/ecrdsa_pub_key.asn1.h 189ecrdsa_generic-y += ecrdsa.o 190ecrdsa_generic-y += ecrdsa_params.asn1.o 191ecrdsa_generic-y += ecrdsa_pub_key.asn1.o 192obj-$(CONFIG_CRYPTO_ECRDSA) += ecrdsa_generic.o 193 194# 195# generic algorithms and the async_tx api 196# 197obj-$(CONFIG_XOR_BLOCKS) += xor.o 198obj-$(CONFIG_ASYNC_CORE) += async_tx/ 199obj-$(CONFIG_ASYMMETRIC_KEY_TYPE) += asymmetric_keys/ 200obj-$(CONFIG_CRYPTO_HASH_INFO) += hash_info.o 201crypto_simd-y := simd.o 202obj-$(CONFIG_CRYPTO_SIMD) += crypto_simd.o 203 204ifneq ($(CONFIG_CRYPTO_FIPS140_MOD),) 205 206FIPS140_CFLAGS := -D__DISABLE_EXPORTS -DBUILD_FIPS140_KO -include fips140-defs.h 207 208CFLAGS_jitterentropy-fips.o := -O0 209KASAN_SANITIZE_jitterentropy-fips.o = n 210UBSAN_SANITIZE_jitterentropy-fips.o = n 211 212# 213# Create a separate FIPS archive containing a duplicate of each builtin generic 214# module that is in scope for FIPS 140-2 certification 215# 216crypto-fips-objs := drbg.o ecb.o cbc.o ctr.o cts.o gcm.o xts.o hmac.o cmac.o \ 217 gf128mul.o aes_generic.o lib-crypto-aes.o \ 218 jitterentropy.o jitterentropy-kcapi.o \ 219 sha1_generic.o sha256_generic.o sha512_generic.o \ 220 lib-memneq.o lib-sha1.o lib-crypto-sha256.o 221crypto-fips-objs := $(foreach o,$(crypto-fips-objs),$(o:.o=-fips.o)) 222 223# get the arch to add its objects to $(crypto-fips-objs) 224include $(srctree)/arch/$(ARCH)/crypto/Kbuild.fips140 225 226extra-$(CONFIG_CRYPTO_FIPS140_MOD) += crypto-fips.a 227 228$(obj)/%-fips.o: KBUILD_CFLAGS += $(FIPS140_CFLAGS) 229$(obj)/%-fips.o: $(src)/%.c FORCE 230 $(call if_changed_rule,cc_o_c) 231$(obj)/lib-%-fips.o: $(srctree)/lib/%.c FORCE 232 $(call if_changed_rule,cc_o_c) 233$(obj)/lib-crypto-%-fips.o: $(srctree)/lib/crypto/%.c FORCE 234 $(call if_changed_rule,cc_o_c) 235 236$(obj)/crypto-fips.a: $(addprefix $(obj)/,$(crypto-fips-objs)) FORCE 237 $(call if_changed,ar_and_symver) 238 239fips140-objs := \ 240 fips140-alg-registration.o \ 241 fips140-module.o \ 242 fips140-refs.o \ 243 fips140-selftests.o \ 244 crypto-fips.a 245fips140-$(CONFIG_CRYPTO_FIPS140_MOD_EVAL_TESTING) += \ 246 fips140-eval-testing.o 247obj-m += fips140.o 248 249CFLAGS_fips140-alg-registration.o += $(FIPS140_CFLAGS) 250CFLAGS_fips140-module.o += $(FIPS140_CFLAGS) 251CFLAGS_fips140-selftests.o += $(FIPS140_CFLAGS) 252CFLAGS_fips140-eval-testing.o += $(FIPS140_CFLAGS) 253 254hostprogs-always-y := fips140_gen_hmac 255HOSTLDLIBS_fips140_gen_hmac := -lcrypto -lelf 256 257endif 258