diff options
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.3 | 235 |
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 | ||
31 | sets the callback function for | ||
32 | .Fa ctx | ||
33 | to be used when a DH parameters are required to | ||
34 | .Fa tmp_dh_callback . | ||
35 | The callback is inherited by all | ||
36 | .Vt ssl | ||
37 | objects created from | ||
38 | .Fa ctx . | ||
39 | .Pp | ||
40 | .Fn SSL_CTX_set_tmp_dh | ||
41 | sets DH parameters to be used to be | ||
42 | .Sy dh Ns . | ||
43 | The key is inherited by all | ||
44 | .Fa ssl | ||
45 | objects created from | ||
46 | .Fa ctx . | ||
47 | .Pp | ||
48 | .Fn SSL_set_tmp_dh_callback | ||
49 | sets the callback only for | ||
50 | .Fa ssl . | ||
51 | .Pp | ||
52 | .Fn SSL_set_tmp_dh | ||
53 | sets the parameters only for | ||
54 | .Fa ssl . | ||
55 | .Pp | ||
56 | These functions apply to SSL/TLS servers only. | ||
57 | .Sh NOTES | ||
58 | When using a cipher with RSA authentication, | ||
59 | an ephemeral DH key exchange can take place. | ||
60 | Ciphers with DSA keys always use ephemeral DH keys as well. | ||
61 | In these cases, the session data are negotiated using the ephemeral/temporary | ||
62 | DH key and the key supplied and certified by the certificate chain is only used | ||
63 | for signing. | ||
64 | Anonymous ciphers (without a permanent server key) also use ephemeral DH keys. | ||
65 | .Pp | ||
66 | Using ephemeral DH key exchange yields forward secrecy, | ||
67 | as the connection can only be decrypted when the DH key is known. | ||
68 | By generating a temporary DH key inside the server application that is lost | ||
69 | when the application is left, it becomes impossible for an attacker to decrypt | ||
70 | past sessions, even if he gets hold of the normal (certified) key, | ||
71 | as this key was only used for signing. | ||
72 | .Pp | ||
73 | In order to perform a DH key exchange the server must use a DH group | ||
74 | (DH parameters) and generate a DH key. | ||
75 | 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 | ||
105 | As generating DH parameters is extremely time consuming, an application should | ||
106 | not generate the parameters on the fly but supply the parameters. | ||
107 | DH parameters can be reused, | ||
108 | 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 | ||
110 | often used DH group. | ||
111 | Applications should therefore generate their own DH parameters during the | ||
112 | installation process using the openssl | ||
113 | .Xr openssl 1 | ||
114 | application. | ||
115 | In order to reduce the computer time needed for this generation, | ||
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 | ||
122 | Application authors may compile in DH parameters. | ||
123 | Files | ||
124 | .Pa dh512.pem , | ||
125 | .Pa dh1024.pem , | ||
126 | .Pa dh2048.pem , | ||
127 | and | ||
128 | .Pa dh4096.pem | ||
129 | in the | ||
130 | .Pa apps | ||
131 | directory of the current version of the OpenSSL distribution contain the | ||
132 | .Sq SKIP | ||
133 | DH parameters, | ||
134 | which use safe primes and were generated verifiably pseudo-randomly. | ||
135 | These files can be converted into C code using the | ||
136 | .Fl C | ||
137 | option of the | ||
138 | .Xr openssl 1 | ||
139 | application. | ||
140 | Authors may also generate their own set of parameters using | ||
141 | .Xr openssl 1 , | ||
142 | but a user may not be sure how the parameters were generated. | ||
143 | The generation of DH parameters during installation is therefore recommended. | ||
144 | .Pp | ||
145 | An application may either directly specify the DH parameters or can supply the | ||
146 | 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 | ||
150 | The | ||
151 | .Fa tmp_dh_callback | ||
152 | is called with the | ||
153 | .Fa keylength | ||
154 | needed and the | ||
155 | .Fa is_export | ||
156 | information. | ||
157 | The | ||
158 | .Fa is_export | ||
159 | flag is set when the ephemeral DH key exchange is performed with an export | ||
160 | cipher. | ||
161 | .Sh RETURN VALUES | ||
162 | .Fn SSL_CTX_set_tmp_dh_callback | ||
163 | and | ||
164 | .Fn SSL_set_tmp_dh_callback | ||
165 | do not return diagnostic output. | ||
166 | .Pp | ||
167 | .Fn SSL_CTX_set_tmp_dh | ||
168 | and | ||
169 | .Fn SSL_set_tmp_dh | ||
170 | do return 1 on success and 0 on failure. | ||
171 | Check the error queue to find out the reason of failure. | ||
172 | .Sh EXAMPLES | ||
173 | Handle 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 */ | ||
178 | DH *dh_512 = NULL; | ||
179 | DH *dh_1024 = NULL; | ||
180 | FILE *paramfile; | ||
181 | |||
182 | \&... | ||
183 | |||
184 | /* "openssl dhparam -out dh_param_512.pem -2 512" */ | ||
185 | paramfile = fopen("dh_param_512.pem", "r"); | ||
186 | if (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" */ | ||
191 | paramfile = fopen("dh_param_1024.pem", "r"); | ||
192 | if (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... */ | ||
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 | } | ||
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 | ||