1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-12-24 17:41:01 +03:00

Removed recursion from fix #309.

This commit is contained in:
Janos Follath
2015-10-25 14:24:10 +01:00
parent 8483e28e21
commit 3fc644f246

View File

@@ -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 );
}