xref: /freebsd/crypto/openssl/doc/man3/DH_generate_parameters.pod (revision ad991e4c142ebabad7aef488ad97b189ecabb270)
1e71b7053SJung-uk Kim=pod
2e71b7053SJung-uk Kim
3e71b7053SJung-uk Kim=head1 NAME
4e71b7053SJung-uk Kim
5e71b7053SJung-uk KimDH_generate_parameters_ex, DH_generate_parameters,
6e71b7053SJung-uk KimDH_check, DH_check_params,
7e71b7053SJung-uk KimDH_check_ex, DH_check_params_ex, DH_check_pub_key_ex
8e71b7053SJung-uk Kim- generate and check Diffie-Hellman
9e71b7053SJung-uk Kimparameters
10e71b7053SJung-uk Kim
11e71b7053SJung-uk Kim=head1 SYNOPSIS
12e71b7053SJung-uk Kim
13e71b7053SJung-uk Kim #include <openssl/dh.h>
14e71b7053SJung-uk Kim
15b077aed3SPierre ProncheryThe following functions have been deprecated since OpenSSL 3.0, and can be
16b077aed3SPierre Proncheryhidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value,
17b077aed3SPierre Proncherysee L<openssl_user_macros(7)>:
18b077aed3SPierre Pronchery
19e71b7053SJung-uk Kim int DH_generate_parameters_ex(DH *dh, int prime_len, int generator, BN_GENCB *cb);
20e71b7053SJung-uk Kim
21e71b7053SJung-uk Kim int DH_check(DH *dh, int *codes);
22e71b7053SJung-uk Kim int DH_check_params(DH *dh, int *codes);
23e71b7053SJung-uk Kim
24e71b7053SJung-uk Kim int DH_check_ex(const DH *dh);
25e71b7053SJung-uk Kim int DH_check_params_ex(const DH *dh);
26e71b7053SJung-uk Kim int DH_check_pub_key_ex(const DH *dh, const BIGNUM *pub_key);
27e71b7053SJung-uk Kim
28b077aed3SPierre ProncheryThe following functions have been deprecated since OpenSSL 0.9.8, and can be
29b077aed3SPierre Proncheryhidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value,
30b077aed3SPierre Proncherysee L<openssl_user_macros(7)>:
31e71b7053SJung-uk Kim
32e71b7053SJung-uk Kim DH *DH_generate_parameters(int prime_len, int generator,
33e71b7053SJung-uk Kim                            void (*callback)(int, int, void *), void *cb_arg);
34e71b7053SJung-uk Kim
35e71b7053SJung-uk Kim=head1 DESCRIPTION
36e71b7053SJung-uk Kim
37b077aed3SPierre ProncheryAll of the functions described on this page are deprecated.
38b077aed3SPierre ProncheryApplications should instead use L<EVP_PKEY_check(3)>,
39b077aed3SPierre ProncheryL<EVP_PKEY_public_check(3)>, L<EVP_PKEY_private_check(3)> and
40b077aed3SPierre ProncheryL<EVP_PKEY_param_check(3)>.
41b077aed3SPierre Pronchery
42e71b7053SJung-uk KimDH_generate_parameters_ex() generates Diffie-Hellman parameters that can
43e71b7053SJung-uk Kimbe shared among a group of users, and stores them in the provided B<DH>
44e71b7053SJung-uk Kimstructure. The pseudo-random number generator must be
45e71b7053SJung-uk Kimseeded before calling it.
46e71b7053SJung-uk KimThe parameters generated by DH_generate_parameters_ex() should not be used in
47e71b7053SJung-uk Kimsignature schemes.
48e71b7053SJung-uk Kim
49e71b7053SJung-uk KimB<prime_len> is the length in bits of the safe prime to be generated.
50e71b7053SJung-uk KimB<generator> is a small number E<gt> 1, typically 2 or 5.
51e71b7053SJung-uk Kim
52e71b7053SJung-uk KimA callback function may be used to provide feedback about the progress
53e71b7053SJung-uk Kimof the key generation. If B<cb> is not B<NULL>, it will be
54e71b7053SJung-uk Kimcalled as described in L<BN_generate_prime(3)> while a random prime
55e71b7053SJung-uk Kimnumber is generated, and when a prime has been found, B<BN_GENCB_call(cb, 3, 0)>
56e71b7053SJung-uk Kimis called. See L<BN_generate_prime_ex(3)> for information on
57e71b7053SJung-uk Kimthe BN_GENCB_call() function.
58e71b7053SJung-uk Kim
59e71b7053SJung-uk KimDH_generate_parameters() is similar to DH_generate_prime_ex() but
60e71b7053SJung-uk Kimexpects an old-style callback function; see
61e71b7053SJung-uk KimL<BN_generate_prime(3)> for information on the old-style callback.
62e71b7053SJung-uk Kim
63e71b7053SJung-uk KimDH_check_params() confirms that the B<p> and B<g> are likely enough to
64e71b7053SJung-uk Kimbe valid.
65e71b7053SJung-uk KimThis is a lightweight check, if a more thorough check is needed, use
66e71b7053SJung-uk KimDH_check().
67e71b7053SJung-uk KimThe value of B<*codes> is updated with any problems found.
68e71b7053SJung-uk KimIf B<*codes> is zero then no problems were found, otherwise the
69e71b7053SJung-uk Kimfollowing bits may be set:
70e71b7053SJung-uk Kim
71e71b7053SJung-uk Kim=over 4
72e71b7053SJung-uk Kim
73e71b7053SJung-uk Kim=item DH_CHECK_P_NOT_PRIME
74e71b7053SJung-uk Kim
75e71b7053SJung-uk KimThe parameter B<p> has been determined to not being an odd prime.
76e71b7053SJung-uk KimNote that the lack of this bit doesn't guarantee that B<p> is a
77e71b7053SJung-uk Kimprime.
78e71b7053SJung-uk Kim
79e71b7053SJung-uk Kim=item DH_NOT_SUITABLE_GENERATOR
80e71b7053SJung-uk Kim
81e71b7053SJung-uk KimThe generator B<g> is not suitable.
82e71b7053SJung-uk KimNote that the lack of this bit doesn't guarantee that B<g> is
83e71b7053SJung-uk Kimsuitable, unless B<p> is known to be a strong prime.
84e71b7053SJung-uk Kim
85b077aed3SPierre Pronchery=item DH_MODULUS_TOO_SMALL
86b077aed3SPierre Pronchery
87b077aed3SPierre ProncheryThe modulus is too small.
88b077aed3SPierre Pronchery
89b077aed3SPierre Pronchery=item DH_MODULUS_TOO_LARGE
90b077aed3SPierre Pronchery
91b077aed3SPierre ProncheryThe modulus is too large.
92b077aed3SPierre Pronchery
93e71b7053SJung-uk Kim=back
94e71b7053SJung-uk Kim
95e71b7053SJung-uk KimDH_check() confirms that the Diffie-Hellman parameters B<dh> are valid. The
96e71b7053SJung-uk Kimvalue of B<*codes> is updated with any problems found. If B<*codes> is zero then
97e71b7053SJung-uk Kimno problems were found, otherwise the following bits may be set:
98e71b7053SJung-uk Kim
99e71b7053SJung-uk Kim=over 4
100e71b7053SJung-uk Kim
101e71b7053SJung-uk Kim=item DH_CHECK_P_NOT_PRIME
102e71b7053SJung-uk Kim
103e71b7053SJung-uk KimThe parameter B<p> is not prime.
104e71b7053SJung-uk Kim
105e71b7053SJung-uk Kim=item DH_CHECK_P_NOT_SAFE_PRIME
106e71b7053SJung-uk Kim
107e71b7053SJung-uk KimThe parameter B<p> is not a safe prime and no B<q> value is present.
108e71b7053SJung-uk Kim
109e71b7053SJung-uk Kim=item DH_UNABLE_TO_CHECK_GENERATOR
110e71b7053SJung-uk Kim
111e71b7053SJung-uk KimThe generator B<g> cannot be checked for suitability.
112e71b7053SJung-uk Kim
113e71b7053SJung-uk Kim=item DH_NOT_SUITABLE_GENERATOR
114e71b7053SJung-uk Kim
115e71b7053SJung-uk KimThe generator B<g> is not suitable.
116e71b7053SJung-uk Kim
117e71b7053SJung-uk Kim=item DH_CHECK_Q_NOT_PRIME
118e71b7053SJung-uk Kim
119e71b7053SJung-uk KimThe parameter B<q> is not prime.
120e71b7053SJung-uk Kim
121e71b7053SJung-uk Kim=item DH_CHECK_INVALID_Q_VALUE
122e71b7053SJung-uk Kim
123e71b7053SJung-uk KimThe parameter B<q> is invalid.
124e71b7053SJung-uk Kim
125e71b7053SJung-uk Kim=item DH_CHECK_INVALID_J_VALUE
126e71b7053SJung-uk Kim
127e71b7053SJung-uk KimThe parameter B<j> is invalid.
128e71b7053SJung-uk Kim
129e71b7053SJung-uk Kim=back
130e71b7053SJung-uk Kim
131*ad991e4cSEd MasteIf 0 is returned or B<*codes> is set to a nonzero value the supplied
132*ad991e4cSEd Masteparameters should not be used for Diffie-Hellman operations otherwise
133*ad991e4cSEd Mastethe security properties of the key exchange are not guaranteed.
134*ad991e4cSEd Maste
135e71b7053SJung-uk KimDH_check_ex(), DH_check_params() and DH_check_pub_key_ex() are similar to
136e71b7053SJung-uk KimDH_check() and DH_check_params() respectively, but the error reasons are added
137e71b7053SJung-uk Kimto the thread's error queue instead of provided as return values from the
138e71b7053SJung-uk Kimfunction.
139e71b7053SJung-uk Kim
140e71b7053SJung-uk Kim=head1 RETURN VALUES
141e71b7053SJung-uk Kim
142e71b7053SJung-uk KimDH_generate_parameters_ex(), DH_check() and DH_check_params() return 1
143e71b7053SJung-uk Kimif the check could be performed, 0 otherwise.
144e71b7053SJung-uk Kim
145e71b7053SJung-uk KimDH_generate_parameters() returns a pointer to the DH structure or NULL if
146e71b7053SJung-uk Kimthe parameter generation fails.
147e71b7053SJung-uk Kim
148e71b7053SJung-uk KimDH_check_ex(), DH_check_params() and DH_check_pub_key_ex() return 1 if the
149e71b7053SJung-uk Kimcheck is successful, 0 for failed.
150e71b7053SJung-uk Kim
151e71b7053SJung-uk KimThe error codes can be obtained by L<ERR_get_error(3)>.
152e71b7053SJung-uk Kim
153e71b7053SJung-uk Kim=head1 SEE ALSO
154e71b7053SJung-uk Kim
155e71b7053SJung-uk KimL<DH_new(3)>, L<ERR_get_error(3)>, L<RAND_bytes(3)>,
156e71b7053SJung-uk KimL<DH_free(3)>
157e71b7053SJung-uk Kim
158e71b7053SJung-uk Kim=head1 HISTORY
159e71b7053SJung-uk Kim
160b077aed3SPierre ProncheryAll of these functions were deprecated in OpenSSL 3.0.
161b077aed3SPierre Pronchery
162e71b7053SJung-uk KimDH_generate_parameters() was deprecated in OpenSSL 0.9.8; use
163e71b7053SJung-uk KimDH_generate_parameters_ex() instead.
164e71b7053SJung-uk Kim
165e71b7053SJung-uk Kim=head1 COPYRIGHT
166e71b7053SJung-uk Kim
167*ad991e4cSEd MasteCopyright 2000-2023 The OpenSSL Project Authors. All Rights Reserved.
168e71b7053SJung-uk Kim
169b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
170e71b7053SJung-uk Kimthis file except in compliance with the License.  You can obtain a copy
171e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at
172e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>.
173e71b7053SJung-uk Kim
174e71b7053SJung-uk Kim=cut
175