Skip to content

Commit

Permalink
Merge pull request #3209 from aurel32/fix-ecp_double_add_mxz
Browse files Browse the repository at this point in the history
Fix wrong modulo call in ecp_double_add_mxz
  • Loading branch information
mpg authored Apr 24, 2020
2 parents 494f6cb + 66deb38 commit b1c8e41
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ChangeLog.d/fix-ecp_double_add_mxz.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Changes
* Fix minor performance issue in operations on Curve25519 caused by using a
suboptimal modular reduction in one place. Found and fix contributed by
Aurelien Jarno in #3209.
2 changes: 1 addition & 1 deletion library/ecp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2332,7 +2332,7 @@ static int ecp_double_add_mxz( const mbedtls_ecp_group *grp,
MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mod( grp, &D, &Q->X, &Q->Z ) );
MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mod( grp, &DA, &D, &A ) );
MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mod( grp, &CB, &C, &B ) );
MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &S->X, &DA, &CB ) ); MOD_MUL( S->X );
MBEDTLS_MPI_CHK( mbedtls_mpi_add_mod( grp, &S->X, &DA, &CB ) );
MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mod( grp, &S->X, &S->X, &S->X ) );
MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mod( grp, &S->Z, &DA, &CB ) );
MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mod( grp, &S->Z, &S->Z, &S->Z ) );
Expand Down

0 comments on commit b1c8e41

Please sign in to comment.