mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-23 13:55:29 +00:00
Removed recursion from fix #309.
This commit is contained in:
parent
8483e28e21
commit
3fc644f246
|
@ -859,22 +859,21 @@ int mbedtls_mpi_add_abs( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi
|
|||
int ret;
|
||||
size_t i, j;
|
||||
mbedtls_mpi_uint *o, *p, c;
|
||||
mbedtls_mpi TB;
|
||||
|
||||
if( X == B )
|
||||
{
|
||||
B = A; A = X;
|
||||
|
||||
if( B == A )
|
||||
{
|
||||
// Making a temporary copy instead of shifting by one to deny
|
||||
// the possibility of corresponding side-channel attacks.
|
||||
mbedtls_mpi TB;
|
||||
|
||||
mbedtls_mpi_init( &TB );
|
||||
MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &TB, B ) );
|
||||
|
||||
return mbedtls_mpi_add_abs( X, A, &TB );
|
||||
B = &TB;
|
||||
}
|
||||
|
||||
B = A; A = X;
|
||||
}
|
||||
|
||||
if( X != A )
|
||||
|
@ -911,6 +910,10 @@ int mbedtls_mpi_add_abs( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi
|
|||
}
|
||||
|
||||
cleanup:
|
||||
if( &TB == B )
|
||||
{
|
||||
mbedtls_mpi_free( &TB );
|
||||
}
|
||||
|
||||
return( ret );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue