ce6a11089534fc42feec8e31364d55abe1b360f9
[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  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);
18
19  int    DH_generate_key(DH *dh);
20  int    DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh);
21
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);
27
28  DH *   d2i_DHparams(DH **a, unsigned char **pp, long length);
29  int    i2d_DHparams(const DH *a, unsigned char **pp);
30
31  int    DHparams_print_fp(FILE *fp, const DH *x);
32  int    DHparams_print(BIO *bp, const DH *x);
33
34 =head1 DESCRIPTION
35
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.
40
41 The B<DH> structure consists of several BIGNUM components.
42
43  struct
44         {
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
49         // ...
50         };
51  DH
52
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
59 modify keys.
60
61 =head1 SEE ALSO
62
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)>,
69 L<RSA_print(3)> 
70
71 =cut