summaryrefslogtreecommitdiff
path: root/src/lib/libssl/doc/SSL_CTX_set_tmp_dh_callback.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libssl/doc/SSL_CTX_set_tmp_dh_callback.3')
-rw-r--r--src/lib/libssl/doc/SSL_CTX_set_tmp_dh_callback.3235
1 files changed, 0 insertions, 235 deletions
diff --git a/src/lib/libssl/doc/SSL_CTX_set_tmp_dh_callback.3 b/src/lib/libssl/doc/SSL_CTX_set_tmp_dh_callback.3
deleted file mode 100644
index 17eed868ee..0000000000
--- a/src/lib/libssl/doc/SSL_CTX_set_tmp_dh_callback.3
+++ /dev/null
@@ -1,235 +0,0 @@
1.\"
2.\" $OpenBSD: SSL_CTX_set_tmp_dh_callback.3,v 1.2 2014/12/02 14:11:01 jmc Exp $
3.\"
4.Dd $Mdocdate: December 2 2014 $
5.Dt SSL_CTX_SET_TMP_DH_CALLBACK 3
6.Os
7.Sh NAME
8.Nm SSL_CTX_set_tmp_dh_callback ,
9.Nm SSL_CTX_set_tmp_dh ,
10.Nm SSL_set_tmp_dh_callback ,
11.Nm SSL_set_tmp_dh
12.Nd handle DH keys for ephemeral key exchange
13.Sh SYNOPSIS
14.In openssl/ssl.h
15.Ft void
16.Fo SSL_CTX_set_tmp_dh_callback
17.Fa "SSL_CTX *ctx"
18.Fa "DH *(*tmp_dh_callback)(SSL *ssl, int is_export, int keylength)"
19.Fc
20.Ft long
21.Fn SSL_CTX_set_tmp_dh "SSL_CTX *ctx" "DH *dh"
22.Ft void
23.Fo SSL_set_tmp_dh_callback
24.Fa "SSL *ssl"
25.Fa "DH *(*tmp_dh_callback)(SSL *ssl, int is_export, int keylength"
26.Fc
27.Ft long
28.Fn SSL_set_tmp_dh "SSL *ssl" "DH *dh"
29.Sh DESCRIPTION
30.Fn SSL_CTX_set_tmp_dh_callback
31sets the callback function for
32.Fa ctx
33to be used when a DH parameters are required to
34.Fa tmp_dh_callback .
35The callback is inherited by all
36.Vt ssl
37objects created from
38.Fa ctx .
39.Pp
40.Fn SSL_CTX_set_tmp_dh
41sets DH parameters to be used to be
42.Sy dh Ns .
43The key is inherited by all
44.Fa ssl
45objects created from
46.Fa ctx .
47.Pp
48.Fn SSL_set_tmp_dh_callback
49sets the callback only for
50.Fa ssl .
51.Pp
52.Fn SSL_set_tmp_dh
53sets the parameters only for
54.Fa ssl .
55.Pp
56These functions apply to SSL/TLS servers only.
57.Sh NOTES
58When using a cipher with RSA authentication,
59an ephemeral DH key exchange can take place.
60Ciphers with DSA keys always use ephemeral DH keys as well.
61In these cases, the session data are negotiated using the ephemeral/temporary
62DH key and the key supplied and certified by the certificate chain is only used
63for signing.
64Anonymous ciphers (without a permanent server key) also use ephemeral DH keys.
65.Pp
66Using ephemeral DH key exchange yields forward secrecy,
67as the connection can only be decrypted when the DH key is known.
68By generating a temporary DH key inside the server application that is lost
69when the application is left, it becomes impossible for an attacker to decrypt
70past sessions, even if he gets hold of the normal (certified) key,
71as this key was only used for signing.
72.Pp
73In order to perform a DH key exchange the server must use a DH group
74(DH parameters) and generate a DH key.
75The 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
105As generating DH parameters is extremely time consuming, an application should
106not generate the parameters on the fly but supply the parameters.
107DH parameters can be reused,
108as the actual key is newly generated during the negotiation.
109The risk in reusing DH parameters is that an attacker may specialize on a very
110often used DH group.
111Applications should therefore generate their own DH parameters during the
112installation process using the openssl
113.Xr openssl 1
114application.
115In order to reduce the computer time needed for this generation,
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
122Application authors may compile in DH parameters.
123Files
124.Pa dh512.pem ,
125.Pa dh1024.pem ,
126.Pa dh2048.pem ,
127and
128.Pa dh4096.pem
129in the
130.Pa apps
131directory of the current version of the OpenSSL distribution contain the
132.Sq SKIP
133DH parameters,
134which use safe primes and were generated verifiably pseudo-randomly.
135These files can be converted into C code using the
136.Fl C
137option of the
138.Xr openssl 1
139application.
140Authors may also generate their own set of parameters using
141.Xr openssl 1 ,
142but a user may not be sure how the parameters were generated.
143The generation of DH parameters during installation is therefore recommended.
144.Pp
145An application may either directly specify the DH parameters or can supply the
146DH parameters via a callback function.
147The callback approach has the advantage that the callback may supply DH
148parameters for different key lengths.
149.Pp
150The
151.Fa tmp_dh_callback
152is called with the
153.Fa keylength
154needed and the
155.Fa is_export
156information.
157The
158.Fa is_export
159flag is set when the ephemeral DH key exchange is performed with an export
160cipher.
161.Sh RETURN VALUES
162.Fn SSL_CTX_set_tmp_dh_callback
163and
164.Fn SSL_set_tmp_dh_callback
165do not return diagnostic output.
166.Pp
167.Fn SSL_CTX_set_tmp_dh
168and
169.Fn SSL_set_tmp_dh
170do return 1 on success and 0 on failure.
171Check the error queue to find out the reason of failure.
172.Sh EXAMPLES
173Handle DH parameters for key lengths of 512 and 1024 bits.
174(Error handling partly left out.)
175.Bd -literal
176\&...
177/* Set up ephemeral DH stuff */
178DH *dh_512 = NULL;
179DH *dh_1024 = NULL;
180FILE *paramfile;
181
182\&...
183
184/* "openssl dhparam -out dh_param_512.pem -2 512" */
185paramfile = fopen("dh_param_512.pem", "r");
186if (paramfile) {
187 dh_512 = PEM_read_DHparams(paramfile, NULL, NULL, NULL);
188 fclose(paramfile);
189}
190/* "openssl dhparam -out dh_param_1024.pem -2 1024" */
191paramfile = fopen("dh_param_1024.pem", "r");
192if (paramfile) {
193 dh_1024 = PEM_read_DHparams(paramfile, NULL, NULL, NULL);
194 fclose(paramfile);
195}
196
197\&...
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}
229.Ed
230.Sh SEE ALSO
231.Xr openssl 1 ,
232.Xr ssl 3 ,
233.Xr SSL_CTX_set_cipher_list 3 ,
234.Xr SSL_CTX_set_options 3 ,
235.Xr SSL_CTX_set_tmp_rsa_callback 3