Skip to main content

mbedtls_dhm_calc_secret

Function mbedtls_dhm_calc_secret 

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

\brief This function derives and exports the shared secret \c (G^Y)^X mod \c P.

\note If \p f_rng is not \c NULL, it is used to blind the input as a countermeasure against timing attacks. Blinding is used only if our private key \c X is re-used, and not used otherwise. We recommend always passing a non-NULL \p f_rng argument.

\param ctx The DHM context to use. This must be initialized and have its own private key generated and the peer’s public key imported. \param output The buffer to write the generated shared key to. This must be a writable buffer of size \p output_size Bytes. \param output_size The size of the destination buffer. This must be at least the size of \c ctx->len (the size of \c P). \param olen On exit, holds the actual number of Bytes written. \param f_rng The RNG function. Must not be \c NULL. Used for blinding. \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.