diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 2567cc0dd..d9e9c82a4 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -715,6 +715,10 @@ component_build_deprecated () { make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' lib programs make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests + msg "test: make, full config + DEPRECATED_WARNING, expect warnings" # ~ 30s + make -C tests clean + make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-error=deprecated-declarations -DMBEDTLS_TEST_DEPRECATED' tests + msg "build: make, full config + DEPRECATED_REMOVED, clang -O" # ~ 30s # No cleanup, just tweak the configuration and rebuild make clean diff --git a/tests/suites/main_test.function b/tests/suites/main_test.function index 5d15f2bbe..6ddfc5927 100644 --- a/tests/suites/main_test.function +++ b/tests/suites/main_test.function @@ -29,6 +29,10 @@ #include "psa/crypto.h" #endif /* MBEDTLS_USE_PSA_CRYPTO */ +#if !defined(MBEDTLS_DEPRECATED_REMOVED) && !defined(MBEDTLS_DEPRECATED_WARNING) +#define MBEDTLS_TEST_DEPRECATED +#endif + /*----------------------------------------------------------------------------*/ /* Common helper code */ diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index d62d3c198..5236b4e2b 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -1164,6 +1164,18 @@ void static_checks( ) * encoding. The shifted mask is the maximum truncated value. The * untruncated algorithm may be one byte larger. */ TEST_ASSERT( PSA_MAC_MAX_SIZE <= 1 + max_truncated_mac_size ); + +#if defined(MBEDTLS_TEST_DEPRECATED) + /* Check deprecated constants. */ + TEST_EQUAL( PSA_ERROR_UNKNOWN_ERROR, PSA_ERROR_GENERIC_ERROR ); + TEST_EQUAL( PSA_ERROR_OCCUPIED_SLOT, PSA_ERROR_ALREADY_EXISTS ); + TEST_EQUAL( PSA_ERROR_EMPTY_SLOT, PSA_ERROR_DOES_NOT_EXIST ); + TEST_EQUAL( PSA_ERROR_INSUFFICIENT_CAPACITY, PSA_ERROR_INSUFFICIENT_DATA ); + TEST_EQUAL( PSA_ERROR_TAMPERING_DETECTED, PSA_ERROR_CORRUPTION_DETECTED ); + TEST_EQUAL( PSA_KEY_USAGE_SIGN, PSA_KEY_USAGE_SIGN_HASH ); + TEST_EQUAL( PSA_KEY_USAGE_VERIFY, PSA_KEY_USAGE_VERIFY_HASH ); + TEST_EQUAL( PSA_ASYMMETRIC_SIGNATURE_MAX_SIZE, PSA_SIGNATURE_MAX_SIZE ); +#endif /* MBEDTLS_TEST_DEPRECATED */ } /* END_CASE */ @@ -3703,7 +3715,13 @@ void signature_size( int type_arg, psa_key_type_t type = type_arg; psa_algorithm_t alg = alg_arg; size_t actual_size = PSA_SIGN_OUTPUT_SIZE( type, bits, alg ); + TEST_EQUAL( actual_size, (size_t) expected_size_arg ); +#if defined(MBEDTLS_TEST_DEPRECATED) + TEST_EQUAL( actual_size, + PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE( type, bits, alg ) ); +#endif /* MBEDTLS_TEST_DEPRECATED */ + exit: ; }