95b5fab81e14d0f0373d3c8c1100285512183dd2
[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
11  DH *DH_new(void);
12  void DH_free(DH *dh);
13
14  DH *DH_generate_parameters(int prime_len, int generator,
15                 void (*callback)(int, int, void *), void *cb_arg);
16  int DH_check(const DH *dh, int *codes);
17
18  int DH_generate_key(DH *dh);
19  int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh);
20
21  void DH_set_default_method(const DH_METHOD *meth);
22  const DH_METHOD *DH_get_default_method(void);
23  int DH_set_method(DH *dh, const DH_METHOD *meth);
24  DH *DH_new_method(ENGINE *engine);
25  const DH_METHOD *DH_OpenSSL(void);
26
27  DH *d2i_DHparams(DH **a, unsigned char **pp, long length);
28  int i2d_DHparams(const DH *a, unsigned char **pp);
29
30  int DHparams_print_fp(FILE *fp, const DH *x);
31  int DHparams_print(BIO *bp, const DH *x);
32
33 =head1 DESCRIPTION
34
35 These functions implement the Diffie-Hellman key agreement protocol.
36 The generation of shared DH parameters is described in
37 L<DH_generate_parameters(3)>; L<DH_generate_key(3)> describes how
38 to perform a key agreement.
39
40 The B<DH> structure consists of several BIGNUM components. The prime B<p>, the
41 generate B<g>, the Private key B<priv_key> and the public key B<pub_key>.
42 Optionally there may also be an additional parameter B<q>.
43
44 Note that DH keys may use non-standard B<DH_METHOD> implementations,
45 either directly or by the use of B<ENGINE> modules. In some cases (eg. an
46 ENGINE providing support for hardware-embedded keys), these BIGNUM values
47 will not be used by the implementation or may be used for alternative data
48 storage.
49
50 =head1 SEE ALSO
51
52 L<dhparam(1)>, L<bn(3)>, L<dsa(3)>, L<err(3)>,
53 L<rand(3)>, L<rsa(3)>, L<engine(3)>,
54 L<DH_set_method(3)>, L<DH_new(3)>,
55 L<DH_get_ex_new_index(3)>,
56 L<DH_generate_parameters(3)>,
57 L<DH_compute_key(3)>, L<DH_get0_pqg(3)>, L<DH_meth_new(3)>, L<d2i_DHparams(3)>,
58 L<RSA_print(3)>
59
60 =head1 COPYRIGHT
61
62 Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
63
64 Licensed under the OpenSSL license (the "License").  You may not use
65 this file except in compliance with the License.  You can obtain a copy
66 in the file LICENSE in the source distribution or at
67 L<https://www.openssl.org/source/license.html>.
68
69 =cut