From 82823b2fe88b2a38b698a59b1645dd68326ae5f3 Mon Sep 17 00:00:00 2001 From: Janos Follath Date: Thu, 27 Jul 2023 12:25:05 +0100 Subject: [PATCH] Fix new bignum tests These tests weren't working, because they use CMake and can't pass options with CFLAGS directly. This could be mitigated by adding a CMake option, but using config.py is less invasive and it is what we normally use for setting build options anyway. Signed-off-by: Janos Follath --- library/ecp_invasive.h | 13 ++++++++----- tests/scripts/all.sh | 12 ++++++++---- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/library/ecp_invasive.h b/library/ecp_invasive.h index db9dee3f47..0c6858a40a 100644 --- a/library/ecp_invasive.h +++ b/library/ecp_invasive.h @@ -31,6 +31,14 @@ #include "bignum_mod.h" #include "mbedtls/ecp.h" +/* + * Turning this option on enables using the new bignum code in the ECC modules. + * + * WARNING: ECC implementation using the new bignum code is a work in progress, + * this option serves only development and testing purposes. + */ +//#define MBEDTLS_ECP_WITH_MPI_UINT + /* * Curve modulus types */ @@ -40,11 +48,6 @@ typedef enum { MBEDTLS_ECP_MOD_SCALAR } mbedtls_ecp_modulus_type; -/* Provide a commented-out definition so that `check_names.py` knows that - * it's not a typo. - */ -//#define MBEDTLS_ECP_WITH_MPI_UINT - typedef enum { MBEDTLS_ECP_VARIANT_NONE = 0, MBEDTLS_ECP_VARIANT_WITH_MPI_STRUCT, diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index b6f6b600c8..71e2332a7e 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -134,13 +134,14 @@ pre_initialize_variables () { CONFIG_H='include/mbedtls/mbedtls_config.h' CRYPTO_CONFIG_H='include/psa/crypto_config.h' CONFIG_TEST_DRIVER_H='tests/include/test/drivers/config_test_driver.h' + CONFIG_NEW_BIGNUM_H='library/ecp_invasive.h' # Files that are clobbered by some jobs will be backed up. Use a different # suffix from auxiliary scripts so that all.sh and auxiliary scripts can # independently decide when to remove the backup file. backup_suffix='.all.bak' # Files clobbered by config.py - files_to_back_up="$CONFIG_H $CRYPTO_CONFIG_H $CONFIG_TEST_DRIVER_H" + files_to_back_up="$CONFIG_H $CRYPTO_CONFIG_H $CONFIG_TEST_DRIVER_H $CONFIG_NEW_BIGNUM_H" # Files clobbered by in-tree cmake files_to_back_up="$files_to_back_up Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile" @@ -1028,8 +1029,9 @@ component_test_default_cmake_gcc_asan () { component_test_default_cmake_gcc_asan_new_bignum () { msg "build: cmake, gcc, ASan" # ~ 1 min 50s + scripts/config.py -f "$CONFIG_NEW_BIGNUM_H" set MBEDTLS_ECP_WITH_MPI_UINT CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . - make CFLAGS="-D MBEDTLS_ECP_WITH_MPI_UINT" + make msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s make test @@ -1086,8 +1088,9 @@ component_test_full_cmake_gcc_asan () { component_test_full_cmake_gcc_asan_new_bignum () { msg "build: full config, cmake, gcc, ASan" scripts/config.py full + scripts/config.py -f "$CONFIG_NEW_BIGNUM_H" set MBEDTLS_ECP_WITH_MPI_UINT CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . - make CFLAGS="-D MBEDTLS_ECP_WITH_MPI_UINT" + make msg "test: main suites (inc. selftests) (full config, ASan build)" make test @@ -1122,8 +1125,9 @@ component_test_full_cmake_gcc_asan_new_bignum_test_hooks () { msg "build: full config, cmake, gcc, ASan" scripts/config.py full scripts/config.py set MBEDTLS_TEST_HOOKS + scripts/config.py -f "$CONFIG_NEW_BIGNUM_H" set MBEDTLS_ECP_WITH_MPI_UINT CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . - make CFLAGS="-DMBEDTLS_ECP_WITH_MPI_UINT" + make msg "test: main suites (inc. selftests) (full config, ASan build)" make test