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;
|
int ret;
|
||||||
size_t i, j;
|
size_t i, j;
|
||||||
mbedtls_mpi_uint *o, *p, c;
|
mbedtls_mpi_uint *o, *p, c;
|
||||||
|
mbedtls_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.
|
||||||
mbedtls_mpi TB;
|
|
||||||
|
|
||||||
mbedtls_mpi_init( &TB );
|
mbedtls_mpi_init( &TB );
|
||||||
MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &TB, B ) );
|
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 )
|
if( X != A )
|
||||||
@ -911,6 +910,10 @@ int mbedtls_mpi_add_abs( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
if( &TB == B )
|
||||||
|
{
|
||||||
|
mbedtls_mpi_free( &TB );
|
||||||
|
}
|
||||||
|
|
||||||
return( ret );
|
return( ret );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user