From 376dc89519fe1eb65038225bd6a9bf330e1e6bef Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Tue, 4 Jan 2022 07:14:07 +0000 Subject: [PATCH] Reorder ops in ecp_double_add_mxz() to indicate redundant local MPIs Signed-off-by: Hanno Becker --- library/ecp.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/library/ecp.c b/library/ecp.c index a0b5914ee..cdffa1ca9 100644 --- a/library/ecp.c +++ b/library/ecp.c @@ -2402,22 +2402,22 @@ static int ecp_double_add_mxz( const mbedtls_ecp_group *grp, mbedtls_mpi_init( &D ); mbedtls_mpi_init( &DA ); mbedtls_mpi_init( &CB ); MPI_ECP_ADD( &A, &P->X, &P->Z ); - MPI_ECP_SQR( &AA, &A ); MPI_ECP_SUB( &B, &P->X, &P->Z ); - MPI_ECP_SQR( &BB, &B ); - MPI_ECP_SUB( &E, &AA, &BB ); MPI_ECP_ADD( &C, &Q->X, &Q->Z ); MPI_ECP_SUB( &D, &Q->X, &Q->Z ); - MPI_ECP_MUL( &DA, &D, &A ); - MPI_ECP_MUL( &CB, &C, &B ); + MPI_ECP_MUL( &DA, &D, &A ); /* D no longer needed */ + MPI_ECP_MUL( &CB, &C, &B ); /* C no longer needed */ + MPI_ECP_SQR( &AA, &A ); /* A no longer needed */ + MPI_ECP_SQR( &BB, &B ); /* B no longer needed */ + MPI_ECP_MUL( &R->X, &AA, &BB ); + MPI_ECP_SUB( &E, &AA, &BB ); /* AA no longer needed */ + MPI_ECP_MUL( &R->Z, &grp->A, &E ); + MPI_ECP_ADD( &R->Z, &BB, &R->Z ); /* BB no longer needed */ MPI_ECP_ADD( &S->X, &DA, &CB ); MPI_ECP_SQR( &S->X, &S->X ); MPI_ECP_SUB( &S->Z, &DA, &CB ); MPI_ECP_SQR( &S->Z, &S->Z ); MPI_ECP_MUL( &S->Z, d, &S->Z ); - MPI_ECP_MUL( &R->X, &AA, &BB ); - MPI_ECP_MUL( &R->Z, &grp->A, &E ); - MPI_ECP_ADD( &R->Z, &BB, &R->Z ); MPI_ECP_MUL( &R->Z, &E, &R->Z ); cleanup: