]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
crypto: ecrdsa - fix unknown OID check in ecrdsa_param_curve
authorThorsten Blum <thorsten.blum@linux.dev>
Sat, 2 May 2026 19:09:04 +0000 (21:09 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 7 May 2026 08:10:03 +0000 (16:10 +0800)
The ->curve_oid check in ecrdsa_param_curve() rejects the valid enum
value 0 (OID_id_dsa_with_sha1), but look_up_OID() returns OID__NR on
lookup failure. Compare ->curve_oid with OID__NR instead to ensure that
only unknown OIDs return -EINVAL.

Fixes: 0d7a78643f69 ("crypto: ecrdsa - add EC-RDSA (GOST 34.10) algorithm")
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Lukas Wunner <lukas@wunner.de>
Reviewed-by: Vitaly Chikunov <vt@altlinux.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/ecrdsa.c

index 2c0602f0cd406f56a7b0be3ad9f50cbcdf6858eb..0cd7eb3676041ff4ee23d9e7030b400c67fb1d21 100644 (file)
@@ -145,7 +145,7 @@ int ecrdsa_param_curve(void *context, size_t hdrlen, unsigned char tag,
        struct ecrdsa_ctx *ctx = context;
 
        ctx->curve_oid = look_up_OID(value, vlen);
-       if (!ctx->curve_oid)
+       if (ctx->curve_oid == OID__NR)
                return -EINVAL;
        ctx->curve = get_curve_by_oid(ctx->curve_oid);
        return 0;