1dh(3) OpenSSL dh(3)
2
3
4
6 dh - Diffie-Hellman key agreement
7
9 #include <openssl/dh.h>
10 #include <openssl/engine.h>
11
12 DH * DH_new(void);
13 void DH_free(DH *dh);
14
15 int DH_size(const DH *dh);
16
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);
20
21 int DH_generate_key(DH *dh);
22 int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh);
23
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);
29
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);
34
35 DH * d2i_DHparams(DH **a, unsigned char **pp, long length);
36 int i2d_DHparams(const DH *a, unsigned char **pp);
37
38 int DHparams_print_fp(FILE *fp, const DH *x);
39 int DHparams_print(BIO *bp, const DH *x);
40
42 These functions implement the Diffie-Hellman key agreement protocol.
43 The generation of shared DH parameters is described in
44 DH_generate_parameters(3); DH_generate_key(3) describes how to perform
45 a key agreement.
46
47 The DH structure consists of several BIGNUM components.
48
49 struct
50 {
51 BIGNUM *p; // prime number (shared)
52 BIGNUM *g; // generator of Z_p (shared)
53 BIGNUM *priv_key; // private DH value x
54 BIGNUM *pub_key; // public DH value g^x
55 // ...
56 };
57 DH
58
59 Note that DH keys may use non-standard DH_METHOD implementations,
60 either directly or by the use of ENGINE modules. In some cases (eg. an
61 ENGINE providing support for hardware-embedded keys), these BIGNUM
62 values will not be used by the implementation or may be used for
63 alternative data storage. For this reason, applications should
64 generally avoid using DH structure elements directly and instead use
65 API functions to query or modify keys.
66
68 dhparam(1), bn(3), dsa(3), err(3), rand(3), rsa(3), engine(3),
69 DH_set_method(3), DH_new(3), DH_get_ex_new_index(3),
70 DH_generate_parameters(3), DH_compute_key(3), d2i_DHparams(3),
71 RSA_print(3)
72
73
74
751.0.2o 2020-01-28 dh(3)