Skip to content

Commit

Permalink
crypto: ecdsa - Fix module auto-load on add-key
Browse files Browse the repository at this point in the history
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: c12d448 ("crypto: ecdsa - Register NIST P384 and extend test suite")
Cc: [email protected]
Signed-off-by: Stefan Berger <[email protected]>
Reviewed-by: Vitaly Chikunov <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
stefanberger authored and herbertx committed Apr 2, 2024
1 parent dbad7b6 commit 48e4fd6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crypto/ecdsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");

0 comments on commit 48e4fd6

Please sign in to comment.