Skip to content

Commit e810725

Browse files
stefanbergerKelsey Skunberg
authored andcommitted
certs: Trigger creation of RSA module signing key if it's not an RSA key
BugLink: https://bugs.launchpad.net/bugs/1946024 [ Upstream commit ea35e0d ] 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]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Kamal Mostafa <[email protected]> Signed-off-by: Kelsey Skunberg <[email protected]>
1 parent 15ba02f commit e810725

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
@@ -46,11 +46,19 @@ endif
4646
redirect_openssl = 2>&1
4747
quiet_redirect_openssl = 2>&1
4848
silent_redirect_openssl = 2>/dev/null
49+
openssl_available = $(shell openssl help 2>/dev/null && echo yes)
4950

5051
# We do it this way rather than having a boolean option for enabling an
5152
# external private key, because 'make randconfig' might enable such a
5253
# boolean option and we unfortunately can't make it depend on !RANDCONFIG.
5354
ifeq ($(CONFIG_MODULE_SIG_KEY),"certs/signing_key.pem")
55+
56+
ifeq ($(openssl_available),yes)
57+
X509TEXT=$(shell openssl x509 -in "certs/signing_key.pem" -text 2>/dev/null)
58+
59+
$(if $(findstring rsaEncryption,$(X509TEXT)),,$(shell rm -f "certs/signing_key.pem"))
60+
endif
61+
5462
$(obj)/signing_key.pem: $(obj)/x509.genkey
5563
@$(kecho) "###"
5664
@$(kecho) "### Now generating an X.509 key pair to be used for signing modules."

0 commit comments

Comments
 (0)