5 dh - Diffie-Hellman key agreement
9 #include <openssl/dh.h>
10 #include <openssl/engine.h>
15 DH * DH_generate_parameters(int prime_len, int generator,
16 void (*callback)(int, int, void *), void *cb_arg);
17 int DH_check(const DH *dh, int *codes);
19 int DH_generate_key(DH *dh);
20 int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh);
22 void DH_set_default_method(const DH_METHOD *meth);
23 const DH_METHOD *DH_get_default_method(void);
24 int DH_set_method(DH *dh, const DH_METHOD *meth);
25 DH *DH_new_method(ENGINE *engine);
26 const DH_METHOD *DH_OpenSSL(void);
28 DH * d2i_DHparams(DH **a, unsigned char **pp, long length);
29 int i2d_DHparams(const DH *a, unsigned char **pp);
31 int DHparams_print_fp(FILE *fp, const DH *x);
32 int DHparams_print(BIO *bp, const DH *x);
36 These functions implement the Diffie-Hellman key agreement protocol.
37 The generation of shared DH parameters is described in
38 L<DH_generate_parameters(3)>; L<DH_generate_key(3)> describes how
39 to perform a key agreement.
41 The B<DH> structure consists of several BIGNUM components.
45 BIGNUM *p; // prime number (shared)
46 BIGNUM *g; // generator of Z_p (shared)
47 BIGNUM *priv_key; // private DH value x
48 BIGNUM *pub_key; // public DH value g^x
53 Note that DH keys may use non-standard B<DH_METHOD> implementations,
54 either directly or by the use of B<ENGINE> modules. In some cases (eg. an
55 ENGINE providing support for hardware-embedded keys), these BIGNUM values
56 will not be used by the implementation or may be used for alternative data
57 storage. For this reason, applications should generally avoid using DH
58 structure elements directly and instead use API functions to query or
63 L<dhparam(1)>, L<bn(3)>, L<dsa(3)>, L<err(3)>,
64 L<rand(3)>, L<rsa(3)>, L<engine(3)>,
65 L<DH_set_method(3)>, L<DH_new(3)>,
66 L<DH_get_ex_new_index(3)>,
67 L<DH_generate_parameters(3)>,
68 L<DH_compute_key(3)>, L<d2i_DHparams(3)>,