mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-30 22:43:08 +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:
@ -210,6 +210,13 @@
|
||||
#include "mbedtls/xtea.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_TEST_HOOKS)
|
||||
int mbedtls_err_add( int high, int low, const char *file, int line ) {
|
||||
if( mbedtls_test_err_add_hook != NULL )
|
||||
(*mbedtls_test_err_add_hook)( high, low, file, line );
|
||||
return ( high + low );
|
||||
}
|
||||
#endif
|
||||
|
||||
const char * mbedtls_high_level_strerr( int error_code )
|
||||
{
|
||||
|
Reference in New Issue
Block a user