[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240227201552.GA32765@wunner.de>
Date: Tue, 27 Feb 2024 21:15:52 +0100
From: Lukas Wunner <lukas@...ner.de>
To: Stefan Berger <stefanb@...ux.ibm.com>
Cc: keyrings@...r.kernel.org, linux-crypto@...r.kernel.org,
herbert@...dor.apana.org.au, davem@...emloft.net,
linux-kernel@...r.kernel.org, saulo.alessandre@....jus.br
Subject: Re: [PATCH v3 06/10] crypte: ecc - Implement ecc_curve_get_nbits to
get number of bits
On Fri, Feb 23, 2024 at 03:41:45PM -0500, Stefan Berger wrote:
> --- a/include/crypto/internal/ecc.h
> +++ b/include/crypto/internal/ecc.h
> @@ -75,6 +75,17 @@ static inline void ecc_digits_from_bytes(const u8 *in, unsigned int nbytes,
> ecc_swap_digits(tmp, out, ndigits);
> }
>
> +/**
> + * ecc_curve_get_nbits() - Get the number of bits of the curve
> + * @curve: The curve
> + */
> +static inline unsigned int ecc_curve_get_nbits(const struct ecc_curve *curve)
> +{
> + if (curve->nbits)
> + return curve->nbits;
> + return curve->g.ndigits << ECC_DIGITS_TO_BYTES_SHIFT * 8;
> +}
Since you're amending struct ecc_curve with an extra nbits value anyway,
why not statically fill it in for all curves, instead of adding this
extra complexity in the code?
Thanks,
Lukas
Powered by blists - more mailing lists