Skip to main content

mbedtls_dhm_make_params

Function mbedtls_dhm_make_params 

Source
pub unsafe extern "C" fn mbedtls_dhm_make_params(
    ctx: *mut mbedtls_dhm_context,
    x_size: c_int,
    output: *mut c_uchar,
    olen: *mut usize,
    f_rng: mbedtls_f_rng_t,
    p_rng: *mut c_void,
) -> c_int
Expand description

\brief 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.

\note 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().

\note In a TLS handshake, this is the how the server generates and exports its DHM key material.

\param 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. \param x_size The private key size in Bytes. \param olen The address at which to store the number of Bytes written on success. This must not be \c NULL. \param 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. \param f_rng The RNG function. 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 doesn’t need a context parameter.

\return \c 0 on success. \return An \c MBEDTLS_ERR_DHM_XXX error code on failure.