1e1051a39Sopenharmony_ci=pod
2e1051a39Sopenharmony_ci
3e1051a39Sopenharmony_ci=head1 NAME
4e1051a39Sopenharmony_ci
5e1051a39Sopenharmony_ciDH_generate_parameters_ex, DH_generate_parameters,
6e1051a39Sopenharmony_ciDH_check, DH_check_params,
7e1051a39Sopenharmony_ciDH_check_ex, DH_check_params_ex, DH_check_pub_key_ex
8e1051a39Sopenharmony_ci- generate and check Diffie-Hellman
9e1051a39Sopenharmony_ciparameters
10e1051a39Sopenharmony_ci
11e1051a39Sopenharmony_ci=head1 SYNOPSIS
12e1051a39Sopenharmony_ci
13e1051a39Sopenharmony_ci #include <openssl/dh.h>
14e1051a39Sopenharmony_ci
15e1051a39Sopenharmony_ciThe following functions have been deprecated since OpenSSL 3.0, and can be
16e1051a39Sopenharmony_cihidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value,
17e1051a39Sopenharmony_cisee L<openssl_user_macros(7)>:
18e1051a39Sopenharmony_ci
19e1051a39Sopenharmony_ci int DH_generate_parameters_ex(DH *dh, int prime_len, int generator, BN_GENCB *cb);
20e1051a39Sopenharmony_ci
21e1051a39Sopenharmony_ci int DH_check(DH *dh, int *codes);
22e1051a39Sopenharmony_ci int DH_check_params(DH *dh, int *codes);
23e1051a39Sopenharmony_ci
24e1051a39Sopenharmony_ci int DH_check_ex(const DH *dh);
25e1051a39Sopenharmony_ci int DH_check_params_ex(const DH *dh);
26e1051a39Sopenharmony_ci int DH_check_pub_key_ex(const DH *dh, const BIGNUM *pub_key);
27e1051a39Sopenharmony_ci
28e1051a39Sopenharmony_ciThe following functions have been deprecated since OpenSSL 0.9.8, and can be
29e1051a39Sopenharmony_cihidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value,
30e1051a39Sopenharmony_cisee L<openssl_user_macros(7)>:
31e1051a39Sopenharmony_ci
32e1051a39Sopenharmony_ci DH *DH_generate_parameters(int prime_len, int generator,
33e1051a39Sopenharmony_ci                            void (*callback)(int, int, void *), void *cb_arg);
34e1051a39Sopenharmony_ci
35e1051a39Sopenharmony_ci=head1 DESCRIPTION
36e1051a39Sopenharmony_ci
37e1051a39Sopenharmony_ciAll of the functions described on this page are deprecated.
38e1051a39Sopenharmony_ciApplications should instead use L<EVP_PKEY_check(3)>,
39e1051a39Sopenharmony_ciL<EVP_PKEY_public_check(3)>, L<EVP_PKEY_private_check(3)> and
40e1051a39Sopenharmony_ciL<EVP_PKEY_param_check(3)>.
41e1051a39Sopenharmony_ci
42e1051a39Sopenharmony_ciDH_generate_parameters_ex() generates Diffie-Hellman parameters that can
43e1051a39Sopenharmony_cibe shared among a group of users, and stores them in the provided B<DH>
44e1051a39Sopenharmony_cistructure. The pseudo-random number generator must be
45e1051a39Sopenharmony_ciseeded before calling it.
46e1051a39Sopenharmony_ciThe parameters generated by DH_generate_parameters_ex() should not be used in
47e1051a39Sopenharmony_cisignature schemes.
48e1051a39Sopenharmony_ci
49e1051a39Sopenharmony_ciB<prime_len> is the length in bits of the safe prime to be generated.
50e1051a39Sopenharmony_ciB<generator> is a small number E<gt> 1, typically 2 or 5.
51e1051a39Sopenharmony_ci
52e1051a39Sopenharmony_ciA callback function may be used to provide feedback about the progress
53e1051a39Sopenharmony_ciof the key generation. If B<cb> is not B<NULL>, it will be
54e1051a39Sopenharmony_cicalled as described in L<BN_generate_prime(3)> while a random prime
55e1051a39Sopenharmony_cinumber is generated, and when a prime has been found, B<BN_GENCB_call(cb, 3, 0)>
56e1051a39Sopenharmony_ciis called. See L<BN_generate_prime_ex(3)> for information on
57e1051a39Sopenharmony_cithe BN_GENCB_call() function.
58e1051a39Sopenharmony_ci
59e1051a39Sopenharmony_ciDH_generate_parameters() is similar to DH_generate_prime_ex() but
60e1051a39Sopenharmony_ciexpects an old-style callback function; see
61e1051a39Sopenharmony_ciL<BN_generate_prime(3)> for information on the old-style callback.
62e1051a39Sopenharmony_ci
63e1051a39Sopenharmony_ciDH_check_params() confirms that the B<p> and B<g> are likely enough to
64e1051a39Sopenharmony_cibe valid.
65e1051a39Sopenharmony_ciThis is a lightweight check, if a more thorough check is needed, use
66e1051a39Sopenharmony_ciDH_check().
67e1051a39Sopenharmony_ciThe value of B<*codes> is updated with any problems found.
68e1051a39Sopenharmony_ciIf B<*codes> is zero then no problems were found, otherwise the
69e1051a39Sopenharmony_cifollowing bits may be set:
70e1051a39Sopenharmony_ci
71e1051a39Sopenharmony_ci=over 4
72e1051a39Sopenharmony_ci
73e1051a39Sopenharmony_ci=item DH_CHECK_P_NOT_PRIME
74e1051a39Sopenharmony_ci
75e1051a39Sopenharmony_ciThe parameter B<p> has been determined to not being an odd prime.
76e1051a39Sopenharmony_ciNote that the lack of this bit doesn't guarantee that B<p> is a
77e1051a39Sopenharmony_ciprime.
78e1051a39Sopenharmony_ci
79e1051a39Sopenharmony_ci=item DH_NOT_SUITABLE_GENERATOR
80e1051a39Sopenharmony_ci
81e1051a39Sopenharmony_ciThe generator B<g> is not suitable.
82e1051a39Sopenharmony_ciNote that the lack of this bit doesn't guarantee that B<g> is
83e1051a39Sopenharmony_cisuitable, unless B<p> is known to be a strong prime.
84e1051a39Sopenharmony_ci
85e1051a39Sopenharmony_ci=item DH_MODULUS_TOO_SMALL
86e1051a39Sopenharmony_ci
87e1051a39Sopenharmony_ciThe modulus is too small.
88e1051a39Sopenharmony_ci
89e1051a39Sopenharmony_ci=item DH_MODULUS_TOO_LARGE
90e1051a39Sopenharmony_ci
91e1051a39Sopenharmony_ciThe modulus is too large.
92e1051a39Sopenharmony_ci
93e1051a39Sopenharmony_ci=back
94e1051a39Sopenharmony_ci
95e1051a39Sopenharmony_ciDH_check() confirms that the Diffie-Hellman parameters B<dh> are valid. The
96e1051a39Sopenharmony_civalue of B<*codes> is updated with any problems found. If B<*codes> is zero then
97e1051a39Sopenharmony_cino problems were found, otherwise the following bits may be set:
98e1051a39Sopenharmony_ci
99e1051a39Sopenharmony_ci=over 4
100e1051a39Sopenharmony_ci
101e1051a39Sopenharmony_ci=item DH_CHECK_P_NOT_PRIME
102e1051a39Sopenharmony_ci
103e1051a39Sopenharmony_ciThe parameter B<p> is not prime.
104e1051a39Sopenharmony_ci
105e1051a39Sopenharmony_ci=item DH_CHECK_P_NOT_SAFE_PRIME
106e1051a39Sopenharmony_ci
107e1051a39Sopenharmony_ciThe parameter B<p> is not a safe prime and no B<q> value is present.
108e1051a39Sopenharmony_ci
109e1051a39Sopenharmony_ci=item DH_UNABLE_TO_CHECK_GENERATOR
110e1051a39Sopenharmony_ci
111e1051a39Sopenharmony_ciThe generator B<g> cannot be checked for suitability.
112e1051a39Sopenharmony_ci
113e1051a39Sopenharmony_ci=item DH_NOT_SUITABLE_GENERATOR
114e1051a39Sopenharmony_ci
115e1051a39Sopenharmony_ciThe generator B<g> is not suitable.
116e1051a39Sopenharmony_ci
117e1051a39Sopenharmony_ci=item DH_CHECK_Q_NOT_PRIME
118e1051a39Sopenharmony_ci
119e1051a39Sopenharmony_ciThe parameter B<q> is not prime.
120e1051a39Sopenharmony_ci
121e1051a39Sopenharmony_ci=item DH_CHECK_INVALID_Q_VALUE
122e1051a39Sopenharmony_ci
123e1051a39Sopenharmony_ciThe parameter B<q> is invalid.
124e1051a39Sopenharmony_ci
125e1051a39Sopenharmony_ci=item DH_CHECK_INVALID_J_VALUE
126e1051a39Sopenharmony_ci
127e1051a39Sopenharmony_ciThe parameter B<j> is invalid.
128e1051a39Sopenharmony_ci
129e1051a39Sopenharmony_ci=back
130e1051a39Sopenharmony_ci
131e1051a39Sopenharmony_ciDH_check_ex(), DH_check_params() and DH_check_pub_key_ex() are similar to
132e1051a39Sopenharmony_ciDH_check() and DH_check_params() respectively, but the error reasons are added
133e1051a39Sopenharmony_cito the thread's error queue instead of provided as return values from the
134e1051a39Sopenharmony_cifunction.
135e1051a39Sopenharmony_ci
136e1051a39Sopenharmony_ci=head1 RETURN VALUES
137e1051a39Sopenharmony_ci
138e1051a39Sopenharmony_ciDH_generate_parameters_ex(), DH_check() and DH_check_params() return 1
139e1051a39Sopenharmony_ciif the check could be performed, 0 otherwise.
140e1051a39Sopenharmony_ci
141e1051a39Sopenharmony_ciDH_generate_parameters() returns a pointer to the DH structure or NULL if
142e1051a39Sopenharmony_cithe parameter generation fails.
143e1051a39Sopenharmony_ci
144e1051a39Sopenharmony_ciDH_check_ex(), DH_check_params() and DH_check_pub_key_ex() return 1 if the
145e1051a39Sopenharmony_cicheck is successful, 0 for failed.
146e1051a39Sopenharmony_ci
147e1051a39Sopenharmony_ciThe error codes can be obtained by L<ERR_get_error(3)>.
148e1051a39Sopenharmony_ci
149e1051a39Sopenharmony_ci=head1 SEE ALSO
150e1051a39Sopenharmony_ci
151e1051a39Sopenharmony_ciL<DH_new(3)>, L<ERR_get_error(3)>, L<RAND_bytes(3)>,
152e1051a39Sopenharmony_ciL<DH_free(3)>
153e1051a39Sopenharmony_ci
154e1051a39Sopenharmony_ci=head1 HISTORY
155e1051a39Sopenharmony_ci
156e1051a39Sopenharmony_ciAll of these functions were deprecated in OpenSSL 3.0.
157e1051a39Sopenharmony_ci
158e1051a39Sopenharmony_ciDH_generate_parameters() was deprecated in OpenSSL 0.9.8; use
159e1051a39Sopenharmony_ciDH_generate_parameters_ex() instead.
160e1051a39Sopenharmony_ci
161e1051a39Sopenharmony_ci=head1 COPYRIGHT
162e1051a39Sopenharmony_ci
163e1051a39Sopenharmony_ciCopyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
164e1051a39Sopenharmony_ci
165e1051a39Sopenharmony_ciLicensed under the Apache License 2.0 (the "License").  You may not use
166e1051a39Sopenharmony_cithis file except in compliance with the License.  You can obtain a copy
167e1051a39Sopenharmony_ciin the file LICENSE in the source distribution or at
168e1051a39Sopenharmony_ciL<https://www.openssl.org/source/license.html>.
169e1051a39Sopenharmony_ci
170e1051a39Sopenharmony_ci=cut
171