Skip to content

Commit e6da87c

Browse files
stefanbergersmb49
authored andcommitted
certs: Trigger creation of RSA module signing key if it's not an RSA key
BugLink: https://bugs.launchpad.net/bugs/1946788 [ 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 fabacf1 commit e6da87c

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

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

0 commit comments

Comments
 (0)