Make it easier to define MBEDTLS_PARAM_FAILED as assert

Introduce a new configuration option MBEDTLS_CHECK_PARAMS_ASSERT,
which is disabled by default. When this option is enabled,
MBEDTLS_PARAM_FAILED defaults to assert rather than to a call to
mbedtls_param_failed, and <assert.h> is included.

This fixes #2671 (no easy way to make MBEDTLS_PARAM_FAILED assert)
without breaking backward compatibility. With this change,
`config.pl full` runs tests with MBEDTLS_PARAM_FAILED set to assert,
so the tests will fail if a validation check fails, and programs don't
need to provide their own definition of mbedtls_param_failed().
This commit is contained in:
Gilles Peskine 2019-06-13 16:44:19 +02:00
parent 137d31bf5a
commit 30346f639e
5 changed files with 73 additions and 19 deletions

View file

@ -274,6 +274,14 @@ int query_config( const char *config )
}
#endif /* MBEDTLS_CHECK_PARAMS */
#if defined(MBEDTLS_CHECK_PARAMS_ASSERT)
if( strcmp( "MBEDTLS_CHECK_PARAMS_ASSERT", config ) == 0 )
{
MACRO_EXPANSION_TO_STR( MBEDTLS_CHECK_PARAMS_ASSERT );
return( 0 );
}
#endif /* MBEDTLS_CHECK_PARAMS_ASSERT */
#if defined(MBEDTLS_TIMING_ALT)
if( strcmp( "MBEDTLS_TIMING_ALT", config ) == 0 )
{