1DH_GET0_PQG(3)                      OpenSSL                     DH_GET0_PQG(3)
2
3
4

NAME

6       DH_get0_pqg, DH_set0_pqg, DH_get0_key, DH_set0_key, DH_get0_p,
7       DH_get0_q, DH_get0_g, DH_get0_priv_key, DH_get0_pub_key,
8       DH_clear_flags, DH_test_flags, DH_set_flags, DH_get0_engine,
9       DH_get_length, DH_set_length - Routines for getting and setting data in
10       a DH object
11

SYNOPSIS

13        #include <openssl/dh.h>
14
15        void DH_get0_pqg(const DH *dh,
16                         const BIGNUM **p, const BIGNUM **q, const BIGNUM **g);
17        int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g);
18        void DH_get0_key(const DH *dh,
19                         const BIGNUM **pub_key, const BIGNUM **priv_key);
20        int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key);
21        const BIGNUM *DH_get0_p(const DH *dh);
22        const BIGNUM *DH_get0_q(const DH *dh);
23        const BIGNUM *DH_get0_g(const DH *dh);
24        const BIGNUM *DH_get0_priv_key(const DH *dh);
25        const BIGNUM *DH_get0_pub_key(const DH *dh);
26        void DH_clear_flags(DH *dh, int flags);
27        int DH_test_flags(const DH *dh, int flags);
28        void DH_set_flags(DH *dh, int flags);
29        ENGINE *DH_get0_engine(DH *d);
30        long DH_get_length(const DH *dh);
31        int DH_set_length(DH *dh, long length);
32

DESCRIPTION

34       A DH object contains the parameters p, q and g. Note that the q
35       parameter is optional. It also contains a public key (pub_key) and
36       (optionally) a private key (priv_key).
37
38       The p, q and g parameters can be obtained by calling DH_get0_pqg().  If
39       the parameters have not yet been set then *p, *q and *g will be set to
40       NULL. Otherwise they are set to pointers to their respective values.
41       These point directly to the internal representations of the values and
42       therefore should not be freed directly.  Any of the out parameters p,
43       q, and g can be NULL, in which case no value will be returned for that
44       parameter.
45
46       The p, q and g values can be set by calling DH_set0_pqg() and passing
47       the new values for p, q and g as parameters to the function. Calling
48       this function transfers the memory management of the values to the DH
49       object, and therefore the values that have been passed in should not be
50       freed directly after this function has been called. The q parameter may
51       be NULL.
52
53       To get the public and private key values use the DH_get0_key()
54       function. A pointer to the public key will be stored in *pub_key, and a
55       pointer to the private key will be stored in *priv_key. Either may be
56       NULL if they have not been set yet, although if the private key has
57       been set then the public key must be. The values point to the internal
58       representation of the public key and private key values. This memory
59       should not be freed directly.  Any of the out parameters pub_key and
60       priv_key can be NULL, in which case no value will be returned for that
61       parameter.
62
63       The public and private key values can be set using DH_set0_key().
64       Either parameter may be NULL, which means the corresponding DH field is
65       left untouched. As with DH_set0_pqg() this function transfers the
66       memory management of the key values to the DH object, and therefore
67       they should not be freed directly after this function has been called.
68
69       Any of the values p, q, g, priv_key, and pub_key can also be retrieved
70       separately by the corresponding function DH_get0_p(), DH_get0_q(),
71       DH_get0_g(), DH_get0_priv_key(), and DH_get0_pub_key(), respectively.
72
73       DH_set_flags() sets the flags in the flags parameter on the DH object.
74       Multiple flags can be passed in one go (bitwise ORed together). Any
75       flags that are already set are left set. DH_test_flags() tests to see
76       whether the flags passed in the flags parameter are currently set in
77       the DH object. Multiple flags can be tested in one go. All flags that
78       are currently set are returned, or zero if none of the flags are set.
79       DH_clear_flags() clears the specified flags within the DH object.
80
81       DH_get0_engine() returns a handle to the ENGINE that has been set for
82       this DH object, or NULL if no such ENGINE has been set.
83
84       The DH_get_length() and DH_set_length() functions get and set the
85       optional length parameter associated with this DH object. If the length
86       is nonzero then it is used, otherwise it is ignored. The length
87       parameter indicates the length of the secret exponent (private key) in
88       bits.
89

NOTES

91       Values retrieved with DH_get0_key() are owned by the DH object used in
92       the call and may therefore not be passed to DH_set0_key().  If needed,
93       duplicate the received value using BN_dup() and pass the duplicate.
94       The same applies to DH_get0_pqg() and DH_set0_pqg().
95

RETURN VALUES

97       DH_set0_pqg() and DH_set0_key() return 1 on success or 0 on failure.
98
99       DH_get0_p(), DH_get0_q(), DH_get0_g(), DH_get0_priv_key(), and
100       DH_get0_pub_key() return the respective value, or NULL if it is unset.
101
102       DH_test_flags() returns the current state of the flags in the DH
103       object.
104
105       DH_get0_engine() returns the ENGINE set for the DH object or NULL if no
106       ENGINE has been set.
107
108       DH_get_length() returns the length of the secret exponent (private key)
109       in bits, or zero if no such length has been explicitly set.
110

SEE ALSO

112       DH_new(3), DH_new(3), DH_generate_parameters(3), DH_generate_key(3),
113       DH_set_method(3), DH_size(3), DH_meth_new(3)
114

HISTORY

116       The functions described here were added in OpenSSL 1.1.0.
117
119       Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
120
121       Licensed under the OpenSSL license (the "License").  You may not use
122       this file except in compliance with the License.  You can obtain a copy
123       in the file LICENSE in the source distribution or at
124       <https://www.openssl.org/source/license.html>.
125
126
127
1281.1.1q                            2023-07-20                    DH_GET0_PQG(3)
Impressum