mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-08 17:42:09 +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:
@@ -1085,7 +1085,7 @@ cleanup:
|
||||
mbedtls_mpi_free( &I );
|
||||
|
||||
if( ret != 0 && ret >= -0x007f )
|
||||
return( MBEDTLS_ERR_RSA_PRIVATE_FAILED + ret );
|
||||
return( MBEDTLS_ERR_ADD( MBEDTLS_ERR_RSA_PRIVATE_FAILED, ret ) );
|
||||
|
||||
return( ret );
|
||||
}
|
||||
|
Reference in New Issue
Block a user