Spare some memory

This commit is contained in:
Manuel Pégourié-Gonnard 2013-11-21 10:08:50 +01:00
parent edc1a1f482
commit e282012219

View File

@ -1353,6 +1353,14 @@ static int ecp_precompute_comb( const ecp_group *grp,
ecp_normalize_many( grp, TT, k ); ecp_normalize_many( grp, TT, k );
/*
* Post-precessing: reclaim some memory by not storing Z (always 1)
*/
for( i = 0; i < ( 1U << (w-1) ); i++ )
{
mpi_free( &T[i].Z );
}
cleanup: cleanup:
return( ret ); return( ret );
} }
@ -1368,6 +1376,9 @@ static int ecp_select_comb( const ecp_group *grp, ecp_point *R,
/* Ignore the "sign" bit */ /* Ignore the "sign" bit */
MPI_CHK( ecp_copy( R, &T[ ( i & 0x7Fu ) >> 1 ] ) ); MPI_CHK( ecp_copy( R, &T[ ( i & 0x7Fu ) >> 1 ] ) );
/* Restore the Z coordinate */
MPI_CHK( mpi_lset( &R->Z, 1 ) );
/* /*
* -R = (R.X, -R.Y, R.Z), and * -R = (R.X, -R.Y, R.Z), and
* -R.Y mod P = P - R.Y unless R.Y == 0 * -R.Y mod P = P - R.Y unless R.Y == 0