Skip to content

Commit ea35e0d

Browse files
stefanbergerjarkkojs
authored andcommitted
certs: Trigger creation of RSA module signing key if it's not an RSA key
Address a kbuild issue where a developer created an ECDSA key for signing kernel modules and then builds an older version of the kernel, when bi- secting the kernel for example, that does not support ECDSA keys. If openssl is installed, trigger the creation of an RSA module signing key if it is not an RSA key. Fixes: cfc411e ("Move certificate handling to its own directory") Cc: David Howells <[email protected]> Cc: David Woodhouse <[email protected]> Signed-off-by: Stefan Berger <[email protected]> Reviewed-by: Jarkko Sakkinen <[email protected]> Tested-by: Jarkko Sakkinen <[email protected]> Signed-off-by: Jarkko Sakkinen <[email protected]>
1 parent 6824f85 commit ea35e0d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

certs/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,19 @@ endif
5757
redirect_openssl = 2>&1
5858
quiet_redirect_openssl = 2>&1
5959
silent_redirect_openssl = 2>/dev/null
60+
openssl_available = $(shell openssl help 2>/dev/null && echo yes)
6061

6162
# We do it this way rather than having a boolean option for enabling an
6263
# external private key, because 'make randconfig' might enable such a
6364
# boolean option and we unfortunately can't make it depend on !RANDCONFIG.
6465
ifeq ($(CONFIG_MODULE_SIG_KEY),"certs/signing_key.pem")
66+
67+
ifeq ($(openssl_available),yes)
68+
X509TEXT=$(shell openssl x509 -in "certs/signing_key.pem" -text 2>/dev/null)
69+
70+
$(if $(findstring rsaEncryption,$(X509TEXT)),,$(shell rm -f "certs/signing_key.pem"))
71+
endif
72+
6573
$(obj)/signing_key.pem: $(obj)/x509.genkey
6674
@$(kecho) "###"
6775
@$(kecho) "### Now generating an X.509 key pair to be used for signing modules."

0 commit comments

Comments
 (0)