Merge tag 'xarray-5.18' of git://git.infradead.org/users/willy/xarray
[linux-2.6-microblaze.git] / certs / Makefile
1 # SPDX-License-Identifier: GPL-2.0
2 #
3 # Makefile for the linux kernel signature checking certificates.
4 #
5
6 obj-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += system_keyring.o system_certificates.o common.o
7 obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist.o common.o
8 obj-$(CONFIG_SYSTEM_REVOCATION_LIST) += revocation_certificates.o
9 ifneq ($(CONFIG_SYSTEM_BLACKLIST_HASH_LIST),)
10 obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist_hashes.o
11 else
12 obj-$(CONFIG_SYSTEM_BLACKLIST_KEYRING) += blacklist_nohashes.o
13 endif
14
15 quiet_cmd_extract_certs  = CERT    $@
16       cmd_extract_certs  = $(obj)/extract-cert $(extract-cert-in) $@
17 extract-cert-in = $(or $(filter-out $(obj)/extract-cert, $(real-prereqs)),"")
18
19 $(obj)/system_certificates.o: $(obj)/x509_certificate_list
20
21 $(obj)/x509_certificate_list: $(CONFIG_SYSTEM_TRUSTED_KEYS) $(obj)/extract-cert FORCE
22         $(call if_changed,extract_certs)
23
24 targets += x509_certificate_list
25
26 # If module signing is requested, say by allyesconfig, but a key has not been
27 # supplied, then one will need to be generated to make sure the build does not
28 # fail and that the kernel may be used afterwards.
29 #
30 # We do it this way rather than having a boolean option for enabling an
31 # external private key, because 'make randconfig' might enable such a
32 # boolean option and we unfortunately can't make it depend on !RANDCONFIG.
33 ifeq ($(CONFIG_MODULE_SIG_KEY),certs/signing_key.pem)
34
35 keytype-$(CONFIG_MODULE_SIG_KEY_TYPE_ECDSA) := -newkey ec -pkeyopt ec_paramgen_curve:secp384r1
36
37 quiet_cmd_gen_key = GENKEY  $@
38       cmd_gen_key = openssl req -new -nodes -utf8 -$(CONFIG_MODULE_SIG_HASH) -days 36500 \
39                 -batch -x509 -config $< \
40                 -outform PEM -out $@ -keyout $@ $(keytype-y) 2>&1
41
42 $(obj)/signing_key.pem: $(obj)/x509.genkey FORCE
43         $(call if_changed,gen_key)
44
45 targets += signing_key.pem
46
47 quiet_cmd_copy_x509_config = COPY    $@
48       cmd_copy_x509_config = cat $(srctree)/$(src)/default_x509.genkey > $@
49
50 # You can provide your own config file. If not present, copy the default one.
51 $(obj)/x509.genkey:
52         $(call cmd,copy_x509_config)
53
54 endif # CONFIG_MODULE_SIG_KEY
55
56 $(obj)/system_certificates.o: $(obj)/signing_key.x509
57
58 PKCS11_URI := $(filter pkcs11:%, $(CONFIG_MODULE_SIG_KEY))
59 ifdef PKCS11_URI
60 $(obj)/signing_key.x509: extract-cert-in := $(PKCS11_URI)
61 endif
62
63 $(obj)/signing_key.x509: $(filter-out $(PKCS11_URI),$(CONFIG_MODULE_SIG_KEY)) $(obj)/extract-cert FORCE
64         $(call if_changed,extract_certs)
65
66 targets += signing_key.x509
67
68 $(obj)/revocation_certificates.o: $(obj)/x509_revocation_list
69
70 $(obj)/x509_revocation_list: $(CONFIG_SYSTEM_REVOCATION_KEYS) $(obj)/extract-cert FORCE
71         $(call if_changed,extract_certs)
72
73 targets += x509_revocation_list
74
75 hostprogs := extract-cert
76
77 HOSTCFLAGS_extract-cert.o = $(shell pkg-config --cflags libcrypto 2> /dev/null)
78 HOSTLDLIBS_extract-cert = $(shell pkg-config --libs libcrypto 2> /dev/null || echo -lcrypto)