mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Add macro for error code addition
Adds a macro (`MBEDTLS_ERR_ADD`) to add error codes together and check that the result will not be corrupted. This additional check is only enabled during testing when `MBEDTLS_TEST_HOOKS` is defined. Also includes a reference usage example in `rsa.c` where two high-level error codes could be incorrectly added together under the right conditions. This now ensures that when this error occurs during testing it will be correctly reported. Signed-off-by: Chris Jones <christopher.jones@arm.com>
This commit is contained in:
@ -278,4 +278,14 @@ void mbedtls_test_mutex_usage_init( void );
|
||||
void mbedtls_test_mutex_usage_check( void );
|
||||
#endif /* MBEDTLS_TEST_MUTEX_USAGE */
|
||||
|
||||
#if defined(MBEDTLS_TEST_HOOKS)
|
||||
/**
|
||||
* \brief Check that a pure high-level error code is being combined with a
|
||||
* pure low-level error code as otherwise the resultant error code
|
||||
* would be corrupted.
|
||||
*/
|
||||
void mbedtls_test_err_add_check( int high, int low,
|
||||
const char *file, int line);
|
||||
#endif
|
||||
|
||||
#endif /* TEST_HELPERS_H */
|
||||
|
Reference in New Issue
Block a user