import libcrypto (LibreSSL 2.5.2)
[unleashed.git] / lib / libcrypto / man / DH_generate_parameters.3
blobfac74d8d741be01cc8d5baf343b20249283d175b
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
3 .\"
4 .\" This file was written by Ulf Moeller <ulf@openssl.org>.
5 .\" Copyright (c) 2000, 2016 The OpenSSL Project.  All rights reserved.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\"
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\"
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
17 .\"    distribution.
18 .\"
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/)"
23 .\"
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.
28 .\"
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.
32 .\"
33 .\" 6. Redistributions of any form whatsoever must retain the following
34 .\"    acknowledgment:
35 .\"    "This product includes software developed by the OpenSSL Project
36 .\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37 .\"
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.
50 .\"
51 .Dd $Mdocdate: December 10 2016 $
52 .Dt DH_GENERATE_PARAMETERS 3
53 .Os
54 .Sh NAME
55 .Nm DH_generate_parameters_ex ,
56 .Nm DH_check ,
57 .Nm DH_generate_parameters
58 .Nd generate and check Diffie-Hellman parameters
59 .Sh SYNOPSIS
60 .In openssl/dh.h
61 .Ft int
62 .Fo DH_generate_parameters_ex
63 .Fa "DH *dh"
64 .Fa "int prime_len"
65 .Fa "int generator"
66 .Fa "BN_GENCB *cb"
67 .Fc
68 .Ft int
69 .Fo DH_check
70 .Fa "DH *dh"
71 .Fa "int *codes"
72 .Fc
73 .Pp
74 Deprecated:
75 .Pp
76 .Ft DH *
77 .Fo DH_generate_parameters
78 .Fa "int prime_len"
79 .Fa "int generator"
80 .Fa "void (*callback)(int"
81 .Fa int
82 .Fa "void *)"
83 .Fa "void *cb_arg"
84 .Fc
85 .Sh DESCRIPTION
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
89 .Vt DH
90 structure.
91 .Pp
92 .Fa prime_len
93 is the length in bits of the safe prime to be generated.
94 .Fa generator
95 is a small number > 1, typically 2 or 5.
96 .Pp
97 A callback function may be used to provide feedback about the progress
98 of the key generation.
100 .Fa cb
101 is not
102 .Dv NULL ,
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
106 found,
107 .Fn BN_GENCB_call cb 3 0
108 is called; see
109 .Xr BN_GENCB_call 3 .
111 .Fn DH_check
112 validates Diffie-Hellman parameters.
113 If no problems are found,
114 .Pf * Ar codes
115 is set to zero.
116 Otherwise, one or more of the following bits are set:
117 .Bl -tag -width Ds
118 .It Dv DH_CHECK_P_NOT_PRIME
119 The parameter
120 .Fa dh->p
121 is not prime.
122 .It Dv DH_CHECK_P_NOT_SAFE_PRIME
123 The parameter
124 .Fa dh->p
125 is not a safe prime.
126 .It Dv DH_UNABLE_TO_CHECK_GENERATOR
127 The generator
128 .Fa dh->g
129 cannot be checked for suitability: it is neither 2 nor 5.
130 .It Dv DH_NOT_SUITABLE_GENERATOR
131 The generator
132 .Fa dh->g
133 is not suitable.
135 .Sh RETURN VALUES
136 .Fn DH_generate_parameters_ex
138 .Fn DH_check
139 return 1 if the check could be performed, or 0 otherwise.
141 .Fn DH_generate_parameters
142 (deprecated) returns a pointer to the
143 .Vt DH
144 structure, or
145 .Dv NULL
146 if the parameter generation fails.
148 The error codes can be obtained by
149 .Xr ERR_get_error 3 .
150 .Sh SEE ALSO
151 .Xr DH_new 3 ,
152 .Xr ERR_get_error 3 ,
153 .Xr RAND_bytes 3
154 .Sh HISTORY
155 .Fn DH_check
156 is available in all versions of SSLeay and OpenSSL.
158 .Fa cb_arg
159 argument to
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
165 is used instead of
166 .Dv DH_CHECK_P_NOT_SAFE_PRIME .
167 .Sh CAVEATS
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.
178 .Sh BUGS
180 .Fa generator
181 is not 2 or 5,
182 .Fa dh->g Ns = Ns Fa generator
183 is not a usable generator.