util/incore: fix typo.
[openssl.git] / doc / crypto / dh.pod
1 =pod
2
3 =head1 NAME
4
5 dh - Diffie-Hellman key agreement
6
7 =head1 SYNOPSIS
8
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
41 =head1 DESCRIPTION
42
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.
47
48 The B<DH> structure consists of several BIGNUM components.
49
50  struct
51         {
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
56         // ...
57         };
58  DH
59
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
66 modify keys.
67
68 =head1 SEE ALSO
69
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)> 
77
78 =cut