1 /* ssl/s3_lib.c */
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 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
60 *
61 * Redistribution and use in source and binary forms, with or without
62 * modification, are permitted provided that the following conditions
63 * are met:
64 *
65 * 1. Redistributions of source code must retain the above copyright
66 * notice, this list of conditions and the following disclaimer.
67 *
68 * 2. Redistributions in binary form must reproduce the above copyright
69 * notice, this list of conditions and the following disclaimer in
70 * the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3. All advertising materials mentioning features or use of this
74 * software must display the following acknowledgment:
75 * "This product includes software developed by the OpenSSL Project
76 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
77 *
78 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
79 * endorse or promote products derived from this software without
80 * prior written permission. For written permission, please contact
81 * openssl-core@openssl.org.
82 *
83 * 5. Products derived from this software may not be called "OpenSSL"
84 * nor may "OpenSSL" appear in their names without prior written
85 * permission of the OpenSSL Project.
86 *
87 * 6. Redistributions of any form whatsoever must retain the following
88 * acknowledgment:
89 * "This product includes software developed by the OpenSSL Project
90 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
91 *
92 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
93 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
94 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
95 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
96 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
97 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
98 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
99 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
100 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
101 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
102 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
103 * OF THE POSSIBILITY OF SUCH DAMAGE.
104 * ====================================================================
105 *
106 * This product includes cryptographic software written by Eric Young
107 * (eay@cryptsoft.com). This product includes software written by Tim
108 * Hudson (tjh@cryptsoft.com).
109 *
110 */
111 /* ====================================================================
112 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
113 *
114 * Portions of the attached software ("Contribution") are developed by
115 * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
116 *
117 * The Contribution is licensed pursuant to the OpenSSL open source
118 * license provided above.
119 *
120 * ECC cipher suite support in OpenSSL originally written by
121 * Vipul Gupta and Sumit Gupta of Sun Microsystems Laboratories.
122 *
123 */
124
125 #include <stdio.h>
126 #include <openssl/objects.h>
127 #include "ssl_locl.h"
128 #include "kssl_lcl.h"
129 #include <openssl/md5.h>
130 #ifndef OPENSSL_NO_DH
131 #include <openssl/dh.h>
132 #endif
133 #include <openssl/pq_compat.h>
134
135 const char *ssl3_version_str="SSLv3" OPENSSL_VERSION_PTEXT;
136
137 #define SSL3_NUM_CIPHERS (sizeof(ssl3_ciphers)/sizeof(SSL_CIPHER))
138
139 /* list of available SSLv3 ciphers (sorted by id) */
140 OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
141 /* The RSA ciphers */
142 /* Cipher 01 */
143 {
144 1,
145 SSL3_TXT_RSA_NULL_MD5,
146 SSL3_CK_RSA_NULL_MD5,
147 SSL_kRSA|SSL_aRSA|SSL_eNULL |SSL_MD5|SSL_SSLV3,
148 SSL_NOT_EXP|SSL_STRONG_NONE,
149 0,
150 0,
151 0,
152 SSL_ALL_CIPHERS,
153 SSL_ALL_STRENGTHS,
154 },
155 /* Cipher 02 */
156 {
157 1,
158 SSL3_TXT_RSA_NULL_SHA,
159 SSL3_CK_RSA_NULL_SHA,
160 SSL_kRSA|SSL_aRSA|SSL_eNULL |SSL_SHA1|SSL_SSLV3,
161 SSL_NOT_EXP|SSL_STRONG_NONE,
162 0,
163 0,
164 0,
165 SSL_ALL_CIPHERS,
166 SSL_ALL_STRENGTHS,
167 },
168 /* Cipher 03 */
169 {
170 1,
171 SSL3_TXT_RSA_RC4_40_MD5,
172 SSL3_CK_RSA_RC4_40_MD5,
173 SSL_kRSA|SSL_aRSA|SSL_RC4 |SSL_MD5 |SSL_SSLV3,
174 SSL_EXPORT|SSL_EXP40,
175 0,
176 40,
177 128,
178 SSL_ALL_CIPHERS,
179 SSL_ALL_STRENGTHS,
180 },
181 /* Cipher 04 */
182 {
183 1,
184 SSL3_TXT_RSA_RC4_128_MD5,
185 SSL3_CK_RSA_RC4_128_MD5,
186 SSL_kRSA|SSL_aRSA|SSL_RC4 |SSL_MD5|SSL_SSLV3,
187 SSL_NOT_EXP|SSL_MEDIUM,
188 0,
189 128,
190 128,
191 SSL_ALL_CIPHERS,
192 SSL_ALL_STRENGTHS,
193 },
194 /* Cipher 05 */
195 {
196 1,
197 SSL3_TXT_RSA_RC4_128_SHA,
198 SSL3_CK_RSA_RC4_128_SHA,
199 SSL_kRSA|SSL_aRSA|SSL_RC4 |SSL_SHA1|SSL_SSLV3,
200 SSL_NOT_EXP|SSL_MEDIUM,
201 0,
202 128,
203 128,
204 SSL_ALL_CIPHERS,
205 SSL_ALL_STRENGTHS,
206 },
207 /* Cipher 06 */
208 {
209 1,
210 SSL3_TXT_RSA_RC2_40_MD5,
211 SSL3_CK_RSA_RC2_40_MD5,
212 SSL_kRSA|SSL_aRSA|SSL_RC2 |SSL_MD5 |SSL_SSLV3,
213 SSL_EXPORT|SSL_EXP40,
214 0,
215 40,
216 128,
217 SSL_ALL_CIPHERS,
218 SSL_ALL_STRENGTHS,
219 },
220 /* Cipher 07 */
221 #ifndef OPENSSL_NO_IDEA
222 {
223 1,
224 SSL3_TXT_RSA_IDEA_128_SHA,
225 SSL3_CK_RSA_IDEA_128_SHA,
226 SSL_kRSA|SSL_aRSA|SSL_IDEA |SSL_SHA1|SSL_SSLV3,
227 SSL_NOT_EXP|SSL_MEDIUM,
228 0,
229 128,
230 128,
231 SSL_ALL_CIPHERS,
232 SSL_ALL_STRENGTHS,
233 },
234 #endif
235 /* Cipher 08 */
236 {
237 1,
238 SSL3_TXT_RSA_DES_40_CBC_SHA,
239 SSL3_CK_RSA_DES_40_CBC_SHA,
240 SSL_kRSA|SSL_aRSA|SSL_DES|SSL_SHA1|SSL_SSLV3,
241 SSL_EXPORT|SSL_EXP40,
242 0,
243 40,
244 56,
245 SSL_ALL_CIPHERS,
246 SSL_ALL_STRENGTHS,
247 },
248 /* Cipher 09 */
249 {
250 1,
251 SSL3_TXT_RSA_DES_64_CBC_SHA,
252 SSL3_CK_RSA_DES_64_CBC_SHA,
253 SSL_kRSA|SSL_aRSA|SSL_DES |SSL_SHA1|SSL_SSLV3,
254 SSL_NOT_EXP|SSL_LOW,
255 0,
256 56,
257 56,
258 SSL_ALL_CIPHERS,
259 SSL_ALL_STRENGTHS,
260 },
261 /* Cipher 0A */
262 {
263 1,
264 SSL3_TXT_RSA_DES_192_CBC3_SHA,
265 SSL3_CK_RSA_DES_192_CBC3_SHA,
266 SSL_kRSA|SSL_aRSA|SSL_3DES |SSL_SHA1|SSL_SSLV3,
267 SSL_NOT_EXP|SSL_HIGH,
268 0,
269 168,
270 168,
271 SSL_ALL_CIPHERS,
272 SSL_ALL_STRENGTHS,
273 },
274 /* The DH ciphers */
275 /* Cipher 0B */
276 {
277 0,
278 SSL3_TXT_DH_DSS_DES_40_CBC_SHA,
279 SSL3_CK_DH_DSS_DES_40_CBC_SHA,
280 SSL_kDHd |SSL_aDH|SSL_DES|SSL_SHA1|SSL_SSLV3,
281 SSL_EXPORT|SSL_EXP40,
282 0,
283 40,
284 56,
285 SSL_ALL_CIPHERS,
286 SSL_ALL_STRENGTHS,
287 },
288 /* Cipher 0C */
289 {
290 0,
291 SSL3_TXT_DH_DSS_DES_64_CBC_SHA,
292 SSL3_CK_DH_DSS_DES_64_CBC_SHA,
293 SSL_kDHd |SSL_aDH|SSL_DES |SSL_SHA1|SSL_SSLV3,
294 SSL_NOT_EXP|SSL_LOW,
295 0,
296 56,
297 56,
298 SSL_ALL_CIPHERS,
299 SSL_ALL_STRENGTHS,
300 },
301 /* Cipher 0D */
302 {
303 0,
304 SSL3_TXT_DH_DSS_DES_192_CBC3_SHA,
305 SSL3_CK_DH_DSS_DES_192_CBC3_SHA,
306 SSL_kDHd |SSL_aDH|SSL_3DES |SSL_SHA1|SSL_SSLV3,
307 SSL_NOT_EXP|SSL_HIGH,
308 0,
309 168,
310 168,
311 SSL_ALL_CIPHERS,
312 SSL_ALL_STRENGTHS,
313 },
314 /* Cipher 0E */
315 {
316 0,
317 SSL3_TXT_DH_RSA_DES_40_CBC_SHA,
318 SSL3_CK_DH_RSA_DES_40_CBC_SHA,
319 SSL_kDHr |SSL_aDH|SSL_DES|SSL_SHA1|SSL_SSLV3,
320 SSL_EXPORT|SSL_EXP40,
321 0,
322 40,
323 56,
324 SSL_ALL_CIPHERS,
325 SSL_ALL_STRENGTHS,
326 },
327 /* Cipher 0F */
328 {
329 0,
330 SSL3_TXT_DH_RSA_DES_64_CBC_SHA,
331 SSL3_CK_DH_RSA_DES_64_CBC_SHA,
332 SSL_kDHr |SSL_aDH|SSL_DES |SSL_SHA1|SSL_SSLV3,
333 SSL_NOT_EXP|SSL_LOW,
334 0,
335 56,
336 56,
337 SSL_ALL_CIPHERS,
338 SSL_ALL_STRENGTHS,
339 },
340 /* Cipher 10 */
341 {
342 0,
343 SSL3_TXT_DH_RSA_DES_192_CBC3_SHA,
344 SSL3_CK_DH_RSA_DES_192_CBC3_SHA,
345 SSL_kDHr |SSL_aDH|SSL_3DES |SSL_SHA1|SSL_SSLV3,
346 SSL_NOT_EXP|SSL_HIGH,
347 0,
348 168,
349 168,
350 SSL_ALL_CIPHERS,
351 SSL_ALL_STRENGTHS,
352 },
353
354 /* The Ephemeral DH ciphers */
355 /* Cipher 11 */
356 {
357 1,
358 SSL3_TXT_EDH_DSS_DES_40_CBC_SHA,
359 SSL3_CK_EDH_DSS_DES_40_CBC_SHA,
360 SSL_kEDH|SSL_aDSS|SSL_DES|SSL_SHA1|SSL_SSLV3,
361 SSL_EXPORT|SSL_EXP40,
362 0,
363 40,
364 56,
365 SSL_ALL_CIPHERS,
366 SSL_ALL_STRENGTHS,
367 },
368 /* Cipher 12 */
369 {
370 1,
371 SSL3_TXT_EDH_DSS_DES_64_CBC_SHA,
372 SSL3_CK_EDH_DSS_DES_64_CBC_SHA,
373 SSL_kEDH|SSL_aDSS|SSL_DES |SSL_SHA1|SSL_SSLV3,
374 SSL_NOT_EXP|SSL_LOW,
375 0,
376 56,
377 56,
378 SSL_ALL_CIPHERS,
379 SSL_ALL_STRENGTHS,
380 },
381 /* Cipher 13 */
382 {
383 1,
384 SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA,
385 SSL3_CK_EDH_DSS_DES_192_CBC3_SHA,
386 SSL_kEDH|SSL_aDSS|SSL_3DES |SSL_SHA1|SSL_SSLV3,
387 SSL_NOT_EXP|SSL_HIGH,
388 0,
389 168,
390 168,
391 SSL_ALL_CIPHERS,
392 SSL_ALL_STRENGTHS,
393 },
394 /* Cipher 14 */
395 {
396 1,
397 SSL3_TXT_EDH_RSA_DES_40_CBC_SHA,
398 SSL3_CK_EDH_RSA_DES_40_CBC_SHA,
399 SSL_kEDH|SSL_aRSA|SSL_DES|SSL_SHA1|SSL_SSLV3,
400 SSL_EXPORT|SSL_EXP40,
401 0,
402 40,
403 56,
404 SSL_ALL_CIPHERS,
405 SSL_ALL_STRENGTHS,
406 },
407 /* Cipher 15 */
408 {
409 1,
410 SSL3_TXT_EDH_RSA_DES_64_CBC_SHA,
411 SSL3_CK_EDH_RSA_DES_64_CBC_SHA,
412 SSL_kEDH|SSL_aRSA|SSL_DES |SSL_SHA1|SSL_SSLV3,
413 SSL_NOT_EXP|SSL_LOW,
414 0,
415 56,
416 56,
417 SSL_ALL_CIPHERS,
418 SSL_ALL_STRENGTHS,
419 },
420 /* Cipher 16 */
421 {
422 1,
423 SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA,
424 SSL3_CK_EDH_RSA_DES_192_CBC3_SHA,
425 SSL_kEDH|SSL_aRSA|SSL_3DES |SSL_SHA1|SSL_SSLV3,
426 SSL_NOT_EXP|SSL_HIGH,
427 0,
428 168,
429 168,
430 SSL_ALL_CIPHERS,
431 SSL_ALL_STRENGTHS,
432 },
433 /* Cipher 17 */
434 {
435 1,
436 SSL3_TXT_ADH_RC4_40_MD5,
437 SSL3_CK_ADH_RC4_40_MD5,
438 SSL_kEDH |SSL_aNULL|SSL_RC4 |SSL_MD5 |SSL_SSLV3,
439 SSL_EXPORT|SSL_EXP40,
440 0,
441 40,
442 128,
443 SSL_ALL_CIPHERS,
444 SSL_ALL_STRENGTHS,
445 },
446 /* Cipher 18 */
447 {
448 1,
449 SSL3_TXT_ADH_RC4_128_MD5,
450 SSL3_CK_ADH_RC4_128_MD5,
451 SSL_kEDH |SSL_aNULL|SSL_RC4 |SSL_MD5 |SSL_SSLV3,
452 SSL_NOT_EXP|SSL_MEDIUM,
453 0,
454 128,
455 128,
456 SSL_ALL_CIPHERS,
457 SSL_ALL_STRENGTHS,
458 },
459 /* Cipher 19 */
460 {
461 1,
462 SSL3_TXT_ADH_DES_40_CBC_SHA,
463 SSL3_CK_ADH_DES_40_CBC_SHA,
464 SSL_kEDH |SSL_aNULL|SSL_DES|SSL_SHA1|SSL_SSLV3,
465 SSL_EXPORT|SSL_EXP40,
466 0,
467 40,
468 128,
469 SSL_ALL_CIPHERS,
470 SSL_ALL_STRENGTHS,
471 },
472 /* Cipher 1A */
473 {
474 1,
475 SSL3_TXT_ADH_DES_64_CBC_SHA,
476 SSL3_CK_ADH_DES_64_CBC_SHA,
477 SSL_kEDH |SSL_aNULL|SSL_DES |SSL_SHA1|SSL_SSLV3,
478 SSL_NOT_EXP|SSL_LOW,
479 0,
480 56,
481 56,
482 SSL_ALL_CIPHERS,
483 SSL_ALL_STRENGTHS,
484 },
485 /* Cipher 1B */
486 {
487 1,
488 SSL3_TXT_ADH_DES_192_CBC_SHA,
489 SSL3_CK_ADH_DES_192_CBC_SHA,
490 SSL_kEDH |SSL_aNULL|SSL_3DES |SSL_SHA1|SSL_SSLV3,
491 SSL_NOT_EXP|SSL_HIGH,
492 0,
493 168,
494 168,
495 SSL_ALL_CIPHERS,
496 SSL_ALL_STRENGTHS,
497 },
498
499 /* Fortezza */
500 /* Cipher 1C */
501 {
502 0,
503 SSL3_TXT_FZA_DMS_NULL_SHA,
504 SSL3_CK_FZA_DMS_NULL_SHA,
505 SSL_kFZA|SSL_aFZA |SSL_eNULL |SSL_SHA1|SSL_SSLV3,
506 SSL_NOT_EXP|SSL_STRONG_NONE,
507 0,
508 0,
509 0,
510 SSL_ALL_CIPHERS,
511 SSL_ALL_STRENGTHS,
512 },
513
514 /* Cipher 1D */
515 {
516 0,
517 SSL3_TXT_FZA_DMS_FZA_SHA,
518 SSL3_CK_FZA_DMS_FZA_SHA,
519 SSL_kFZA|SSL_aFZA |SSL_eFZA |SSL_SHA1|SSL_SSLV3,
520 SSL_NOT_EXP|SSL_STRONG_NONE,
521 0,
522 0,
523 0,
524 SSL_ALL_CIPHERS,
525 SSL_ALL_STRENGTHS,
526 },
527
528 #if 0
529 /* Cipher 1E */
530 {
531 0,
532 SSL3_TXT_FZA_DMS_RC4_SHA,
533 SSL3_CK_FZA_DMS_RC4_SHA,
534 SSL_kFZA|SSL_aFZA |SSL_RC4 |SSL_SHA1|SSL_SSLV3,
535 SSL_NOT_EXP|SSL_MEDIUM,
536 0,
537 128,
538 128,
539 SSL_ALL_CIPHERS,
540 SSL_ALL_STRENGTHS,
541 },
542 #endif
543
544 #ifndef OPENSSL_NO_KRB5
545 /* The Kerberos ciphers
546 ** 20000107 VRS: And the first shall be last,
547 ** in hopes of avoiding the lynx ssl renegotiation problem.
548 */
549 /* Cipher 1E VRS */
550 {
551 1,
552 SSL3_TXT_KRB5_DES_64_CBC_SHA,
553 SSL3_CK_KRB5_DES_64_CBC_SHA,
554 SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_SHA1 |SSL_SSLV3,
555 SSL_NOT_EXP|SSL_LOW,
556 0,
557 56,
558 56,
559 SSL_ALL_CIPHERS,
560 SSL_ALL_STRENGTHS,
561 },
562
563 /* Cipher 1F VRS */
564 {
565 1,
566 SSL3_TXT_KRB5_DES_192_CBC3_SHA,
567 SSL3_CK_KRB5_DES_192_CBC3_SHA,
568 SSL_kKRB5|SSL_aKRB5| SSL_3DES|SSL_SHA1 |SSL_SSLV3,
569 SSL_NOT_EXP|SSL_HIGH,
570 0,
571 112,
572 168,
573 SSL_ALL_CIPHERS,
574 SSL_ALL_STRENGTHS,
575 },
576
577 /* Cipher 20 VRS */
578 {
579 1,
580 SSL3_TXT_KRB5_RC4_128_SHA,
581 SSL3_CK_KRB5_RC4_128_SHA,
582 SSL_kKRB5|SSL_aKRB5| SSL_RC4|SSL_SHA1 |SSL_SSLV3,
583 SSL_NOT_EXP|SSL_MEDIUM,
584 0,
585 128,
586 128,
587 SSL_ALL_CIPHERS,
588 SSL_ALL_STRENGTHS,
589 },
590
591 /* Cipher 21 VRS */
592 {
593 1,
594 SSL3_TXT_KRB5_IDEA_128_CBC_SHA,
595 SSL3_CK_KRB5_IDEA_128_CBC_SHA,
596 SSL_kKRB5|SSL_aKRB5| SSL_IDEA|SSL_SHA1 |SSL_SSLV3,
597 SSL_NOT_EXP|SSL_MEDIUM,
598 0,
599 128,
600 128,
601 SSL_ALL_CIPHERS,
602 SSL_ALL_STRENGTHS,
603 },
604
605 /* Cipher 22 VRS */
606 {
607 1,
608 SSL3_TXT_KRB5_DES_64_CBC_MD5,
609 SSL3_CK_KRB5_DES_64_CBC_MD5,
610 SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_MD5 |SSL_SSLV3,
611 SSL_NOT_EXP|SSL_LOW,
612 0,
613 56,
614 56,
615 SSL_ALL_CIPHERS,
616 SSL_ALL_STRENGTHS,
617 },
618
619 /* Cipher 23 VRS */
620 {
621 1,
622 SSL3_TXT_KRB5_DES_192_CBC3_MD5,
623 SSL3_CK_KRB5_DES_192_CBC3_MD5,
624 SSL_kKRB5|SSL_aKRB5| SSL_3DES|SSL_MD5 |SSL_SSLV3,
625 SSL_NOT_EXP|SSL_HIGH,
626 0,
627 112,
628 168,
629 SSL_ALL_CIPHERS,
630 SSL_ALL_STRENGTHS,
631 },
632
633 /* Cipher 24 VRS */
634 {
635 1,
636 SSL3_TXT_KRB5_RC4_128_MD5,
637 SSL3_CK_KRB5_RC4_128_MD5,
638 SSL_kKRB5|SSL_aKRB5| SSL_RC4|SSL_MD5 |SSL_SSLV3,
639 SSL_NOT_EXP|SSL_MEDIUM,
640 0,
641 128,
642 128,
643 SSL_ALL_CIPHERS,
644 SSL_ALL_STRENGTHS,
645 },
646
647 /* Cipher 25 VRS */
648 {
649 1,
650 SSL3_TXT_KRB5_IDEA_128_CBC_MD5,
651 SSL3_CK_KRB5_IDEA_128_CBC_MD5,
652 SSL_kKRB5|SSL_aKRB5| SSL_IDEA|SSL_MD5 |SSL_SSLV3,
653 SSL_NOT_EXP|SSL_MEDIUM,
654 0,
655 128,
656 128,
657 SSL_ALL_CIPHERS,
658 SSL_ALL_STRENGTHS,
659 },
660
661 /* Cipher 26 VRS */
662 {
663 1,
664 SSL3_TXT_KRB5_DES_40_CBC_SHA,
665 SSL3_CK_KRB5_DES_40_CBC_SHA,
666 SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_SHA1 |SSL_SSLV3,
667 SSL_EXPORT|SSL_EXP40,
668 0,
669 40,
670 56,
671 SSL_ALL_CIPHERS,
672 SSL_ALL_STRENGTHS,
673 },
674
675 /* Cipher 27 VRS */
676 {
677 1,
678 SSL3_TXT_KRB5_RC2_40_CBC_SHA,
679 SSL3_CK_KRB5_RC2_40_CBC_SHA,
680 SSL_kKRB5|SSL_aKRB5| SSL_RC2|SSL_SHA1 |SSL_SSLV3,
681 SSL_EXPORT|SSL_EXP40,
682 0,
683 40,
684 128,
685 SSL_ALL_CIPHERS,
686 SSL_ALL_STRENGTHS,
687 },
688
689 /* Cipher 28 VRS */
690 {
691 1,
692 SSL3_TXT_KRB5_RC4_40_SHA,
693 SSL3_CK_KRB5_RC4_40_SHA,
694 SSL_kKRB5|SSL_aKRB5| SSL_RC4|SSL_SHA1 |SSL_SSLV3,
695 SSL_EXPORT|SSL_EXP40,
696 0,
697 128,
698 128,
699 SSL_ALL_CIPHERS,
700 SSL_ALL_STRENGTHS,
701 },
702
703 /* Cipher 29 VRS */
704 {
705 1,
706 SSL3_TXT_KRB5_DES_40_CBC_MD5,
707 SSL3_CK_KRB5_DES_40_CBC_MD5,
708 SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_MD5 |SSL_SSLV3,
709 SSL_EXPORT|SSL_EXP40,
710 0,
711 40,
712 56,
713 SSL_ALL_CIPHERS,
714 SSL_ALL_STRENGTHS,
715 },
716
717 /* Cipher 2A VRS */
718 {
719 1,
720 SSL3_TXT_KRB5_RC2_40_CBC_MD5,
721 SSL3_CK_KRB5_RC2_40_CBC_MD5,
722 SSL_kKRB5|SSL_aKRB5| SSL_RC2|SSL_MD5 |SSL_SSLV3,
723 SSL_EXPORT|SSL_EXP40,
724 0,
725 40,
726 128,
727 SSL_ALL_CIPHERS,
728 SSL_ALL_STRENGTHS,
729 },
730
731 /* Cipher 2B VRS */
732 {
733 1,
734 SSL3_TXT_KRB5_RC4_40_MD5,
735 SSL3_CK_KRB5_RC4_40_MD5,
736 SSL_kKRB5|SSL_aKRB5| SSL_RC4|SSL_MD5 |SSL_SSLV3,
737 SSL_EXPORT|SSL_EXP40,
738 0,
739 128,
740 128,
741 SSL_ALL_CIPHERS,
742 SSL_ALL_STRENGTHS,
743 },
744 #endif /* OPENSSL_NO_KRB5 */
745 /* New AES ciphersuites */
746
747 /* Cipher 2F */
748 {
749 1,
750 TLS1_TXT_RSA_WITH_AES_128_SHA,
751 TLS1_CK_RSA_WITH_AES_128_SHA,
752 SSL_kRSA|SSL_aRSA|SSL_AES|SSL_SHA |SSL_TLSV1,
753 SSL_NOT_EXP|SSL_HIGH,
754 0,
755 128,
756 128,
757 SSL_ALL_CIPHERS,
758 SSL_ALL_STRENGTHS,
759 },
760 /* Cipher 30 */
761 {
762 0,
763 TLS1_TXT_DH_DSS_WITH_AES_128_SHA,
764 TLS1_CK_DH_DSS_WITH_AES_128_SHA,
765 SSL_kDHd|SSL_aDH|SSL_AES|SSL_SHA|SSL_TLSV1,
766 SSL_NOT_EXP|SSL_HIGH,
767 0,
768 128,
769 128,
770 SSL_ALL_CIPHERS,
771 SSL_ALL_STRENGTHS,
772 },
773 /* Cipher 31 */
774 {
775 0,
776 TLS1_TXT_DH_RSA_WITH_AES_128_SHA,
777 TLS1_CK_DH_RSA_WITH_AES_128_SHA,
778 SSL_kDHr|SSL_aDH|SSL_AES|SSL_SHA|SSL_TLSV1,
779 SSL_NOT_EXP|SSL_HIGH,
780 0,
781 128,
782 128,
783 SSL_ALL_CIPHERS,
784 SSL_ALL_STRENGTHS,
785 },
786 /* Cipher 32 */
787 {
788 1,
789 TLS1_TXT_DHE_DSS_WITH_AES_128_SHA,
790 TLS1_CK_DHE_DSS_WITH_AES_128_SHA,
791 SSL_kEDH|SSL_aDSS|SSL_AES|SSL_SHA|SSL_TLSV1,
792 SSL_NOT_EXP|SSL_HIGH,
793 0,
794 128,
795 128,
796 SSL_ALL_CIPHERS,
797 SSL_ALL_STRENGTHS,
798 },
799 /* Cipher 33 */
800 {
801 1,
802 TLS1_TXT_DHE_RSA_WITH_AES_128_SHA,
803 TLS1_CK_DHE_RSA_WITH_AES_128_SHA,
804 SSL_kEDH|SSL_aRSA|SSL_AES|SSL_SHA|SSL_TLSV1,
805 SSL_NOT_EXP|SSL_HIGH,
806 0,
807 128,
808 128,
809 SSL_ALL_CIPHERS,
810 SSL_ALL_STRENGTHS,
811 },
812 /* Cipher 34 */
813 {
814 1,
815 TLS1_TXT_ADH_WITH_AES_128_SHA,
816 TLS1_CK_ADH_WITH_AES_128_SHA,
817 SSL_kEDH|SSL_aNULL|SSL_AES|SSL_SHA|SSL_TLSV1,
818 SSL_NOT_EXP|SSL_HIGH,
819 0,
820 128,
821 128,
822 SSL_ALL_CIPHERS,
823 SSL_ALL_STRENGTHS,
824 },
825
826 /* Cipher 35 */
827 {
828 1,
829 TLS1_TXT_RSA_WITH_AES_256_SHA,
830 TLS1_CK_RSA_WITH_AES_256_SHA,
831 SSL_kRSA|SSL_aRSA|SSL_AES|SSL_SHA |SSL_TLSV1,
832 SSL_NOT_EXP|SSL_HIGH,
833 0,
834 256,
835 256,
836 SSL_ALL_CIPHERS,
837 SSL_ALL_STRENGTHS,
838 },
839 /* Cipher 36 */
840 {
841 0,
842 TLS1_TXT_DH_DSS_WITH_AES_256_SHA,
843 TLS1_CK_DH_DSS_WITH_AES_256_SHA,
844 SSL_kDHd|SSL_aDH|SSL_AES|SSL_SHA|SSL_TLSV1,
845 SSL_NOT_EXP|SSL_HIGH,
846 0,
847 256,
848 256,
849 SSL_ALL_CIPHERS,
850 SSL_ALL_STRENGTHS,
851 },
852 /* Cipher 37 */
853 {
854 0,
855 TLS1_TXT_DH_RSA_WITH_AES_256_SHA,
856 TLS1_CK_DH_RSA_WITH_AES_256_SHA,
857 SSL_kDHr|SSL_aDH|SSL_AES|SSL_SHA|SSL_TLSV1,
858 SSL_NOT_EXP|SSL_HIGH,
859 0,
860 256,
861 256,
862 SSL_ALL_CIPHERS,
863 SSL_ALL_STRENGTHS,
864 },
865 /* Cipher 38 */
866 {
867 1,
868 TLS1_TXT_DHE_DSS_WITH_AES_256_SHA,
869 TLS1_CK_DHE_DSS_WITH_AES_256_SHA,
870 SSL_kEDH|SSL_aDSS|SSL_AES|SSL_SHA|SSL_TLSV1,
871 SSL_NOT_EXP|SSL_HIGH,
872 0,
873 256,
874 256,
875 SSL_ALL_CIPHERS,
876 SSL_ALL_STRENGTHS,
877 },
878 /* Cipher 39 */
879 {
880 1,
881 TLS1_TXT_DHE_RSA_WITH_AES_256_SHA,
882 TLS1_CK_DHE_RSA_WITH_AES_256_SHA,
883 SSL_kEDH|SSL_aRSA|SSL_AES|SSL_SHA|SSL_TLSV1,
884 SSL_NOT_EXP|SSL_HIGH,
885 0,
886 256,
887 256,
888 SSL_ALL_CIPHERS,
889 SSL_ALL_STRENGTHS,
890 },
891 /* Cipher 3A */
892 {
893 1,
894 TLS1_TXT_ADH_WITH_AES_256_SHA,
895 TLS1_CK_ADH_WITH_AES_256_SHA,
896 SSL_kEDH|SSL_aNULL|SSL_AES|SSL_SHA|SSL_TLSV1,
897 SSL_NOT_EXP|SSL_HIGH,
898 0,
899 256,
900 256,
901 SSL_ALL_CIPHERS,
902 SSL_ALL_STRENGTHS,
903 },
904 #ifndef OPENSSL_NO_ECDH
905 /* Cipher 47 */
906 {
907 1,
908 TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA,
909 TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA,
910 SSL_kECDH|SSL_aECDSA|SSL_eNULL|SSL_SHA|SSL_TLSV1,
911 SSL_NOT_EXP,
912 0,
913 0,
914 0,
915 SSL_ALL_CIPHERS,
916 SSL_ALL_STRENGTHS,
917 },
918
919 /* Cipher 48 */
920 {
921 1,
922 TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA,
923 TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA,
924 SSL_kECDH|SSL_aECDSA|SSL_RC4|SSL_SHA|SSL_TLSV1,
925 SSL_NOT_EXP,
926 0,
927 128,
928 128,
929 SSL_ALL_CIPHERS,
930 SSL_ALL_STRENGTHS,
931 },
932
933 /* Cipher 49 */
934 {
935 1,
936 TLS1_TXT_ECDH_ECDSA_WITH_DES_CBC_SHA,
937 TLS1_CK_ECDH_ECDSA_WITH_DES_CBC_SHA,
938 SSL_kECDH|SSL_aECDSA|SSL_DES|SSL_SHA|SSL_TLSV1,
939 SSL_NOT_EXP|SSL_LOW,
940 0,
941 56,
942 56,
943 SSL_ALL_CIPHERS,
944 SSL_ALL_STRENGTHS,
945 },
946
947 /* Cipher 4A */
948 {
949 1,
950 TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA,
951 TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA,
952 SSL_kECDH|SSL_aECDSA|SSL_3DES|SSL_SHA|SSL_TLSV1,
953 SSL_NOT_EXP|SSL_HIGH,
954 0,
955 168,
956 168,
957 SSL_ALL_CIPHERS,
958 SSL_ALL_STRENGTHS,
959 },
960
961 /* Cipher 4B */
962 {
963 1,
964 TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA,
965 TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA,
966 SSL_kECDH|SSL_aECDSA|SSL_AES|SSL_SHA|SSL_TLSV1,
967 SSL_NOT_EXP|SSL_HIGH,
968 0,
969 128,
970 128,
971 SSL_ALL_CIPHERS,
972 SSL_ALL_STRENGTHS,
973 },
974
975 /* Cipher 4C */
976 {
977 1,
978 TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA,
979 TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA,
980 SSL_kECDH|SSL_aECDSA|SSL_AES|SSL_SHA|SSL_TLSV1,
981 SSL_NOT_EXP|SSL_HIGH,
982 0,
983 256,
984 256,
985 SSL_ALL_CIPHERS,
986 SSL_ALL_STRENGTHS,
987 },
988
989 /* Cipher 4D */
990 {
991 1,
992 TLS1_TXT_ECDH_RSA_WITH_NULL_SHA,
993 TLS1_CK_ECDH_RSA_WITH_NULL_SHA,
994 SSL_kECDH|SSL_aRSA|SSL_eNULL|SSL_SHA|SSL_TLSV1,
995 SSL_NOT_EXP,
996 0,
997 0,
998 0,
999 SSL_ALL_CIPHERS,
1000 SSL_ALL_STRENGTHS,
1001 },
1002
1003 /* Cipher 4E */
1004 {
1005 1,
1006 TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA,
1007 TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA,
1008 SSL_kECDH|SSL_aRSA|SSL_RC4|SSL_SHA|SSL_TLSV1,
1009 SSL_NOT_EXP,
1010 0,
1011 128,
1012 128,
1013 SSL_ALL_CIPHERS,
1014 SSL_ALL_STRENGTHS,
1015 },
1016
1017 /* Cipher 4F */
1018 {
1019 1,
1020 TLS1_TXT_ECDH_RSA_WITH_DES_CBC_SHA,
1021 TLS1_CK_ECDH_RSA_WITH_DES_CBC_SHA,
1022 SSL_kECDH|SSL_aRSA|SSL_DES|SSL_SHA|SSL_TLSV1,
1023 SSL_NOT_EXP|SSL_LOW,
1024 0,
1025 56,
1026 56,
1027 SSL_ALL_CIPHERS,
1028 SSL_ALL_STRENGTHS,
1029 },
1030
1031 /* Cipher 50 */
1032 {
1033 1,
1034 TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA,
1035 TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA,
1036 SSL_kECDH|SSL_aRSA|SSL_3DES|SSL_SHA|SSL_TLSV1,
1037 SSL_NOT_EXP|SSL_HIGH,
1038 0,
1039 168,
1040 168,
1041 SSL_ALL_CIPHERS,
1042 SSL_ALL_STRENGTHS,
1043 },
1044
1045 /* Cipher 51 */
1046 {
1047 1,
1048 TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA,
1049 TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA,
1050 SSL_kECDH|SSL_aRSA|SSL_AES|SSL_SHA|SSL_TLSV1,
1051 SSL_NOT_EXP|SSL_HIGH,
1052 0,
1053 128,
1054 128,
1055 SSL_ALL_CIPHERS,
1056 SSL_ALL_STRENGTHS,
1057 },
1058
1059 /* Cipher 52 */
1060 {
1061 1,
1062 TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA,
1063 TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA,
1064 SSL_kECDH|SSL_aRSA|SSL_AES|SSL_SHA|SSL_TLSV1,
1065 SSL_NOT_EXP|SSL_HIGH,
1066 0,
1067 256,
1068 256,
1069 SSL_ALL_CIPHERS,
1070 SSL_ALL_STRENGTHS,
1071 },
1072
1073 /* Cipher 53 */
1074 {
1075 1,
1076 TLS1_TXT_ECDH_RSA_EXPORT_WITH_RC4_40_SHA,
1077 TLS1_CK_ECDH_RSA_EXPORT_WITH_RC4_40_SHA,
1078 SSL_kECDH|SSL_aRSA|SSL_RC4|SSL_SHA|SSL_TLSV1,
1079 SSL_EXPORT|SSL_EXP40,
1080 0,
1081 40,
1082 128,
1083 SSL_ALL_CIPHERS,
1084 SSL_ALL_STRENGTHS,
1085 },
1086
1087 /* Cipher 54 */
1088 {
1089 1,
1090 TLS1_TXT_ECDH_RSA_EXPORT_WITH_RC4_56_SHA,
1091 TLS1_CK_ECDH_RSA_EXPORT_WITH_RC4_56_SHA,
1092 SSL_kECDH|SSL_aRSA|SSL_RC4|SSL_SHA|SSL_TLSV1,
1093 SSL_EXPORT|SSL_EXP56,
1094 0,
1095 56,
1096 128,
1097 SSL_ALL_CIPHERS,
1098 SSL_ALL_STRENGTHS,
1099 },
1100
1101 /* Cipher 55 */
1102 {
1103 1,
1104 TLS1_TXT_ECDH_anon_WITH_NULL_SHA,
1105 TLS1_CK_ECDH_anon_WITH_NULL_SHA,
1106 SSL_kECDHE|SSL_aNULL|SSL_eNULL|SSL_SHA|SSL_TLSV1,
1107 SSL_NOT_EXP,
1108 0,
1109 0,
1110 0,
1111 SSL_ALL_CIPHERS,
1112 SSL_ALL_STRENGTHS,
1113 },
1114
1115 /* Cipher 56 */
1116 {
1117 1,
1118 TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA,
1119 TLS1_CK_ECDH_anon_WITH_RC4_128_SHA,
1120 SSL_kECDHE|SSL_aNULL|SSL_RC4|SSL_SHA|SSL_TLSV1,
1121 SSL_NOT_EXP,
1122 0,
1123 128,
1124 128,
1125 SSL_ALL_CIPHERS,
1126 SSL_ALL_STRENGTHS,
1127 },
1128
1129 /* Cipher 57 */
1130 {
1131 1,
1132 TLS1_TXT_ECDH_anon_WITH_DES_CBC_SHA,
1133 TLS1_CK_ECDH_anon_WITH_DES_CBC_SHA,
1134 SSL_kECDHE|SSL_aNULL|SSL_DES|SSL_SHA|SSL_TLSV1,
1135 SSL_NOT_EXP|SSL_LOW,
1136 0,
1137 56,
1138 56,
1139 SSL_ALL_CIPHERS,
1140 SSL_ALL_STRENGTHS,
1141 },
1142
1143 /* Cipher 58 */
1144 {
1145 1,
1146 TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA,
1147 TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA,
1148 SSL_kECDHE|SSL_aNULL|SSL_3DES|SSL_SHA|SSL_TLSV1,
1149 SSL_NOT_EXP|SSL_HIGH,
1150 0,
1151 168,
1152 168,
1153 SSL_ALL_CIPHERS,
1154 SSL_ALL_STRENGTHS,
1155 },
1156
1157 /* Cipher 59 */
1158 {
1159 1,
1160 TLS1_TXT_ECDH_anon_EXPORT_WITH_DES_40_CBC_SHA,
1161 TLS1_CK_ECDH_anon_EXPORT_WITH_DES_40_CBC_SHA,
1162 SSL_kECDHE|SSL_aNULL|SSL_DES|SSL_SHA|SSL_TLSV1,
1163 SSL_EXPORT|SSL_EXP40,
1164 0,
1165 40,
1166 56,
1167 SSL_ALL_CIPHERS,
1168 SSL_ALL_STRENGTHS,
1169 },
1170
1171 /* Cipher 5A */
1172 {
1173 1,
1174 TLS1_TXT_ECDH_anon_EXPORT_WITH_RC4_40_SHA,
1175 TLS1_CK_ECDH_anon_EXPORT_WITH_RC4_40_SHA,
1176 SSL_kECDHE|SSL_aNULL|SSL_RC4|SSL_SHA|SSL_TLSV1,
1177 SSL_EXPORT|SSL_EXP40,
1178 0,
1179 40,
1180 128,
1181 SSL_ALL_CIPHERS,
1182 SSL_ALL_STRENGTHS,
1183 },
1184 /* Cipher 5B */
1185 /* XXX NOTE: The ECC/TLS draft has a bug and reuses 4B for this */
1186 {
1187 1,
1188 TLS1_TXT_ECDH_ECDSA_EXPORT_WITH_RC4_40_SHA,
1189 TLS1_CK_ECDH_ECDSA_EXPORT_WITH_RC4_40_SHA,
1190 SSL_kECDH|SSL_aECDSA|SSL_RC4|SSL_SHA|SSL_TLSV1,
1191 SSL_EXPORT|SSL_EXP40,
1192 0,
1193 40,
1194 128,
1195 SSL_ALL_CIPHERS,
1196 SSL_ALL_STRENGTHS,
1197 },
1198
1199 /* Cipher 5C */
1200 /* XXX NOTE: The ECC/TLS draft has a bug and reuses 4C for this */
1201 {
1202 1,
1203 TLS1_TXT_ECDH_ECDSA_EXPORT_WITH_RC4_56_SHA,
1204 TLS1_CK_ECDH_ECDSA_EXPORT_WITH_RC4_56_SHA,
1205 SSL_kECDH|SSL_aECDSA|SSL_RC4|SSL_SHA|SSL_TLSV1,
1206 SSL_EXPORT|SSL_EXP56,
1207 0,
1208 56,
1209 128,
1210 SSL_ALL_CIPHERS,
1211 SSL_ALL_STRENGTHS,
1212 },
1213
1214 #endif /* OPENSSL_NO_ECDH */
1215
1216 #if TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES
1217 /* New TLS Export CipherSuites */
1218 /* Cipher 60 */
1219 {
1220 1,
1221 TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5,
1222 TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5,
1223 SSL_kRSA|SSL_aRSA|SSL_RC4|SSL_MD5|SSL_TLSV1,
1224 SSL_EXPORT|SSL_EXP56,
1225 0,
1226 56,
1227 128,
1228 SSL_ALL_CIPHERS,
1229 SSL_ALL_STRENGTHS,
1230 },
1231 /* Cipher 61 */
1232 {
1233 1,
1234 TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5,
1235 TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5,
1236 SSL_kRSA|SSL_aRSA|SSL_RC2|SSL_MD5|SSL_TLSV1,
1237 SSL_EXPORT|SSL_EXP56,
1238 0,
1239 56,
1240 128,
1241 SSL_ALL_CIPHERS,
1242 SSL_ALL_STRENGTHS,
1243 },
1244 /* Cipher 62 */
1245 {
1246 1,
1247 TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA,
1248 TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA,
1249 SSL_kRSA|SSL_aRSA|SSL_DES|SSL_SHA|SSL_TLSV1,
1250 SSL_EXPORT|SSL_EXP56,
1251 0,
1252 56,
1253 56,
1254 SSL_ALL_CIPHERS,
1255 SSL_ALL_STRENGTHS,
1256 },
1257 /* Cipher 63 */
1258 {
1259 1,
1260 TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA,
1261 TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA,
1262 SSL_kEDH|SSL_aDSS|SSL_DES|SSL_SHA|SSL_TLSV1,
1263 SSL_EXPORT|SSL_EXP56,
1264 0,
1265 56,
1266 56,
1267 SSL_ALL_CIPHERS,
1268 SSL_ALL_STRENGTHS,
1269 },
1270 /* Cipher 64 */
1271 {
1272 1,
1273 TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA,
1274 TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA,
1275 SSL_kRSA|SSL_aRSA|SSL_RC4|SSL_SHA|SSL_TLSV1,
1276 SSL_EXPORT|SSL_EXP56,
1277 0,
1278 56,
1279 128,
1280 SSL_ALL_CIPHERS,
1281 SSL_ALL_STRENGTHS,
1282 },
1283 /* Cipher 65 */
1284 {
1285 1,
1286 TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA,
1287 TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA,
1288 SSL_kEDH|SSL_aDSS|SSL_RC4|SSL_SHA|SSL_TLSV1,
1289 SSL_EXPORT|SSL_EXP56,
1290 0,
1291 56,
1292 128,
1293 SSL_ALL_CIPHERS,
1294 SSL_ALL_STRENGTHS,
1295 },
1296 /* Cipher 66 */
1297 {
1298 1,
1299 TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA,
1300 TLS1_CK_DHE_DSS_WITH_RC4_128_SHA,
1301 SSL_kEDH|SSL_aDSS|SSL_RC4|SSL_SHA|SSL_TLSV1,
1302 SSL_NOT_EXP|SSL_MEDIUM,
1303 0,
1304 128,
1305 128,
1306 SSL_ALL_CIPHERS,
1307 SSL_ALL_STRENGTHS
1308 },
1309 #endif
1310
1311 #ifndef OPENSSL_NO_ECDH
1312 /* Cipher 77 XXX: ECC ciphersuites offering forward secrecy
1313 * are not yet specified in the ECC/TLS draft but our code
1314 * allows them to be implemented very easily. To add such
1315 * a cipher suite, one needs to add two constant definitions
1316 * to tls1.h and a new structure in this file as shown below. We
1317 * illustrate the process for the made-up cipher
1318 * ECDHE-ECDSA-AES128-SHA.
1319 */
1320 {
1321 1,
1322 TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
1323 TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
1324 SSL_kECDHE|SSL_aECDSA|SSL_AES|SSL_SHA|SSL_TLSV1,
1325 SSL_NOT_EXP|SSL_HIGH,
1326 0,
1327 128,
1328 128,
1329 SSL_ALL_CIPHERS,
1330 SSL_ALL_STRENGTHS,
1331 },
1332
1333 /* Cipher 78 XXX: Another made-up ECC cipher suite that
1334 * offers forward secrecy (ECDHE-RSA-AES128-SHA).
1335 */
1336 {
1337 1,
1338 TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA,
1339 TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA,
1340 SSL_kECDHE|SSL_aRSA|SSL_AES|SSL_SHA|SSL_TLSV1,
1341 SSL_NOT_EXP|SSL_HIGH,
1342 0,
1343 128,
1344 128,
1345 SSL_ALL_CIPHERS,
1346 SSL_ALL_STRENGTHS,
1347 },
1348 #endif /* !OPENSSL_NO_ECDH */
1349
1350 /* end of list */
1351 };
1352
1353 SSL3_ENC_METHOD SSLv3_enc_data={
1354 ssl3_enc,
1355 ssl3_mac,
1356 ssl3_setup_key_block,
1357 ssl3_generate_master_secret,
1358 ssl3_change_cipher_state,
1359 ssl3_final_finish_mac,
1360 MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH,
1361 ssl3_cert_verify_mac,
1362 SSL3_MD_CLIENT_FINISHED_CONST,4,
1363 SSL3_MD_SERVER_FINISHED_CONST,4,
1364 ssl3_alert_code,
1365 };
1366
ssl3_default_timeout(void)1367 long ssl3_default_timeout(void)
1368 {
1369 /* 2 hours, the 24 hours mentioned in the SSLv3 spec
1370 * is way too long for http, the cache would over fill */
1371 return(60*60*2);
1372 }
1373
IMPLEMENT_ssl3_meth_func(sslv3_base_method,ssl_undefined_function,ssl_undefined_function,ssl_bad_method)1374 IMPLEMENT_ssl3_meth_func(sslv3_base_method,
1375 ssl_undefined_function,
1376 ssl_undefined_function,
1377 ssl_bad_method)
1378
1379 int ssl3_num_ciphers(void)
1380 {
1381 return(SSL3_NUM_CIPHERS);
1382 }
1383
ssl3_get_cipher(unsigned int u)1384 SSL_CIPHER *ssl3_get_cipher(unsigned int u)
1385 {
1386 if (u < SSL3_NUM_CIPHERS)
1387 return(&(ssl3_ciphers[SSL3_NUM_CIPHERS-1-u]));
1388 else
1389 return(NULL);
1390 }
1391
ssl3_pending(const SSL * s)1392 int ssl3_pending(const SSL *s)
1393 {
1394 if (s->rstate == SSL_ST_READ_BODY)
1395 return 0;
1396
1397 return (s->s3->rrec.type == SSL3_RT_APPLICATION_DATA) ? s->s3->rrec.length : 0;
1398 }
1399
ssl3_new(SSL * s)1400 int ssl3_new(SSL *s)
1401 {
1402 SSL3_STATE *s3;
1403
1404 if ((s3=OPENSSL_malloc(sizeof *s3)) == NULL) goto err;
1405 memset(s3,0,sizeof *s3);
1406 EVP_MD_CTX_init(&s3->finish_dgst1);
1407 EVP_MD_CTX_init(&s3->finish_dgst2);
1408 pq_64bit_init(&(s3->rrec.seq_num));
1409 pq_64bit_init(&(s3->wrec.seq_num));
1410
1411 s->s3=s3;
1412
1413 s->method->ssl_clear(s);
1414 return(1);
1415 err:
1416 return(0);
1417 }
1418
ssl3_free(SSL * s)1419 void ssl3_free(SSL *s)
1420 {
1421 if(s == NULL)
1422 return;
1423
1424 ssl3_cleanup_key_block(s);
1425 if (s->s3->rbuf.buf != NULL)
1426 OPENSSL_free(s->s3->rbuf.buf);
1427 if (s->s3->wbuf.buf != NULL)
1428 OPENSSL_free(s->s3->wbuf.buf);
1429 if (s->s3->rrec.comp != NULL)
1430 OPENSSL_free(s->s3->rrec.comp);
1431 #ifndef OPENSSL_NO_DH
1432 if (s->s3->tmp.dh != NULL)
1433 DH_free(s->s3->tmp.dh);
1434 #endif
1435 #ifndef OPENSSL_NO_ECDH
1436 if (s->s3->tmp.ecdh != NULL)
1437 EC_KEY_free(s->s3->tmp.ecdh);
1438 #endif
1439
1440 if (s->s3->tmp.ca_names != NULL)
1441 sk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free);
1442 EVP_MD_CTX_cleanup(&s->s3->finish_dgst1);
1443 EVP_MD_CTX_cleanup(&s->s3->finish_dgst2);
1444 pq_64bit_free(&(s->s3->rrec.seq_num));
1445 pq_64bit_free(&(s->s3->wrec.seq_num));
1446
1447 OPENSSL_cleanse(s->s3,sizeof *s->s3);
1448 OPENSSL_free(s->s3);
1449 s->s3=NULL;
1450 }
1451
ssl3_clear(SSL * s)1452 void ssl3_clear(SSL *s)
1453 {
1454 unsigned char *rp,*wp;
1455 size_t rlen, wlen;
1456
1457 ssl3_cleanup_key_block(s);
1458 if (s->s3->tmp.ca_names != NULL)
1459 sk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free);
1460
1461 if (s->s3->rrec.comp != NULL)
1462 {
1463 OPENSSL_free(s->s3->rrec.comp);
1464 s->s3->rrec.comp=NULL;
1465 }
1466 #ifndef OPENSSL_NO_DH
1467 if (s->s3->tmp.dh != NULL)
1468 DH_free(s->s3->tmp.dh);
1469 #endif
1470 #ifndef OPENSSL_NO_ECDH
1471 if (s->s3->tmp.ecdh != NULL)
1472 EC_KEY_free(s->s3->tmp.ecdh);
1473 #endif
1474
1475 rp = s->s3->rbuf.buf;
1476 wp = s->s3->wbuf.buf;
1477 rlen = s->s3->rbuf.len;
1478 wlen = s->s3->wbuf.len;
1479
1480 EVP_MD_CTX_cleanup(&s->s3->finish_dgst1);
1481 EVP_MD_CTX_cleanup(&s->s3->finish_dgst2);
1482
1483 memset(s->s3,0,sizeof *s->s3);
1484 s->s3->rbuf.buf = rp;
1485 s->s3->wbuf.buf = wp;
1486 s->s3->rbuf.len = rlen;
1487 s->s3->wbuf.len = wlen;
1488
1489 ssl_free_wbio_buffer(s);
1490
1491 s->packet_length=0;
1492 s->s3->renegotiate=0;
1493 s->s3->total_renegotiations=0;
1494 s->s3->num_renegotiations=0;
1495 s->s3->in_read_app_data=0;
1496 s->version=SSL3_VERSION;
1497 }
1498
ssl3_ctrl(SSL * s,int cmd,long larg,void * parg)1499 long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg)
1500 {
1501 int ret=0;
1502
1503 #if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA)
1504 if (
1505 #ifndef OPENSSL_NO_RSA
1506 cmd == SSL_CTRL_SET_TMP_RSA ||
1507 cmd == SSL_CTRL_SET_TMP_RSA_CB ||
1508 #endif
1509 #ifndef OPENSSL_NO_DSA
1510 cmd == SSL_CTRL_SET_TMP_DH ||
1511 cmd == SSL_CTRL_SET_TMP_DH_CB ||
1512 #endif
1513 0)
1514 {
1515 if (!ssl_cert_inst(&s->cert))
1516 {
1517 SSLerr(SSL_F_SSL3_CTRL, ERR_R_MALLOC_FAILURE);
1518 return(0);
1519 }
1520 }
1521 #endif
1522
1523 switch (cmd)
1524 {
1525 case SSL_CTRL_GET_SESSION_REUSED:
1526 ret=s->hit;
1527 break;
1528 case SSL_CTRL_GET_CLIENT_CERT_REQUEST:
1529 break;
1530 case SSL_CTRL_GET_NUM_RENEGOTIATIONS:
1531 ret=s->s3->num_renegotiations;
1532 break;
1533 case SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS:
1534 ret=s->s3->num_renegotiations;
1535 s->s3->num_renegotiations=0;
1536 break;
1537 case SSL_CTRL_GET_TOTAL_RENEGOTIATIONS:
1538 ret=s->s3->total_renegotiations;
1539 break;
1540 case SSL_CTRL_GET_FLAGS:
1541 ret=(int)(s->s3->flags);
1542 break;
1543 #ifndef OPENSSL_NO_RSA
1544 case SSL_CTRL_NEED_TMP_RSA:
1545 if ((s->cert != NULL) && (s->cert->rsa_tmp == NULL) &&
1546 ((s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) ||
1547 (EVP_PKEY_size(s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey) > (512/8))))
1548 ret = 1;
1549 break;
1550 case SSL_CTRL_SET_TMP_RSA:
1551 {
1552 RSA *rsa = (RSA *)parg;
1553 if (rsa == NULL)
1554 {
1555 SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
1556 return(ret);
1557 }
1558 if ((rsa = RSAPrivateKey_dup(rsa)) == NULL)
1559 {
1560 SSLerr(SSL_F_SSL3_CTRL, ERR_R_RSA_LIB);
1561 return(ret);
1562 }
1563 if (s->cert->rsa_tmp != NULL)
1564 RSA_free(s->cert->rsa_tmp);
1565 s->cert->rsa_tmp = rsa;
1566 ret = 1;
1567 }
1568 break;
1569 case SSL_CTRL_SET_TMP_RSA_CB:
1570 {
1571 SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
1572 return(ret);
1573 }
1574 break;
1575 #endif
1576 #ifndef OPENSSL_NO_DH
1577 case SSL_CTRL_SET_TMP_DH:
1578 {
1579 DH *dh = (DH *)parg;
1580 if (dh == NULL)
1581 {
1582 SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
1583 return(ret);
1584 }
1585 if ((dh = DHparams_dup(dh)) == NULL)
1586 {
1587 SSLerr(SSL_F_SSL3_CTRL, ERR_R_DH_LIB);
1588 return(ret);
1589 }
1590 if (!(s->options & SSL_OP_SINGLE_DH_USE))
1591 {
1592 if (!DH_generate_key(dh))
1593 {
1594 DH_free(dh);
1595 SSLerr(SSL_F_SSL3_CTRL, ERR_R_DH_LIB);
1596 return(ret);
1597 }
1598 }
1599 if (s->cert->dh_tmp != NULL)
1600 DH_free(s->cert->dh_tmp);
1601 s->cert->dh_tmp = dh;
1602 ret = 1;
1603 }
1604 break;
1605 case SSL_CTRL_SET_TMP_DH_CB:
1606 {
1607 SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
1608 return(ret);
1609 }
1610 break;
1611 #endif
1612 #ifndef OPENSSL_NO_ECDH
1613 case SSL_CTRL_SET_TMP_ECDH:
1614 {
1615 EC_KEY *ecdh = NULL;
1616
1617 if (parg == NULL)
1618 {
1619 SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
1620 return(ret);
1621 }
1622 if (!EC_KEY_up_ref((EC_KEY *)parg))
1623 {
1624 SSLerr(SSL_F_SSL3_CTRL,ERR_R_ECDH_LIB);
1625 return(ret);
1626 }
1627 ecdh = (EC_KEY *)parg;
1628 if (!(s->options & SSL_OP_SINGLE_ECDH_USE))
1629 {
1630 if (!EC_KEY_generate_key(ecdh))
1631 {
1632 EC_KEY_free(ecdh);
1633 SSLerr(SSL_F_SSL3_CTRL,ERR_R_ECDH_LIB);
1634 return(ret);
1635 }
1636 }
1637 if (s->cert->ecdh_tmp != NULL)
1638 EC_KEY_free(s->cert->ecdh_tmp);
1639 s->cert->ecdh_tmp = ecdh;
1640 ret = 1;
1641 }
1642 break;
1643 case SSL_CTRL_SET_TMP_ECDH_CB:
1644 {
1645 SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
1646 return(ret);
1647 }
1648 break;
1649 #endif /* !OPENSSL_NO_ECDH */
1650 default:
1651 break;
1652 }
1653 return(ret);
1654 }
1655
ssl3_callback_ctrl(SSL * s,int cmd,void (* fp)(void))1656 long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp)(void))
1657 {
1658 int ret=0;
1659
1660 #if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA)
1661 if (
1662 #ifndef OPENSSL_NO_RSA
1663 cmd == SSL_CTRL_SET_TMP_RSA_CB ||
1664 #endif
1665 #ifndef OPENSSL_NO_DSA
1666 cmd == SSL_CTRL_SET_TMP_DH_CB ||
1667 #endif
1668 0)
1669 {
1670 if (!ssl_cert_inst(&s->cert))
1671 {
1672 SSLerr(SSL_F_SSL3_CALLBACK_CTRL, ERR_R_MALLOC_FAILURE);
1673 return(0);
1674 }
1675 }
1676 #endif
1677
1678 switch (cmd)
1679 {
1680 #ifndef OPENSSL_NO_RSA
1681 case SSL_CTRL_SET_TMP_RSA_CB:
1682 {
1683 s->cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
1684 }
1685 break;
1686 #endif
1687 #ifndef OPENSSL_NO_DH
1688 case SSL_CTRL_SET_TMP_DH_CB:
1689 {
1690 s->cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
1691 }
1692 break;
1693 #endif
1694 #ifndef OPENSSL_NO_ECDH
1695 case SSL_CTRL_SET_TMP_ECDH_CB:
1696 {
1697 s->cert->ecdh_tmp_cb = (EC_KEY *(*)(SSL *, int, int))fp;
1698 }
1699 break;
1700 #endif
1701 default:
1702 break;
1703 }
1704 return(ret);
1705 }
1706
ssl3_ctx_ctrl(SSL_CTX * ctx,int cmd,long larg,void * parg)1707 long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg)
1708 {
1709 CERT *cert;
1710
1711 cert=ctx->cert;
1712
1713 switch (cmd)
1714 {
1715 #ifndef OPENSSL_NO_RSA
1716 case SSL_CTRL_NEED_TMP_RSA:
1717 if ( (cert->rsa_tmp == NULL) &&
1718 ((cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) ||
1719 (EVP_PKEY_size(cert->pkeys[SSL_PKEY_RSA_ENC].privatekey) > (512/8)))
1720 )
1721 return(1);
1722 else
1723 return(0);
1724 /* break; */
1725 case SSL_CTRL_SET_TMP_RSA:
1726 {
1727 RSA *rsa;
1728 int i;
1729
1730 rsa=(RSA *)parg;
1731 i=1;
1732 if (rsa == NULL)
1733 i=0;
1734 else
1735 {
1736 if ((rsa=RSAPrivateKey_dup(rsa)) == NULL)
1737 i=0;
1738 }
1739 if (!i)
1740 {
1741 SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_RSA_LIB);
1742 return(0);
1743 }
1744 else
1745 {
1746 if (cert->rsa_tmp != NULL)
1747 RSA_free(cert->rsa_tmp);
1748 cert->rsa_tmp=rsa;
1749 return(1);
1750 }
1751 }
1752 /* break; */
1753 case SSL_CTRL_SET_TMP_RSA_CB:
1754 {
1755 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
1756 return(0);
1757 }
1758 break;
1759 #endif
1760 #ifndef OPENSSL_NO_DH
1761 case SSL_CTRL_SET_TMP_DH:
1762 {
1763 DH *new=NULL,*dh;
1764
1765 dh=(DH *)parg;
1766 if ((new=DHparams_dup(dh)) == NULL)
1767 {
1768 SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_DH_LIB);
1769 return 0;
1770 }
1771 if (!(ctx->options & SSL_OP_SINGLE_DH_USE))
1772 {
1773 if (!DH_generate_key(new))
1774 {
1775 SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_DH_LIB);
1776 DH_free(new);
1777 return 0;
1778 }
1779 }
1780 if (cert->dh_tmp != NULL)
1781 DH_free(cert->dh_tmp);
1782 cert->dh_tmp=new;
1783 return 1;
1784 }
1785 /*break; */
1786 case SSL_CTRL_SET_TMP_DH_CB:
1787 {
1788 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
1789 return(0);
1790 }
1791 break;
1792 #endif
1793 #ifndef OPENSSL_NO_ECDH
1794 case SSL_CTRL_SET_TMP_ECDH:
1795 {
1796 EC_KEY *ecdh = NULL;
1797
1798 if (parg == NULL)
1799 {
1800 SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_ECDH_LIB);
1801 return 0;
1802 }
1803 ecdh = EC_KEY_dup((EC_KEY *)parg);
1804 if (ecdh == NULL)
1805 {
1806 SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_EC_LIB);
1807 return 0;
1808 }
1809 if (!(ctx->options & SSL_OP_SINGLE_ECDH_USE))
1810 {
1811 if (!EC_KEY_generate_key(ecdh))
1812 {
1813 EC_KEY_free(ecdh);
1814 SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_ECDH_LIB);
1815 return 0;
1816 }
1817 }
1818
1819 if (cert->ecdh_tmp != NULL)
1820 {
1821 EC_KEY_free(cert->ecdh_tmp);
1822 }
1823 cert->ecdh_tmp = ecdh;
1824 return 1;
1825 }
1826 /* break; */
1827 case SSL_CTRL_SET_TMP_ECDH_CB:
1828 {
1829 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
1830 return(0);
1831 }
1832 break;
1833 #endif /* !OPENSSL_NO_ECDH */
1834 /* A Thawte special :-) */
1835 case SSL_CTRL_EXTRA_CHAIN_CERT:
1836 if (ctx->extra_certs == NULL)
1837 {
1838 if ((ctx->extra_certs=sk_X509_new_null()) == NULL)
1839 return(0);
1840 }
1841 sk_X509_push(ctx->extra_certs,(X509 *)parg);
1842 break;
1843
1844 default:
1845 return(0);
1846 }
1847 return(1);
1848 }
1849
ssl3_ctx_callback_ctrl(SSL_CTX * ctx,int cmd,void (* fp)(void))1850 long ssl3_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)(void))
1851 {
1852 CERT *cert;
1853
1854 cert=ctx->cert;
1855
1856 switch (cmd)
1857 {
1858 #ifndef OPENSSL_NO_RSA
1859 case SSL_CTRL_SET_TMP_RSA_CB:
1860 {
1861 cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
1862 }
1863 break;
1864 #endif
1865 #ifndef OPENSSL_NO_DH
1866 case SSL_CTRL_SET_TMP_DH_CB:
1867 {
1868 cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
1869 }
1870 break;
1871 #endif
1872 #ifndef OPENSSL_NO_ECDH
1873 case SSL_CTRL_SET_TMP_ECDH_CB:
1874 {
1875 cert->ecdh_tmp_cb = (EC_KEY *(*)(SSL *, int, int))fp;
1876 }
1877 break;
1878 #endif
1879 default:
1880 return(0);
1881 }
1882 return(1);
1883 }
1884
1885 /* This function needs to check if the ciphers required are actually
1886 * available */
ssl3_get_cipher_by_char(const unsigned char * p)1887 SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p)
1888 {
1889 SSL_CIPHER c,*cp;
1890 unsigned long id;
1891
1892 id=0x03000000L|((unsigned long)p[0]<<8L)|(unsigned long)p[1];
1893 c.id=id;
1894 cp = (SSL_CIPHER *)OBJ_bsearch((char *)&c,
1895 (char *)ssl3_ciphers,
1896 SSL3_NUM_CIPHERS,sizeof(SSL_CIPHER),
1897 FP_ICC ssl_cipher_id_cmp);
1898 if (cp == NULL || cp->valid == 0)
1899 return NULL;
1900 else
1901 return cp;
1902 }
1903
ssl3_put_cipher_by_char(const SSL_CIPHER * c,unsigned char * p)1904 int ssl3_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p)
1905 {
1906 long l;
1907
1908 if (p != NULL)
1909 {
1910 l=c->id;
1911 if ((l & 0xff000000) != 0x03000000) return(0);
1912 p[0]=((unsigned char)(l>> 8L))&0xFF;
1913 p[1]=((unsigned char)(l ))&0xFF;
1914 }
1915 return(2);
1916 }
1917
ssl3_choose_cipher(SSL * s,STACK_OF (SSL_CIPHER)* clnt,STACK_OF (SSL_CIPHER)* srvr)1918 SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt,
1919 STACK_OF(SSL_CIPHER) *srvr)
1920 {
1921 SSL_CIPHER *c,*ret=NULL;
1922 STACK_OF(SSL_CIPHER) *prio, *allow;
1923 int i,j,ok;
1924 CERT *cert;
1925 unsigned long alg,mask,emask;
1926
1927 /* Let's see which ciphers we can support */
1928 cert=s->cert;
1929
1930 #if 0
1931 /* Do not set the compare functions, because this may lead to a
1932 * reordering by "id". We want to keep the original ordering.
1933 * We may pay a price in performance during sk_SSL_CIPHER_find(),
1934 * but would have to pay with the price of sk_SSL_CIPHER_dup().
1935 */
1936 sk_SSL_CIPHER_set_cmp_func(srvr, ssl_cipher_ptr_id_cmp);
1937 sk_SSL_CIPHER_set_cmp_func(clnt, ssl_cipher_ptr_id_cmp);
1938 #endif
1939
1940 #ifdef CIPHER_DEBUG
1941 printf("Server has %d from %p:\n", sk_SSL_CIPHER_num(srvr), srvr);
1942 for(i=0 ; i < sk_SSL_CIPHER_num(srvr) ; ++i)
1943 {
1944 c=sk_SSL_CIPHER_value(srvr,i);
1945 printf("%p:%s\n",c,c->name);
1946 }
1947 printf("Client sent %d from %p:\n", sk_SSL_CIPHER_num(clnt), clnt);
1948 for(i=0 ; i < sk_SSL_CIPHER_num(clnt) ; ++i)
1949 {
1950 c=sk_SSL_CIPHER_value(clnt,i);
1951 printf("%p:%s\n",c,c->name);
1952 }
1953 #endif
1954
1955 if (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE)
1956 {
1957 prio = srvr;
1958 allow = clnt;
1959 }
1960 else
1961 {
1962 prio = clnt;
1963 allow = srvr;
1964 }
1965
1966 for (i=0; i<sk_SSL_CIPHER_num(prio); i++)
1967 {
1968 c=sk_SSL_CIPHER_value(prio,i);
1969
1970 ssl_set_cert_masks(cert,c);
1971 mask=cert->mask;
1972 emask=cert->export_mask;
1973
1974 #ifdef KSSL_DEBUG
1975 printf("ssl3_choose_cipher %d alg= %lx\n", i,c->algorithms);
1976 #endif /* KSSL_DEBUG */
1977
1978 alg=c->algorithms&(SSL_MKEY_MASK|SSL_AUTH_MASK);
1979 #ifndef OPENSSL_NO_KRB5
1980 if (alg & SSL_KRB5)
1981 {
1982 if ( !kssl_keytab_is_available(s->kssl_ctx) )
1983 continue;
1984 }
1985 #endif /* OPENSSL_NO_KRB5 */
1986 if (SSL_C_IS_EXPORT(c))
1987 {
1988 ok=((alg & emask) == alg)?1:0;
1989 #ifdef CIPHER_DEBUG
1990 printf("%d:[%08lX:%08lX]%p:%s (export)\n",ok,alg,emask,
1991 c,c->name);
1992 #endif
1993 }
1994 else
1995 {
1996 ok=((alg & mask) == alg)?1:0;
1997 #ifdef CIPHER_DEBUG
1998 printf("%d:[%08lX:%08lX]%p:%s\n",ok,alg,mask,c,
1999 c->name);
2000 #endif
2001 }
2002
2003 if (!ok) continue;
2004 j=sk_SSL_CIPHER_find(allow,c);
2005 if (j >= 0)
2006 {
2007 ret=sk_SSL_CIPHER_value(allow,j);
2008 break;
2009 }
2010 }
2011 return(ret);
2012 }
2013
ssl3_get_req_cert_type(SSL * s,unsigned char * p)2014 int ssl3_get_req_cert_type(SSL *s, unsigned char *p)
2015 {
2016 int ret=0;
2017 unsigned long alg;
2018
2019 alg=s->s3->tmp.new_cipher->algorithms;
2020
2021 #ifndef OPENSSL_NO_DH
2022 if (alg & (SSL_kDHr|SSL_kEDH))
2023 {
2024 # ifndef OPENSSL_NO_RSA
2025 p[ret++]=SSL3_CT_RSA_FIXED_DH;
2026 # endif
2027 # ifndef OPENSSL_NO_DSA
2028 p[ret++]=SSL3_CT_DSS_FIXED_DH;
2029 # endif
2030 }
2031 if ((s->version == SSL3_VERSION) &&
2032 (alg & (SSL_kEDH|SSL_kDHd|SSL_kDHr)))
2033 {
2034 # ifndef OPENSSL_NO_RSA
2035 p[ret++]=SSL3_CT_RSA_EPHEMERAL_DH;
2036 # endif
2037 # ifndef OPENSSL_NO_DSA
2038 p[ret++]=SSL3_CT_DSS_EPHEMERAL_DH;
2039 # endif
2040 }
2041 #endif /* !OPENSSL_NO_DH */
2042 #ifndef OPENSSL_NO_RSA
2043 p[ret++]=SSL3_CT_RSA_SIGN;
2044 #endif
2045 #ifndef OPENSSL_NO_DSA
2046 p[ret++]=SSL3_CT_DSS_SIGN;
2047 #endif
2048 #ifndef OPENSSL_NO_ECDH
2049 /* We should ask for fixed ECDH certificates only
2050 * for SSL_kECDH (and not SSL_kECDHE)
2051 */
2052 if ((alg & SSL_kECDH) && (s->version >= TLS1_VERSION))
2053 {
2054 p[ret++]=TLS_CT_RSA_FIXED_ECDH;
2055 p[ret++]=TLS_CT_ECDSA_FIXED_ECDH;
2056 }
2057 #endif
2058
2059 #ifndef OPENSSL_NO_ECDSA
2060 /* ECDSA certs can be used with RSA cipher suites as well
2061 * so we don't need to check for SSL_kECDH or SSL_kECDHE
2062 */
2063 if (s->version >= TLS1_VERSION)
2064 {
2065 p[ret++]=TLS_CT_ECDSA_SIGN;
2066 }
2067 #endif
2068 return(ret);
2069 }
2070
ssl3_shutdown(SSL * s)2071 int ssl3_shutdown(SSL *s)
2072 {
2073
2074 /* Don't do anything much if we have not done the handshake or
2075 * we don't want to send messages :-) */
2076 if ((s->quiet_shutdown) || (s->state == SSL_ST_BEFORE))
2077 {
2078 s->shutdown=(SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
2079 return(1);
2080 }
2081
2082 if (!(s->shutdown & SSL_SENT_SHUTDOWN))
2083 {
2084 s->shutdown|=SSL_SENT_SHUTDOWN;
2085 #if 1
2086 ssl3_send_alert(s,SSL3_AL_WARNING,SSL_AD_CLOSE_NOTIFY);
2087 #endif
2088 /* our shutdown alert has been sent now, and if it still needs
2089 * to be written, s->s3->alert_dispatch will be true */
2090 }
2091 else if (s->s3->alert_dispatch)
2092 {
2093 /* resend it if not sent */
2094 #if 1
2095 s->method->ssl_dispatch_alert(s);
2096 #endif
2097 }
2098 else if (!(s->shutdown & SSL_RECEIVED_SHUTDOWN))
2099 {
2100 /* If we are waiting for a close from our peer, we are closed */
2101 s->method->ssl_read_bytes(s,0,NULL,0,0);
2102 }
2103
2104 if ((s->shutdown == (SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN)) &&
2105 !s->s3->alert_dispatch)
2106 return(1);
2107 else
2108 return(0);
2109 }
2110
ssl3_write(SSL * s,const void * buf,int len)2111 int ssl3_write(SSL *s, const void *buf, int len)
2112 {
2113 int ret,n;
2114
2115 #if 0
2116 if (s->shutdown & SSL_SEND_SHUTDOWN)
2117 {
2118 s->rwstate=SSL_NOTHING;
2119 return(0);
2120 }
2121 #endif
2122 clear_sys_error();
2123 if (s->s3->renegotiate) ssl3_renegotiate_check(s);
2124
2125 /* This is an experimental flag that sends the
2126 * last handshake message in the same packet as the first
2127 * use data - used to see if it helps the TCP protocol during
2128 * session-id reuse */
2129 /* The second test is because the buffer may have been removed */
2130 if ((s->s3->flags & SSL3_FLAGS_POP_BUFFER) && (s->wbio == s->bbio))
2131 {
2132 /* First time through, we write into the buffer */
2133 if (s->s3->delay_buf_pop_ret == 0)
2134 {
2135 ret=ssl3_write_bytes(s,SSL3_RT_APPLICATION_DATA,
2136 buf,len);
2137 if (ret <= 0) return(ret);
2138
2139 s->s3->delay_buf_pop_ret=ret;
2140 }
2141
2142 s->rwstate=SSL_WRITING;
2143 n=BIO_flush(s->wbio);
2144 if (n <= 0) return(n);
2145 s->rwstate=SSL_NOTHING;
2146
2147 /* We have flushed the buffer, so remove it */
2148 ssl_free_wbio_buffer(s);
2149 s->s3->flags&= ~SSL3_FLAGS_POP_BUFFER;
2150
2151 ret=s->s3->delay_buf_pop_ret;
2152 s->s3->delay_buf_pop_ret=0;
2153 }
2154 else
2155 {
2156 ret=s->method->ssl_write_bytes(s,SSL3_RT_APPLICATION_DATA,
2157 buf,len);
2158 if (ret <= 0) return(ret);
2159 }
2160
2161 return(ret);
2162 }
2163
ssl3_read_internal(SSL * s,void * buf,int len,int peek)2164 static int ssl3_read_internal(SSL *s, void *buf, int len, int peek)
2165 {
2166 int ret;
2167
2168 clear_sys_error();
2169 if (s->s3->renegotiate) ssl3_renegotiate_check(s);
2170 s->s3->in_read_app_data=1;
2171 ret=s->method->ssl_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len,peek);
2172 if ((ret == -1) && (s->s3->in_read_app_data == 2))
2173 {
2174 /* ssl3_read_bytes decided to call s->handshake_func, which
2175 * called ssl3_read_bytes to read handshake data.
2176 * However, ssl3_read_bytes actually found application data
2177 * and thinks that application data makes sense here; so disable
2178 * handshake processing and try to read application data again. */
2179 s->in_handshake++;
2180 ret=s->method->ssl_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len,peek);
2181 s->in_handshake--;
2182 }
2183 else
2184 s->s3->in_read_app_data=0;
2185
2186 return(ret);
2187 }
2188
ssl3_read(SSL * s,void * buf,int len)2189 int ssl3_read(SSL *s, void *buf, int len)
2190 {
2191 return ssl3_read_internal(s, buf, len, 0);
2192 }
2193
ssl3_peek(SSL * s,void * buf,int len)2194 int ssl3_peek(SSL *s, void *buf, int len)
2195 {
2196 return ssl3_read_internal(s, buf, len, 1);
2197 }
2198
ssl3_renegotiate(SSL * s)2199 int ssl3_renegotiate(SSL *s)
2200 {
2201 if (s->handshake_func == NULL)
2202 return(1);
2203
2204 if (s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS)
2205 return(0);
2206
2207 s->s3->renegotiate=1;
2208 return(1);
2209 }
2210
ssl3_renegotiate_check(SSL * s)2211 int ssl3_renegotiate_check(SSL *s)
2212 {
2213 int ret=0;
2214
2215 if (s->s3->renegotiate)
2216 {
2217 if ( (s->s3->rbuf.left == 0) &&
2218 (s->s3->wbuf.left == 0) &&
2219 !SSL_in_init(s))
2220 {
2221 /*
2222 if we are the server, and we have sent a 'RENEGOTIATE' message, we
2223 need to go to SSL_ST_ACCEPT.
2224 */
2225 /* SSL_ST_ACCEPT */
2226 s->state=SSL_ST_RENEGOTIATE;
2227 s->s3->renegotiate=0;
2228 s->s3->num_renegotiations++;
2229 s->s3->total_renegotiations++;
2230 ret=1;
2231 }
2232 }
2233 return(ret);
2234 }
2235
2236