dh(3) OpenSSL dh(3) NNAAMMEE dh - Diffie-Hellman key agreement SSYYNNOOPPSSIISS #include #include DH * DH_new(void); void DH_free(DH *dh); int DH_size(const DH *dh); DH * DH_generate_parameters(int prime_len, int generator, void (*callback)(int, int, void *), void *cb_arg); int DH_check(const DH *dh, int *codes); int DH_generate_key(DH *dh); int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh); void DH_set_default_method(const DH_METHOD *meth); const DH_METHOD *DH_get_default_method(void); int DH_set_method(DH *dh, const DH_METHOD *meth); DH *DH_new_method(ENGINE *engine); const DH_METHOD *DH_OpenSSL(void); int DH_get_ex_new_index(long argl, char *argp, int (*new_func)(), int (*dup_func)(), void (*free_func)()); int DH_set_ex_data(DH *d, int idx, char *arg); char *DH_get_ex_data(DH *d, int idx); DH * d2i_DHparams(DH **a, unsigned char **pp, long length); int i2d_DHparams(const DH *a, unsigned char **pp); int DHparams_print_fp(FILE *fp, const DH *x); int DHparams_print(BIO *bp, const DH *x); DDEESSCCRRIIPPTTIIOONN These functions implement the Diffie-Hellman key agreement protocol. The generation of shared DH parameters is described in _D_H___g_e_n_e_r_- _a_t_e___p_a_r_a_m_e_t_e_r_s(3); _D_H___g_e_n_e_r_a_t_e___k_e_y(3) describes how to perform a key agreement. The DDHH structure consists of several BIGNUM components. struct { BIGNUM *p; // prime number (shared) BIGNUM *g; // generator of Z_p (shared) BIGNUM *priv_key; // private DH value x BIGNUM *pub_key; // public DH value g^x // ... }; DH Note that DH keys may use non-standard DDHH__MMEETTHHOODD implementations, either directly or by the use of EENNGGIINNEE modules. In some cases (eg. an ENGINE providing support for hardware-embedded keys), these BIGNUM val- ues will not be used by the implementation or may be used for alterna- tive data storage. For this reason, applications should generally avoid using DH structure elements directly and instead use API functions to query or modify keys. SSEEEE AALLSSOO _d_h_p_a_r_a_m(1), _b_n(3), _d_s_a(3), _e_r_r(3), _r_a_n_d(3), _r_s_a(3), _e_n_g_i_n_e(3), _D_H___s_e_t___m_e_t_h_o_d(3), _D_H___n_e_w(3), _D_H___g_e_t___e_x___n_e_w___i_n_d_e_x(3), _D_H___g_e_n_e_r_a_t_e___p_a_r_a_m_- _e_t_e_r_s(3), _D_H___c_o_m_p_u_t_e___k_e_y(3), _d_2_i___D_H_p_a_r_a_m_s(3), _R_S_A___p_r_i_n_t(3) 1.0.2u 2019-12-20 dh(3)