aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/Makefile')
-rw-r--r--kernel/Makefile77
1 files changed, 77 insertions, 0 deletions
diff --git a/kernel/Makefile b/kernel/Makefile
index 5404911eaee..0dfeca4324e 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -54,6 +54,7 @@ obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock.o
54obj-$(CONFIG_PROVE_LOCKING) += spinlock.o 54obj-$(CONFIG_PROVE_LOCKING) += spinlock.o
55obj-$(CONFIG_UID16) += uid16.o 55obj-$(CONFIG_UID16) += uid16.o
56obj-$(CONFIG_MODULES) += module.o 56obj-$(CONFIG_MODULES) += module.o
57obj-$(CONFIG_MODULE_SIG) += module_signing.o modsign_pubkey.o
57obj-$(CONFIG_KALLSYMS) += kallsyms.o 58obj-$(CONFIG_KALLSYMS) += kallsyms.o
58obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o 59obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o
59obj-$(CONFIG_KEXEC) += kexec.o 60obj-$(CONFIG_KEXEC) += kexec.o
@@ -130,3 +131,79 @@ quiet_cmd_timeconst = TIMEC $@
130targets += timeconst.h 131targets += timeconst.h
131$(obj)/timeconst.h: $(src)/timeconst.pl FORCE 132$(obj)/timeconst.h: $(src)/timeconst.pl FORCE
132 $(call if_changed,timeconst) 133 $(call if_changed,timeconst)
134
135ifeq ($(CONFIG_MODULE_SIG),y)
136#
137# Pull the signing certificate and any extra certificates into the kernel
138#
139extra_certificates:
140 touch $@
141
142kernel/modsign_pubkey.o: signing_key.x509 extra_certificates
143
144###############################################################################
145#
146# If module signing is requested, say by allyesconfig, but a key has not been
147# supplied, then one will need to be generated to make sure the build does not
148# fail and that the kernel may be used afterwards.
149#
150###############################################################################
151sign_key_with_hash :=
152ifeq ($(CONFIG_MODULE_SIG_SHA1),y)
153sign_key_with_hash := -sha1
154endif
155ifeq ($(CONFIG_MODULE_SIG_SHA224),y)
156sign_key_with_hash := -sha224
157endif
158ifeq ($(CONFIG_MODULE_SIG_SHA256),y)
159sign_key_with_hash := -sha256
160endif
161ifeq ($(CONFIG_MODULE_SIG_SHA384),y)
162sign_key_with_hash := -sha384
163endif
164ifeq ($(CONFIG_MODULE_SIG_SHA512),y)
165sign_key_with_hash := -sha512
166endif
167ifeq ($(sign_key_with_hash),)
168$(error Could not determine digest type to use from kernel config)
169endif
170
171signing_key.priv signing_key.x509: x509.genkey
172 @echo "###"
173 @echo "### Now generating an X.509 key pair to be used for signing modules."
174 @echo "###"
175 @echo "### If this takes a long time, you might wish to run rngd in the"
176 @echo "### background to keep the supply of entropy topped up. It"
177 @echo "### needs to be run as root, and should use a hardware random"
178 @echo "### number generator if one is available, eg:"
179 @echo "###"
180 @echo "### rngd -r /dev/hwrandom"
181 @echo "###"
182 openssl req -new -nodes -utf8 $(sign_key_with_hash) -days 36500 -batch \
183 -x509 -config x509.genkey \
184 -outform DER -out signing_key.x509 \
185 -keyout signing_key.priv
186 @echo "###"
187 @echo "### Key pair generated."
188 @echo "###"
189
190x509.genkey:
191 @echo Generating X.509 key generation config
192 @echo >x509.genkey "[ req ]"
193 @echo >>x509.genkey "default_bits = 4096"
194 @echo >>x509.genkey "distinguished_name = req_distinguished_name"
195 @echo >>x509.genkey "prompt = no"
196 @echo >>x509.genkey "string_mask = utf8only"
197 @echo >>x509.genkey "x509_extensions = myexts"
198 @echo >>x509.genkey
199 @echo >>x509.genkey "[ req_distinguished_name ]"
200 @echo >>x509.genkey "O = Magrathea"
201 @echo >>x509.genkey "CN = Glacier signing key"
202 @echo >>x509.genkey "emailAddress = slartibartfast@magrathea.h2g2"
203 @echo >>x509.genkey
204 @echo >>x509.genkey "[ myexts ]"
205 @echo >>x509.genkey "basicConstraints=critical,CA:FALSE"
206 @echo >>x509.genkey "keyUsage=digitalSignature"
207 @echo >>x509.genkey "subjectKeyIdentifier=hash"
208 @echo >>x509.genkey "authorityKeyIdentifier=keyid"
209endif