Add tests of deprecated PSA macros
When MBEDTLS_TEST_DEPRECATED is defined, run some additional tests to validate deprecated PSA macros. We don't need to test deprecated features extensively, but we should at least ensure that they don't break the build. Add some code to component_build_deprecated in all.sh to run these tests with MBEDTLS_DEPRECATED_WARNING enabled. The tests are also executed when MBEDTLS_DEPRECATED_WARNING and MBEDTLS_DEPRECATED_REMOVED are both disabled.
This commit is contained in:
parent
1a96049e30
commit
841b14be02
3 changed files with 26 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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:
|
||||
;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue