lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240223204149.4055630-7-stefanb@linux.ibm.com>
Date: Fri, 23 Feb 2024 15:41:45 -0500
From: Stefan Berger <stefanb@...ux.ibm.com>
To: keyrings@...r.kernel.org, linux-crypto@...r.kernel.org,
        herbert@...dor.apana.org.au, davem@...emloft.net
Cc: linux-kernel@...r.kernel.org, saulo.alessandre@....jus.br,
        Stefan Berger <stefanb@...ux.ibm.com>
Subject: [PATCH v3 06/10] crypte: ecc - Implement ecc_curve_get_nbits to get number of bits

If curve->nbits is set then return this number, otherwise use
the curve->ndigits to calculate the number of bits.

Signed-off-by: Stefan Berger <stefanb@...ux.ibm.com>
---
 include/crypto/internal/ecc.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/include/crypto/internal/ecc.h b/include/crypto/internal/ecc.h
index b8ca5023b3b5..2d321b47d0f7 100644
--- 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;
+}
+
 /**
  * ecc_is_key_valid() - Validate a given ECDH private key
  *
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ