From 3e80b1a6576a89d4e4cd77668e1af98e317d6148 Mon Sep 17 00:00:00 2001 From: Andrzej Kurek Date: Mon, 7 Dec 2020 07:01:22 -0500 Subject: [PATCH] Fix compilation errors when building sign_with_k test function Signed-off-by: Andrzej Kurek --- include/tinycrypt/ecc_dsa.h | 2 +- scripts/baremetal.sh | 8 ++++---- tests/scripts/all.sh | 4 ++-- tests/suites/test_suite_tinycrypt.function | 3 +-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/include/tinycrypt/ecc_dsa.h b/include/tinycrypt/ecc_dsa.h index 0001ecb2d..30cbe5eef 100644 --- a/include/tinycrypt/ecc_dsa.h +++ b/include/tinycrypt/ecc_dsa.h @@ -115,7 +115,7 @@ int uECC_sign(const uint8_t *p_private_key, const uint8_t *p_message_hash, * Refer to uECC_sign() function for real applications. */ int uECC_sign_with_k(const uint8_t *private_key, const uint8_t *message_hash, - unsigned int hash_size, uECC_word_t *k, uint8_t *signature) + unsigned int hash_size, uECC_word_t *k, uint8_t *signature); #endif /** diff --git a/scripts/baremetal.sh b/scripts/baremetal.sh index 53ccedbb0..e2c0338d1 100755 --- a/scripts/baremetal.sh +++ b/scripts/baremetal.sh @@ -97,7 +97,7 @@ baremetal_build_gcc() if [ $check -ne 0 ]; then CFLAGS_BAREMETAL="$CFLAGS_BAREMETAL -Werror" fi - CFLAGS="$CFLAGS_BAREMETAL $CFLAGS_CONFIG" + CFLAGS="$CFLAGS_BAREMETAL $CFLAGS_CONFIG -DENABLE_TESTS" echo "GCC version: $gcc_ver" echo "Flags: $CFLAGS_BAREMETAL" @@ -132,7 +132,7 @@ baremetal_build_armc5() fi CFLAGS_BAREMETAL="$OPTIM_CFLAGS_ARMC5 --thumb --cpu Cortex-m0plus" - CFLAGS="$CFLAGS_BAREMETAL $CFLAGS_CONFIG" + CFLAGS="$CFLAGS_BAREMETAL $CFLAGS_CONFIG -DENABLE_TESTS" WARNING_CFLAGS="--strict --c99" if [ $check -ne 0 ]; then @@ -175,7 +175,7 @@ baremetal_build_armc6() if [ $check -ne 0 ]; then CFLAGS_BAREMETAL="$CFLAGS_BAREMETAL -Werror" fi - CFLAGS="$CFLAGS_BAREMETAL $CFLAGS_CONFIG" + CFLAGS="$CFLAGS_BAREMETAL $CFLAGS_CONFIG -DENABLE_TESTS" echo "ARMC6 version: $armc6_ver" echo "Flags: $CFLAGS_BAREMETAL" @@ -204,7 +204,7 @@ baremetal_ram_build() { echo "Cleanup..." make clean - CFLAGS="$BASE_CFLAGS $CFLAGS_CONFIG $CFLAGS_USER_CONFIG" + CFLAGS="$BASE_CFLAGS $CFLAGS_CONFIG $CFLAGS_USER_CONFIG -DENABLE_TESTS" if [ "$build_only" -eq 1 ]; then CFLAGS="$CFLAGS -Werror" fi diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index a8747c2a0..a770f6d5b 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -1765,7 +1765,7 @@ component_test_default_tinycrypt_without_legacy_ecc () { scripts/config.pl unset MBEDTLS_ECP_DP_SECP192K1_ENABLED scripts/config.pl unset MBEDTLS_ECP_DP_SECP224K1_ENABLED scripts/config.pl unset MBEDTLS_ECP_DP_SECP256K1_ENABLED - make CC=gcc CFLAGS='-Werror -Wall -Wextra' + make CC=gcc CFLAGS='-Werror -Wall -Wextra -DENABLE_TESTS' msg "test: default config with tinycrypt enabled and legacy ECC disabled" make test @@ -1813,7 +1813,7 @@ component_test_hardcoded_pk_type () { scripts/config.pl unset MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED scripts/config.pl unset MBEDTLS_KEY_EXCHANGE_RSA_ENABLED scripts/config.pl unset MBEDTLS_X509_RSASSA_PSS_SUPPORT - make CFLAGS='-Werror -O1' + make CFLAGS='-Werror -O1 -DENABLE_TESTS' msg "test: default config + single PK type harcoded (tinycrypt)" make test diff --git a/tests/suites/test_suite_tinycrypt.function b/tests/suites/test_suite_tinycrypt.function index 91d29bf52..ac3492941 100644 --- a/tests/suites/test_suite_tinycrypt.function +++ b/tests/suites/test_suite_tinycrypt.function @@ -60,7 +60,6 @@ void test_ecdsa() /* BEGIN_CASE depends_on:MBEDTLS_USE_TINYCRYPT */ void ecdh_primitive_vector( data_t * qx_str, data_t * qy_str, data_t * d_str, data_t * z_str ) - { uint8_t public[2*NUM_ECC_BYTES] = {0}; uint8_t private[NUM_ECC_BYTES] = {0}; @@ -138,7 +137,7 @@ void ecdsa_sig( data_t * message, data_t * d_str, data_t * k_str, k[i] = k_str->x[NUM_ECC_BYTES - i - 1]; } TEST_ASSERT( mbedtls_sha256_ret( message->x, message->len, hash, 0 ) == 0 ); - TEST_ASSERT( uECC_sign_with_k( d_str->x, hash, sizeof(hash), k, + TEST_ASSERT( uECC_sign_with_k( d_str->x, hash, sizeof(hash), (uECC_word_t*) k, sig_bytes ) == UECC_SUCCESS ); TEST_ASSERT( memcmp( sig_bytes, r_str->x, NUM_ECC_BYTES) == 0 ); TEST_ASSERT( memcmp( sig_bytes + NUM_ECC_BYTES, s_str->x, NUM_ECC_BYTES ) == 0 );