Function esp_idf_sys::mbedtls_mpi_safe_cond_assign
source · pub unsafe extern "C" fn mbedtls_mpi_safe_cond_assign(
X: *mut mbedtls_mpi,
Y: *const mbedtls_mpi,
assign: c_uchar,
) -> c_int
Expand description
\brief Perform a safe conditional copy of MPI which doesn’t reveal whether the condition was true or not.
\param X The MPI to conditionally assign to. This must point
to an initialized MPI.
\param Y The MPI to be assigned from. This must point to an
initialized MPI.
\param assign The condition deciding whether to perform the
assignment or not. Must be either 0 or 1:
* \c 1: Perform the assignment X = Y
.
* \c 0: Keep the original value of \p X.
\note This function is equivalent to
if( assign ) mbedtls_mpi_copy( X, Y );
except that it avoids leaking any information about whether
the assignment was done or not (the above code may leak
information through branch prediction and/or memory access
patterns analysis).
\warning If \p assign is neither 0 nor 1, the result of this function is indeterminate, and the resulting value in \p X might be neither its original value nor the value in \p Y.
\return \c 0 if successful. \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed. \return Another negative error code on other kinds of failure.