All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: ecdsa - Fix module auto-load on add-key
@ 2024-03-21 14:44 Stefan Berger
  2024-03-22 22:27 ` Vitaly Chikunov
  2024-03-28 10:56 ` Herbert Xu
  0 siblings, 2 replies; 3+ messages in thread
From: Stefan Berger @ 2024-03-21 14:44 UTC (permalink / raw
  To: linux-crypto, herbert, davem
  Cc: linux-kernel, saulo.alessandre, vt, Stefan Berger, stable

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")
Cc: stable@vger.kernel.org
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
---
 crypto/ecdsa.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/crypto/ecdsa.c b/crypto/ecdsa.c
index fbd76498aba8..3f9ec273a121 100644
--- a/crypto/ecdsa.c
+++ b/crypto/ecdsa.c
@@ -373,4 +373,7 @@ module_exit(ecdsa_exit);
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Stefan Berger <stefanb@linux.ibm.com>");
 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");
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] crypto: ecdsa - Fix module auto-load on add-key
  2024-03-21 14:44 [PATCH] crypto: ecdsa - Fix module auto-load on add-key Stefan Berger
@ 2024-03-22 22:27 ` Vitaly Chikunov
  2024-03-28 10:56 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Vitaly Chikunov @ 2024-03-22 22:27 UTC (permalink / raw
  To: Stefan Berger
  Cc: linux-crypto, herbert, davem, linux-kernel, saulo.alessandre

On Thu, Mar 21, 2024 at 10:44:33AM -0400, Stefan Berger wrote:
> 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")
> Cc: stable@vger.kernel.org
> Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>

Reviewed-by: Vitaly Chikunov <vt@altlinux.org>

> ---
>  crypto/ecdsa.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/crypto/ecdsa.c b/crypto/ecdsa.c
> index fbd76498aba8..3f9ec273a121 100644
> --- a/crypto/ecdsa.c
> +++ b/crypto/ecdsa.c
> @@ -373,4 +373,7 @@ module_exit(ecdsa_exit);
>  MODULE_LICENSE("GPL");
>  MODULE_AUTHOR("Stefan Berger <stefanb@linux.ibm.com>");
>  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");
> -- 
> 2.43.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] crypto: ecdsa - Fix module auto-load on add-key
  2024-03-21 14:44 [PATCH] crypto: ecdsa - Fix module auto-load on add-key Stefan Berger
  2024-03-22 22:27 ` Vitaly Chikunov
@ 2024-03-28 10:56 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2024-03-28 10:56 UTC (permalink / raw
  To: Stefan Berger
  Cc: linux-crypto, davem, linux-kernel, saulo.alessandre, vt, stable

On Thu, Mar 21, 2024 at 10:44:33AM -0400, Stefan Berger wrote:
> 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")
> Cc: stable@vger.kernel.org
> Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
> ---
>  crypto/ecdsa.c | 3 +++
>  1 file changed, 3 insertions(+)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-28 10:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-21 14:44 [PATCH] crypto: ecdsa - Fix module auto-load on add-key Stefan Berger
2024-03-22 22:27 ` Vitaly Chikunov
2024-03-28 10:56 ` Herbert Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.