diff options
author | David Woodhouse <David.Woodhouse@intel.com> | 2015-07-20 16:16:30 -0400 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2015-08-07 11:26:14 -0400 |
commit | fb1179499134bc718dc7557c7a6a95dc72f224cb (patch) | |
tree | 5a0b7e87708c275071f4c3079099854a13eee812 | |
parent | 1329e8cc69b93a0b1bc6d197b30dcff628c18dbf (diff) |
modsign: Use single PEM file for autogenerated key
The current rule for generating signing_key.priv and signing_key.x509 is
a classic example of a bad rule which has a tendency to break parallel
make. When invoked to create *either* target, it generates the other
target as a side-effect that make didn't predict.
So let's switch to using a single file signing_key.pem which contains
both key and certificate. That matches what we do in the case of an
external key specified by CONFIG_MODULE_SIG_KEY anyway, so it's also
slightly cleaner.
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: David Howells <dhowells@redhat.com>
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Documentation/module-signing.txt | 9 | ||||
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | init/Kconfig | 4 | ||||
-rw-r--r-- | kernel/Makefile | 15 |
5 files changed, 16 insertions, 17 deletions
diff --git a/.gitignore b/.gitignore index 4ad4a98b884b..17fa24dd7e46 100644 --- a/.gitignore +++ b/.gitignore | |||
@@ -97,6 +97,7 @@ GTAGS | |||
97 | # Leavings from module signing | 97 | # Leavings from module signing |
98 | # | 98 | # |
99 | extra_certificates | 99 | extra_certificates |
100 | signing_key.pem | ||
100 | signing_key.priv | 101 | signing_key.priv |
101 | signing_key.x509 | 102 | signing_key.x509 |
102 | x509.genkey | 103 | x509.genkey |
diff --git a/Documentation/module-signing.txt b/Documentation/module-signing.txt index 693001920890..5d5e4e32dc26 100644 --- a/Documentation/module-signing.txt +++ b/Documentation/module-signing.txt | |||
@@ -91,7 +91,7 @@ This has a number of options available: | |||
91 | (4) "File name or PKCS#11 URI of module signing key" (CONFIG_MODULE_SIG_KEY) | 91 | (4) "File name or PKCS#11 URI of module signing key" (CONFIG_MODULE_SIG_KEY) |
92 | 92 | ||
93 | Setting this option to something other than its default of | 93 | Setting this option to something other than its default of |
94 | "signing_key.priv" will disable the autogeneration of signing keys and | 94 | "signing_key.pem" will disable the autogeneration of signing keys and |
95 | allow the kernel modules to be signed with a key of your choosing. | 95 | allow the kernel modules to be signed with a key of your choosing. |
96 | The string provided should identify a file containing both a private | 96 | The string provided should identify a file containing both a private |
97 | key and its corresponding X.509 certificate in PEM form, or — on | 97 | key and its corresponding X.509 certificate in PEM form, or — on |
@@ -116,11 +116,10 @@ kernel so that it can be used to check the signatures as the modules are | |||
116 | loaded. | 116 | loaded. |
117 | 117 | ||
118 | Under normal conditions, when CONFIG_MODULE_SIG_KEY is unchanged from its | 118 | Under normal conditions, when CONFIG_MODULE_SIG_KEY is unchanged from its |
119 | default of "signing_key.priv", the kernel build will automatically generate | 119 | default, the kernel build will automatically generate a new keypair using |
120 | a new keypair using openssl if one does not exist in the files: | 120 | openssl if one does not exist in the file: |
121 | 121 | ||
122 | signing_key.priv | 122 | signing_key.pem |
123 | signing_key.x509 | ||
124 | 123 | ||
125 | during the building of vmlinux (the public part of the key needs to be built | 124 | during the building of vmlinux (the public part of the key needs to be built |
126 | into vmlinux) using parameters in the: | 125 | into vmlinux) using parameters in the: |
@@ -1173,8 +1173,8 @@ MRPROPER_DIRS += include/config usr/include include/generated \ | |||
1173 | arch/*/include/generated .tmp_objdiff | 1173 | arch/*/include/generated .tmp_objdiff |
1174 | MRPROPER_FILES += .config .config.old .version .old_version \ | 1174 | MRPROPER_FILES += .config .config.old .version .old_version \ |
1175 | Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \ | 1175 | Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \ |
1176 | signing_key.priv signing_key.x509 x509.genkey \ | 1176 | signing_key.pem signing_key.priv signing_key.x509 \ |
1177 | extra_certificates signing_key.x509.keyid \ | 1177 | x509.genkey extra_certificates signing_key.x509.keyid \ |
1178 | signing_key.x509.signer vmlinux-gdb.py | 1178 | signing_key.x509.signer vmlinux-gdb.py |
1179 | 1179 | ||
1180 | # clean - Delete most, but leave enough to build external modules | 1180 | # clean - Delete most, but leave enough to build external modules |
diff --git a/init/Kconfig b/init/Kconfig index e2e0a1d27886..2b119850784b 100644 --- a/init/Kconfig +++ b/init/Kconfig | |||
@@ -1950,7 +1950,7 @@ config MODULE_SIG_HASH | |||
1950 | 1950 | ||
1951 | config MODULE_SIG_KEY | 1951 | config MODULE_SIG_KEY |
1952 | string "File name or PKCS#11 URI of module signing key" | 1952 | string "File name or PKCS#11 URI of module signing key" |
1953 | default "signing_key.priv" | 1953 | default "signing_key.pem" |
1954 | depends on MODULE_SIG | 1954 | depends on MODULE_SIG |
1955 | help | 1955 | help |
1956 | Provide the file name of a private key/certificate in PEM format, | 1956 | Provide the file name of a private key/certificate in PEM format, |
@@ -1958,7 +1958,7 @@ config MODULE_SIG_KEY | |||
1958 | the URI should identify, both the certificate and its corresponding | 1958 | the URI should identify, both the certificate and its corresponding |
1959 | private key. | 1959 | private key. |
1960 | 1960 | ||
1961 | If this option is unchanged from its default "signing_key.priv", | 1961 | If this option is unchanged from its default "signing_key.pem", |
1962 | then the kernel will automatically generate the private key and | 1962 | then the kernel will automatically generate the private key and |
1963 | certificate as described in Documentation/module-signing.txt | 1963 | certificate as described in Documentation/module-signing.txt |
1964 | 1964 | ||
diff --git a/kernel/Makefile b/kernel/Makefile index fa2f8b84b18a..7453283981ca 100644 --- a/kernel/Makefile +++ b/kernel/Makefile | |||
@@ -173,8 +173,8 @@ endif | |||
173 | # We do it this way rather than having a boolean option for enabling an | 173 | # We do it this way rather than having a boolean option for enabling an |
174 | # external private key, because 'make randconfig' might enable such a | 174 | # external private key, because 'make randconfig' might enable such a |
175 | # boolean option and we unfortunately can't make it depend on !RANDCONFIG. | 175 | # boolean option and we unfortunately can't make it depend on !RANDCONFIG. |
176 | ifeq ($(CONFIG_MODULE_SIG_KEY),"signing_key.priv") | 176 | ifeq ($(CONFIG_MODULE_SIG_KEY),"signing_key.pem") |
177 | signing_key.priv signing_key.x509: x509.genkey | 177 | signing_key.pem: x509.genkey |
178 | @echo "###" | 178 | @echo "###" |
179 | @echo "### Now generating an X.509 key pair to be used for signing modules." | 179 | @echo "### Now generating an X.509 key pair to be used for signing modules." |
180 | @echo "###" | 180 | @echo "###" |
@@ -185,8 +185,8 @@ signing_key.priv signing_key.x509: x509.genkey | |||
185 | @echo "###" | 185 | @echo "###" |
186 | openssl req -new -nodes -utf8 -$(CONFIG_MODULE_SIG_HASH) -days 36500 \ | 186 | openssl req -new -nodes -utf8 -$(CONFIG_MODULE_SIG_HASH) -days 36500 \ |
187 | -batch -x509 -config x509.genkey \ | 187 | -batch -x509 -config x509.genkey \ |
188 | -outform DER -out signing_key.x509 \ | 188 | -outform PEM -out signing_key.pem \ |
189 | -keyout signing_key.priv 2>&1 | 189 | -keyout signing_key.pem 2>&1 |
190 | @echo "###" | 190 | @echo "###" |
191 | @echo "### Key pair generated." | 191 | @echo "### Key pair generated." |
192 | @echo "###" | 192 | @echo "###" |
@@ -210,9 +210,9 @@ x509.genkey: | |||
210 | @echo >>x509.genkey "keyUsage=digitalSignature" | 210 | @echo >>x509.genkey "keyUsage=digitalSignature" |
211 | @echo >>x509.genkey "subjectKeyIdentifier=hash" | 211 | @echo >>x509.genkey "subjectKeyIdentifier=hash" |
212 | @echo >>x509.genkey "authorityKeyIdentifier=keyid" | 212 | @echo >>x509.genkey "authorityKeyIdentifier=keyid" |
213 | else | 213 | endif |
214 | # For external (PKCS#11 or PEM) key, we need to obtain the certificate from | 214 | |
215 | # CONFIG_MODULE_SIG_KEY automatically. | 215 | # We need to obtain the certificate from CONFIG_MODULE_SIG_KEY. |
216 | quiet_cmd_extract_der = CERT_DER $(2) | 216 | quiet_cmd_extract_der = CERT_DER $(2) |
217 | cmd_extract_der = scripts/extract-cert "$(2)" signing_key.x509 | 217 | cmd_extract_der = scripts/extract-cert "$(2)" signing_key.x509 |
218 | 218 | ||
@@ -249,4 +249,3 @@ endif | |||
249 | signing_key.x509: scripts/extract-cert include/config/module/sig/key.h $(X509_DEP) | 249 | signing_key.x509: scripts/extract-cert include/config/module/sig/key.h $(X509_DEP) |
250 | $(call cmd,extract_der,$(X509_SOURCE)) | 250 | $(call cmd,extract_der,$(X509_SOURCE)) |
251 | endif | 251 | endif |
252 | endif | ||