mbedtls_mpi_gcd: small optimization

Shifting TA and TB before the loop is not necessary. If A != 0, it will be
done at the start of the loop iteration. If A == 0, then lz==0 and G is
correctly set to B after 0 loop iterations.

Signed-off-by: Gilles Peskine <[email protected]>
This commit is contained in:
Gilles Peskine
2021-06-22 12:44:05 +02:00
parent 27253bc885
commit b4347d859b
-3
View File
@@ -2404,9 +2404,6 @@ int mbedtls_mpi_gcd( mbedtls_mpi *G, const mbedtls_mpi *A, const mbedtls_mpi *B
if( lzt < lz )
lz = lzt;
MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &TA, lz ) );
MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &TB, lz ) );
TA.s = TB.s = 1;
while( mbedtls_mpi_cmp_int( &TA, 0 ) != 0 )