5 dh - Diffie-Hellman key agreement
9 #include <openssl/dh.h>
10 #include <openssl/engine.h>
15 int DH_size(const DH *dh);
17 DH * DH_generate_parameters(int prime_len, int generator,
18 void (*callback)(int, int, void *), void *cb_arg);
19 int DH_check(const DH *dh, int *codes);
21 int DH_generate_key(DH *dh);
22 int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh);
24 void DH_set_default_method(const DH_METHOD *meth);
25 const DH_METHOD *DH_get_default_method(void);
26 int DH_set_method(DH *dh, const DH_METHOD *meth);
27 DH *DH_new_method(ENGINE *engine);
28 const DH_METHOD *DH_OpenSSL(void);
30 int DH_get_ex_new_index(long argl, char *argp, int (*new_func)(),
31 int (*dup_func)(), void (*free_func)());
32 int DH_set_ex_data(DH *d, int idx, char *arg);
33 char *DH_get_ex_data(DH *d, int idx);
35 DH * d2i_DHparams(DH **a, unsigned char **pp, long length);
36 int i2d_DHparams(const DH *a, unsigned char **pp);
38 int DHparams_print_fp(FILE *fp, const DH *x);
39 int DHparams_print(BIO *bp, const DH *x);
43 These functions implement the Diffie-Hellman key agreement protocol.
44 The generation of shared DH parameters is described in
45 L<DH_generate_parameters(3)|DH_generate_parameters(3)>; L<DH_generate_key(3)|DH_generate_key(3)> describes how
46 to perform a key agreement.
48 The B<DH> structure consists of several BIGNUM components.
52 BIGNUM *p; // prime number (shared)
53 BIGNUM *g; // generator of Z_p (shared)
54 BIGNUM *priv_key; // private DH value x
55 BIGNUM *pub_key; // public DH value g^x
60 Note that DH keys may use non-standard B<DH_METHOD> implementations,
61 either directly or by the use of B<ENGINE> modules. In some cases (eg. an
62 ENGINE providing support for hardware-embedded keys), these BIGNUM values
63 will not be used by the implementation or may be used for alternative data
64 storage. For this reason, applications should generally avoid using DH
65 structure elements directly and instead use API functions to query or
70 L<dhparam(1)|dhparam(1)>, L<bn(3)|bn(3)>, L<dsa(3)|dsa(3)>, L<err(3)|err(3)>,
71 L<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, L<engine(3)|engine(3)>,
72 L<DH_set_method(3)|DH_set_method(3)>, L<DH_new(3)|DH_new(3)>,
73 L<DH_get_ex_new_index(3)|DH_get_ex_new_index(3)>,
74 L<DH_generate_parameters(3)|DH_generate_parameters(3)>,
75 L<DH_compute_key(3)|DH_compute_key(3)>, L<d2i_DHparams(3)|d2i_DHparams(3)>,
76 L<RSA_print(3)|RSA_print(3)>