mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-25 18:45:46 +01:00
Optimize some case of mbedtls_ecp_muladd()
Those are used by EC-JPAKE
This commit is contained in:
parent
cb7cd03412
commit
1a7c5ef42b
@ -1697,8 +1697,17 @@ int mbedtls_ecp_muladd( mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
|
||||
|
||||
mbedtls_ecp_point_init( &mP );
|
||||
|
||||
MBEDTLS_MPI_CHK( mbedtls_ecp_mul( grp, &mP, m, P, NULL, NULL ) );
|
||||
MBEDTLS_MPI_CHK( mbedtls_ecp_mul( grp, R, n, Q, NULL, NULL ) );
|
||||
/* Optimize some simple special cases */
|
||||
if( mbedtls_mpi_cmp_int( m, 1 ) == 0 )
|
||||
MBEDTLS_MPI_CHK( mbedtls_ecp_copy( &mP, P ) );
|
||||
else
|
||||
MBEDTLS_MPI_CHK( mbedtls_ecp_mul( grp, &mP, m, P, NULL, NULL ) );
|
||||
|
||||
if( mbedtls_mpi_cmp_int( n, 1 ) == 0 )
|
||||
MBEDTLS_MPI_CHK( mbedtls_ecp_copy( R, Q ) );
|
||||
else
|
||||
MBEDTLS_MPI_CHK( mbedtls_ecp_mul( grp, R, n, Q, NULL, NULL ) );
|
||||
|
||||
MBEDTLS_MPI_CHK( ecp_add_mixed( grp, R, &mP, R ) );
|
||||
MBEDTLS_MPI_CHK( ecp_normalize_jac( grp, R ) );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user