DH_generate_key(3) OpenSSL DH_generate_key(3) NNAAMMEE DH_generate_key, DH_compute_key - perform Diffie-Hellman key exchange SSYYNNOOPPSSIISS #include int DH_generate_key(DH *dh); int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh); DDEESSCCRRIIPPTTIIOONN _D_H___g_e_n_e_r_a_t_e___k_e_y_(_) performs the first step of a Diffie-Hellman key exchange by generating private and public DH values. By calling _D_H___c_o_m_- _p_u_t_e___k_e_y_(_), these are combined with the other party's public value to compute the shared key. _D_H___g_e_n_e_r_a_t_e___k_e_y_(_) expects ddhh to contain the shared parameters ddhh-->>pp and ddhh-->>gg. It generates a random private DH value unless ddhh-->>pprriivv__kkeeyy is already set, and computes the corresponding public value ddhh-->>ppuubb__kkeeyy, which can then be published. _D_H___c_o_m_p_u_t_e___k_e_y_(_) computes the shared secret from the private DH value in ddhh and the other party's public value in ppuubb__kkeeyy and stores it in kkeeyy. kkeeyy must point to DDHH__ssiizzee((ddhh)) bytes of memory. RREETTUURRNN VVAALLUUEESS _D_H___g_e_n_e_r_a_t_e___k_e_y_(_) returns 1 on success, 0 otherwise. _D_H___c_o_m_p_u_t_e___k_e_y_(_) returns the size of the shared secret on success, -1 on error. The error codes can be obtained by _E_R_R___g_e_t___e_r_r_o_r(3). SSEEEE AALLSSOO _d_h(3), _E_R_R___g_e_t___e_r_r_o_r(3), _r_a_n_d(3), _D_H___s_i_z_e(3) HHIISSTTOORRYY _D_H___g_e_n_e_r_a_t_e___k_e_y_(_) and _D_H___c_o_m_p_u_t_e___k_e_y_(_) are available in all versions of SSLeay and OpenSSL. 1.0.2u 2019-12-20 DH_generate_key(3)