1 .\" $OpenBSD: DH_generate_parameters.3,v 1.6 2016/12/10 22:22:59 schwarze Exp $
2 .\" OpenSSL 05ea606a May 20 20:52:46 2016 -0400
4 .\" This file was written by Ulf Moeller <ulf@openssl.org>.
5 .\" Copyright (c) 2000, 2016 The OpenSSL Project. All rights reserved.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in
16 .\" the documentation and/or other materials provided with the
19 .\" 3. All advertising materials mentioning features or use of this
20 .\" software must display the following acknowledgment:
21 .\" "This product includes software developed by the OpenSSL Project
22 .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25 .\" endorse or promote products derived from this software without
26 .\" prior written permission. For written permission, please contact
27 .\" openssl-core@openssl.org.
29 .\" 5. Products derived from this software may not be called "OpenSSL"
30 .\" nor may "OpenSSL" appear in their names without prior written
31 .\" permission of the OpenSSL Project.
33 .\" 6. Redistributions of any form whatsoever must retain the following
35 .\" "This product includes software developed by the OpenSSL Project
36 .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
51 .Dd $Mdocdate: December 10 2016 $
52 .Dt DH_GENERATE_PARAMETERS 3
55 .Nm DH_generate_parameters_ex ,
57 .Nm DH_generate_parameters
58 .Nd generate and check Diffie-Hellman parameters
62 .Fo DH_generate_parameters_ex
77 .Fo DH_generate_parameters
80 .Fa "void (*callback)(int"
86 .Fn DH_generate_parameters_ex
87 generates Diffie-Hellman parameters that can be shared among a group of
88 users, and stores them in the provided
93 is the length in bits of the safe prime to be generated.
95 is a small number > 1, typically 2 or 5.
97 A callback function may be used to provide feedback about the progress
98 of the key generation.
103 it will be called as described in
104 .Xr BN_generate_prime 3
105 while a random prime number is generated, and when a prime has been
107 .Fn BN_GENCB_call cb 3 0
109 .Xr BN_GENCB_call 3 .
112 validates Diffie-Hellman parameters.
113 If no problems are found,
116 Otherwise, one or more of the following bits are set:
118 .It Dv DH_CHECK_P_NOT_PRIME
122 .It Dv DH_CHECK_P_NOT_SAFE_PRIME
126 .It Dv DH_UNABLE_TO_CHECK_GENERATOR
129 cannot be checked for suitability: it is neither 2 nor 5.
130 .It Dv DH_NOT_SUITABLE_GENERATOR
136 .Fn DH_generate_parameters_ex
139 return 1 if the check could be performed, or 0 otherwise.
141 .Fn DH_generate_parameters
142 (deprecated) returns a pointer to the
146 if the parameter generation fails.
148 The error codes can be obtained by
149 .Xr ERR_get_error 3 .
152 .Xr ERR_get_error 3 ,
156 is available in all versions of SSLeay and OpenSSL.
160 .Fn DH_generate_parameters
161 was added in SSLeay 0.9.0.
163 In versions before OpenSSL 0.9.5,
164 .Dv DH_CHECK_P_NOT_STRONG_PRIME
166 .Dv DH_CHECK_P_NOT_SAFE_PRIME .
168 .Fn DH_generate_parameters_ex
170 .Fn DH_generate_parameters
171 may run for several hours before finding a suitable prime.
173 The parameters generated by
174 .Fn DH_generate_parameters_ex
176 .Fn DH_generate_parameters
177 are not to be used in signature schemes.
182 .Fa dh->g Ns = Ns Fa generator
183 is not a usable generator.