crypto: ecdsa - Replace ndigits with nbits where precision is needed
authorStefan Berger <stefanb@linux.ibm.com>
Thu, 4 Apr 2024 14:18:52 +0000 (10:18 -0400)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 12 Apr 2024 07:07:52 +0000 (15:07 +0800)
Replace the usage of ndigits with nbits where precise space calculations
are needed, such as in ecdsa_max_size where the length of a coordinate is
determined.

Tested-by: Lukas Wunner <lukas@wunner.de>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/ecdsa.c

index 9b84ab5032762cf55bafdfd20d59b7e007affc68..75d3eea885dbb28b43f4aaec15c5f127c02dee75 100644 (file)
@@ -266,7 +266,7 @@ static unsigned int ecdsa_max_size(struct crypto_akcipher *tfm)
 {
        struct ecc_ctx *ctx = akcipher_tfm_ctx(tfm);
 
-       return ctx->pub_key.ndigits << ECC_DIGITS_TO_BYTES_SHIFT;
+       return DIV_ROUND_UP(ctx->curve->nbits, 8);
 }
 
 static int ecdsa_nist_p384_init_tfm(struct crypto_akcipher *tfm)