mbedtls_ecdh_compute_shared() function
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
Arguments
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().
z
The destination MPI (shared secret). This must be initialized.
Q
The public key from another party. This must be initialized.
d
Our secret exponent (private key). This must be initialized.
f_rng
The RNG function. This may be \c NULL if randomization of intermediate results during the ECP computations is not needed (discouraged). See the documentation of mbedtls_ecp_mul() for more.
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 value
\c 0 on success. Another \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX error code on failure.
Notes
If \p f_rng is not NULL, it is used to implement countermeasures against side-channel attacks. For more information, see mbedtls_ecp_mul().