mbedtls_dhm_make_params() function
This function generates a DHM key pair and exports its public part together with the DHM parameters in the format used in a TLS ServerKeyExchange handshake message.
Arguments
ctx
The DHM context to use. This must be initialized and have the DHM parameters set. It may or may not already have imported the peer's public key.
x_size
The private key size in Bytes.
output
The destination buffer. This must be a writable buffer of sufficient size to hold the reduced binary presentation of the modulus, the generator and the public key, each wrapped with a 2-byte length field. It is the responsibility of the caller to ensure that enough space is available. Refer to mbedtls_mpi_size() to computing the byte-size of an MPI.
olen
The address at which to store the number of Bytes written on success. This must not be \c NULL.
f_rng
The RNG function. Must not be \c NULL.
p_rng
The RNG context to be passed to \p f_rng. This may be \c NULL if \p f_rng doesn't need a context parameter.
Return value
\c 0 on success. An \c MBEDTLS_ERR_DHM_XXX error code on failure.
Notes
This function assumes that the DHM parameters \c ctx->P and \c ctx->G have already been properly set. For that, use mbedtls_dhm_set_group() below in conjunction with mbedtls_mpi_read_binary() and mbedtls_mpi_read_string(). In a TLS handshake, this is the how the server generates and exports its DHM key material.
mbedtls_dhm_make_params() is called by 1 function and calls 4 functions:
![]()
mbedtls_dhm_make_params()
mbedtls_dhm_make_params():
![]()
mbedtls_dhm_make_params()