Function esp_idf_hal::sys::mbedtls_ecdh_compute_shared
source · pub unsafe extern "C" fn mbedtls_ecdh_compute_shared(
grp: *mut mbedtls_ecp_group,
z: *mut mbedtls_mpi,
Q: *const mbedtls_ecp_point,
d: *const mbedtls_mpi,
f_rng: Option<unsafe extern "C" fn(_: *mut c_void, _: *mut u8, _: usize) -> i32>,
p_rng: *mut c_void,
) -> i32
Expand description
\brief This function computes the shared secret.
This function performs the second of two core computations
implemented during the ECDH key exchange. The first core
computation is performed by mbedtls_ecdh_gen_public().
\see ecp.h
\note If \p f_rng is not NULL, it is used to implement countermeasures against side-channel attacks. For more information, see mbedtls_ecp_mul().
\param grp The ECP group to use. This must be initialized and have domain parameters loaded, for example through mbedtls_ecp_load() or mbedtls_ecp_tls_read_group(). \param z The destination MPI (shared secret). This must be initialized. \param Q The public key from another party. This must be initialized. \param d Our secret exponent (private key). This must be initialized. \param f_rng The RNG function to use. This must not be \c NULL. \param p_rng The RNG context to be passed to \p f_rng. This may be \c NULL if \p f_rng is \c NULL or doesn’t need a context argument.
\return \c 0 on success. \return Another \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX error code on failure.