From 7c51451cce78da5e467e54d6137d1dbd2a88e69d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Thu, 6 Jan 2022 12:20:48 +0100 Subject: [PATCH] Tune coverage of ecc-heap.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Include more curves. For example, the Brainpool curves don't have dedicated "mod p" reduction routines, so they have a much larger number of allocs (comparable to the NIST curves with `MBEDTLS_ECP_NIST_OPTIM` disabled). On the other hand, to keep the script's running time reasonable, remove a few things: - curves smaller than 256 bits (out of favour these days) - window sizes larger than the default: 6 was particularly useless as it's never selected by the current code; 5 can only be selected with curves >= 384 and is unlikely to be used in practice as it increases heap usage quite a lot for very little performance gain. Signed-off-by: Manuel Pégourié-Gonnard --- scripts/ecc-heap.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/ecc-heap.sh b/scripts/ecc-heap.sh index d0032777a..43fc7dfa1 100755 --- a/scripts/ecc-heap.sh +++ b/scripts/ecc-heap.sh @@ -61,12 +61,19 @@ cat << EOF >$CONFIG_H #define MBEDTLS_SHA224_C // SHA256 requires this for now #define MBEDTLS_ECDH_C -#define MBEDTLS_ECP_DP_SECP192R1_ENABLED -#define MBEDTLS_ECP_DP_SECP224R1_ENABLED +// NIST curves >= 256 bits #define MBEDTLS_ECP_DP_SECP256R1_ENABLED #define MBEDTLS_ECP_DP_SECP384R1_ENABLED #define MBEDTLS_ECP_DP_SECP521R1_ENABLED +// SECP "koblitz-like" curve >= 256 bits +#define MBEDTLS_ECP_DP_SECP256K1_ENABLED +// Brainpool curves (no specialised "mod p" routine) +#define MBEDTLS_ECP_DP_BP256R1_ENABLED +#define MBEDTLS_ECP_DP_BP384R1_ENABLED +#define MBEDTLS_ECP_DP_BP512R1_ENABLED +// Montgomery curves #define MBEDTLS_ECP_DP_CURVE25519_ENABLED +#define MBEDTLS_ECP_DP_CURVE448_ENABLED #define MBEDTLS_HAVE_ASM // just make things a bit faster #define MBEDTLS_ECP_NIST_OPTIM // faster and less allocations @@ -76,7 +83,7 @@ cat << EOF >$CONFIG_H EOF for F in 0 1; do - for W in 2 3 4 5 6; do + for W in 2 3 4; do scripts/config.py set MBEDTLS_ECP_WINDOW_SIZE $W scripts/config.py set MBEDTLS_ECP_FIXED_POINT_OPTIM $F make benchmark >/dev/null 2>&1