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(3), ERR_get_error(3), rand(3), DH_size(3)
40

HISTORY

42       DH_generate_key() and DH_compute_key() are available in all versions of
43       SSLeay and OpenSSL.
44
45
46
471.0.2o                            2019-09-10                DH_generate_key(3)
Impressum