summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschwarze <>2016-12-01 21:53:42 +0000
committerschwarze <>2016-12-01 21:53:42 +0000
commit137758a4f77d603861bf0b68e2af2d77070d247e (patch)
tree4fb7b87001ca9459161e1ac2ab0589cfa89ec3f0
parente53fcf2ef6fbb38de4669f45977b6eff4ef3b901 (diff)
downloadopenbsd-137758a4f77d603861bf0b68e2af2d77070d247e.tar.gz
openbsd-137758a4f77d603861bf0b68e2af2d77070d247e.tar.bz2
openbsd-137758a4f77d603861bf0b68e2af2d77070d247e.zip
Add Copyright and license.
Merge various updates from OpenSSL, in particular stop talking about what happens without SSL_OP_SINGLE_DH_USE, which is now always on.
-rw-r--r--src/lib/libssl/man/SSL_CTX_set_tmp_dh_callback.3203
1 files changed, 95 insertions, 108 deletions
diff --git a/src/lib/libssl/man/SSL_CTX_set_tmp_dh_callback.3 b/src/lib/libssl/man/SSL_CTX_set_tmp_dh_callback.3
index ad734839a9..94ec9e9b90 100644
--- a/src/lib/libssl/man/SSL_CTX_set_tmp_dh_callback.3
+++ b/src/lib/libssl/man/SSL_CTX_set_tmp_dh_callback.3
@@ -1,7 +1,54 @@
1.\" $OpenBSD: SSL_CTX_set_tmp_dh_callback.3,v 1.2 2016/12/01 21:53:42 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
1.\" 3.\"
2.\" $OpenBSD: SSL_CTX_set_tmp_dh_callback.3,v 1.1 2016/11/05 15:32:19 schwarze Exp $ 4.\" This file was written by Lutz Jaenicke <jaenicke@openssl.org>.
5.\" Copyright (c) 2001, 2014, 2015 The OpenSSL Project. All rights reserved.
3.\" 6.\"
4.Dd $Mdocdate: November 5 2016 $ 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 1 2016 $
5.Dt SSL_CTX_SET_TMP_DH_CALLBACK 3 52.Dt SSL_CTX_SET_TMP_DH_CALLBACK 3
6.Os 53.Os
7.Sh NAME 54.Sh NAME
@@ -54,7 +101,7 @@ sets the parameters only for
54.Fa ssl . 101.Fa ssl .
55.Pp 102.Pp
56These functions apply to SSL/TLS servers only. 103These functions apply to SSL/TLS servers only.
57.Sh NOTES 104.Pp
58When using a cipher with RSA authentication, 105When using a cipher with RSA authentication,
59an ephemeral DH key exchange can take place. 106an ephemeral DH key exchange can take place.
60Ciphers with DSA keys always use ephemeral DH keys as well. 107Ciphers with DSA keys always use ephemeral DH keys as well.
@@ -72,35 +119,7 @@ as this key was only used for signing.
72.Pp 119.Pp
73In order to perform a DH key exchange the server must use a DH group 120In order to perform a DH key exchange the server must use a DH group
74(DH parameters) and generate a DH key. 121(DH parameters) and generate a DH key.
75The server will always generate a new DH key during the negotiation, 122The server will always generate a new DH key during the negotiation.
76when the DH parameters are supplied via callback and/or when the
77.Dv SSL_OP_SINGLE_DH_USE
78option of
79.Xr SSL_CTX_set_options 3
80is set.
81It will immediately create a DH key, when DH parameters are supplied via
82.Fn SSL_CTX_set_tmp_dh
83and
84.Dv SSL_OP_SINGLE_DH_USE
85is not set.
86In this case, it may happen that a key is generated on initialization without
87later being needed, while on the other hand the computer time during the
88negotiation is being saved.
89.Pp
90If
91.Dq strong
92primes were used to generate the DH parameters, it is not strictly necessary to
93generate a new key for each handshake but it does improve forward secrecy.
94If it is not assured that
95.Dq strong
96primes were used (see especially the section about DSA parameters below),
97.Dv SSL_OP_SINGLE_DH_USE
98must be used in order to prevent small subgroup attacks.
99Always using
100.Dv SSL_OP_SINGLE_DH_USE
101has an impact on the computer time needed during negotiation,
102but it is not very large,
103so application authors/users should consider always enabling this option.
104.Pp 123.Pp
105As generating DH parameters is extremely time consuming, an application should 124As generating DH parameters is extremely time consuming, an application should
106not generate the parameters on the fly but supply the parameters. 125not generate the parameters on the fly but supply the parameters.
@@ -109,21 +128,14 @@ as the actual key is newly generated during the negotiation.
109The risk in reusing DH parameters is that an attacker may specialize on a very 128The risk in reusing DH parameters is that an attacker may specialize on a very
110often used DH group. 129often used DH group.
111Applications should therefore generate their own DH parameters during the 130Applications should therefore generate their own DH parameters during the
112installation process using the openssl 131installation process using the
113.Xr openssl 1 132.Xr openssl 1
133.Cm dhparam
114application. 134application.
115In order to reduce the computer time needed for this generation, 135This application guarantees that "strong" primes are used.
116it is possible to use DSA parameters instead (see
117.Xr openssl 1 ) ,
118but in this case
119.Dv SSL_OP_SINGLE_DH_USE
120is mandatory.
121.Pp 136.Pp
122Application authors may compile in DH parameters.
123Files 137Files
124.Pa dh512.pem , 138.Pa dh2048.pem
125.Pa dh1024.pem ,
126.Pa dh2048.pem ,
127and 139and
128.Pa dh4096.pem 140.Pa dh4096.pem
129in the 141in the
@@ -136,28 +148,32 @@ These files can be converted into C code using the
136.Fl C 148.Fl C
137option of the 149option of the
138.Xr openssl 1 150.Xr openssl 1
151.Cm dhparam
139application. 152application.
140Authors may also generate their own set of parameters using 153Generation of custom DH parameters during installation should still
141.Xr openssl 1 , 154be preferred to stop an attacker from specializing on a commonly
142but a user may not be sure how the parameters were generated. 155used group.
143The generation of DH parameters during installation is therefore recommended. 156The file
157.Pa dh1024.pem
158contains old parameters that must not be used by applications.
144.Pp 159.Pp
145An application may either directly specify the DH parameters or can supply the 160An application may either directly specify the DH parameters or can supply the
146DH parameters via a callback function. 161DH parameters via a callback function.
147The callback approach has the advantage that the callback may supply DH
148parameters for different key lengths.
149.Pp 162.Pp
150The 163Previous versions of the callback used
151.Fa tmp_dh_callback
152is called with the
153.Fa keylength
154needed and the
155.Fa is_export 164.Fa is_export
156information. 165and
157The 166.Fa keylength
167parameters to control parameter generation for export and non-export
168cipher suites.
169Modern servers that do not support export ciphersuites are advised
170to either use
171.Fn SSL_CTX_set_tmp_dh
172or alternatively, use the callback but ignore
173.Fa keylength
174and
158.Fa is_export 175.Fa is_export
159flag is set when the ephemeral DH key exchange is performed with an export 176and simply supply at least 2048-bit parameters in the callback.
160cipher.
161.Sh RETURN VALUES 177.Sh RETURN VALUES
162.Fn SSL_CTX_set_tmp_dh_callback 178.Fn SSL_CTX_set_tmp_dh_callback
163and 179and
@@ -170,66 +186,37 @@ and
170do return 1 on success and 0 on failure. 186do return 1 on success and 0 on failure.
171Check the error queue to find out the reason of failure. 187Check the error queue to find out the reason of failure.
172.Sh EXAMPLES 188.Sh EXAMPLES
173Handle DH parameters for key lengths of 512 and 1024 bits. 189Set up DH parameters with a key length of 2048 bits.
174(Error handling partly left out.) 190Error handling is partly left out.
191.Pp
192Command-line parameter generation:
193.Pp
194.Dl openssl dhparam -out dh_param_2048.pem 2048
195.Pp
196Code for setting up parameters during server initialization:
175.Bd -literal 197.Bd -literal
176\&... 198SSL_CTX ctx = SSL_CTX_new();
177/* Set up ephemeral DH stuff */
178DH *dh_512 = NULL;
179DH *dh_1024 = NULL;
180FILE *paramfile;
181
182\&... 199\&...
183 200
184/* "openssl dhparam -out dh_param_512.pem -2 512" */ 201/* Set up ephemeral DH parameters. */
185paramfile = fopen("dh_param_512.pem", "r"); 202DH *dh_2048 = NULL;
203FILE *paramfile;
204paramfile = fopen("dh_param_2048.pem", "r");
186if (paramfile) { 205if (paramfile) {
187 dh_512 = PEM_read_DHparams(paramfile, NULL, NULL, NULL); 206 dh_2048 = PEM_read_DHparams(paramfile, NULL, NULL, NULL);
188 fclose(paramfile); 207 fclose(paramfile);
208} else {
209 /* Error. */
189} 210}
190/* "openssl dhparam -out dh_param_1024.pem -2 1024" */ 211if (dh_2048 == NULL) {
191paramfile = fopen("dh_param_1024.pem", "r"); 212 /* Error. */
192if (paramfile) {
193 dh_1024 = PEM_read_DHparams(paramfile, NULL, NULL, NULL);
194 fclose(paramfile);
195} 213}
196 214if (SSL_CTX_set_tmp_dh(ctx, dh_2048) != 1) {
197\&... 215 /* Error. */
198
199/* "openssl dhparam -C -2 512" etc... */
200DH *get_dh512() { ... }
201DH *get_dh1024() { ... }
202
203DH *
204tmp_dh_callback(SSL *s, int is_export, int keylength)
205{
206 DH *dh_tmp=NULL;
207
208 switch (keylength) {
209 case 512:
210 if (!dh_512)
211 dh_512 = get_dh512();
212 dh_tmp = dh_512;
213 break;
214 case 1024:
215 if (!dh_1024)
216 dh_1024 = get_dh1024();
217 dh_tmp = dh_1024;
218 break;
219 default:
220 /*
221 * Generating a key on the fly is very costly,
222 * so use what is there
223 */
224 setup_dh_parameters_like_above();
225 }
226
227 return(dh_tmp);
228} 216}
229.Ed 217.Ed
230.Sh SEE ALSO 218.Sh SEE ALSO
231.Xr openssl 1 , 219.Xr openssl 1 ,
232.Xr ssl 3 , 220.Xr ssl 3 ,
233.Xr SSL_CTX_set_cipher_list 3 , 221.Xr SSL_CTX_set_cipher_list 3 ,
234.Xr SSL_CTX_set_options 3 , 222.Xr SSL_CTX_set_options 3
235.Xr SSL_CTX_set_tmp_rsa_callback 3