Skip to contentSkip to conversation

Explicit check for existing X.509 module signing keypair

RFC PATCH Superseded Abelardo Ricart III 1 participant 2 messages Apr 9, 2015 Kbuild

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 Explicit check for existing X.509 module signing keypair

The module-signing.txt documentation states that the kernel will use an existing x.509 key pair for module signing should they exist in the root of the source tree. However, user provided signing keys are overwritten during build if the last-modified times on the key pair don't align with what make expects. This patch explicitly checks for the existence of the signing key files, skipping key generation should they exist.

---

kernel/Makefile +5 -0
index 1408b33..6b8f292 100644
@@ -168,6 +168,9 @@ ifndef CONFIG_MODULE_SIG_HASH
 $(error Could not determine digest type to use from kernel config)
 endif
 
+ifneq ("$(wildcard $(srctree)/signing_key.priv)","")
+ifneq ("$(wildcard $(srctree)/signing_key.x509)","")
+$(warning *** X.509 module signing key pair not found in root of source tree ***)
 signing_key.priv signing_key.x509: x509.genkey
        @echo "###"
        @echo "### Now generating an X.509 key pair to be used for signing modules."
@@ -184,6 +187,8 @@ signing_key.priv signing_key.x509: x509.genkey
        @echo "###"
        @echo "### Key pair generated."
        @echo "###"
+endif
+endif
 
 x509.genkey:
        @echo Generating X.509 key generation config
#1 lore raw

Annnnnnd I just realized this patch is incorrect. Comments on the concept are still welcome however.

Quoted 39 lines · Abelardo Ricart III

The module-signing.txt documentation states that the kernel will use an existing
x.509 key pair for module signing should they exist in the root of the source tree.
However, user provided signing keys are overwritten during build if the last- modified
times on the key pair don't align with what make expects. This patch explicitly checks
for the existence of the signing key files, skipping key generation should they exist.

---

kernel/Makefile +3 -0
index 1408b33..6b8f292 100644
@@ -168,6 +168,9 @@ ifndef CONFIG_MODULE_SIG_HASH
 $(error Could not determine digest type to use from kernel config)
 endif
 
+ifneq ("$(wildcard $(srctree)/signing_key.priv)","")
+ifneq ("$(wildcard $(srctree)/signing_key.x509)","")
+$(warning *** X.509 module signing key pair not found in root of source tree 
 ***)
 signing_key.priv signing_key.x509: x509.genkey
        @echo "###"

@echo "### Now generating an X.509 key pair to be used for signing
modules."

kernel/Makefile +2 -0
@@ -184,6 +187,8 @@ signing_key.priv signing_key.x509: x509.genkey
        @echo "###"
        @echo "### Key pair generated."
        @echo "###"
+endif
+endif
 
 x509.genkey:
        @echo Generating X.509 key generation config