[RFC PATCH 0/3] Introduce ecc_digits_to_bytes and clean up ecdh.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux