The ECDH context to use. This must be initialized and have its own private key generated and the peer's public key imported.
olen
The address at which to store the total number of Bytes written on success. This must not be \c NULL.
buf
The buffer to write the generated shared key to. This must be a writable buffer of size \p blen Bytes.
blen
The length of the destination buffer \p buf in Bytes.
f_rng
The RNG function to use. This must not be \c NULL.
p_rng
The RNG context. This may be \c NULL if \p f_rng doesn't need a context argument.
Return value
\c 0 on success. #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of operations was reached: see \c mbedtls_ecp_set_max_ops(). Another \c MBEDTLS_ERR_ECP_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().
This function sets up an ECDH context from an EC key. It is used by clients and servers in place of the ServerKeyExchange for static ECDH, and imports ECDH parameters from the EC key information of a certificate. \see ecp.h
This function sets up the ECDH context with the information given. This function should be called after mbedtls_ecdh_init() but before mbedtls_ecdh_make_params(). There is no need to call this function before mbedtls_ecdh_read_params(). This is the first function used by a TLS server for ECDHE ciphersuites.
This function generates a public key and exports it as a TLS ClientKeyExchange payload. This is the second function used by a TLS client for ECDH(E) ciphersuites. \see ecp.h
This function parses and processes the ECDHE payload of a TLS ClientKeyExchange message. This is the third function used by a TLS server for ECDH(E) ciphersuites. (It is called after mbedtls_ecdh_setup() and mbedtls_ecdh_make_params().) \see ecp.h
This function generates an EC key pair and exports its in the format used in a TLS ServerKeyExchange handshake message. This is the second function used by a TLS server for ECDHE ciphersuites. (It is called after mbedtls_ecdh_setup().) \see ecp.h
Print a field of the ECDH structure in the SSL context to the debug output. This function is always used through the MBEDTLS_SSL_DEBUG_ECDH() macro, which supplies the ssl context, file and line number parameters. \attention This function is intended for INTERNAL usage within the library only.
Examples
mbedtls_ecdh_calc_secret() is referenced by 1 libraries and example projects: