mpi_exp_mod: simplify freeing loop
Signed-off-by: Janos Follath <janos.follath@arm.com>
diff --git a/library/bignum.c b/library/bignum.c
index d3cd90d..9b47739 100644
--- a/library/bignum.c
+++ b/library/bignum.c
@@ -2219,12 +2219,12 @@
cleanup:
- for( i = ( one << ( window_bitsize - 1 ) );
- i < ( one << window_bitsize ); i++ )
+ /* The first bit of the sliding window is always 1 and therefore the first
+ * half of the table was unused. */
+ for( i = w_table_used_size/2; i < w_table_used_size; i++ )
mbedtls_mpi_free( &W[i] );
mbedtls_mpi_free( &W[1] );
- mbedtls_mpi_free( &W[x_index] );
mbedtls_mpi_free( &T );
mbedtls_mpi_free( &Apos );
mbedtls_mpi_free( &WW );