mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-06-04 14:28:26 +00:00
Removed recursion from fix #309.
This commit is contained in:
parent
ff5317e99b
commit
2b806fad7b
|
@ -889,23 +889,22 @@ int mpi_add_abs( mpi *X, const mpi *A, const mpi *B )
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
size_t i, j;
|
size_t i, j;
|
||||||
t_uint *o, *p, c;
|
mpi_uint *o, *p, c;
|
||||||
|
mpi TB;
|
||||||
|
|
||||||
if( X == B )
|
if( X == B )
|
||||||
{
|
{
|
||||||
|
B = A; A = X;
|
||||||
|
|
||||||
if( B == A )
|
if( B == A )
|
||||||
{
|
{
|
||||||
// Making a temporary copy instead of shifting by one to deny
|
// Making a temporary copy instead of shifting by one to deny
|
||||||
// the possibility of corresponding side-channel attacks.
|
// the possibility of corresponding side-channel attacks.
|
||||||
mpi TB;
|
|
||||||
|
|
||||||
mpi_init( &TB );
|
mpi_init( &TB );
|
||||||
MBEDTLS_MPI_CHK( mpi_copy( &TB, B ) );
|
MPI_CHK( mpi_copy( &TB, B ) );
|
||||||
|
|
||||||
return mpi_add_abs( X, A, &TB );
|
B = &TB;
|
||||||
}
|
}
|
||||||
|
|
||||||
B = A; A = X;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( X != A )
|
if( X != A )
|
||||||
|
@ -942,6 +941,10 @@ int mpi_add_abs( mpi *X, const mpi *A, const mpi *B )
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
if( &TB == B )
|
||||||
|
{
|
||||||
|
mpi_free( &TB );
|
||||||
|
}
|
||||||
|
|
||||||
return( ret );
|
return( ret );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue