certs: remove unneeded -I$(srctree) option for system_certificates.o
[linux-block.git] / certs / Makefile
CommitLineData
b2441318 1# SPDX-License-Identifier: GPL-2.0
cfc411e7
DH
2#
3# Makefile for the linux kernel signature checking certificates.
4#
5
2565ca7f 6obj-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += system_keyring.o system_certificates.o common.o
d1f04410
ES
7obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist.o common.o
8obj-$(CONFIG_SYSTEM_REVOCATION_LIST) += revocation_certificates.o
734114f8
DH
9ifneq ($(CONFIG_SYSTEM_BLACKLIST_HASH_LIST),"")
10obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist_hashes.o
11else
12obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist_nohashes.o
13endif
cfc411e7 14
1c4bd9f7
MY
15quiet_cmd_extract_certs = CERT $@
16 cmd_extract_certs = scripts/extract-cert $(2) $@
17
cfc411e7
DH
18ifeq ($(CONFIG_SYSTEM_TRUSTED_KEYRING),y)
19
20$(eval $(call config_filename,SYSTEM_TRUSTED_KEYS))
21
22# GCC doesn't include .incbin files in -MD generated dependencies (PR#66871)
23$(obj)/system_certificates.o: $(obj)/x509_certificate_list
24
cfc411e7
DH
25targets += x509_certificate_list
26$(obj)/x509_certificate_list: scripts/extract-cert $(SYSTEM_TRUSTED_KEYS_SRCPREFIX)$(SYSTEM_TRUSTED_KEYS_FILENAME) FORCE
27 $(call if_changed,extract_certs,$(SYSTEM_TRUSTED_KEYS_SRCPREFIX)$(CONFIG_SYSTEM_TRUSTED_KEYS))
5ccbdbf9 28endif # CONFIG_SYSTEM_TRUSTED_KEYRING
cfc411e7 29
d1f04410 30clean-files := x509_certificate_list .x509.list x509_revocation_list
cfc411e7
DH
31
32ifeq ($(CONFIG_MODULE_SIG),y)
0165f4ca
NJ
33 SIGN_KEY = y
34endif
35
36ifeq ($(CONFIG_IMA_APPRAISE_MODSIG),y)
781a5739 37ifeq ($(CONFIG_MODULES),y)
0165f4ca
NJ
38 SIGN_KEY = y
39endif
781a5739 40endif
0165f4ca
NJ
41
42ifdef SIGN_KEY
cfc411e7
DH
43###############################################################################
44#
45# If module signing is requested, say by allyesconfig, but a key has not been
46# supplied, then one will need to be generated to make sure the build does not
47# fail and that the kernel may be used afterwards.
48#
49###############################################################################
cfc411e7
DH
50
51# We do it this way rather than having a boolean option for enabling an
52# external private key, because 'make randconfig' might enable such a
53# boolean option and we unfortunately can't make it depend on !RANDCONFIG.
54ifeq ($(CONFIG_MODULE_SIG_KEY),"certs/signing_key.pem")
ea35e0d5 55
e06a61a8 56keytype-$(CONFIG_MODULE_SIG_KEY_TYPE_ECDSA) := -newkey ec -pkeyopt ec_paramgen_curve:secp384r1
ea35e0d5 57
54c8b517
MY
58quiet_cmd_gen_key = GENKEY $@
59 cmd_gen_key = openssl req -new -nodes -utf8 -$(CONFIG_MODULE_SIG_HASH) -days 36500 \
c537e4d0
MY
60 -batch -x509 -config $< \
61 -outform PEM -out $@ -keyout $@ $(keytype-y) 2>&1
e06a61a8
MY
62
63$(obj)/signing_key.pem: $(obj)/x509.genkey FORCE
64 $(call if_changed,gen_key)
54c8b517 65
e06a61a8 66targets += signing_key.pem
cfc411e7 67
f3a2ba44
MY
68quiet_cmd_copy_x509_config = COPY $@
69 cmd_copy_x509_config = cat $(srctree)/$(src)/default_x509.genkey > $@
70
71# You can provide your own config file. If not present, copy the default one.
cfc411e7 72$(obj)/x509.genkey:
f3a2ba44
MY
73 $(call cmd,copy_x509_config)
74
5ccbdbf9 75endif # CONFIG_MODULE_SIG_KEY
cfc411e7
DH
76
77$(eval $(call config_filename,MODULE_SIG_KEY))
78
79# If CONFIG_MODULE_SIG_KEY isn't a PKCS#11 URI, depend on it
80ifeq ($(patsubst pkcs11:%,%,$(firstword $(MODULE_SIG_KEY_FILENAME))),$(firstword $(MODULE_SIG_KEY_FILENAME)))
81X509_DEP := $(MODULE_SIG_KEY_SRCPREFIX)$(MODULE_SIG_KEY_FILENAME)
82endif
83
84# GCC PR#66871 again.
85$(obj)/system_certificates.o: $(obj)/signing_key.x509
86
62172c81
DW
87targets += signing_key.x509
88$(obj)/signing_key.x509: scripts/extract-cert $(X509_DEP) FORCE
89 $(call if_changed,extract_certs,$(MODULE_SIG_KEY_SRCPREFIX)$(CONFIG_MODULE_SIG_KEY))
5ccbdbf9 90endif # CONFIG_MODULE_SIG
d1f04410
ES
91
92ifeq ($(CONFIG_SYSTEM_REVOCATION_LIST),y)
93
94$(eval $(call config_filename,SYSTEM_REVOCATION_KEYS))
95
96$(obj)/revocation_certificates.o: $(obj)/x509_revocation_list
97
d1f04410
ES
98targets += x509_revocation_list
99$(obj)/x509_revocation_list: scripts/extract-cert $(SYSTEM_REVOCATION_KEYS_SRCPREFIX)$(SYSTEM_REVOCATION_KEYS_FILENAME) FORCE
100 $(call if_changed,extract_certs,$(SYSTEM_REVOCATION_KEYS_SRCPREFIX)$(CONFIG_SYSTEM_REVOCATION_KEYS))
101endif