mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 18:35:42 +01:00
Merge remote-tracking branch 'public/pr/2142' into development
This commit is contained in:
commit
da095619bb
@ -233,7 +233,9 @@ int mbedtls_ecp_check_budget( const mbedtls_ecp_group *grp,
|
||||
unsigned ops );
|
||||
|
||||
/* Utility macro for checking and updating ops budget */
|
||||
#define MBEDTLS_ECP_BUDGET( ops ) MBEDTLS_MPI_CHK( mbedtls_ecp_check_budget( grp, rs_ctx, ops ) );
|
||||
#define MBEDTLS_ECP_BUDGET( ops ) \
|
||||
MBEDTLS_MPI_CHK( mbedtls_ecp_check_budget( grp, rs_ctx, \
|
||||
(unsigned) (ops) ) );
|
||||
|
||||
#else /* MBEDTLS_ECP_RESTARTABLE */
|
||||
|
||||
|
@ -248,9 +248,16 @@ int mbedtls_ecp_check_budget( const mbedtls_ecp_group *grp,
|
||||
else if( grp->pbits >= 384 )
|
||||
ops *= 2;
|
||||
|
||||
/* avoid infinite loops: always allow first step */
|
||||
if( rs_ctx->ops_done != 0 && rs_ctx->ops_done + ops > ecp_max_ops )
|
||||
/* Avoid infinite loops: always allow first step.
|
||||
* Because of that, however, it's not generally true
|
||||
* that ops_done <= ecp_max_ops, so the check
|
||||
* ops_done > ecp_max_ops below is mandatory. */
|
||||
if( ( rs_ctx->ops_done != 0 ) &&
|
||||
( rs_ctx->ops_done > ecp_max_ops ||
|
||||
ops > ecp_max_ops - rs_ctx->ops_done ) )
|
||||
{
|
||||
return( MBEDTLS_ERR_ECP_IN_PROGRESS );
|
||||
}
|
||||
|
||||
/* update running count */
|
||||
rs_ctx->ops_done += ops;
|
||||
|
Loading…
Reference in New Issue
Block a user