diff options
-rw-r--r-- | src/lib/libssl/man/SSL_CTX_set_tmp_dh_callback.3 | 203 |
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 |
56 | These functions apply to SSL/TLS servers only. | 103 | These functions apply to SSL/TLS servers only. |
57 | .Sh NOTES | 104 | .Pp |
58 | When using a cipher with RSA authentication, | 105 | When using a cipher with RSA authentication, |
59 | an ephemeral DH key exchange can take place. | 106 | an ephemeral DH key exchange can take place. |
60 | Ciphers with DSA keys always use ephemeral DH keys as well. | 107 | Ciphers 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 |
73 | In order to perform a DH key exchange the server must use a DH group | 120 | In 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. |
75 | The server will always generate a new DH key during the negotiation, | 122 | The server will always generate a new DH key during the negotiation. |
76 | when the DH parameters are supplied via callback and/or when the | ||
77 | .Dv SSL_OP_SINGLE_DH_USE | ||
78 | option of | ||
79 | .Xr SSL_CTX_set_options 3 | ||
80 | is set. | ||
81 | It will immediately create a DH key, when DH parameters are supplied via | ||
82 | .Fn SSL_CTX_set_tmp_dh | ||
83 | and | ||
84 | .Dv SSL_OP_SINGLE_DH_USE | ||
85 | is not set. | ||
86 | In this case, it may happen that a key is generated on initialization without | ||
87 | later being needed, while on the other hand the computer time during the | ||
88 | negotiation is being saved. | ||
89 | .Pp | ||
90 | If | ||
91 | .Dq strong | ||
92 | primes were used to generate the DH parameters, it is not strictly necessary to | ||
93 | generate a new key for each handshake but it does improve forward secrecy. | ||
94 | If it is not assured that | ||
95 | .Dq strong | ||
96 | primes were used (see especially the section about DSA parameters below), | ||
97 | .Dv SSL_OP_SINGLE_DH_USE | ||
98 | must be used in order to prevent small subgroup attacks. | ||
99 | Always using | ||
100 | .Dv SSL_OP_SINGLE_DH_USE | ||
101 | has an impact on the computer time needed during negotiation, | ||
102 | but it is not very large, | ||
103 | so application authors/users should consider always enabling this option. | ||
104 | .Pp | 123 | .Pp |
105 | As generating DH parameters is extremely time consuming, an application should | 124 | As generating DH parameters is extremely time consuming, an application should |
106 | not generate the parameters on the fly but supply the parameters. | 125 | not generate the parameters on the fly but supply the parameters. |
@@ -109,21 +128,14 @@ as the actual key is newly generated during the negotiation. | |||
109 | The risk in reusing DH parameters is that an attacker may specialize on a very | 128 | The risk in reusing DH parameters is that an attacker may specialize on a very |
110 | often used DH group. | 129 | often used DH group. |
111 | Applications should therefore generate their own DH parameters during the | 130 | Applications should therefore generate their own DH parameters during the |
112 | installation process using the openssl | 131 | installation process using the |
113 | .Xr openssl 1 | 132 | .Xr openssl 1 |
133 | .Cm dhparam | ||
114 | application. | 134 | application. |
115 | In order to reduce the computer time needed for this generation, | 135 | This application guarantees that "strong" primes are used. |
116 | it is possible to use DSA parameters instead (see | ||
117 | .Xr openssl 1 ) , | ||
118 | but in this case | ||
119 | .Dv SSL_OP_SINGLE_DH_USE | ||
120 | is mandatory. | ||
121 | .Pp | 136 | .Pp |
122 | Application authors may compile in DH parameters. | ||
123 | Files | 137 | Files |
124 | .Pa dh512.pem , | 138 | .Pa dh2048.pem |
125 | .Pa dh1024.pem , | ||
126 | .Pa dh2048.pem , | ||
127 | and | 139 | and |
128 | .Pa dh4096.pem | 140 | .Pa dh4096.pem |
129 | in the | 141 | in the |
@@ -136,28 +148,32 @@ These files can be converted into C code using the | |||
136 | .Fl C | 148 | .Fl C |
137 | option of the | 149 | option of the |
138 | .Xr openssl 1 | 150 | .Xr openssl 1 |
151 | .Cm dhparam | ||
139 | application. | 152 | application. |
140 | Authors may also generate their own set of parameters using | 153 | Generation of custom DH parameters during installation should still |
141 | .Xr openssl 1 , | 154 | be preferred to stop an attacker from specializing on a commonly |
142 | but a user may not be sure how the parameters were generated. | 155 | used group. |
143 | The generation of DH parameters during installation is therefore recommended. | 156 | The file |
157 | .Pa dh1024.pem | ||
158 | contains old parameters that must not be used by applications. | ||
144 | .Pp | 159 | .Pp |
145 | An application may either directly specify the DH parameters or can supply the | 160 | An application may either directly specify the DH parameters or can supply the |
146 | DH parameters via a callback function. | 161 | DH parameters via a callback function. |
147 | The callback approach has the advantage that the callback may supply DH | ||
148 | parameters for different key lengths. | ||
149 | .Pp | 162 | .Pp |
150 | The | 163 | Previous versions of the callback used |
151 | .Fa tmp_dh_callback | ||
152 | is called with the | ||
153 | .Fa keylength | ||
154 | needed and the | ||
155 | .Fa is_export | 164 | .Fa is_export |
156 | information. | 165 | and |
157 | The | 166 | .Fa keylength |
167 | parameters to control parameter generation for export and non-export | ||
168 | cipher suites. | ||
169 | Modern servers that do not support export ciphersuites are advised | ||
170 | to either use | ||
171 | .Fn SSL_CTX_set_tmp_dh | ||
172 | or alternatively, use the callback but ignore | ||
173 | .Fa keylength | ||
174 | and | ||
158 | .Fa is_export | 175 | .Fa is_export |
159 | flag is set when the ephemeral DH key exchange is performed with an export | 176 | and simply supply at least 2048-bit parameters in the callback. |
160 | cipher. | ||
161 | .Sh RETURN VALUES | 177 | .Sh RETURN VALUES |
162 | .Fn SSL_CTX_set_tmp_dh_callback | 178 | .Fn SSL_CTX_set_tmp_dh_callback |
163 | and | 179 | and |
@@ -170,66 +186,37 @@ and | |||
170 | do return 1 on success and 0 on failure. | 186 | do return 1 on success and 0 on failure. |
171 | Check the error queue to find out the reason of failure. | 187 | Check the error queue to find out the reason of failure. |
172 | .Sh EXAMPLES | 188 | .Sh EXAMPLES |
173 | Handle DH parameters for key lengths of 512 and 1024 bits. | 189 | Set up DH parameters with a key length of 2048 bits. |
174 | (Error handling partly left out.) | 190 | Error handling is partly left out. |
191 | .Pp | ||
192 | Command-line parameter generation: | ||
193 | .Pp | ||
194 | .Dl openssl dhparam -out dh_param_2048.pem 2048 | ||
195 | .Pp | ||
196 | Code for setting up parameters during server initialization: | ||
175 | .Bd -literal | 197 | .Bd -literal |
176 | \&... | 198 | SSL_CTX ctx = SSL_CTX_new(); |
177 | /* Set up ephemeral DH stuff */ | ||
178 | DH *dh_512 = NULL; | ||
179 | DH *dh_1024 = NULL; | ||
180 | FILE *paramfile; | ||
181 | |||
182 | \&... | 199 | \&... |
183 | 200 | ||
184 | /* "openssl dhparam -out dh_param_512.pem -2 512" */ | 201 | /* Set up ephemeral DH parameters. */ |
185 | paramfile = fopen("dh_param_512.pem", "r"); | 202 | DH *dh_2048 = NULL; |
203 | FILE *paramfile; | ||
204 | paramfile = fopen("dh_param_2048.pem", "r"); | ||
186 | if (paramfile) { | 205 | if (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" */ | 211 | if (dh_2048 == NULL) { |
191 | paramfile = fopen("dh_param_1024.pem", "r"); | 212 | /* Error. */ |
192 | if (paramfile) { | ||
193 | dh_1024 = PEM_read_DHparams(paramfile, NULL, NULL, NULL); | ||
194 | fclose(paramfile); | ||
195 | } | 213 | } |
196 | 214 | if (SSL_CTX_set_tmp_dh(ctx, dh_2048) != 1) { | |
197 | \&... | 215 | /* Error. */ |
198 | |||
199 | /* "openssl dhparam -C -2 512" etc... */ | ||
200 | DH *get_dh512() { ... } | ||
201 | DH *get_dh1024() { ... } | ||
202 | |||
203 | DH * | ||
204 | tmp_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 | ||