mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 16:45:41 +01: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;
|
||||
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 );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user