public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/3] Introduce ecc_digits_to_bytes and clean up ecdh.c
@ 2024-06-12 15:18 Stefan Berger
  2024-06-12 15:18 ` [RFC PATCH 1/3] crypto: ecc - Implement ecc_digits_to_bytes to convert digits to byte array Stefan Berger
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Stefan Berger @ 2024-06-12 15:18 UTC (permalink / raw)
  To: keyrings, linux-crypto, herbert, davem
  Cc: linux-kernel, saulo.alessandre, ardb, Stefan Berger

This series introduces ecc_digits_to_bytes to convert an array of digits
to bytes and uses this function and ecc_digits_from_bytes in ecdh-related
code to convert between byte arrays and digits. Using these functions is
generally better than using ecc_swap_digits. The latter cannot be used with
curves like NIST P521 since it does not properly handle curves that do not
use all bytes in the most significant digit.

It also introduces ecc_curve_get_nbytes to get the number of bytes (nbytes)
a curve needs for its coordinates. It derives this number from the nbits
parameter of a curve. Using this function is also generally better than
deriving nbytes from ndigits, which does not work correctly vor NIST P521.

None of the converted functions have been used with NIST P521 but only
with NIST P192/256/384 so far, so they work fine as they are.

Due to concerns related to constant time operations when signing with EC
private keys I am not planning to add NIST P521 support to ecdh, so the
changes in this series are primarly 'code improvements' (-> RFC).

   Stefan

Stefan Berger (3):
  crypto: ecc - Implement ecc_digits_to_bytes to convert digits to byte
    array
  crypto: ecc - Implement and use ecc_curve_get_nbytes to get curve's
    nbytes
  crypto: ecdh - Use functions to copy digits from and to byte arrays

 crypto/ecc.c                  | 47 ++++++++++++++++++++++++-----------
 crypto/ecdh.c                 | 24 +++++++++++-------
 include/crypto/internal/ecc.h | 37 ++++++++++++++++++++++-----
 3 files changed, 79 insertions(+), 29 deletions(-)

-- 
2.43.0


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

end of thread, other threads:[~2024-06-12 15:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-12 15:18 [RFC PATCH 0/3] Introduce ecc_digits_to_bytes and clean up ecdh.c Stefan Berger
2024-06-12 15:18 ` [RFC PATCH 1/3] crypto: ecc - Implement ecc_digits_to_bytes to convert digits to byte array Stefan Berger
2024-06-12 15:18 ` [RFC PATCH 2/3] crypto: ecc - Implement and use ecc_curve_get_nbytes to get curve's nbytes Stefan Berger
2024-06-12 15:19 ` [RFC PATCH 3/3] crypto: ecdh - Use functions to copy digits from and to byte arrays Stefan Berger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox