From c86acc543478dd70445710b2e647e073d40642b9 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 9 Jun 2021 13:27:05 +0200 Subject: [PATCH] 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 --- library/bignum.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/library/bignum.c b/library/bignum.c index 9f6873dbc..1c83e6357 100644 --- a/library/bignum.c +++ b/library/bignum.c @@ -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 )