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 size \p olen Bytes.
olen
The length of the destination buffer. This must be at least equal to `ctx->len` (the size of \c P).
f_rng
The RNG function. This 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 argument.
Return value
\c 0 on success. An \c MBEDTLS_ERR_DHM_XXX error code on failure.
Notes
The destination buffer is always fully written so as to contain a big-endian representation of G^X mod P. If it is larger than \c ctx->len, it is padded accordingly with zero-bytes at the beginning.
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.