mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-24 00:06:32 +01:00
Fix RSA mutex fix
Once the mutex is acquired, we must goto cleanup rather that return. Since cleanup adjusts the return value, adjust that in test cases. Also, at cleanup we don't want to overwrite 'ret', or we'll loose track of errors. see #257
This commit is contained in:
parent
6a6619b24b
commit
4d04cdcd12
2 changed files with 11 additions and 11 deletions
|
|
@ -283,8 +283,8 @@ int mbedtls_rsa_public( mbedtls_rsa_context *ctx,
|
|||
|
||||
if( mbedtls_mpi_cmp_mpi( &T, &ctx->N ) >= 0 )
|
||||
{
|
||||
mbedtls_mpi_free( &T );
|
||||
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
|
||||
ret = MBEDTLS_ERR_MPI_BAD_INPUT_DATA;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
olen = ctx->len;
|
||||
|
|
@ -293,8 +293,8 @@ int mbedtls_rsa_public( mbedtls_rsa_context *ctx,
|
|||
|
||||
cleanup:
|
||||
#if defined(MBEDTLS_THREADING_C)
|
||||
if( ( ret = mbedtls_mutex_unlock( &ctx->mutex ) ) != 0 )
|
||||
return( ret );
|
||||
if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 )
|
||||
return( MBEDTLS_ERR_THREADING_MUTEX_ERROR );
|
||||
#endif
|
||||
|
||||
mbedtls_mpi_free( &T );
|
||||
|
|
@ -368,8 +368,8 @@ int mbedtls_rsa_private( mbedtls_rsa_context *ctx,
|
|||
MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( &T, input, ctx->len ) );
|
||||
if( mbedtls_mpi_cmp_mpi( &T, &ctx->N ) >= 0 )
|
||||
{
|
||||
mbedtls_mpi_free( &T );
|
||||
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
|
||||
ret = MBEDTLS_ERR_MPI_BAD_INPUT_DATA;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if( f_rng != NULL )
|
||||
|
|
@ -424,8 +424,8 @@ int mbedtls_rsa_private( mbedtls_rsa_context *ctx,
|
|||
|
||||
cleanup:
|
||||
#if defined(MBEDTLS_THREADING_C)
|
||||
if( ( ret = mbedtls_mutex_unlock( &ctx->mutex ) ) != 0 )
|
||||
return( ret );
|
||||
if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 )
|
||||
return( MBEDTLS_ERR_THREADING_MUTEX_ERROR );
|
||||
#endif
|
||||
|
||||
mbedtls_mpi_free( &T ); mbedtls_mpi_free( &T1 ); mbedtls_mpi_free( &T2 );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue