diff options
Diffstat (limited to 'src/lib/libssl/ssl_methods.c')
-rw-r--r-- | src/lib/libssl/ssl_methods.c | 666 |
1 files changed, 666 insertions, 0 deletions
diff --git a/src/lib/libssl/ssl_methods.c b/src/lib/libssl/ssl_methods.c new file mode 100644 index 0000000000..3e9f18bc40 --- /dev/null +++ b/src/lib/libssl/ssl_methods.c | |||
@@ -0,0 +1,666 @@ | |||
1 | /* $OpenBSD: ssl_methods.c,v 1.1 2018/11/05 05:45:15 jsing Exp $ */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #include "ssl_locl.h" | ||
60 | |||
61 | static const SSL_METHOD_INTERNAL DTLSv1_client_method_internal_data = { | ||
62 | .version = DTLS1_VERSION, | ||
63 | .min_version = DTLS1_VERSION, | ||
64 | .max_version = DTLS1_VERSION, | ||
65 | .ssl_new = dtls1_new, | ||
66 | .ssl_clear = dtls1_clear, | ||
67 | .ssl_free = dtls1_free, | ||
68 | .ssl_accept = ssl_undefined_function, | ||
69 | .ssl_connect = ssl3_connect, | ||
70 | .get_ssl_method = dtls1_get_client_method, | ||
71 | .get_timeout = dtls1_default_timeout, | ||
72 | .ssl_version = ssl_undefined_void_function, | ||
73 | .ssl_renegotiate = ssl3_renegotiate, | ||
74 | .ssl_renegotiate_check = ssl3_renegotiate_check, | ||
75 | .ssl_get_message = dtls1_get_message, | ||
76 | .ssl_read_bytes = dtls1_read_bytes, | ||
77 | .ssl_write_bytes = dtls1_write_app_data_bytes, | ||
78 | .ssl3_enc = &DTLSv1_enc_data, | ||
79 | }; | ||
80 | |||
81 | static const SSL_METHOD DTLSv1_client_method_data = { | ||
82 | .ssl_dispatch_alert = dtls1_dispatch_alert, | ||
83 | .num_ciphers = ssl3_num_ciphers, | ||
84 | .get_cipher = dtls1_get_cipher, | ||
85 | .get_cipher_by_char = ssl3_get_cipher_by_char, | ||
86 | .put_cipher_by_char = ssl3_put_cipher_by_char, | ||
87 | .internal = &DTLSv1_client_method_internal_data, | ||
88 | }; | ||
89 | |||
90 | const SSL_METHOD * | ||
91 | DTLSv1_client_method(void) | ||
92 | { | ||
93 | return &DTLSv1_client_method_data; | ||
94 | } | ||
95 | |||
96 | const SSL_METHOD * | ||
97 | dtls1_get_client_method(int ver) | ||
98 | { | ||
99 | if (ver == DTLS1_VERSION) | ||
100 | return (DTLSv1_client_method()); | ||
101 | return (NULL); | ||
102 | } | ||
103 | |||
104 | static const SSL_METHOD *dtls1_get_method(int ver); | ||
105 | |||
106 | static const SSL_METHOD_INTERNAL DTLSv1_method_internal_data = { | ||
107 | .version = DTLS1_VERSION, | ||
108 | .min_version = DTLS1_VERSION, | ||
109 | .max_version = DTLS1_VERSION, | ||
110 | .ssl_new = dtls1_new, | ||
111 | .ssl_clear = dtls1_clear, | ||
112 | .ssl_free = dtls1_free, | ||
113 | .ssl_accept = ssl3_accept, | ||
114 | .ssl_connect = ssl3_connect, | ||
115 | .get_ssl_method = dtls1_get_method, | ||
116 | .get_timeout = dtls1_default_timeout, | ||
117 | .ssl_version = ssl_undefined_void_function, | ||
118 | .ssl_renegotiate = ssl3_renegotiate, | ||
119 | .ssl_renegotiate_check = ssl3_renegotiate_check, | ||
120 | .ssl_get_message = dtls1_get_message, | ||
121 | .ssl_read_bytes = dtls1_read_bytes, | ||
122 | .ssl_write_bytes = dtls1_write_app_data_bytes, | ||
123 | .ssl3_enc = &DTLSv1_enc_data, | ||
124 | }; | ||
125 | |||
126 | static const SSL_METHOD DTLSv1_method_data = { | ||
127 | .ssl_dispatch_alert = dtls1_dispatch_alert, | ||
128 | .num_ciphers = ssl3_num_ciphers, | ||
129 | .get_cipher = dtls1_get_cipher, | ||
130 | .get_cipher_by_char = ssl3_get_cipher_by_char, | ||
131 | .put_cipher_by_char = ssl3_put_cipher_by_char, | ||
132 | .internal = &DTLSv1_method_internal_data, | ||
133 | }; | ||
134 | |||
135 | const SSL_METHOD * | ||
136 | DTLSv1_method(void) | ||
137 | { | ||
138 | return &DTLSv1_method_data; | ||
139 | } | ||
140 | |||
141 | static const SSL_METHOD * | ||
142 | dtls1_get_method(int ver) | ||
143 | { | ||
144 | if (ver == DTLS1_VERSION) | ||
145 | return (DTLSv1_method()); | ||
146 | return (NULL); | ||
147 | } | ||
148 | |||
149 | static const SSL_METHOD_INTERNAL DTLSv1_server_method_internal_data = { | ||
150 | .version = DTLS1_VERSION, | ||
151 | .min_version = DTLS1_VERSION, | ||
152 | .max_version = DTLS1_VERSION, | ||
153 | .ssl_new = dtls1_new, | ||
154 | .ssl_clear = dtls1_clear, | ||
155 | .ssl_free = dtls1_free, | ||
156 | .ssl_accept = ssl3_accept, | ||
157 | .ssl_connect = ssl_undefined_function, | ||
158 | .get_ssl_method = dtls1_get_server_method, | ||
159 | .get_timeout = dtls1_default_timeout, | ||
160 | .ssl_version = ssl_undefined_void_function, | ||
161 | .ssl_renegotiate = ssl3_renegotiate, | ||
162 | .ssl_renegotiate_check = ssl3_renegotiate_check, | ||
163 | .ssl_get_message = dtls1_get_message, | ||
164 | .ssl_read_bytes = dtls1_read_bytes, | ||
165 | .ssl_write_bytes = dtls1_write_app_data_bytes, | ||
166 | .ssl3_enc = &DTLSv1_enc_data, | ||
167 | }; | ||
168 | |||
169 | static const SSL_METHOD DTLSv1_server_method_data = { | ||
170 | .ssl_dispatch_alert = dtls1_dispatch_alert, | ||
171 | .num_ciphers = ssl3_num_ciphers, | ||
172 | .get_cipher = dtls1_get_cipher, | ||
173 | .get_cipher_by_char = ssl3_get_cipher_by_char, | ||
174 | .put_cipher_by_char = ssl3_put_cipher_by_char, | ||
175 | .internal = &DTLSv1_server_method_internal_data, | ||
176 | }; | ||
177 | |||
178 | const SSL_METHOD * | ||
179 | DTLSv1_server_method(void) | ||
180 | { | ||
181 | return &DTLSv1_server_method_data; | ||
182 | } | ||
183 | |||
184 | const SSL_METHOD * | ||
185 | dtls1_get_server_method(int ver) | ||
186 | { | ||
187 | if (ver == DTLS1_VERSION) | ||
188 | return (DTLSv1_server_method()); | ||
189 | return (NULL); | ||
190 | } | ||
191 | |||
192 | static const SSL_METHOD_INTERNAL TLS_client_method_internal_data = { | ||
193 | .version = TLS1_2_VERSION, | ||
194 | .min_version = TLS1_VERSION, | ||
195 | .max_version = TLS1_2_VERSION, | ||
196 | .ssl_new = tls1_new, | ||
197 | .ssl_clear = tls1_clear, | ||
198 | .ssl_free = tls1_free, | ||
199 | .ssl_accept = ssl_undefined_function, | ||
200 | .ssl_connect = ssl3_connect, | ||
201 | .get_ssl_method = tls1_get_client_method, | ||
202 | .get_timeout = tls1_default_timeout, | ||
203 | .ssl_version = ssl_undefined_void_function, | ||
204 | .ssl_renegotiate = ssl_undefined_function, | ||
205 | .ssl_renegotiate_check = ssl_ok, | ||
206 | .ssl_get_message = ssl3_get_message, | ||
207 | .ssl_read_bytes = ssl3_read_bytes, | ||
208 | .ssl_write_bytes = ssl3_write_bytes, | ||
209 | .ssl3_enc = &TLSv1_2_enc_data, | ||
210 | }; | ||
211 | |||
212 | static const SSL_METHOD TLS_client_method_data = { | ||
213 | .ssl_dispatch_alert = ssl3_dispatch_alert, | ||
214 | .num_ciphers = ssl3_num_ciphers, | ||
215 | .get_cipher = ssl3_get_cipher, | ||
216 | .get_cipher_by_char = ssl3_get_cipher_by_char, | ||
217 | .put_cipher_by_char = ssl3_put_cipher_by_char, | ||
218 | .internal = &TLS_client_method_internal_data, | ||
219 | }; | ||
220 | |||
221 | static const SSL_METHOD_INTERNAL TLSv1_client_method_internal_data = { | ||
222 | .version = TLS1_VERSION, | ||
223 | .min_version = TLS1_VERSION, | ||
224 | .max_version = TLS1_VERSION, | ||
225 | .ssl_new = tls1_new, | ||
226 | .ssl_clear = tls1_clear, | ||
227 | .ssl_free = tls1_free, | ||
228 | .ssl_accept = ssl_undefined_function, | ||
229 | .ssl_connect = ssl3_connect, | ||
230 | .get_ssl_method = tls1_get_client_method, | ||
231 | .get_timeout = tls1_default_timeout, | ||
232 | .ssl_version = ssl_undefined_void_function, | ||
233 | .ssl_renegotiate = ssl3_renegotiate, | ||
234 | .ssl_renegotiate_check = ssl3_renegotiate_check, | ||
235 | .ssl_get_message = ssl3_get_message, | ||
236 | .ssl_read_bytes = ssl3_read_bytes, | ||
237 | .ssl_write_bytes = ssl3_write_bytes, | ||
238 | .ssl3_enc = &TLSv1_enc_data, | ||
239 | }; | ||
240 | |||
241 | static const SSL_METHOD TLSv1_client_method_data = { | ||
242 | .ssl_dispatch_alert = ssl3_dispatch_alert, | ||
243 | .num_ciphers = ssl3_num_ciphers, | ||
244 | .get_cipher = ssl3_get_cipher, | ||
245 | .get_cipher_by_char = ssl3_get_cipher_by_char, | ||
246 | .put_cipher_by_char = ssl3_put_cipher_by_char, | ||
247 | .internal = &TLSv1_client_method_internal_data, | ||
248 | }; | ||
249 | |||
250 | static const SSL_METHOD_INTERNAL TLSv1_1_client_method_internal_data = { | ||
251 | .version = TLS1_1_VERSION, | ||
252 | .min_version = TLS1_1_VERSION, | ||
253 | .max_version = TLS1_1_VERSION, | ||
254 | .ssl_new = tls1_new, | ||
255 | .ssl_clear = tls1_clear, | ||
256 | .ssl_free = tls1_free, | ||
257 | .ssl_accept = ssl_undefined_function, | ||
258 | .ssl_connect = ssl3_connect, | ||
259 | .get_ssl_method = tls1_get_client_method, | ||
260 | .get_timeout = tls1_default_timeout, | ||
261 | .ssl_version = ssl_undefined_void_function, | ||
262 | .ssl_renegotiate = ssl3_renegotiate, | ||
263 | .ssl_renegotiate_check = ssl3_renegotiate_check, | ||
264 | .ssl_get_message = ssl3_get_message, | ||
265 | .ssl_read_bytes = ssl3_read_bytes, | ||
266 | .ssl_write_bytes = ssl3_write_bytes, | ||
267 | .ssl3_enc = &TLSv1_1_enc_data, | ||
268 | }; | ||
269 | |||
270 | static const SSL_METHOD TLSv1_1_client_method_data = { | ||
271 | .ssl_dispatch_alert = ssl3_dispatch_alert, | ||
272 | .num_ciphers = ssl3_num_ciphers, | ||
273 | .get_cipher = ssl3_get_cipher, | ||
274 | .get_cipher_by_char = ssl3_get_cipher_by_char, | ||
275 | .put_cipher_by_char = ssl3_put_cipher_by_char, | ||
276 | .internal = &TLSv1_1_client_method_internal_data, | ||
277 | }; | ||
278 | |||
279 | static const SSL_METHOD_INTERNAL TLSv1_2_client_method_internal_data = { | ||
280 | .version = TLS1_2_VERSION, | ||
281 | .min_version = TLS1_2_VERSION, | ||
282 | .max_version = TLS1_2_VERSION, | ||
283 | .ssl_new = tls1_new, | ||
284 | .ssl_clear = tls1_clear, | ||
285 | .ssl_free = tls1_free, | ||
286 | .ssl_accept = ssl_undefined_function, | ||
287 | .ssl_connect = ssl3_connect, | ||
288 | .get_ssl_method = tls1_get_client_method, | ||
289 | .get_timeout = tls1_default_timeout, | ||
290 | .ssl_version = ssl_undefined_void_function, | ||
291 | .ssl_renegotiate = ssl3_renegotiate, | ||
292 | .ssl_renegotiate_check = ssl3_renegotiate_check, | ||
293 | .ssl_get_message = ssl3_get_message, | ||
294 | .ssl_read_bytes = ssl3_read_bytes, | ||
295 | .ssl_write_bytes = ssl3_write_bytes, | ||
296 | .ssl3_enc = &TLSv1_2_enc_data, | ||
297 | }; | ||
298 | |||
299 | static const SSL_METHOD TLSv1_2_client_method_data = { | ||
300 | .ssl_dispatch_alert = ssl3_dispatch_alert, | ||
301 | .num_ciphers = ssl3_num_ciphers, | ||
302 | .get_cipher = ssl3_get_cipher, | ||
303 | .get_cipher_by_char = ssl3_get_cipher_by_char, | ||
304 | .put_cipher_by_char = ssl3_put_cipher_by_char, | ||
305 | .internal = &TLSv1_2_client_method_internal_data, | ||
306 | }; | ||
307 | |||
308 | const SSL_METHOD * | ||
309 | tls1_get_client_method(int ver) | ||
310 | { | ||
311 | if (ver == TLS1_2_VERSION) | ||
312 | return (TLSv1_2_client_method()); | ||
313 | if (ver == TLS1_1_VERSION) | ||
314 | return (TLSv1_1_client_method()); | ||
315 | if (ver == TLS1_VERSION) | ||
316 | return (TLSv1_client_method()); | ||
317 | return (NULL); | ||
318 | } | ||
319 | |||
320 | const SSL_METHOD * | ||
321 | SSLv23_client_method(void) | ||
322 | { | ||
323 | return (TLS_client_method()); | ||
324 | } | ||
325 | |||
326 | const SSL_METHOD * | ||
327 | TLS_client_method(void) | ||
328 | { | ||
329 | return (&TLS_client_method_data); | ||
330 | } | ||
331 | |||
332 | const SSL_METHOD * | ||
333 | TLSv1_client_method(void) | ||
334 | { | ||
335 | return (&TLSv1_client_method_data); | ||
336 | } | ||
337 | |||
338 | const SSL_METHOD * | ||
339 | TLSv1_1_client_method(void) | ||
340 | { | ||
341 | return (&TLSv1_1_client_method_data); | ||
342 | } | ||
343 | |||
344 | const SSL_METHOD * | ||
345 | TLSv1_2_client_method(void) | ||
346 | { | ||
347 | return (&TLSv1_2_client_method_data); | ||
348 | } | ||
349 | |||
350 | static const SSL_METHOD *tls1_get_method(int ver); | ||
351 | |||
352 | static const SSL_METHOD_INTERNAL TLS_method_internal_data = { | ||
353 | .version = TLS1_2_VERSION, | ||
354 | .min_version = TLS1_VERSION, | ||
355 | .max_version = TLS1_2_VERSION, | ||
356 | .ssl_new = tls1_new, | ||
357 | .ssl_clear = tls1_clear, | ||
358 | .ssl_free = tls1_free, | ||
359 | .ssl_accept = ssl3_accept, | ||
360 | .ssl_connect = ssl3_connect, | ||
361 | .get_ssl_method = tls1_get_method, | ||
362 | .get_timeout = tls1_default_timeout, | ||
363 | .ssl_version = ssl_undefined_void_function, | ||
364 | .ssl_renegotiate = ssl_undefined_function, | ||
365 | .ssl_renegotiate_check = ssl_ok, | ||
366 | .ssl_get_message = ssl3_get_message, | ||
367 | .ssl_read_bytes = ssl3_read_bytes, | ||
368 | .ssl_write_bytes = ssl3_write_bytes, | ||
369 | .ssl3_enc = &TLSv1_2_enc_data, | ||
370 | }; | ||
371 | |||
372 | static const SSL_METHOD TLS_method_data = { | ||
373 | .ssl_dispatch_alert = ssl3_dispatch_alert, | ||
374 | .num_ciphers = ssl3_num_ciphers, | ||
375 | .get_cipher = ssl3_get_cipher, | ||
376 | .get_cipher_by_char = ssl3_get_cipher_by_char, | ||
377 | .put_cipher_by_char = ssl3_put_cipher_by_char, | ||
378 | .internal = &TLS_method_internal_data, | ||
379 | }; | ||
380 | |||
381 | static const SSL_METHOD_INTERNAL TLSv1_method_internal_data = { | ||
382 | .version = TLS1_VERSION, | ||
383 | .min_version = TLS1_VERSION, | ||
384 | .max_version = TLS1_VERSION, | ||
385 | .ssl_new = tls1_new, | ||
386 | .ssl_clear = tls1_clear, | ||
387 | .ssl_free = tls1_free, | ||
388 | .ssl_accept = ssl3_accept, | ||
389 | .ssl_connect = ssl3_connect, | ||
390 | .get_ssl_method = tls1_get_method, | ||
391 | .get_timeout = tls1_default_timeout, | ||
392 | .ssl_version = ssl_undefined_void_function, | ||
393 | .ssl_renegotiate = ssl3_renegotiate, | ||
394 | .ssl_renegotiate_check = ssl3_renegotiate_check, | ||
395 | .ssl_get_message = ssl3_get_message, | ||
396 | .ssl_read_bytes = ssl3_read_bytes, | ||
397 | .ssl_write_bytes = ssl3_write_bytes, | ||
398 | .ssl3_enc = &TLSv1_enc_data, | ||
399 | }; | ||
400 | |||
401 | static const SSL_METHOD TLSv1_method_data = { | ||
402 | .ssl_dispatch_alert = ssl3_dispatch_alert, | ||
403 | .num_ciphers = ssl3_num_ciphers, | ||
404 | .get_cipher = ssl3_get_cipher, | ||
405 | .get_cipher_by_char = ssl3_get_cipher_by_char, | ||
406 | .put_cipher_by_char = ssl3_put_cipher_by_char, | ||
407 | .internal = &TLSv1_method_internal_data, | ||
408 | }; | ||
409 | |||
410 | static const SSL_METHOD_INTERNAL TLSv1_1_method_internal_data = { | ||
411 | .version = TLS1_1_VERSION, | ||
412 | .min_version = TLS1_1_VERSION, | ||
413 | .max_version = TLS1_1_VERSION, | ||
414 | .ssl_new = tls1_new, | ||
415 | .ssl_clear = tls1_clear, | ||
416 | .ssl_free = tls1_free, | ||
417 | .ssl_accept = ssl3_accept, | ||
418 | .ssl_connect = ssl3_connect, | ||
419 | .get_ssl_method = tls1_get_method, | ||
420 | .get_timeout = tls1_default_timeout, | ||
421 | .ssl_version = ssl_undefined_void_function, | ||
422 | .ssl_renegotiate = ssl3_renegotiate, | ||
423 | .ssl_renegotiate_check = ssl3_renegotiate_check, | ||
424 | .ssl_get_message = ssl3_get_message, | ||
425 | .ssl_read_bytes = ssl3_read_bytes, | ||
426 | .ssl_write_bytes = ssl3_write_bytes, | ||
427 | .ssl3_enc = &TLSv1_1_enc_data, | ||
428 | }; | ||
429 | |||
430 | static const SSL_METHOD TLSv1_1_method_data = { | ||
431 | .ssl_dispatch_alert = ssl3_dispatch_alert, | ||
432 | .num_ciphers = ssl3_num_ciphers, | ||
433 | .get_cipher = ssl3_get_cipher, | ||
434 | .get_cipher_by_char = ssl3_get_cipher_by_char, | ||
435 | .put_cipher_by_char = ssl3_put_cipher_by_char, | ||
436 | .internal = &TLSv1_1_method_internal_data, | ||
437 | }; | ||
438 | |||
439 | static const SSL_METHOD_INTERNAL TLSv1_2_method_internal_data = { | ||
440 | .version = TLS1_2_VERSION, | ||
441 | .min_version = TLS1_2_VERSION, | ||
442 | .max_version = TLS1_2_VERSION, | ||
443 | .ssl_new = tls1_new, | ||
444 | .ssl_clear = tls1_clear, | ||
445 | .ssl_free = tls1_free, | ||
446 | .ssl_accept = ssl3_accept, | ||
447 | .ssl_connect = ssl3_connect, | ||
448 | .get_ssl_method = tls1_get_method, | ||
449 | .get_timeout = tls1_default_timeout, | ||
450 | .ssl_version = ssl_undefined_void_function, | ||
451 | .ssl_renegotiate = ssl3_renegotiate, | ||
452 | .ssl_renegotiate_check = ssl3_renegotiate_check, | ||
453 | .ssl_get_message = ssl3_get_message, | ||
454 | .ssl_read_bytes = ssl3_read_bytes, | ||
455 | .ssl_write_bytes = ssl3_write_bytes, | ||
456 | .ssl3_enc = &TLSv1_2_enc_data, | ||
457 | }; | ||
458 | |||
459 | static const SSL_METHOD TLSv1_2_method_data = { | ||
460 | .ssl_dispatch_alert = ssl3_dispatch_alert, | ||
461 | .num_ciphers = ssl3_num_ciphers, | ||
462 | .get_cipher = ssl3_get_cipher, | ||
463 | .get_cipher_by_char = ssl3_get_cipher_by_char, | ||
464 | .put_cipher_by_char = ssl3_put_cipher_by_char, | ||
465 | .internal = &TLSv1_2_method_internal_data, | ||
466 | }; | ||
467 | |||
468 | static const SSL_METHOD * | ||
469 | tls1_get_method(int ver) | ||
470 | { | ||
471 | if (ver == TLS1_2_VERSION) | ||
472 | return (TLSv1_2_method()); | ||
473 | if (ver == TLS1_1_VERSION) | ||
474 | return (TLSv1_1_method()); | ||
475 | if (ver == TLS1_VERSION) | ||
476 | return (TLSv1_method()); | ||
477 | return (NULL); | ||
478 | } | ||
479 | |||
480 | const SSL_METHOD * | ||
481 | SSLv23_method(void) | ||
482 | { | ||
483 | return (TLS_method()); | ||
484 | } | ||
485 | |||
486 | const SSL_METHOD * | ||
487 | TLS_method(void) | ||
488 | { | ||
489 | return &TLS_method_data; | ||
490 | } | ||
491 | |||
492 | const SSL_METHOD * | ||
493 | TLSv1_method(void) | ||
494 | { | ||
495 | return (&TLSv1_method_data); | ||
496 | } | ||
497 | |||
498 | const SSL_METHOD * | ||
499 | TLSv1_1_method(void) | ||
500 | { | ||
501 | return (&TLSv1_1_method_data); | ||
502 | } | ||
503 | |||
504 | const SSL_METHOD * | ||
505 | TLSv1_2_method(void) | ||
506 | { | ||
507 | return (&TLSv1_2_method_data); | ||
508 | } | ||
509 | |||
510 | static const SSL_METHOD_INTERNAL TLS_server_method_internal_data = { | ||
511 | .version = TLS1_2_VERSION, | ||
512 | .min_version = TLS1_VERSION, | ||
513 | .max_version = TLS1_2_VERSION, | ||
514 | .ssl_new = tls1_new, | ||
515 | .ssl_clear = tls1_clear, | ||
516 | .ssl_free = tls1_free, | ||
517 | .ssl_accept = ssl3_accept, | ||
518 | .ssl_connect = ssl_undefined_function, | ||
519 | .get_ssl_method = tls1_get_server_method, | ||
520 | .get_timeout = tls1_default_timeout, | ||
521 | .ssl_version = ssl_undefined_void_function, | ||
522 | .ssl_renegotiate = ssl_undefined_function, | ||
523 | .ssl_renegotiate_check = ssl_ok, | ||
524 | .ssl_get_message = ssl3_get_message, | ||
525 | .ssl_read_bytes = ssl3_read_bytes, | ||
526 | .ssl_write_bytes = ssl3_write_bytes, | ||
527 | .ssl3_enc = &TLSv1_2_enc_data, | ||
528 | }; | ||
529 | |||
530 | static const SSL_METHOD TLS_server_method_data = { | ||
531 | .ssl_dispatch_alert = ssl3_dispatch_alert, | ||
532 | .num_ciphers = ssl3_num_ciphers, | ||
533 | .get_cipher = ssl3_get_cipher, | ||
534 | .get_cipher_by_char = ssl3_get_cipher_by_char, | ||
535 | .put_cipher_by_char = ssl3_put_cipher_by_char, | ||
536 | .internal = &TLS_server_method_internal_data, | ||
537 | }; | ||
538 | |||
539 | static const SSL_METHOD_INTERNAL TLSv1_server_method_internal_data = { | ||
540 | .version = TLS1_VERSION, | ||
541 | .min_version = TLS1_VERSION, | ||
542 | .max_version = TLS1_VERSION, | ||
543 | .ssl_new = tls1_new, | ||
544 | .ssl_clear = tls1_clear, | ||
545 | .ssl_free = tls1_free, | ||
546 | .ssl_accept = ssl3_accept, | ||
547 | .ssl_connect = ssl_undefined_function, | ||
548 | .get_ssl_method = tls1_get_server_method, | ||
549 | .get_timeout = tls1_default_timeout, | ||
550 | .ssl_version = ssl_undefined_void_function, | ||
551 | .ssl_renegotiate = ssl3_renegotiate, | ||
552 | .ssl_renegotiate_check = ssl3_renegotiate_check, | ||
553 | .ssl_get_message = ssl3_get_message, | ||
554 | .ssl_read_bytes = ssl3_read_bytes, | ||
555 | .ssl_write_bytes = ssl3_write_bytes, | ||
556 | .ssl3_enc = &TLSv1_enc_data, | ||
557 | }; | ||
558 | |||
559 | static const SSL_METHOD TLSv1_server_method_data = { | ||
560 | .ssl_dispatch_alert = ssl3_dispatch_alert, | ||
561 | .num_ciphers = ssl3_num_ciphers, | ||
562 | .get_cipher = ssl3_get_cipher, | ||
563 | .get_cipher_by_char = ssl3_get_cipher_by_char, | ||
564 | .put_cipher_by_char = ssl3_put_cipher_by_char, | ||
565 | .internal = &TLSv1_server_method_internal_data, | ||
566 | }; | ||
567 | |||
568 | static const SSL_METHOD_INTERNAL TLSv1_1_server_method_internal_data = { | ||
569 | .version = TLS1_1_VERSION, | ||
570 | .min_version = TLS1_1_VERSION, | ||
571 | .max_version = TLS1_1_VERSION, | ||
572 | .ssl_new = tls1_new, | ||
573 | .ssl_clear = tls1_clear, | ||
574 | .ssl_free = tls1_free, | ||
575 | .ssl_accept = ssl3_accept, | ||
576 | .ssl_connect = ssl_undefined_function, | ||
577 | .get_ssl_method = tls1_get_server_method, | ||
578 | .get_timeout = tls1_default_timeout, | ||
579 | .ssl_version = ssl_undefined_void_function, | ||
580 | .ssl_renegotiate = ssl3_renegotiate, | ||
581 | .ssl_renegotiate_check = ssl3_renegotiate_check, | ||
582 | .ssl_get_message = ssl3_get_message, | ||
583 | .ssl_read_bytes = ssl3_read_bytes, | ||
584 | .ssl_write_bytes = ssl3_write_bytes, | ||
585 | .ssl3_enc = &TLSv1_1_enc_data, | ||
586 | }; | ||
587 | |||
588 | static const SSL_METHOD TLSv1_1_server_method_data = { | ||
589 | .ssl_dispatch_alert = ssl3_dispatch_alert, | ||
590 | .num_ciphers = ssl3_num_ciphers, | ||
591 | .get_cipher = ssl3_get_cipher, | ||
592 | .get_cipher_by_char = ssl3_get_cipher_by_char, | ||
593 | .put_cipher_by_char = ssl3_put_cipher_by_char, | ||
594 | .internal = &TLSv1_1_server_method_internal_data, | ||
595 | }; | ||
596 | |||
597 | static const SSL_METHOD_INTERNAL TLSv1_2_server_method_internal_data = { | ||
598 | .version = TLS1_2_VERSION, | ||
599 | .min_version = TLS1_2_VERSION, | ||
600 | .max_version = TLS1_2_VERSION, | ||
601 | .ssl_new = tls1_new, | ||
602 | .ssl_clear = tls1_clear, | ||
603 | .ssl_free = tls1_free, | ||
604 | .ssl_accept = ssl3_accept, | ||
605 | .ssl_connect = ssl_undefined_function, | ||
606 | .get_ssl_method = tls1_get_server_method, | ||
607 | .get_timeout = tls1_default_timeout, | ||
608 | .ssl_version = ssl_undefined_void_function, | ||
609 | .ssl_renegotiate = ssl3_renegotiate, | ||
610 | .ssl_renegotiate_check = ssl3_renegotiate_check, | ||
611 | .ssl_get_message = ssl3_get_message, | ||
612 | .ssl_read_bytes = ssl3_read_bytes, | ||
613 | .ssl_write_bytes = ssl3_write_bytes, | ||
614 | .ssl3_enc = &TLSv1_2_enc_data, | ||
615 | }; | ||
616 | |||
617 | static const SSL_METHOD TLSv1_2_server_method_data = { | ||
618 | .ssl_dispatch_alert = ssl3_dispatch_alert, | ||
619 | .num_ciphers = ssl3_num_ciphers, | ||
620 | .get_cipher = ssl3_get_cipher, | ||
621 | .get_cipher_by_char = ssl3_get_cipher_by_char, | ||
622 | .put_cipher_by_char = ssl3_put_cipher_by_char, | ||
623 | .internal = &TLSv1_2_server_method_internal_data, | ||
624 | }; | ||
625 | |||
626 | const SSL_METHOD * | ||
627 | tls1_get_server_method(int ver) | ||
628 | { | ||
629 | if (ver == TLS1_2_VERSION) | ||
630 | return (TLSv1_2_server_method()); | ||
631 | if (ver == TLS1_1_VERSION) | ||
632 | return (TLSv1_1_server_method()); | ||
633 | if (ver == TLS1_VERSION) | ||
634 | return (TLSv1_server_method()); | ||
635 | return (NULL); | ||
636 | } | ||
637 | |||
638 | const SSL_METHOD * | ||
639 | SSLv23_server_method(void) | ||
640 | { | ||
641 | return (TLS_server_method()); | ||
642 | } | ||
643 | |||
644 | const SSL_METHOD * | ||
645 | TLS_server_method(void) | ||
646 | { | ||
647 | return (&TLS_server_method_data); | ||
648 | } | ||
649 | |||
650 | const SSL_METHOD * | ||
651 | TLSv1_server_method(void) | ||
652 | { | ||
653 | return (&TLSv1_server_method_data); | ||
654 | } | ||
655 | |||
656 | const SSL_METHOD * | ||
657 | TLSv1_1_server_method(void) | ||
658 | { | ||
659 | return (&TLSv1_1_server_method_data); | ||
660 | } | ||
661 | |||
662 | const SSL_METHOD * | ||
663 | TLSv1_2_server_method(void) | ||
664 | { | ||
665 | return (&TLSv1_2_server_method_data); | ||
666 | } | ||