1DH_GENERATE_KEY(3)                  OpenSSL                 DH_GENERATE_KEY(3)
2
3
4

NAME

6       DH_generate_key, DH_compute_key - perform Diffie-Hellman key exchange
7

SYNOPSIS

9        #include <openssl/dh.h>
10
11        int DH_generate_key(DH *dh);
12
13        int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh);
14

DESCRIPTION

16       DH_generate_key() performs the first step of a Diffie-Hellman key
17       exchange by generating private and public DH values. By calling
18       DH_compute_key(), these are combined with the other party's public
19       value to compute the shared key.
20
21       DH_generate_key() expects dh to contain the shared parameters dh->p and
22       dh->g. It generates a random private DH value unless dh->priv_key is
23       already set, and computes the corresponding public value dh->pub_key,
24       which can then be published.
25
26       DH_compute_key() computes the shared secret from the private DH value
27       in dh and the other party's public value in pub_key and stores it in
28       key. key must point to DH_size(dh) bytes of memory.
29

RETURN VALUES

31       DH_generate_key() returns 1 on success, 0 otherwise.
32
33       DH_compute_key() returns the size of the shared secret on success, -1
34       on error.
35
36       The error codes can be obtained by ERR_get_error(3).
37

SEE ALSO

39       DH_new(3), ERR_get_error(3), RAND_bytes(3), DH_size(3)
40
42       Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
43
44       Licensed under the OpenSSL license (the "License").  You may not use
45       this file except in compliance with the License.  You can obtain a copy
46       in the file LICENSE in the source distribution or at
47       <https://www.openssl.org/source/license.html>.
48
49
50
511.1.1i                            2021-07-22                DH_GENERATE_KEY(3)
Impressum