Removed recursion from fix #309.

This commit is contained in:
Janos Follath 2015-10-25 14:24:10 +01:00 committed by Manuel Pégourié-Gonnard
parent ff5317e99b
commit 2b806fad7b

View File

@ -889,23 +889,22 @@ int mpi_add_abs( mpi *X, const mpi *A, const mpi *B )
{
int ret;
size_t i, j;
t_uint *o, *p, c;
mpi_uint *o, *p, c;
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.
mpi 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 )
@ -942,6 +941,10 @@ int mpi_add_abs( mpi *X, const mpi *A, const mpi *B )
}
cleanup:
if( &TB == B )
{
mpi_free( &TB );
}
return( ret );
}