mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-23 03:05:43 +01:00
Stop checking for argument change
This was intended to detect aborted operations, but now that case is handled by the caller freeing the restart context. Also, as the internal sub-context is managed by the callee, no need for the caller to free/reset the restart context between successful calls.
This commit is contained in:
parent
3cade22f96
commit
8467e6848d
@ -263,9 +263,10 @@ typedef struct
|
||||
*
|
||||
* If more operations are needed to complete a computation,
|
||||
* MBEDTLS_ERR_ECP_IN_PROGRESS will be returned by the
|
||||
* function performing the computation. That function will
|
||||
* then need to be called again with the same arguments until
|
||||
* it returns 0 or an other error code.
|
||||
* function performing the computation. It is then the
|
||||
* caller's responsibility to either call again with the same
|
||||
* arguments until it returns 0 or an error code; or to free
|
||||
* the restart context if the operation is to be aborted.
|
||||
*
|
||||
* This only affects functions that accept a pointer to a
|
||||
* \c mbedtls_ecp_restart_ctx as an argument, and only works
|
||||
@ -615,14 +616,11 @@ int mbedtls_ecp_mul( mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
|
||||
* \param P Point to multiply
|
||||
* \param f_rng RNG function (see notes)
|
||||
* \param p_rng RNG parameter
|
||||
* \param rs_ctx Restart context - must be non-NULL to enable early-return
|
||||
* \param rs_ctx Restart context
|
||||
*
|
||||
* \return See \c mbedtls_ecp_mul(), or
|
||||
* MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of
|
||||
* operations was reached (see \c mbedtls_ecp_set_max_ops()),
|
||||
* indicating the function should be called again with the
|
||||
* exact same arguments.
|
||||
*
|
||||
* operations was reached: see \c mbedtls_ecp_set_max_ops().
|
||||
*/
|
||||
int mbedtls_ecp_mul_restartable( mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
|
||||
const mbedtls_mpi *m, const mbedtls_ecp_point *P,
|
||||
|
@ -105,8 +105,6 @@ void mbedtls_ecp_set_max_ops( unsigned max_ops )
|
||||
*/
|
||||
struct mbedtls_ecp_restart_mul {
|
||||
unsigned ops_done; /* number of operations done this time */
|
||||
mbedtls_mpi m; /* saved argument: scalar */
|
||||
mbedtls_ecp_point P; /* saved argument: point */
|
||||
mbedtls_ecp_point R; /* current intermediate result */
|
||||
size_t i; /* current index in various loops, 0 outside */
|
||||
mbedtls_ecp_point *T; /* table for precomputed points */
|
||||
@ -139,8 +137,6 @@ static void ecp_restart_mul_free( mbedtls_ecp_restart_mul_ctx *ctx )
|
||||
if( ctx == NULL )
|
||||
return;
|
||||
|
||||
mbedtls_mpi_free( &ctx->m );
|
||||
mbedtls_ecp_point_free( &ctx->P );
|
||||
mbedtls_ecp_point_free( &ctx->R );
|
||||
|
||||
if( ctx->T != NULL ) {
|
||||
@ -1763,17 +1759,6 @@ static int ecp_mul_comb( mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ECP_EARLY_RETURN)
|
||||
/* check for restart with new arguments */
|
||||
if( rs_ctx != NULL && rs_ctx->rsm != NULL && rs_ctx->rsm != NULL &&
|
||||
( mbedtls_mpi_cmp_mpi( m, &rs_ctx->rsm->m ) != 0 ||
|
||||
mbedtls_mpi_cmp_mpi( &P->X, &rs_ctx->rsm->P.X ) != 0 ||
|
||||
mbedtls_mpi_cmp_mpi( &P->Y, &rs_ctx->rsm->P.Y ) != 0 ) )
|
||||
{
|
||||
ecp_restart_mul_free( rs_ctx->rsm );
|
||||
mbedtls_free( rs_ctx->rsm );
|
||||
rs_ctx->rsm = NULL;
|
||||
}
|
||||
|
||||
/* set up restart context if needed */
|
||||
if( ecp_max_ops != 0 && rs_ctx != NULL && rs_ctx->rsm == NULL )
|
||||
{
|
||||
@ -1782,9 +1767,6 @@ static int ecp_mul_comb( mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
|
||||
return( MBEDTLS_ERR_ECP_ALLOC_FAILED );
|
||||
|
||||
ecp_restart_mul_init( rs_ctx->rsm );
|
||||
|
||||
MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &rs_ctx->rsm->m, m ) );
|
||||
MBEDTLS_MPI_CHK( mbedtls_ecp_copy( &rs_ctx->rsm->P, P ) );
|
||||
}
|
||||
|
||||
/* reset ops count for this call */
|
||||
|
@ -116,9 +116,6 @@ void ecp_test_vect_restart( int id,
|
||||
TEST_ASSERT( cnt_restarts >= min_restarts );
|
||||
TEST_ASSERT( cnt_restarts <= max_restarts );
|
||||
|
||||
/* Prepare context for new operation */
|
||||
mbedtls_ecp_restart_free( &ctx );
|
||||
|
||||
/* Non-base point case */
|
||||
cnt_restarts = 0;
|
||||
do {
|
||||
|
Loading…
Reference in New Issue
Block a user