mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Rm ecp_add() and add ecp_muladd()
This commit is contained in:
@ -203,9 +203,9 @@ int mbedtls_ecdsa_verify( mbedtls_ecp_group *grp,
|
||||
{
|
||||
int ret;
|
||||
mbedtls_mpi e, s_inv, u1, u2;
|
||||
mbedtls_ecp_point R, P;
|
||||
mbedtls_ecp_point R;
|
||||
|
||||
mbedtls_ecp_point_init( &R ); mbedtls_ecp_point_init( &P );
|
||||
mbedtls_ecp_point_init( &R );
|
||||
mbedtls_mpi_init( &e ); mbedtls_mpi_init( &s_inv ); mbedtls_mpi_init( &u1 ); mbedtls_mpi_init( &u2 );
|
||||
|
||||
/* Fail cleanly on curves such as Curve25519 that can't be used for ECDSA */
|
||||
@ -249,9 +249,7 @@ int mbedtls_ecdsa_verify( mbedtls_ecp_group *grp,
|
||||
* Since we're not using any secret data, no need to pass a RNG to
|
||||
* mbedtls_ecp_mul() for countermesures.
|
||||
*/
|
||||
MBEDTLS_MPI_CHK( mbedtls_ecp_mul( grp, &R, &u1, &grp->G, NULL, NULL ) );
|
||||
MBEDTLS_MPI_CHK( mbedtls_ecp_mul( grp, &P, &u2, Q, NULL, NULL ) );
|
||||
MBEDTLS_MPI_CHK( mbedtls_ecp_add( grp, &R, &R, &P ) );
|
||||
MBEDTLS_MPI_CHK( mbedtls_ecp_muladd( grp, &R, &u1, &grp->G, &u2, Q ) );
|
||||
|
||||
if( mbedtls_ecp_is_zero( &R ) )
|
||||
{
|
||||
@ -275,7 +273,7 @@ int mbedtls_ecdsa_verify( mbedtls_ecp_group *grp,
|
||||
}
|
||||
|
||||
cleanup:
|
||||
mbedtls_ecp_point_free( &R ); mbedtls_ecp_point_free( &P );
|
||||
mbedtls_ecp_point_free( &R );
|
||||
mbedtls_mpi_free( &e ); mbedtls_mpi_free( &s_inv ); mbedtls_mpi_free( &u1 ); mbedtls_mpi_free( &u2 );
|
||||
|
||||
return( ret );
|
||||
|
@ -1048,24 +1048,6 @@ cleanup:
|
||||
return( ret );
|
||||
}
|
||||
|
||||
/*
|
||||
* Addition: R = P + Q, result's coordinates normalized
|
||||
*/
|
||||
int mbedtls_ecp_add( const mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
|
||||
const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q )
|
||||
{
|
||||
int ret;
|
||||
|
||||
if( ecp_get_type( grp ) != ECP_TYPE_SHORT_WEIERSTRASS )
|
||||
return( MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE );
|
||||
|
||||
MBEDTLS_MPI_CHK( ecp_add_mixed( grp, R, P, Q ) );
|
||||
MBEDTLS_MPI_CHK( ecp_normalize_jac( grp, R ) );
|
||||
|
||||
cleanup:
|
||||
return( ret );
|
||||
}
|
||||
|
||||
/*
|
||||
* Randomize jacobian coordinates:
|
||||
* (X, Y, Z) -> (l^2 X, l^3 Y, l Z) for random l
|
||||
@ -1684,6 +1666,32 @@ cleanup:
|
||||
}
|
||||
#endif /* ECP_SHORTWEIERSTRASS */
|
||||
|
||||
/*
|
||||
* Linear combination
|
||||
*/
|
||||
int mbedtls_ecp_muladd( mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
|
||||
const mbedtls_mpi *m, const mbedtls_ecp_point *P,
|
||||
const mbedtls_mpi *n, const mbedtls_ecp_point *Q )
|
||||
{
|
||||
int ret;
|
||||
mbedtls_ecp_point mP;
|
||||
|
||||
if( ecp_get_type( grp ) != ECP_TYPE_SHORT_WEIERSTRASS )
|
||||
return( MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE );
|
||||
|
||||
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 ) );
|
||||
MBEDTLS_MPI_CHK( ecp_add_mixed( grp, R, &mP, R ) );
|
||||
MBEDTLS_MPI_CHK( ecp_normalize_jac( grp, R ) );
|
||||
|
||||
cleanup:
|
||||
mbedtls_ecp_point_free( &mP );
|
||||
|
||||
return( ret );
|
||||
}
|
||||
|
||||
|
||||
#if defined(ECP_MONTGOMERY)
|
||||
/*
|
||||
|
Reference in New Issue
Block a user