]> git.ipfire.org Git - thirdparty/openssl.git/blame - doc/man3/DH_generate_key.pod
Deprecate the low level Diffie-Hellman functions.
[thirdparty/openssl.git] / doc / man3 / DH_generate_key.pod
CommitLineData
4486d0cd
UM
1=pod
2
3=head1 NAME
4
4d524e10 5DH_generate_key, DH_compute_key - perform Diffie-Hellman key exchange
4486d0cd
UM
6
7=head1 SYNOPSIS
8
9 #include <openssl/dh.h>
10
ada66e78
P
11Deprecated since OpenSSL 3.0, can be hidden entirely by defining
12B<OPENSSL_API_COMPAT> with a suitable version value, see
13L<openssl_user_macros(7)>:
14
4486d0cd
UM
15 int DH_generate_key(DH *dh);
16
17 int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh);
18
19=head1 DESCRIPTION
20
ada66e78
P
21Both of the functions described on this page are deprecated.
22Applications should instead use L<EVP_PKEY_derive_init(3)>
23and L<EVP_PKEY_derive(3)>.
24
4486d0cd
UM
25DH_generate_key() performs the first step of a Diffie-Hellman key
26exchange by generating private and public DH values. By calling
27DH_compute_key(), these are combined with the other party's public
28value to compute the shared key.
29
30DH_generate_key() expects B<dh> to contain the shared parameters
31B<dh-E<gt>p> and B<dh-E<gt>g>. It generates a random private DH value
924875e5
BM
32unless B<dh-E<gt>priv_key> is already set, and computes the
33corresponding public value B<dh-E<gt>pub_key>, which can then be
34published.
4486d0cd
UM
35
36DH_compute_key() computes the shared secret from the private DH value
37in B<dh> and the other party's public value in B<pub_key> and stores
38it in B<key>. B<key> must point to B<DH_size(dh)> bytes of memory.
39
40=head1 RETURN VALUES
41
42DH_generate_key() returns 1 on success, 0 otherwise.
43
44DH_compute_key() returns the size of the shared secret on success, -1
45on error.
46
9b86974e 47The error codes can be obtained by L<ERR_get_error(3)>.
4486d0cd
UM
48
49=head1 SEE ALSO
50
ada66e78 51L<EVP_PKEY_derive(3)>,
b97fdb57 52L<DH_new(3)>, L<ERR_get_error(3)>, L<RAND_bytes(3)>, L<DH_size(3)>
4486d0cd 53
ada66e78
P
54=head1 HISTORY
55
56Both of these functions were deprecated in OpenSSL 3.0.
57
e2f92610
RS
58=head1 COPYRIGHT
59
60Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
61
4746f25a 62Licensed under the Apache License 2.0 (the "License"). You may not use
e2f92610
RS
63this file except in compliance with the License. You can obtain a copy
64in the file LICENSE in the source distribution or at
65L<https://www.openssl.org/source/license.html>.
66
67=cut