Skip to contentSkip to conversation

crypto: ecdsa - Fix module auto-load on add-key

PATCH In review Stefan Berger 3 participants 3 messages Mar 21, 2024 – Mar 28, 2024

Subsystems (3)
lore
Share & tools
lore

Stefan Berger

author reviewer
#0 lore raw

PATCH 1/1 crypto: ecdsa - Fix module auto-load on add-key

Add module alias with the algorithm cra_name similar to what we have for RSA-related and other algorithms.

The kernel attempts to modprobe asymmetric algorithms using the names "crypto-$cra_name" and "crypto-$cra_name-all." However, since these aliases are currently missing, the modules are not loaded. For instance, when using the add_key function, the hash algorithm is typically loaded automatically, but the asymmetric algorithm is not.

Steps to test:

1. Create certificate

  openssl req -x509 -sha256 -newkey ec \
  -pkeyopt "ec_paramgen_curve:secp384r1" -keyout key.pem -days 365 \
  -subj '/CN=test' -nodes -outform der -out nist-p384.der

2. Optionally, trace module requests with: trace-cmd stream -e module &

3. Trigger add_key call for the cert:

   # keyctl padd asymmetric "" @u < nist-p384.der
   641069229
   # lsmod | head -2
   Module                  Size  Used by
   ecdsa_generic          16384  0
Fixes c12d448ba939 ("crypto: ecdsa - Register NIST P384 and extend test suite")
---
 crypto/ecdsa.c | 3 +++
 1 file changed, 3 insertions(+)
crypto/ecdsa.c +3 -0
index fbd76498aba8..3f9ec273a121 100644
@@ -373,4 +373,7 @@ module_exit(ecdsa_exit);
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Stefan Berger <[email protected]>");
 MODULE_DESCRIPTION("ECDSA generic algorithm");
+MODULE_ALIAS_CRYPTO("ecdsa-nist-p192");
+MODULE_ALIAS_CRYPTO("ecdsa-nist-p256");
+MODULE_ALIAS_CRYPTO("ecdsa-nist-p384");
 MODULE_ALIAS_CRYPTO("ecdsa-generic");
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 27 lines · Stefan Berger

Add module alias with the algorithm cra_name similar to what we have for RSA-related and other algorithms.

The kernel attempts to modprobe asymmetric algorithms using the names "crypto-$cra_name" and "crypto-$cra_name-all." However, since these aliases are currently missing, the modules are not loaded. For instance, when using the add_key function, the hash algorithm is typically loaded automatically, but the asymmetric algorithm is not.

Steps to test:

1. Create certificate

  openssl req -x509 -sha256 -newkey ec \
  -pkeyopt "ec_paramgen_curve:secp384r1" -keyout key.pem -days 365 \
  -subj '/CN=test' -nodes -outform der -out nist-p384.der

2. Optionally, trace module requests with: trace-cmd stream -e module &

3. Trigger add_key call for the cert:

   # keyctl padd asymmetric "" @u < nist-p384.der
   641069229
   # lsmod | head -2
   Module                  Size  Used by
   ecdsa_generic          16384  0
Quoted 3 lines
Fixes c12d448ba939 ("crypto: ecdsa - Register NIST P384 and extend test suite")
Quoted 18 lines
---
 crypto/ecdsa.c | 3 +++
 1 file changed, 3 insertions(+)
crypto/ecdsa.c +3 -0
index fbd76498aba8..3f9ec273a121 100644
@@ -373,4 +373,7 @@ module_exit(ecdsa_exit);
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Stefan Berger <[email protected]>");
 MODULE_DESCRIPTION("ECDSA generic algorithm");
+MODULE_ALIAS_CRYPTO("ecdsa-nist-p192");
+MODULE_ALIAS_CRYPTO("ecdsa-nist-p256");
+MODULE_ALIAS_CRYPTO("ecdsa-nist-p384");
 MODULE_ALIAS_CRYPTO("ecdsa-generic");
Signature · 1 line
2.43.0
maintainer
#2 lore raw
In reply to Stefan Berger
Quoted 27 lines · Stefan Berger

Add module alias with the algorithm cra_name similar to what we have for RSA-related and other algorithms.

The kernel attempts to modprobe asymmetric algorithms using the names "crypto-$cra_name" and "crypto-$cra_name-all." However, since these aliases are currently missing, the modules are not loaded. For instance, when using the add_key function, the hash algorithm is typically loaded automatically, but the asymmetric algorithm is not.

Steps to test:

1. Create certificate

  openssl req -x509 -sha256 -newkey ec \
  -pkeyopt "ec_paramgen_curve:secp384r1" -keyout key.pem -days 365 \
  -subj '/CN=test' -nodes -outform der -out nist-p384.der

2. Optionally, trace module requests with: trace-cmd stream -e module &

3. Trigger add_key call for the cert:

   # keyctl padd asymmetric "" @u < nist-p384.der
   641069229
   # lsmod | head -2
   Module                  Size  Used by
   ecdsa_generic          16384  0
Quoted 6 lines
Fixes c12d448ba939 ("crypto: ecdsa - Register NIST P384 and extend test suite")
---
 crypto/ecdsa.c | 3 +++
 1 file changed, 3 insertions(+)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt