1 # SPDX-License-Identifier: GPL-2.0 1 # SPDX-License-Identifier: GPL-2.0 2 # 2 # 3 # Makefile for the linux kernel signature chec 3 # Makefile for the linux kernel signature checking certificates. 4 # 4 # 5 5 6 obj-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += system !! 6 obj-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += system_keyring.o system_certificates.o common.o 7 obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blac !! 7 obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist.o common.o 8 obj-$(CONFIG_SYSTEM_REVOCATION_LIST) += revoca 8 obj-$(CONFIG_SYSTEM_REVOCATION_LIST) += revocation_certificates.o 9 !! 9 ifneq ($(CONFIG_SYSTEM_BLACKLIST_HASH_LIST),) 10 $(obj)/blacklist_hashes.o: $(obj)/blacklist_ha !! 10 obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist_hashes.o 11 CFLAGS_blacklist_hashes.o := -I $(obj) !! 11 else 12 !! 12 obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist_nohashes.o 13 quiet_cmd_check_and_copy_blacklist_hash_list = !! 13 endif 14 cmd_check_and_copy_blacklist_hash_list = << 15 $(if $(CONFIG_SYSTEM_BLACKLIST_HASH_LI << 16 $(AWK) -f $(src)/check-blacklist-hashe << 17 { cat $(CONFIG_SYSTEM_BLACKLIST_HASH_L << 18 echo NULL > $@) << 19 << 20 $(obj)/blacklist_hash_list: $(CONFIG_SYSTEM_BL << 21 $(call if_changed,check_and_copy_black << 22 << 23 targets += blacklist_hash_list << 24 14 25 quiet_cmd_extract_certs = CERT $@ 15 quiet_cmd_extract_certs = CERT $@ 26 cmd_extract_certs = $(obj)/extract-cert !! 16 cmd_extract_certs = $(obj)/extract-cert $(2) $@ 27 extract-cert-in = $(filter-out $(obj)/extract- << 28 17 29 $(obj)/system_certificates.o: $(obj)/x509_cert 18 $(obj)/system_certificates.o: $(obj)/x509_certificate_list 30 19 31 $(obj)/x509_certificate_list: $(CONFIG_SYSTEM_ 20 $(obj)/x509_certificate_list: $(CONFIG_SYSTEM_TRUSTED_KEYS) $(obj)/extract-cert FORCE 32 $(call if_changed,extract_certs) !! 21 $(call if_changed,extract_certs,$(if $(CONFIG_SYSTEM_TRUSTED_KEYS),$<,"")) 33 22 34 targets += x509_certificate_list 23 targets += x509_certificate_list 35 24 >> 25 ifeq ($(CONFIG_MODULE_SIG),y) >> 26 SIGN_KEY = y >> 27 endif >> 28 >> 29 ifeq ($(CONFIG_IMA_APPRAISE_MODSIG),y) >> 30 ifeq ($(CONFIG_MODULES),y) >> 31 SIGN_KEY = y >> 32 endif >> 33 endif >> 34 >> 35 ifdef SIGN_KEY >> 36 ############################################################################### >> 37 # 36 # If module signing is requested, say by allye 38 # If module signing is requested, say by allyesconfig, but a key has not been 37 # supplied, then one will need to be generated 39 # supplied, then one will need to be generated to make sure the build does not 38 # fail and that the kernel may be used afterwa 40 # fail and that the kernel may be used afterwards. 39 # 41 # >> 42 ############################################################################### >> 43 40 # We do it this way rather than having a boole 44 # We do it this way rather than having a boolean option for enabling an 41 # external private key, because 'make randconf 45 # external private key, because 'make randconfig' might enable such a 42 # boolean option and we unfortunately can't ma 46 # boolean option and we unfortunately can't make it depend on !RANDCONFIG. 43 ifeq ($(CONFIG_MODULE_SIG_KEY),certs/signing_k 47 ifeq ($(CONFIG_MODULE_SIG_KEY),certs/signing_key.pem) 44 48 45 keytype-$(CONFIG_MODULE_SIG_KEY_TYPE_ECDSA) := 49 keytype-$(CONFIG_MODULE_SIG_KEY_TYPE_ECDSA) := -newkey ec -pkeyopt ec_paramgen_curve:secp384r1 46 50 47 quiet_cmd_gen_key = GENKEY $@ 51 quiet_cmd_gen_key = GENKEY $@ 48 cmd_gen_key = openssl req -new -nodes -u 52 cmd_gen_key = openssl req -new -nodes -utf8 -$(CONFIG_MODULE_SIG_HASH) -days 36500 \ 49 -batch -x509 -config $< \ 53 -batch -x509 -config $< \ 50 -outform PEM -out $@ -keyout $ 54 -outform PEM -out $@ -keyout $@ $(keytype-y) 2>&1 51 55 52 $(obj)/signing_key.pem: $(obj)/x509.genkey FOR 56 $(obj)/signing_key.pem: $(obj)/x509.genkey FORCE 53 $(call if_changed,gen_key) 57 $(call if_changed,gen_key) 54 58 55 targets += signing_key.pem 59 targets += signing_key.pem 56 60 57 quiet_cmd_copy_x509_config = COPY $@ 61 quiet_cmd_copy_x509_config = COPY $@ 58 cmd_copy_x509_config = cat $(src)/defaul !! 62 cmd_copy_x509_config = cat $(srctree)/$(src)/default_x509.genkey > $@ 59 63 60 # You can provide your own config file. If not 64 # You can provide your own config file. If not present, copy the default one. 61 $(obj)/x509.genkey: 65 $(obj)/x509.genkey: 62 $(call cmd,copy_x509_config) 66 $(call cmd,copy_x509_config) 63 67 64 endif # CONFIG_MODULE_SIG_KEY 68 endif # CONFIG_MODULE_SIG_KEY 65 69 66 $(obj)/system_certificates.o: $(obj)/signing_k !! 70 # If CONFIG_MODULE_SIG_KEY isn't a PKCS#11 URI, depend on it 67 !! 71 ifneq ($(filter-out pkcs11:%, $(CONFIG_MODULE_SIG_KEY)),) 68 PKCS11_URI := $(filter pkcs11:%, $(CONFIG_MODU !! 72 X509_DEP := $(CONFIG_MODULE_SIG_KEY) 69 ifdef PKCS11_URI << 70 $(obj)/signing_key.x509: extract-cert-in := $( << 71 endif 73 endif 72 74 73 $(obj)/signing_key.x509: $(filter-out $(PKCS11 !! 75 $(obj)/system_certificates.o: $(obj)/signing_key.x509 74 $(call if_changed,extract_certs) !! 76 >> 77 $(obj)/signing_key.x509: $(X509_DEP) $(obj)/extract-cert FORCE >> 78 $(call if_changed,extract_certs,$(if $(CONFIG_MODULE_SIG_KEY),$(if $(X509_DEP),$<,$(CONFIG_MODULE_SIG_KEY)),"")) >> 79 endif # CONFIG_MODULE_SIG 75 80 76 targets += signing_key.x509 81 targets += signing_key.x509 77 82 78 $(obj)/revocation_certificates.o: $(obj)/x509_ 83 $(obj)/revocation_certificates.o: $(obj)/x509_revocation_list 79 84 80 $(obj)/x509_revocation_list: $(CONFIG_SYSTEM_R 85 $(obj)/x509_revocation_list: $(CONFIG_SYSTEM_REVOCATION_KEYS) $(obj)/extract-cert FORCE 81 $(call if_changed,extract_certs) !! 86 $(call if_changed,extract_certs,$(if $(CONFIG_SYSTEM_REVOCATION_KEYS),$<,"")) 82 87 83 targets += x509_revocation_list 88 targets += x509_revocation_list 84 89 85 hostprogs := extract-cert 90 hostprogs := extract-cert 86 91 87 HOSTCFLAGS_extract-cert.o = $(shell $(HOSTPKG_ !! 92 HOSTCFLAGS_extract-cert.o = $(shell pkg-config --cflags libcrypto 2> /dev/null) 88 HOSTLDLIBS_extract-cert = $(shell $(HOSTPKG_CO !! 93 HOSTLDLIBS_extract-cert = $(shell pkg-config --libs libcrypto 2> /dev/null || echo -lcrypto)
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.