Function esp_idf_sys::mbedtls_ecp_set_max_ops

source ·
pub unsafe extern "C" fn mbedtls_ecp_set_max_ops(max_ops: c_uint)
Expand description

\brief Set the maximum number of basic operations done in a row.

             If more operations are needed to complete a computation,
             #MBEDTLS_ERR_ECP_IN_PROGRESS will be returned by the
             function performing the computation. It is then the
             caller's responsibility to either call again with the same
             parameters until it returns 0 or an error code; or to free
             the restart context if the operation is to be aborted.

             It is strictly required that all input parameters and the
             restart context be the same on successive calls for the
             same operation, but output parameters need not be the
             same; they must not be used until the function finally
             returns 0.

             This only applies to functions whose documentation
             mentions they may return #MBEDTLS_ERR_ECP_IN_PROGRESS (or
             #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS for functions in the
             SSL module). For functions that accept a "restart context"
             argument, passing NULL disables restart and makes the
             function equivalent to the function with the same name
             with \c _restartable removed. For functions in the ECDH
             module, restart is disabled unless the function accepts
             an "ECDH context" argument and
             mbedtls_ecdh_enable_restart() was previously called on
             that context. For function in the SSL module, restart is
             only enabled for specific sides and key exchanges
             (currently only for clients and ECDHE-ECDSA).

\warning Using the PSA interruptible interfaces with keys in local storage and no accelerator driver will also call this function to set the values specified via those interfaces, overwriting values previously set. Care should be taken if mixing these two interfaces.

\param max_ops Maximum number of basic operations done in a row. Default: 0 (unlimited). Lower (non-zero) values mean ECC functions will block for a lesser maximum amount of time.

\note A “basic operation” is defined as a rough equivalent of a multiplication in GF(p) for the NIST P-256 curve. As an indication, with default settings, a scalar multiplication (full run of \c mbedtls_ecp_mul()) is: - about 3300 basic operations for P-256 - about 9400 basic operations for P-384

\note Very low values are not always respected: sometimes functions need to block for a minimum number of operations, and will do so even if max_ops is set to a lower value. That minimum depends on the curve size, and can be made lower by decreasing the value of \c MBEDTLS_ECP_WINDOW_SIZE. As an indication, here is the lowest effective value for various curves and values of that parameter (w for short): w=6 w=5 w=4 w=3 w=2 P-256 208 208 160 136 124 P-384 682 416 320 272 248 P-521 1364 832 640 544 496

\note This setting is currently ignored by Curve25519.