25b652c20a0a3f3b65302fa9590c41debb7ca83a
[openssl.git] / ssl / s3_lib.c
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-2007 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  * Copyright 2005 Nokia. All rights reserved.
126  *
127  * The portions of the attached software ("Contribution") is developed by
128  * Nokia Corporation and is licensed pursuant to the OpenSSL open source
129  * license.
130  *
131  * The Contribution, originally written by Mika Kousa and Pasi Eronen of
132  * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites
133  * support (see RFC 4279) to OpenSSL.
134  *
135  * No patent licenses or other rights except those expressly stated in
136  * the OpenSSL open source license shall be deemed granted or received
137  * expressly, by implication, estoppel, or otherwise.
138  *
139  * No assurances are provided by Nokia that the Contribution does not
140  * infringe the patent or other intellectual property rights of any third
141  * party or that the license provides you with all the necessary rights
142  * to make use of the Contribution.
143  *
144  * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN
145  * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA
146  * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY
147  * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR
148  * OTHERWISE.
149  */
150
151 #include <stdio.h>
152 #include <openssl/objects.h>
153 #include "ssl_locl.h"
154 #include "kssl_lcl.h"
155 #include <openssl/md5.h>
156 #ifndef OPENSSL_NO_DH
157 #include <openssl/dh.h>
158 #endif
159
160 const char ssl3_version_str[]="SSLv3" OPENSSL_VERSION_PTEXT;
161
162 #define SSL3_NUM_CIPHERS        (sizeof(ssl3_ciphers)/sizeof(SSL_CIPHER))
163
164 /* FIXED_NONCE_LEN is a macro that results in the correct value to set the
165  * fixed nonce length in SSL_CIPHER.algorithms2. It's the inverse of
166  * SSL_CIPHER_AEAD_FIXED_NONCE_LEN. */
167 #define FIXED_NONCE_LEN(x) ((x/2)<<24)
168
169 /* list of available SSLv3 ciphers (sorted by id) */
170 OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
171
172 /* The RSA ciphers */
173 /* Cipher 01 */
174         {
175         1,
176         SSL3_TXT_RSA_NULL_MD5,
177         SSL3_CK_RSA_NULL_MD5,
178         SSL_kRSA,
179         SSL_aRSA,
180         SSL_eNULL,
181         SSL_MD5,
182         SSL_SSLV3,
183         SSL_NOT_EXP|SSL_STRONG_NONE,
184         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
185         0,
186         0,
187         },
188
189 /* Cipher 02 */
190         {
191         1,
192         SSL3_TXT_RSA_NULL_SHA,
193         SSL3_CK_RSA_NULL_SHA,
194         SSL_kRSA,
195         SSL_aRSA,
196         SSL_eNULL,
197         SSL_SHA1,
198         SSL_SSLV3,
199         SSL_NOT_EXP|SSL_STRONG_NONE|SSL_FIPS,
200         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
201         0,
202         0,
203         },
204
205 /* Cipher 03 */
206         {
207         1,
208         SSL3_TXT_RSA_RC4_40_MD5,
209         SSL3_CK_RSA_RC4_40_MD5,
210         SSL_kRSA,
211         SSL_aRSA,
212         SSL_RC4,
213         SSL_MD5,
214         SSL_SSLV3,
215         SSL_EXPORT|SSL_EXP40,
216         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
217         40,
218         128,
219         },
220
221 /* Cipher 04 */
222         {
223         1,
224         SSL3_TXT_RSA_RC4_128_MD5,
225         SSL3_CK_RSA_RC4_128_MD5,
226         SSL_kRSA,
227         SSL_aRSA,
228         SSL_RC4,
229         SSL_MD5,
230         SSL_SSLV3,
231         SSL_NOT_EXP|SSL_MEDIUM,
232         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
233         128,
234         128,
235         },
236
237 /* Cipher 05 */
238         {
239         1,
240         SSL3_TXT_RSA_RC4_128_SHA,
241         SSL3_CK_RSA_RC4_128_SHA,
242         SSL_kRSA,
243         SSL_aRSA,
244         SSL_RC4,
245         SSL_SHA1,
246         SSL_SSLV3,
247         SSL_NOT_EXP|SSL_MEDIUM,
248         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
249         128,
250         128,
251         },
252
253 /* Cipher 06 */
254         {
255         1,
256         SSL3_TXT_RSA_RC2_40_MD5,
257         SSL3_CK_RSA_RC2_40_MD5,
258         SSL_kRSA,
259         SSL_aRSA,
260         SSL_RC2,
261         SSL_MD5,
262         SSL_SSLV3,
263         SSL_EXPORT|SSL_EXP40,
264         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
265         40,
266         128,
267         },
268
269 /* Cipher 07 */
270 #ifndef OPENSSL_NO_IDEA
271         {
272         1,
273         SSL3_TXT_RSA_IDEA_128_SHA,
274         SSL3_CK_RSA_IDEA_128_SHA,
275         SSL_kRSA,
276         SSL_aRSA,
277         SSL_IDEA,
278         SSL_SHA1,
279         SSL_SSLV3,
280         SSL_NOT_EXP|SSL_MEDIUM,
281         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
282         128,
283         128,
284         },
285 #endif
286
287 /* Cipher 08 */
288         {
289         1,
290         SSL3_TXT_RSA_DES_40_CBC_SHA,
291         SSL3_CK_RSA_DES_40_CBC_SHA,
292         SSL_kRSA,
293         SSL_aRSA,
294         SSL_DES,
295         SSL_SHA1,
296         SSL_SSLV3,
297         SSL_EXPORT|SSL_EXP40,
298         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
299         40,
300         56,
301         },
302
303 /* Cipher 09 */
304         {
305         1,
306         SSL3_TXT_RSA_DES_64_CBC_SHA,
307         SSL3_CK_RSA_DES_64_CBC_SHA,
308         SSL_kRSA,
309         SSL_aRSA,
310         SSL_DES,
311         SSL_SHA1,
312         SSL_SSLV3,
313         SSL_NOT_EXP|SSL_LOW,
314         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
315         56,
316         56,
317         },
318
319 /* Cipher 0A */
320         {
321         1,
322         SSL3_TXT_RSA_DES_192_CBC3_SHA,
323         SSL3_CK_RSA_DES_192_CBC3_SHA,
324         SSL_kRSA,
325         SSL_aRSA,
326         SSL_3DES,
327         SSL_SHA1,
328         SSL_SSLV3,
329         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
330         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
331         168,
332         168,
333         },
334
335 /* The DH ciphers */
336 /* Cipher 0B */
337         {
338         1,
339         SSL3_TXT_DH_DSS_DES_40_CBC_SHA,
340         SSL3_CK_DH_DSS_DES_40_CBC_SHA,
341         SSL_kDHd,
342         SSL_aDH,
343         SSL_DES,
344         SSL_SHA1,
345         SSL_SSLV3,
346         SSL_EXPORT|SSL_EXP40,
347         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
348         40,
349         56,
350         },
351
352 /* Cipher 0C */
353         {
354         1,
355         SSL3_TXT_DH_DSS_DES_64_CBC_SHA,
356         SSL3_CK_DH_DSS_DES_64_CBC_SHA,
357         SSL_kDHd,
358         SSL_aDH,
359         SSL_DES,
360         SSL_SHA1,
361         SSL_SSLV3,
362         SSL_NOT_EXP|SSL_LOW,
363         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
364         56,
365         56,
366         },
367
368 /* Cipher 0D */
369         {
370         1,
371         SSL3_TXT_DH_DSS_DES_192_CBC3_SHA,
372         SSL3_CK_DH_DSS_DES_192_CBC3_SHA,
373         SSL_kDHd,
374         SSL_aDH,
375         SSL_3DES,
376         SSL_SHA1,
377         SSL_SSLV3,
378         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
379         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
380         168,
381         168,
382         },
383
384 /* Cipher 0E */
385         {
386         1,
387         SSL3_TXT_DH_RSA_DES_40_CBC_SHA,
388         SSL3_CK_DH_RSA_DES_40_CBC_SHA,
389         SSL_kDHr,
390         SSL_aDH,
391         SSL_DES,
392         SSL_SHA1,
393         SSL_SSLV3,
394         SSL_EXPORT|SSL_EXP40,
395         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
396         40,
397         56,
398         },
399
400 /* Cipher 0F */
401         {
402         1,
403         SSL3_TXT_DH_RSA_DES_64_CBC_SHA,
404         SSL3_CK_DH_RSA_DES_64_CBC_SHA,
405         SSL_kDHr,
406         SSL_aDH,
407         SSL_DES,
408         SSL_SHA1,
409         SSL_SSLV3,
410         SSL_NOT_EXP|SSL_LOW,
411         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
412         56,
413         56,
414         },
415
416 /* Cipher 10 */
417         {
418         1,
419         SSL3_TXT_DH_RSA_DES_192_CBC3_SHA,
420         SSL3_CK_DH_RSA_DES_192_CBC3_SHA,
421         SSL_kDHr,
422         SSL_aDH,
423         SSL_3DES,
424         SSL_SHA1,
425         SSL_SSLV3,
426         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
427         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
428         168,
429         168,
430         },
431
432 /* The Ephemeral DH ciphers */
433 /* Cipher 11 */
434         {
435         1,
436         SSL3_TXT_EDH_DSS_DES_40_CBC_SHA,
437         SSL3_CK_EDH_DSS_DES_40_CBC_SHA,
438         SSL_kEDH,
439         SSL_aDSS,
440         SSL_DES,
441         SSL_SHA1,
442         SSL_SSLV3,
443         SSL_EXPORT|SSL_EXP40,
444         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
445         40,
446         56,
447         },
448
449 /* Cipher 12 */
450         {
451         1,
452         SSL3_TXT_EDH_DSS_DES_64_CBC_SHA,
453         SSL3_CK_EDH_DSS_DES_64_CBC_SHA,
454         SSL_kEDH,
455         SSL_aDSS,
456         SSL_DES,
457         SSL_SHA1,
458         SSL_SSLV3,
459         SSL_NOT_EXP|SSL_LOW,
460         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
461         56,
462         56,
463         },
464
465 /* Cipher 13 */
466         {
467         1,
468         SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA,
469         SSL3_CK_EDH_DSS_DES_192_CBC3_SHA,
470         SSL_kEDH,
471         SSL_aDSS,
472         SSL_3DES,
473         SSL_SHA1,
474         SSL_SSLV3,
475         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
476         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
477         168,
478         168,
479         },
480
481 /* Cipher 14 */
482         {
483         1,
484         SSL3_TXT_EDH_RSA_DES_40_CBC_SHA,
485         SSL3_CK_EDH_RSA_DES_40_CBC_SHA,
486         SSL_kEDH,
487         SSL_aRSA,
488         SSL_DES,
489         SSL_SHA1,
490         SSL_SSLV3,
491         SSL_EXPORT|SSL_EXP40,
492         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
493         40,
494         56,
495         },
496
497 /* Cipher 15 */
498         {
499         1,
500         SSL3_TXT_EDH_RSA_DES_64_CBC_SHA,
501         SSL3_CK_EDH_RSA_DES_64_CBC_SHA,
502         SSL_kEDH,
503         SSL_aRSA,
504         SSL_DES,
505         SSL_SHA1,
506         SSL_SSLV3,
507         SSL_NOT_EXP|SSL_LOW,
508         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
509         56,
510         56,
511         },
512
513 /* Cipher 16 */
514         {
515         1,
516         SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA,
517         SSL3_CK_EDH_RSA_DES_192_CBC3_SHA,
518         SSL_kEDH,
519         SSL_aRSA,
520         SSL_3DES,
521         SSL_SHA1,
522         SSL_SSLV3,
523         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
524         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
525         168,
526         168,
527         },
528
529 /* Cipher 17 */
530         {
531         1,
532         SSL3_TXT_ADH_RC4_40_MD5,
533         SSL3_CK_ADH_RC4_40_MD5,
534         SSL_kEDH,
535         SSL_aNULL,
536         SSL_RC4,
537         SSL_MD5,
538         SSL_SSLV3,
539         SSL_EXPORT|SSL_EXP40,
540         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
541         40,
542         128,
543         },
544
545 /* Cipher 18 */
546         {
547         1,
548         SSL3_TXT_ADH_RC4_128_MD5,
549         SSL3_CK_ADH_RC4_128_MD5,
550         SSL_kEDH,
551         SSL_aNULL,
552         SSL_RC4,
553         SSL_MD5,
554         SSL_SSLV3,
555         SSL_NOT_EXP|SSL_MEDIUM,
556         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
557         128,
558         128,
559         },
560
561 /* Cipher 19 */
562         {
563         1,
564         SSL3_TXT_ADH_DES_40_CBC_SHA,
565         SSL3_CK_ADH_DES_40_CBC_SHA,
566         SSL_kEDH,
567         SSL_aNULL,
568         SSL_DES,
569         SSL_SHA1,
570         SSL_SSLV3,
571         SSL_EXPORT|SSL_EXP40,
572         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
573         40,
574         128,
575         },
576
577 /* Cipher 1A */
578         {
579         1,
580         SSL3_TXT_ADH_DES_64_CBC_SHA,
581         SSL3_CK_ADH_DES_64_CBC_SHA,
582         SSL_kEDH,
583         SSL_aNULL,
584         SSL_DES,
585         SSL_SHA1,
586         SSL_SSLV3,
587         SSL_NOT_EXP|SSL_LOW,
588         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
589         56,
590         56,
591         },
592
593 /* Cipher 1B */
594         {
595         1,
596         SSL3_TXT_ADH_DES_192_CBC_SHA,
597         SSL3_CK_ADH_DES_192_CBC_SHA,
598         SSL_kEDH,
599         SSL_aNULL,
600         SSL_3DES,
601         SSL_SHA1,
602         SSL_SSLV3,
603         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
604         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
605         168,
606         168,
607         },
608
609 /* Fortezza ciphersuite from SSL 3.0 spec */
610 #if 0
611 /* Cipher 1C */
612         {
613         0,
614         SSL3_TXT_FZA_DMS_NULL_SHA,
615         SSL3_CK_FZA_DMS_NULL_SHA,
616         SSL_kFZA,
617         SSL_aFZA,
618         SSL_eNULL,
619         SSL_SHA1,
620         SSL_SSLV3,
621         SSL_NOT_EXP|SSL_STRONG_NONE,
622         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
623         0,
624         0,
625         },
626
627 /* Cipher 1D */
628         {
629         0,
630         SSL3_TXT_FZA_DMS_FZA_SHA,
631         SSL3_CK_FZA_DMS_FZA_SHA,
632         SSL_kFZA,
633         SSL_aFZA,
634         SSL_eFZA,
635         SSL_SHA1,
636         SSL_SSLV3,
637         SSL_NOT_EXP|SSL_STRONG_NONE,
638         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
639         0,
640         0,
641         },
642
643 /* Cipher 1E */
644         {
645         0,
646         SSL3_TXT_FZA_DMS_RC4_SHA,
647         SSL3_CK_FZA_DMS_RC4_SHA,
648         SSL_kFZA,
649         SSL_aFZA,
650         SSL_RC4,
651         SSL_SHA1,
652         SSL_SSLV3,
653         SSL_NOT_EXP|SSL_MEDIUM,
654         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
655         128,
656         128,
657         },
658 #endif
659
660 #ifndef OPENSSL_NO_KRB5
661 /* The Kerberos ciphers*/
662 /* Cipher 1E */
663         {
664         1,
665         SSL3_TXT_KRB5_DES_64_CBC_SHA,
666         SSL3_CK_KRB5_DES_64_CBC_SHA,
667         SSL_kKRB5,
668         SSL_aKRB5,
669         SSL_DES,
670         SSL_SHA1,
671         SSL_SSLV3,
672         SSL_NOT_EXP|SSL_LOW,
673         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
674         56,
675         56,
676         },
677
678 /* Cipher 1F */
679         {
680         1,
681         SSL3_TXT_KRB5_DES_192_CBC3_SHA,
682         SSL3_CK_KRB5_DES_192_CBC3_SHA,
683         SSL_kKRB5,
684         SSL_aKRB5,
685         SSL_3DES,
686         SSL_SHA1,
687         SSL_SSLV3,
688         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
689         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
690         168,
691         168,
692         },
693
694 /* Cipher 20 */
695         {
696         1,
697         SSL3_TXT_KRB5_RC4_128_SHA,
698         SSL3_CK_KRB5_RC4_128_SHA,
699         SSL_kKRB5,
700         SSL_aKRB5,
701         SSL_RC4,
702         SSL_SHA1,
703         SSL_SSLV3,
704         SSL_NOT_EXP|SSL_MEDIUM,
705         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
706         128,
707         128,
708         },
709
710 /* Cipher 21 */
711         {
712         1,
713         SSL3_TXT_KRB5_IDEA_128_CBC_SHA,
714         SSL3_CK_KRB5_IDEA_128_CBC_SHA,
715         SSL_kKRB5,
716         SSL_aKRB5,
717         SSL_IDEA,
718         SSL_SHA1,
719         SSL_SSLV3,
720         SSL_NOT_EXP|SSL_MEDIUM,
721         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
722         128,
723         128,
724         },
725
726 /* Cipher 22 */
727         {
728         1,
729         SSL3_TXT_KRB5_DES_64_CBC_MD5,
730         SSL3_CK_KRB5_DES_64_CBC_MD5,
731         SSL_kKRB5,
732         SSL_aKRB5,
733         SSL_DES,
734         SSL_MD5,
735         SSL_SSLV3,
736         SSL_NOT_EXP|SSL_LOW,
737         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
738         56,
739         56,
740         },
741
742 /* Cipher 23 */
743         {
744         1,
745         SSL3_TXT_KRB5_DES_192_CBC3_MD5,
746         SSL3_CK_KRB5_DES_192_CBC3_MD5,
747         SSL_kKRB5,
748         SSL_aKRB5,
749         SSL_3DES,
750         SSL_MD5,
751         SSL_SSLV3,
752         SSL_NOT_EXP|SSL_HIGH,
753         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
754         168,
755         168,
756         },
757
758 /* Cipher 24 */
759         {
760         1,
761         SSL3_TXT_KRB5_RC4_128_MD5,
762         SSL3_CK_KRB5_RC4_128_MD5,
763         SSL_kKRB5,
764         SSL_aKRB5,
765         SSL_RC4,
766         SSL_MD5,
767         SSL_SSLV3,
768         SSL_NOT_EXP|SSL_MEDIUM,
769         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
770         128,
771         128,
772         },
773
774 /* Cipher 25 */
775         {
776         1,
777         SSL3_TXT_KRB5_IDEA_128_CBC_MD5,
778         SSL3_CK_KRB5_IDEA_128_CBC_MD5,
779         SSL_kKRB5,
780         SSL_aKRB5,
781         SSL_IDEA,
782         SSL_MD5,
783         SSL_SSLV3,
784         SSL_NOT_EXP|SSL_MEDIUM,
785         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
786         128,
787         128,
788         },
789
790 /* Cipher 26 */
791         {
792         1,
793         SSL3_TXT_KRB5_DES_40_CBC_SHA,
794         SSL3_CK_KRB5_DES_40_CBC_SHA,
795         SSL_kKRB5,
796         SSL_aKRB5,
797         SSL_DES,
798         SSL_SHA1,
799         SSL_SSLV3,
800         SSL_EXPORT|SSL_EXP40,
801         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
802         40,
803         56,
804         },
805
806 /* Cipher 27 */
807         {
808         1,
809         SSL3_TXT_KRB5_RC2_40_CBC_SHA,
810         SSL3_CK_KRB5_RC2_40_CBC_SHA,
811         SSL_kKRB5,
812         SSL_aKRB5,
813         SSL_RC2,
814         SSL_SHA1,
815         SSL_SSLV3,
816         SSL_EXPORT|SSL_EXP40,
817         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
818         40,
819         128,
820         },
821
822 /* Cipher 28 */
823         {
824         1,
825         SSL3_TXT_KRB5_RC4_40_SHA,
826         SSL3_CK_KRB5_RC4_40_SHA,
827         SSL_kKRB5,
828         SSL_aKRB5,
829         SSL_RC4,
830         SSL_SHA1,
831         SSL_SSLV3,
832         SSL_EXPORT|SSL_EXP40,
833         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
834         40,
835         128,
836         },
837
838 /* Cipher 29 */
839         {
840         1,
841         SSL3_TXT_KRB5_DES_40_CBC_MD5,
842         SSL3_CK_KRB5_DES_40_CBC_MD5,
843         SSL_kKRB5,
844         SSL_aKRB5,
845         SSL_DES,
846         SSL_MD5,
847         SSL_SSLV3,
848         SSL_EXPORT|SSL_EXP40,
849         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
850         40,
851         56,
852         },
853
854 /* Cipher 2A */
855         {
856         1,
857         SSL3_TXT_KRB5_RC2_40_CBC_MD5,
858         SSL3_CK_KRB5_RC2_40_CBC_MD5,
859         SSL_kKRB5,
860         SSL_aKRB5,
861         SSL_RC2,
862         SSL_MD5,
863         SSL_SSLV3,
864         SSL_EXPORT|SSL_EXP40,
865         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
866         40,
867         128,
868         },
869
870 /* Cipher 2B */
871         {
872         1,
873         SSL3_TXT_KRB5_RC4_40_MD5,
874         SSL3_CK_KRB5_RC4_40_MD5,
875         SSL_kKRB5,
876         SSL_aKRB5,
877         SSL_RC4,
878         SSL_MD5,
879         SSL_SSLV3,
880         SSL_EXPORT|SSL_EXP40,
881         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
882         40,
883         128,
884         },
885 #endif  /* OPENSSL_NO_KRB5 */
886
887 /* New AES ciphersuites */
888 /* Cipher 2F */
889         {
890         1,
891         TLS1_TXT_RSA_WITH_AES_128_SHA,
892         TLS1_CK_RSA_WITH_AES_128_SHA,
893         SSL_kRSA,
894         SSL_aRSA,
895         SSL_AES128,
896         SSL_SHA1,
897         SSL_TLSV1,
898         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
899         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
900         128,
901         128,
902         },
903 /* Cipher 30 */
904         {
905         1,
906         TLS1_TXT_DH_DSS_WITH_AES_128_SHA,
907         TLS1_CK_DH_DSS_WITH_AES_128_SHA,
908         SSL_kDHd,
909         SSL_aDH,
910         SSL_AES128,
911         SSL_SHA1,
912         SSL_TLSV1,
913         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
914         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
915         128,
916         128,
917         },
918 /* Cipher 31 */
919         {
920         1,
921         TLS1_TXT_DH_RSA_WITH_AES_128_SHA,
922         TLS1_CK_DH_RSA_WITH_AES_128_SHA,
923         SSL_kDHr,
924         SSL_aDH,
925         SSL_AES128,
926         SSL_SHA1,
927         SSL_TLSV1,
928         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
929         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
930         128,
931         128,
932         },
933 /* Cipher 32 */
934         {
935         1,
936         TLS1_TXT_DHE_DSS_WITH_AES_128_SHA,
937         TLS1_CK_DHE_DSS_WITH_AES_128_SHA,
938         SSL_kEDH,
939         SSL_aDSS,
940         SSL_AES128,
941         SSL_SHA1,
942         SSL_TLSV1,
943         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
944         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
945         128,
946         128,
947         },
948 /* Cipher 33 */
949         {
950         1,
951         TLS1_TXT_DHE_RSA_WITH_AES_128_SHA,
952         TLS1_CK_DHE_RSA_WITH_AES_128_SHA,
953         SSL_kEDH,
954         SSL_aRSA,
955         SSL_AES128,
956         SSL_SHA1,
957         SSL_TLSV1,
958         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
959         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
960         128,
961         128,
962         },
963 /* Cipher 34 */
964         {
965         1,
966         TLS1_TXT_ADH_WITH_AES_128_SHA,
967         TLS1_CK_ADH_WITH_AES_128_SHA,
968         SSL_kEDH,
969         SSL_aNULL,
970         SSL_AES128,
971         SSL_SHA1,
972         SSL_TLSV1,
973         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
974         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
975         128,
976         128,
977         },
978
979 /* Cipher 35 */
980         {
981         1,
982         TLS1_TXT_RSA_WITH_AES_256_SHA,
983         TLS1_CK_RSA_WITH_AES_256_SHA,
984         SSL_kRSA,
985         SSL_aRSA,
986         SSL_AES256,
987         SSL_SHA1,
988         SSL_TLSV1,
989         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
990         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
991         256,
992         256,
993         },
994 /* Cipher 36 */
995         {
996         1,
997         TLS1_TXT_DH_DSS_WITH_AES_256_SHA,
998         TLS1_CK_DH_DSS_WITH_AES_256_SHA,
999         SSL_kDHd,
1000         SSL_aDH,
1001         SSL_AES256,
1002         SSL_SHA1,
1003         SSL_TLSV1,
1004         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1005         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1006         256,
1007         256,
1008         },
1009
1010 /* Cipher 37 */
1011         {
1012         1,
1013         TLS1_TXT_DH_RSA_WITH_AES_256_SHA,
1014         TLS1_CK_DH_RSA_WITH_AES_256_SHA,
1015         SSL_kDHr,
1016         SSL_aDH,
1017         SSL_AES256,
1018         SSL_SHA1,
1019         SSL_TLSV1,
1020         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1021         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1022         256,
1023         256,
1024         },
1025
1026 /* Cipher 38 */
1027         {
1028         1,
1029         TLS1_TXT_DHE_DSS_WITH_AES_256_SHA,
1030         TLS1_CK_DHE_DSS_WITH_AES_256_SHA,
1031         SSL_kEDH,
1032         SSL_aDSS,
1033         SSL_AES256,
1034         SSL_SHA1,
1035         SSL_TLSV1,
1036         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1037         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1038         256,
1039         256,
1040         },
1041
1042 /* Cipher 39 */
1043         {
1044         1,
1045         TLS1_TXT_DHE_RSA_WITH_AES_256_SHA,
1046         TLS1_CK_DHE_RSA_WITH_AES_256_SHA,
1047         SSL_kEDH,
1048         SSL_aRSA,
1049         SSL_AES256,
1050         SSL_SHA1,
1051         SSL_TLSV1,
1052         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1053         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1054         256,
1055         256,
1056         },
1057
1058         /* Cipher 3A */
1059         {
1060         1,
1061         TLS1_TXT_ADH_WITH_AES_256_SHA,
1062         TLS1_CK_ADH_WITH_AES_256_SHA,
1063         SSL_kEDH,
1064         SSL_aNULL,
1065         SSL_AES256,
1066         SSL_SHA1,
1067         SSL_TLSV1,
1068         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1069         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1070         256,
1071         256,
1072         },
1073
1074         /* TLS v1.2 ciphersuites */
1075         /* Cipher 3B */
1076         {
1077         1,
1078         TLS1_TXT_RSA_WITH_NULL_SHA256,
1079         TLS1_CK_RSA_WITH_NULL_SHA256,
1080         SSL_kRSA,
1081         SSL_aRSA,
1082         SSL_eNULL,
1083         SSL_SHA256,
1084         SSL_TLSV1_2,
1085         SSL_NOT_EXP|SSL_STRONG_NONE|SSL_FIPS,
1086         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1087         0,
1088         0,
1089         },
1090
1091         /* Cipher 3C */
1092         {
1093         1,
1094         TLS1_TXT_RSA_WITH_AES_128_SHA256,
1095         TLS1_CK_RSA_WITH_AES_128_SHA256,
1096         SSL_kRSA,
1097         SSL_aRSA,
1098         SSL_AES128,
1099         SSL_SHA256,
1100         SSL_TLSV1_2,
1101         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1102         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1103         128,
1104         128,
1105         },
1106
1107         /* Cipher 3D */
1108         {
1109         1,
1110         TLS1_TXT_RSA_WITH_AES_256_SHA256,
1111         TLS1_CK_RSA_WITH_AES_256_SHA256,
1112         SSL_kRSA,
1113         SSL_aRSA,
1114         SSL_AES256,
1115         SSL_SHA256,
1116         SSL_TLSV1_2,
1117         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1118         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1119         256,
1120         256,
1121         },
1122
1123         /* Cipher 3E */
1124         {
1125         1,
1126         TLS1_TXT_DH_DSS_WITH_AES_128_SHA256,
1127         TLS1_CK_DH_DSS_WITH_AES_128_SHA256,
1128         SSL_kDHd,
1129         SSL_aDH,
1130         SSL_AES128,
1131         SSL_SHA256,
1132         SSL_TLSV1_2,
1133         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1134         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1135         128,
1136         128,
1137         },
1138
1139         /* Cipher 3F */
1140         {
1141         1,
1142         TLS1_TXT_DH_RSA_WITH_AES_128_SHA256,
1143         TLS1_CK_DH_RSA_WITH_AES_128_SHA256,
1144         SSL_kDHr,
1145         SSL_aDH,
1146         SSL_AES128,
1147         SSL_SHA256,
1148         SSL_TLSV1_2,
1149         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1150         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1151         128,
1152         128,
1153         },
1154
1155         /* Cipher 40 */
1156         {
1157         1,
1158         TLS1_TXT_DHE_DSS_WITH_AES_128_SHA256,
1159         TLS1_CK_DHE_DSS_WITH_AES_128_SHA256,
1160         SSL_kEDH,
1161         SSL_aDSS,
1162         SSL_AES128,
1163         SSL_SHA256,
1164         SSL_TLSV1_2,
1165         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1166         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1167         128,
1168         128,
1169         },
1170
1171 #ifndef OPENSSL_NO_CAMELLIA
1172         /* Camellia ciphersuites from RFC4132 (128-bit portion) */
1173
1174         /* Cipher 41 */
1175         {
1176         1,
1177         TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA,
1178         TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA,
1179         SSL_kRSA,
1180         SSL_aRSA,
1181         SSL_CAMELLIA128,
1182         SSL_SHA1,
1183         SSL_TLSV1,
1184         SSL_NOT_EXP|SSL_HIGH,
1185         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1186         128,
1187         128,
1188         },
1189
1190         /* Cipher 42 */
1191         {
1192         1,
1193         TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA,
1194         TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA,
1195         SSL_kDHd,
1196         SSL_aDH,
1197         SSL_CAMELLIA128,
1198         SSL_SHA1,
1199         SSL_TLSV1,
1200         SSL_NOT_EXP|SSL_HIGH,
1201         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1202         128,
1203         128,
1204         },
1205
1206         /* Cipher 43 */
1207         {
1208         1,
1209         TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA,
1210         TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA,
1211         SSL_kDHr,
1212         SSL_aDH,
1213         SSL_CAMELLIA128,
1214         SSL_SHA1,
1215         SSL_TLSV1,
1216         SSL_NOT_EXP|SSL_HIGH,
1217         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1218         128,
1219         128,
1220         },
1221
1222         /* Cipher 44 */
1223         {
1224         1,
1225         TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA,
1226         TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA,
1227         SSL_kEDH,
1228         SSL_aDSS,
1229         SSL_CAMELLIA128,
1230         SSL_SHA1,
1231         SSL_TLSV1,
1232         SSL_NOT_EXP|SSL_HIGH,
1233         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1234         128,
1235         128,
1236         },
1237
1238         /* Cipher 45 */
1239         {
1240         1,
1241         TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA,
1242         TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA,
1243         SSL_kEDH,
1244         SSL_aRSA,
1245         SSL_CAMELLIA128,
1246         SSL_SHA1,
1247         SSL_TLSV1,
1248         SSL_NOT_EXP|SSL_HIGH,
1249         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1250         128,
1251         128,
1252         },
1253
1254         /* Cipher 46 */
1255         {
1256         1,
1257         TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA,
1258         TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA,
1259         SSL_kEDH,
1260         SSL_aNULL,
1261         SSL_CAMELLIA128,
1262         SSL_SHA1,
1263         SSL_TLSV1,
1264         SSL_NOT_EXP|SSL_HIGH,
1265         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1266         128,
1267         128,
1268         },
1269 #endif /* OPENSSL_NO_CAMELLIA */
1270
1271 #if TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES
1272         /* New TLS Export CipherSuites from expired ID */
1273 #if 0
1274         /* Cipher 60 */
1275         {
1276         1,
1277         TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5,
1278         TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5,
1279         SSL_kRSA,
1280         SSL_aRSA,
1281         SSL_RC4,
1282         SSL_MD5,
1283         SSL_TLSV1,
1284         SSL_EXPORT|SSL_EXP56,
1285         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1286         56,
1287         128,
1288         },
1289
1290         /* Cipher 61 */
1291         {
1292         1,
1293         TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5,
1294         TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5,
1295         SSL_kRSA,
1296         SSL_aRSA,
1297         SSL_RC2,
1298         SSL_MD5,
1299         SSL_TLSV1,
1300         SSL_EXPORT|SSL_EXP56,
1301         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1302         56,
1303         128,
1304         },
1305 #endif
1306
1307         /* Cipher 62 */
1308         {
1309         1,
1310         TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA,
1311         TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA,
1312         SSL_kRSA,
1313         SSL_aRSA,
1314         SSL_DES,
1315         SSL_SHA1,
1316         SSL_TLSV1,
1317         SSL_EXPORT|SSL_EXP56,
1318         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1319         56,
1320         56,
1321         },
1322
1323         /* Cipher 63 */
1324         {
1325         1,
1326         TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA,
1327         TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA,
1328         SSL_kEDH,
1329         SSL_aDSS,
1330         SSL_DES,
1331         SSL_SHA1,
1332         SSL_TLSV1,
1333         SSL_EXPORT|SSL_EXP56,
1334         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1335         56,
1336         56,
1337         },
1338
1339         /* Cipher 64 */
1340         {
1341         1,
1342         TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA,
1343         TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA,
1344         SSL_kRSA,
1345         SSL_aRSA,
1346         SSL_RC4,
1347         SSL_SHA1,
1348         SSL_TLSV1,
1349         SSL_EXPORT|SSL_EXP56,
1350         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1351         56,
1352         128,
1353         },
1354
1355         /* Cipher 65 */
1356         {
1357         1,
1358         TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA,
1359         TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA,
1360         SSL_kEDH,
1361         SSL_aDSS,
1362         SSL_RC4,
1363         SSL_SHA1,
1364         SSL_TLSV1,
1365         SSL_EXPORT|SSL_EXP56,
1366         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1367         56,
1368         128,
1369         },
1370
1371         /* Cipher 66 */
1372         {
1373         1,
1374         TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA,
1375         TLS1_CK_DHE_DSS_WITH_RC4_128_SHA,
1376         SSL_kEDH,
1377         SSL_aDSS,
1378         SSL_RC4,
1379         SSL_SHA1,
1380         SSL_TLSV1,
1381         SSL_NOT_EXP|SSL_MEDIUM,
1382         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1383         128,
1384         128,
1385         },
1386 #endif
1387
1388         /* TLS v1.2 ciphersuites */
1389         /* Cipher 67 */
1390         {
1391         1,
1392         TLS1_TXT_DHE_RSA_WITH_AES_128_SHA256,
1393         TLS1_CK_DHE_RSA_WITH_AES_128_SHA256,
1394         SSL_kEDH,
1395         SSL_aRSA,
1396         SSL_AES128,
1397         SSL_SHA256,
1398         SSL_TLSV1_2,
1399         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1400         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1401         128,
1402         128,
1403         },
1404
1405         /* Cipher 68 */
1406         {
1407         1,
1408         TLS1_TXT_DH_DSS_WITH_AES_256_SHA256,
1409         TLS1_CK_DH_DSS_WITH_AES_256_SHA256,
1410         SSL_kDHd,
1411         SSL_aDH,
1412         SSL_AES256,
1413         SSL_SHA256,
1414         SSL_TLSV1_2,
1415         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1416         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1417         256,
1418         256,
1419         },
1420
1421         /* Cipher 69 */
1422         {
1423         1,
1424         TLS1_TXT_DH_RSA_WITH_AES_256_SHA256,
1425         TLS1_CK_DH_RSA_WITH_AES_256_SHA256,
1426         SSL_kDHr,
1427         SSL_aDH,
1428         SSL_AES256,
1429         SSL_SHA256,
1430         SSL_TLSV1_2,
1431         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1432         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1433         256,
1434         256,
1435         },
1436
1437         /* Cipher 6A */
1438         {
1439         1,
1440         TLS1_TXT_DHE_DSS_WITH_AES_256_SHA256,
1441         TLS1_CK_DHE_DSS_WITH_AES_256_SHA256,
1442         SSL_kEDH,
1443         SSL_aDSS,
1444         SSL_AES256,
1445         SSL_SHA256,
1446         SSL_TLSV1_2,
1447         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1448         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1449         256,
1450         256,
1451         },
1452
1453         /* Cipher 6B */
1454         {
1455         1,
1456         TLS1_TXT_DHE_RSA_WITH_AES_256_SHA256,
1457         TLS1_CK_DHE_RSA_WITH_AES_256_SHA256,
1458         SSL_kEDH,
1459         SSL_aRSA,
1460         SSL_AES256,
1461         SSL_SHA256,
1462         SSL_TLSV1_2,
1463         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1464         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1465         256,
1466         256,
1467         },
1468
1469         /* Cipher 6C */
1470         {
1471         1,
1472         TLS1_TXT_ADH_WITH_AES_128_SHA256,
1473         TLS1_CK_ADH_WITH_AES_128_SHA256,
1474         SSL_kEDH,
1475         SSL_aNULL,
1476         SSL_AES128,
1477         SSL_SHA256,
1478         SSL_TLSV1_2,
1479         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1480         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1481         128,
1482         128,
1483         },
1484
1485         /* Cipher 6D */
1486         {
1487         1,
1488         TLS1_TXT_ADH_WITH_AES_256_SHA256,
1489         TLS1_CK_ADH_WITH_AES_256_SHA256,
1490         SSL_kEDH,
1491         SSL_aNULL,
1492         SSL_AES256,
1493         SSL_SHA256,
1494         SSL_TLSV1_2,
1495         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1496         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1497         256,
1498         256,
1499         },
1500
1501         /* GOST Ciphersuites */
1502
1503         {
1504         1,
1505         "GOST94-GOST89-GOST89",
1506         0x3000080,
1507         SSL_kGOST,
1508         SSL_aGOST94,
1509         SSL_eGOST2814789CNT,
1510         SSL_GOST89MAC,
1511         SSL_TLSV1,
1512         SSL_NOT_EXP|SSL_HIGH,
1513         SSL_HANDSHAKE_MAC_GOST94|TLS1_PRF_GOST94|TLS1_STREAM_MAC,
1514         256,
1515         256
1516         },
1517         {
1518         1,
1519         "GOST2001-GOST89-GOST89",
1520         0x3000081,
1521         SSL_kGOST,
1522         SSL_aGOST01,
1523         SSL_eGOST2814789CNT,
1524         SSL_GOST89MAC,
1525         SSL_TLSV1,
1526         SSL_NOT_EXP|SSL_HIGH,
1527         SSL_HANDSHAKE_MAC_GOST94|TLS1_PRF_GOST94|TLS1_STREAM_MAC,
1528         256,
1529         256
1530         },
1531         {
1532         1,
1533         "GOST94-NULL-GOST94",
1534         0x3000082,
1535         SSL_kGOST,
1536         SSL_aGOST94,
1537         SSL_eNULL,
1538         SSL_GOST94,
1539         SSL_TLSV1,
1540         SSL_NOT_EXP|SSL_STRONG_NONE,
1541         SSL_HANDSHAKE_MAC_GOST94|TLS1_PRF_GOST94,
1542         0,
1543         0
1544         },
1545         {
1546         1,
1547         "GOST2001-NULL-GOST94",
1548         0x3000083,
1549         SSL_kGOST,
1550         SSL_aGOST01,
1551         SSL_eNULL,
1552         SSL_GOST94,
1553         SSL_TLSV1,
1554         SSL_NOT_EXP|SSL_STRONG_NONE,
1555         SSL_HANDSHAKE_MAC_GOST94|TLS1_PRF_GOST94,
1556         0,
1557         0
1558         },
1559
1560 #ifndef OPENSSL_NO_CAMELLIA
1561         /* Camellia ciphersuites from RFC4132 (256-bit portion) */
1562
1563         /* Cipher 84 */
1564         {
1565         1,
1566         TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA,
1567         TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA,
1568         SSL_kRSA,
1569         SSL_aRSA,
1570         SSL_CAMELLIA256,
1571         SSL_SHA1,
1572         SSL_TLSV1,
1573         SSL_NOT_EXP|SSL_HIGH,
1574         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1575         256,
1576         256,
1577         },
1578         /* Cipher 85 */
1579         {
1580         1,
1581         TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA,
1582         TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA,
1583         SSL_kDHd,
1584         SSL_aDH,
1585         SSL_CAMELLIA256,
1586         SSL_SHA1,
1587         SSL_TLSV1,
1588         SSL_NOT_EXP|SSL_HIGH,
1589         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1590         256,
1591         256,
1592         },
1593
1594         /* Cipher 86 */
1595         {
1596         1,
1597         TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA,
1598         TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA,
1599         SSL_kDHr,
1600         SSL_aDH,
1601         SSL_CAMELLIA256,
1602         SSL_SHA1,
1603         SSL_TLSV1,
1604         SSL_NOT_EXP|SSL_HIGH,
1605         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1606         256,
1607         256,
1608         },
1609
1610         /* Cipher 87 */
1611         {
1612         1,
1613         TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA,
1614         TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA,
1615         SSL_kEDH,
1616         SSL_aDSS,
1617         SSL_CAMELLIA256,
1618         SSL_SHA1,
1619         SSL_TLSV1,
1620         SSL_NOT_EXP|SSL_HIGH,
1621         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1622         256,
1623         256,
1624         },
1625
1626         /* Cipher 88 */
1627         {
1628         1,
1629         TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA,
1630         TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA,
1631         SSL_kEDH,
1632         SSL_aRSA,
1633         SSL_CAMELLIA256,
1634         SSL_SHA1,
1635         SSL_TLSV1,
1636         SSL_NOT_EXP|SSL_HIGH,
1637         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1638         256,
1639         256,
1640         },
1641
1642         /* Cipher 89 */
1643         {
1644         1,
1645         TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA,
1646         TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA,
1647         SSL_kEDH,
1648         SSL_aNULL,
1649         SSL_CAMELLIA256,
1650         SSL_SHA1,
1651         SSL_TLSV1,
1652         SSL_NOT_EXP|SSL_HIGH,
1653         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1654         256,
1655         256,
1656         },
1657 #endif /* OPENSSL_NO_CAMELLIA */
1658
1659 #ifndef OPENSSL_NO_PSK
1660         /* Cipher 8A */
1661         {
1662         1,
1663         TLS1_TXT_PSK_WITH_RC4_128_SHA,
1664         TLS1_CK_PSK_WITH_RC4_128_SHA,
1665         SSL_kPSK,
1666         SSL_aPSK,
1667         SSL_RC4,
1668         SSL_SHA1,
1669         SSL_TLSV1,
1670         SSL_NOT_EXP|SSL_MEDIUM,
1671         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1672         128,
1673         128,
1674         },
1675
1676         /* Cipher 8B */
1677         {
1678         1,
1679         TLS1_TXT_PSK_WITH_3DES_EDE_CBC_SHA,
1680         TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA,
1681         SSL_kPSK,
1682         SSL_aPSK,
1683         SSL_3DES,
1684         SSL_SHA1,
1685         SSL_TLSV1,
1686         SSL_NOT_EXP|SSL_HIGH,
1687         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1688         168,
1689         168,
1690         },
1691
1692         /* Cipher 8C */
1693         {
1694         1,
1695         TLS1_TXT_PSK_WITH_AES_128_CBC_SHA,
1696         TLS1_CK_PSK_WITH_AES_128_CBC_SHA,
1697         SSL_kPSK,
1698         SSL_aPSK,
1699         SSL_AES128,
1700         SSL_SHA1,
1701         SSL_TLSV1,
1702         SSL_NOT_EXP|SSL_HIGH,
1703         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1704         128,
1705         128,
1706         },
1707
1708         /* Cipher 8D */
1709         {
1710         1,
1711         TLS1_TXT_PSK_WITH_AES_256_CBC_SHA,
1712         TLS1_CK_PSK_WITH_AES_256_CBC_SHA,
1713         SSL_kPSK,
1714         SSL_aPSK,
1715         SSL_AES256,
1716         SSL_SHA1,
1717         SSL_TLSV1,
1718         SSL_NOT_EXP|SSL_HIGH,
1719         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1720         256,
1721         256,
1722         },
1723 #endif  /* OPENSSL_NO_PSK */
1724
1725 #ifndef OPENSSL_NO_SEED
1726         /* SEED ciphersuites from RFC4162 */
1727
1728         /* Cipher 96 */
1729         {
1730         1,
1731         TLS1_TXT_RSA_WITH_SEED_SHA,
1732         TLS1_CK_RSA_WITH_SEED_SHA,
1733         SSL_kRSA,
1734         SSL_aRSA,
1735         SSL_SEED,
1736         SSL_SHA1,
1737         SSL_TLSV1,
1738         SSL_NOT_EXP|SSL_MEDIUM,
1739         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1740         128,
1741         128,
1742         },
1743
1744         /* Cipher 97 */
1745         {
1746         1,
1747         TLS1_TXT_DH_DSS_WITH_SEED_SHA,
1748         TLS1_CK_DH_DSS_WITH_SEED_SHA,
1749         SSL_kDHd,
1750         SSL_aDH,
1751         SSL_SEED,
1752         SSL_SHA1,
1753         SSL_TLSV1,
1754         SSL_NOT_EXP|SSL_MEDIUM,
1755         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1756         128,
1757         128,
1758         },
1759
1760         /* Cipher 98 */
1761         {
1762         1,
1763         TLS1_TXT_DH_RSA_WITH_SEED_SHA,
1764         TLS1_CK_DH_RSA_WITH_SEED_SHA,
1765         SSL_kDHr,
1766         SSL_aDH,
1767         SSL_SEED,
1768         SSL_SHA1,
1769         SSL_TLSV1,
1770         SSL_NOT_EXP|SSL_MEDIUM,
1771         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1772         128,
1773         128,
1774         },
1775
1776         /* Cipher 99 */
1777         {
1778         1,
1779         TLS1_TXT_DHE_DSS_WITH_SEED_SHA,
1780         TLS1_CK_DHE_DSS_WITH_SEED_SHA,
1781         SSL_kEDH,
1782         SSL_aDSS,
1783         SSL_SEED,
1784         SSL_SHA1,
1785         SSL_TLSV1,
1786         SSL_NOT_EXP|SSL_MEDIUM,
1787         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1788         128,
1789         128,
1790         },
1791
1792         /* Cipher 9A */
1793         {
1794         1,
1795         TLS1_TXT_DHE_RSA_WITH_SEED_SHA,
1796         TLS1_CK_DHE_RSA_WITH_SEED_SHA,
1797         SSL_kEDH,
1798         SSL_aRSA,
1799         SSL_SEED,
1800         SSL_SHA1,
1801         SSL_TLSV1,
1802         SSL_NOT_EXP|SSL_MEDIUM,
1803         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1804         128,
1805         128,
1806         },
1807
1808         /* Cipher 9B */
1809         {
1810         1,
1811         TLS1_TXT_ADH_WITH_SEED_SHA,
1812         TLS1_CK_ADH_WITH_SEED_SHA,
1813         SSL_kEDH,
1814         SSL_aNULL,
1815         SSL_SEED,
1816         SSL_SHA1,
1817         SSL_TLSV1,
1818         SSL_NOT_EXP|SSL_MEDIUM,
1819         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1820         128,
1821         128,
1822         },
1823
1824 #endif /* OPENSSL_NO_SEED */
1825
1826         /* GCM ciphersuites from RFC5288 */
1827
1828         /* Cipher 9C */
1829         {
1830         1,
1831         TLS1_TXT_RSA_WITH_AES_128_GCM_SHA256,
1832         TLS1_CK_RSA_WITH_AES_128_GCM_SHA256,
1833         SSL_kRSA,
1834         SSL_aRSA,
1835         SSL_AES128GCM,
1836         SSL_AEAD,
1837         SSL_TLSV1_2,
1838         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1839         SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256|SSL_CIPHER_ALGORITHM2_AEAD|
1840                 FIXED_NONCE_LEN(4)|
1841                 SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
1842         128,
1843         128,
1844         },
1845
1846         /* Cipher 9D */
1847         {
1848         1,
1849         TLS1_TXT_RSA_WITH_AES_256_GCM_SHA384,
1850         TLS1_CK_RSA_WITH_AES_256_GCM_SHA384,
1851         SSL_kRSA,
1852         SSL_aRSA,
1853         SSL_AES256GCM,
1854         SSL_AEAD,
1855         SSL_TLSV1_2,
1856         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1857         SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384|SSL_CIPHER_ALGORITHM2_AEAD|
1858                 FIXED_NONCE_LEN(4)|
1859                 SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
1860         256,
1861         256,
1862         },
1863
1864         /* Cipher 9E */
1865         {
1866         1,
1867         TLS1_TXT_DHE_RSA_WITH_AES_128_GCM_SHA256,
1868         TLS1_CK_DHE_RSA_WITH_AES_128_GCM_SHA256,
1869         SSL_kEDH,
1870         SSL_aRSA,
1871         SSL_AES128GCM,
1872         SSL_AEAD,
1873         SSL_TLSV1_2,
1874         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1875         SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256|SSL_CIPHER_ALGORITHM2_AEAD|
1876                 FIXED_NONCE_LEN(4)|
1877                 SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
1878         128,
1879         128,
1880         },
1881
1882         /* Cipher 9F */
1883         {
1884         1,
1885         TLS1_TXT_DHE_RSA_WITH_AES_256_GCM_SHA384,
1886         TLS1_CK_DHE_RSA_WITH_AES_256_GCM_SHA384,
1887         SSL_kEDH,
1888         SSL_aRSA,
1889         SSL_AES256GCM,
1890         SSL_AEAD,
1891         SSL_TLSV1_2,
1892         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1893         SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384|SSL_CIPHER_ALGORITHM2_AEAD|
1894                 FIXED_NONCE_LEN(4)|
1895                 SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
1896         256,
1897         256,
1898         },
1899
1900         /* Cipher A0 */
1901         {
1902         1,
1903         TLS1_TXT_DH_RSA_WITH_AES_128_GCM_SHA256,
1904         TLS1_CK_DH_RSA_WITH_AES_128_GCM_SHA256,
1905         SSL_kDHr,
1906         SSL_aDH,
1907         SSL_AES128GCM,
1908         SSL_AEAD,
1909         SSL_TLSV1_2,
1910         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1911         SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256|SSL_CIPHER_ALGORITHM2_AEAD|
1912                 FIXED_NONCE_LEN(4)|
1913                 SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
1914         128,
1915         128,
1916         },
1917
1918         /* Cipher A1 */
1919         {
1920         1,
1921         TLS1_TXT_DH_RSA_WITH_AES_256_GCM_SHA384,
1922         TLS1_CK_DH_RSA_WITH_AES_256_GCM_SHA384,
1923         SSL_kDHr,
1924         SSL_aDH,
1925         SSL_AES256GCM,
1926         SSL_AEAD,
1927         SSL_TLSV1_2,
1928         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1929         SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384|SSL_CIPHER_ALGORITHM2_AEAD|
1930                 FIXED_NONCE_LEN(4)|
1931                 SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
1932         256,
1933         256,
1934         },
1935
1936         /* Cipher A2 */
1937         {
1938         1,
1939         TLS1_TXT_DHE_DSS_WITH_AES_128_GCM_SHA256,
1940         TLS1_CK_DHE_DSS_WITH_AES_128_GCM_SHA256,
1941         SSL_kEDH,
1942         SSL_aDSS,
1943         SSL_AES128GCM,
1944         SSL_AEAD,
1945         SSL_TLSV1_2,
1946         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1947         SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256|SSL_CIPHER_ALGORITHM2_AEAD|
1948                 FIXED_NONCE_LEN(4)|
1949                 SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
1950         128,
1951         128,
1952         },
1953
1954         /* Cipher A3 */
1955         {
1956         1,
1957         TLS1_TXT_DHE_DSS_WITH_AES_256_GCM_SHA384,
1958         TLS1_CK_DHE_DSS_WITH_AES_256_GCM_SHA384,
1959         SSL_kEDH,
1960         SSL_aDSS,
1961         SSL_AES256GCM,
1962         SSL_AEAD,
1963         SSL_TLSV1_2,
1964         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1965         SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384|SSL_CIPHER_ALGORITHM2_AEAD|
1966                 FIXED_NONCE_LEN(4)|
1967                 SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
1968         256,
1969         256,
1970         },
1971
1972         /* Cipher A4 */
1973         {
1974         1,
1975         TLS1_TXT_DH_DSS_WITH_AES_128_GCM_SHA256,
1976         TLS1_CK_DH_DSS_WITH_AES_128_GCM_SHA256,
1977         SSL_kDHd,
1978         SSL_aDH,
1979         SSL_AES128GCM,
1980         SSL_AEAD,
1981         SSL_TLSV1_2,
1982         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1983         SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256|SSL_CIPHER_ALGORITHM2_AEAD|
1984                 FIXED_NONCE_LEN(4)|
1985                 SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
1986         128,
1987         128,
1988         },
1989
1990         /* Cipher A5 */
1991         {
1992         1,
1993         TLS1_TXT_DH_DSS_WITH_AES_256_GCM_SHA384,
1994         TLS1_CK_DH_DSS_WITH_AES_256_GCM_SHA384,
1995         SSL_kDHd,
1996         SSL_aDH,
1997         SSL_AES256GCM,
1998         SSL_AEAD,
1999         SSL_TLSV1_2,
2000         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2001         SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384|SSL_CIPHER_ALGORITHM2_AEAD|
2002                 FIXED_NONCE_LEN(4)|
2003                 SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
2004         256,
2005         256,
2006         },
2007
2008         /* Cipher A6 */
2009         {
2010         1,
2011         TLS1_TXT_ADH_WITH_AES_128_GCM_SHA256,
2012         TLS1_CK_ADH_WITH_AES_128_GCM_SHA256,
2013         SSL_kEDH,
2014         SSL_aNULL,
2015         SSL_AES128GCM,
2016         SSL_AEAD,
2017         SSL_TLSV1_2,
2018         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2019         SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256|SSL_CIPHER_ALGORITHM2_AEAD|
2020                 FIXED_NONCE_LEN(4)|
2021                 SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
2022         128,
2023         128,
2024         },
2025
2026         /* Cipher A7 */
2027         {
2028         1,
2029         TLS1_TXT_ADH_WITH_AES_256_GCM_SHA384,
2030         TLS1_CK_ADH_WITH_AES_256_GCM_SHA384,
2031         SSL_kEDH,
2032         SSL_aNULL,
2033         SSL_AES256GCM,
2034         SSL_AEAD,
2035         SSL_TLSV1_2,
2036         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2037         SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384|SSL_CIPHER_ALGORITHM2_AEAD|
2038                 FIXED_NONCE_LEN(4)|
2039                 SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
2040         256,
2041         256,
2042         },
2043 #ifdef OPENSSL_SSL_DEBUG_BROKEN_PROTOCOL
2044         {
2045         1,
2046         "SCSV",
2047         SSL3_CK_SCSV,
2048         0,
2049         0,
2050         0,
2051         0,
2052         0,
2053         0,
2054         0,
2055         0,
2056         0
2057         },
2058 #endif
2059
2060 #ifndef OPENSSL_NO_ECDH
2061         /* Cipher C001 */
2062         {
2063         1,
2064         TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA,
2065         TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA,
2066         SSL_kECDHe,
2067         SSL_aECDH,
2068         SSL_eNULL,
2069         SSL_SHA1,
2070         SSL_TLSV1,
2071         SSL_NOT_EXP|SSL_STRONG_NONE|SSL_FIPS,
2072         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2073         0,
2074         0,
2075         },
2076
2077         /* Cipher C002 */
2078         {
2079         1,
2080         TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA,
2081         TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA,
2082         SSL_kECDHe,
2083         SSL_aECDH,
2084         SSL_RC4,
2085         SSL_SHA1,
2086         SSL_TLSV1,
2087         SSL_NOT_EXP|SSL_MEDIUM,
2088         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2089         128,
2090         128,
2091         },
2092
2093         /* Cipher C003 */
2094         {
2095         1,
2096         TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA,
2097         TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA,
2098         SSL_kECDHe,
2099         SSL_aECDH,
2100         SSL_3DES,
2101         SSL_SHA1,
2102         SSL_TLSV1,
2103         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2104         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2105         168,
2106         168,
2107         },
2108
2109         /* Cipher C004 */
2110         {
2111         1,
2112         TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA,
2113         TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA,
2114         SSL_kECDHe,
2115         SSL_aECDH,
2116         SSL_AES128,
2117         SSL_SHA1,
2118         SSL_TLSV1,
2119         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2120         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2121         128,
2122         128,
2123         },
2124
2125         /* Cipher C005 */
2126         {
2127         1,
2128         TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA,
2129         TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA,
2130         SSL_kECDHe,
2131         SSL_aECDH,
2132         SSL_AES256,
2133         SSL_SHA1,
2134         SSL_TLSV1,
2135         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2136         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2137         256,
2138         256,
2139         },
2140
2141         /* Cipher C006 */
2142         {
2143         1,
2144         TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA,
2145         TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA,
2146         SSL_kEECDH,
2147         SSL_aECDSA,
2148         SSL_eNULL,
2149         SSL_SHA1,
2150         SSL_TLSV1,
2151         SSL_NOT_EXP|SSL_STRONG_NONE|SSL_FIPS,
2152         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2153         0,
2154         0,
2155         },
2156
2157         /* Cipher C007 */
2158         {
2159         1,
2160         TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA,
2161         TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA,
2162         SSL_kEECDH,
2163         SSL_aECDSA,
2164         SSL_RC4,
2165         SSL_SHA1,
2166         SSL_TLSV1,
2167         SSL_NOT_EXP|SSL_MEDIUM,
2168         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2169         128,
2170         128,
2171         },
2172
2173         /* Cipher C008 */
2174         {
2175         1,
2176         TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA,
2177         TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA,
2178         SSL_kEECDH,
2179         SSL_aECDSA,
2180         SSL_3DES,
2181         SSL_SHA1,
2182         SSL_TLSV1,
2183         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2184         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2185         168,
2186         168,
2187         },
2188
2189         /* Cipher C009 */
2190         {
2191         1,
2192         TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
2193         TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
2194         SSL_kEECDH,
2195         SSL_aECDSA,
2196         SSL_AES128,
2197         SSL_SHA1,
2198         SSL_TLSV1,
2199         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2200         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2201         128,
2202         128,
2203         },
2204
2205         /* Cipher C00A */
2206         {
2207         1,
2208         TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
2209         TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
2210         SSL_kEECDH,
2211         SSL_aECDSA,
2212         SSL_AES256,
2213         SSL_SHA1,
2214         SSL_TLSV1,
2215         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2216         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2217         256,
2218         256,
2219         },
2220
2221         /* Cipher C00B */
2222         {
2223         1,
2224         TLS1_TXT_ECDH_RSA_WITH_NULL_SHA,
2225         TLS1_CK_ECDH_RSA_WITH_NULL_SHA,
2226         SSL_kECDHr,
2227         SSL_aECDH,
2228         SSL_eNULL,
2229         SSL_SHA1,
2230         SSL_TLSV1,
2231         SSL_NOT_EXP|SSL_STRONG_NONE|SSL_FIPS,
2232         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2233         0,
2234         0,
2235         },
2236
2237         /* Cipher C00C */
2238         {
2239         1,
2240         TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA,
2241         TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA,
2242         SSL_kECDHr,
2243         SSL_aECDH,
2244         SSL_RC4,
2245         SSL_SHA1,
2246         SSL_TLSV1,
2247         SSL_NOT_EXP|SSL_MEDIUM,
2248         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2249         128,
2250         128,
2251         },
2252
2253         /* Cipher C00D */
2254         {
2255         1,
2256         TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA,
2257         TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA,
2258         SSL_kECDHr,
2259         SSL_aECDH,
2260         SSL_3DES,
2261         SSL_SHA1,
2262         SSL_TLSV1,
2263         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2264         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2265         168,
2266         168,
2267         },
2268
2269         /* Cipher C00E */
2270         {
2271         1,
2272         TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA,
2273         TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA,
2274         SSL_kECDHr,
2275         SSL_aECDH,
2276         SSL_AES128,
2277         SSL_SHA1,
2278         SSL_TLSV1,
2279         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2280         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2281         128,
2282         128,
2283         },
2284
2285         /* Cipher C00F */
2286         {
2287         1,
2288         TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA,
2289         TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA,
2290         SSL_kECDHr,
2291         SSL_aECDH,
2292         SSL_AES256,
2293         SSL_SHA1,
2294         SSL_TLSV1,
2295         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2296         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2297         256,
2298         256,
2299         },
2300
2301         /* Cipher C010 */
2302         {
2303         1,
2304         TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA,
2305         TLS1_CK_ECDHE_RSA_WITH_NULL_SHA,
2306         SSL_kEECDH,
2307         SSL_aRSA,
2308         SSL_eNULL,
2309         SSL_SHA1,
2310         SSL_TLSV1,
2311         SSL_NOT_EXP|SSL_STRONG_NONE|SSL_FIPS,
2312         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2313         0,
2314         0,
2315         },
2316
2317         /* Cipher C011 */
2318         {
2319         1,
2320         TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA,
2321         TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA,
2322         SSL_kEECDH,
2323         SSL_aRSA,
2324         SSL_RC4,
2325         SSL_SHA1,
2326         SSL_TLSV1,
2327         SSL_NOT_EXP|SSL_MEDIUM,
2328         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2329         128,
2330         128,
2331         },
2332
2333         /* Cipher C012 */
2334         {
2335         1,
2336         TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA,
2337         TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA,
2338         SSL_kEECDH,
2339         SSL_aRSA,
2340         SSL_3DES,
2341         SSL_SHA1,
2342         SSL_TLSV1,
2343         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2344         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2345         168,
2346         168,
2347         },
2348
2349         /* Cipher C013 */
2350         {
2351         1,
2352         TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA,
2353         TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA,
2354         SSL_kEECDH,
2355         SSL_aRSA,
2356         SSL_AES128,
2357         SSL_SHA1,
2358         SSL_TLSV1,
2359         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2360         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2361         128,
2362         128,
2363         },
2364
2365         /* Cipher C014 */
2366         {
2367         1,
2368         TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA,
2369         TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA,
2370         SSL_kEECDH,
2371         SSL_aRSA,
2372         SSL_AES256,
2373         SSL_SHA1,
2374         SSL_TLSV1,
2375         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2376         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2377         256,
2378         256,
2379         },
2380
2381         /* Cipher C015 */
2382         {
2383         1,
2384         TLS1_TXT_ECDH_anon_WITH_NULL_SHA,
2385         TLS1_CK_ECDH_anon_WITH_NULL_SHA,
2386         SSL_kEECDH,
2387         SSL_aNULL,
2388         SSL_eNULL,
2389         SSL_SHA1,
2390         SSL_TLSV1,
2391         SSL_NOT_EXP|SSL_STRONG_NONE|SSL_FIPS,
2392         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2393         0,
2394         0,
2395         },
2396
2397         /* Cipher C016 */
2398         {
2399         1,
2400         TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA,
2401         TLS1_CK_ECDH_anon_WITH_RC4_128_SHA,
2402         SSL_kEECDH,
2403         SSL_aNULL,
2404         SSL_RC4,
2405         SSL_SHA1,
2406         SSL_TLSV1,
2407         SSL_NOT_EXP|SSL_MEDIUM,
2408         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2409         128,
2410         128,
2411         },
2412
2413         /* Cipher C017 */
2414         {
2415         1,
2416         TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA,
2417         TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA,
2418         SSL_kEECDH,
2419         SSL_aNULL,
2420         SSL_3DES,
2421         SSL_SHA1,
2422         SSL_TLSV1,
2423         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2424         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2425         168,
2426         168,
2427         },
2428
2429         /* Cipher C018 */
2430         {
2431         1,
2432         TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA,
2433         TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA,
2434         SSL_kEECDH,
2435         SSL_aNULL,
2436         SSL_AES128,
2437         SSL_SHA1,
2438         SSL_TLSV1,
2439         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2440         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2441         128,
2442         128,
2443         },
2444
2445         /* Cipher C019 */
2446         {
2447         1,
2448         TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA,
2449         TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA,
2450         SSL_kEECDH,
2451         SSL_aNULL,
2452         SSL_AES256,
2453         SSL_SHA1,
2454         SSL_TLSV1,
2455         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2456         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2457         256,
2458         256,
2459         },
2460 #endif  /* OPENSSL_NO_ECDH */
2461
2462 #ifndef OPENSSL_NO_SRP
2463         /* Cipher C01A */
2464         {
2465         1,
2466         TLS1_TXT_SRP_SHA_WITH_3DES_EDE_CBC_SHA,
2467         TLS1_CK_SRP_SHA_WITH_3DES_EDE_CBC_SHA,
2468         SSL_kSRP,
2469         SSL_aNULL,
2470         SSL_3DES,
2471         SSL_SHA1,
2472         SSL_TLSV1,
2473         SSL_NOT_EXP|SSL_HIGH,
2474         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2475         168,
2476         168,
2477         },
2478
2479         /* Cipher C01B */
2480         {
2481         1,
2482         TLS1_TXT_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA,
2483         TLS1_CK_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA,
2484         SSL_kSRP,
2485         SSL_aRSA,
2486         SSL_3DES,
2487         SSL_SHA1,
2488         SSL_TLSV1,
2489         SSL_NOT_EXP|SSL_HIGH,
2490         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2491         168,
2492         168,
2493         },
2494
2495         /* Cipher C01C */
2496         {
2497         1,
2498         TLS1_TXT_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA,
2499         TLS1_CK_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA,
2500         SSL_kSRP,
2501         SSL_aDSS,
2502         SSL_3DES,
2503         SSL_SHA1,
2504         SSL_TLSV1,
2505         SSL_NOT_EXP|SSL_HIGH,
2506         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2507         168,
2508         168,
2509         },
2510
2511         /* Cipher C01D */
2512         {
2513         1,
2514         TLS1_TXT_SRP_SHA_WITH_AES_128_CBC_SHA,
2515         TLS1_CK_SRP_SHA_WITH_AES_128_CBC_SHA,
2516         SSL_kSRP,
2517         SSL_aNULL,
2518         SSL_AES128,
2519         SSL_SHA1,
2520         SSL_TLSV1,
2521         SSL_NOT_EXP|SSL_HIGH,
2522         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2523         128,
2524         128,
2525         },
2526
2527         /* Cipher C01E */
2528         {
2529         1,
2530         TLS1_TXT_SRP_SHA_RSA_WITH_AES_128_CBC_SHA,
2531         TLS1_CK_SRP_SHA_RSA_WITH_AES_128_CBC_SHA,
2532         SSL_kSRP,
2533         SSL_aRSA,
2534         SSL_AES128,
2535         SSL_SHA1,
2536         SSL_TLSV1,
2537         SSL_NOT_EXP|SSL_HIGH,
2538         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2539         128,
2540         128,
2541         },
2542
2543         /* Cipher C01F */
2544         {
2545         1,
2546         TLS1_TXT_SRP_SHA_DSS_WITH_AES_128_CBC_SHA,
2547         TLS1_CK_SRP_SHA_DSS_WITH_AES_128_CBC_SHA,
2548         SSL_kSRP,
2549         SSL_aDSS,
2550         SSL_AES128,
2551         SSL_SHA1,
2552         SSL_TLSV1,
2553         SSL_NOT_EXP|SSL_HIGH,
2554         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2555         128,
2556         128,
2557         },
2558
2559         /* Cipher C020 */
2560         {
2561         1,
2562         TLS1_TXT_SRP_SHA_WITH_AES_256_CBC_SHA,
2563         TLS1_CK_SRP_SHA_WITH_AES_256_CBC_SHA,
2564         SSL_kSRP,
2565         SSL_aNULL,
2566         SSL_AES256,
2567         SSL_SHA1,
2568         SSL_TLSV1,
2569         SSL_NOT_EXP|SSL_HIGH,
2570         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2571         256,
2572         256,
2573         },
2574
2575         /* Cipher C021 */
2576         {
2577         1,
2578         TLS1_TXT_SRP_SHA_RSA_WITH_AES_256_CBC_SHA,
2579         TLS1_CK_SRP_SHA_RSA_WITH_AES_256_CBC_SHA,
2580         SSL_kSRP,
2581         SSL_aRSA,
2582         SSL_AES256,
2583         SSL_SHA1,
2584         SSL_TLSV1,
2585         SSL_NOT_EXP|SSL_HIGH,
2586         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2587         256,
2588         256,
2589         },
2590
2591         /* Cipher C022 */
2592         {
2593         1,
2594         TLS1_TXT_SRP_SHA_DSS_WITH_AES_256_CBC_SHA,
2595         TLS1_CK_SRP_SHA_DSS_WITH_AES_256_CBC_SHA,
2596         SSL_kSRP,
2597         SSL_aDSS,
2598         SSL_AES256,
2599         SSL_SHA1,
2600         SSL_TLSV1,
2601         SSL_NOT_EXP|SSL_HIGH,
2602         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2603         256,
2604         256,
2605         },
2606 #endif  /* OPENSSL_NO_SRP */
2607 #ifndef OPENSSL_NO_ECDH
2608
2609         /* HMAC based TLS v1.2 ciphersuites from RFC5289 */
2610
2611         /* Cipher C023 */
2612         {
2613         1,
2614         TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_SHA256,
2615         TLS1_CK_ECDHE_ECDSA_WITH_AES_128_SHA256,
2616         SSL_kEECDH,
2617         SSL_aECDSA,
2618         SSL_AES128,
2619         SSL_SHA256,
2620         SSL_TLSV1_2,
2621         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2622         SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
2623         128,
2624         128,
2625         },
2626
2627         /* Cipher C024 */
2628         {
2629         1,
2630         TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_SHA384,
2631         TLS1_CK_ECDHE_ECDSA_WITH_AES_256_SHA384,
2632         SSL_kEECDH,
2633         SSL_aECDSA,
2634         SSL_AES256,
2635         SSL_SHA384,
2636         SSL_TLSV1_2,
2637         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2638         SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
2639         256,
2640         256,
2641         },
2642
2643         /* Cipher C025 */
2644         {
2645         1,
2646         TLS1_TXT_ECDH_ECDSA_WITH_AES_128_SHA256,
2647         TLS1_CK_ECDH_ECDSA_WITH_AES_128_SHA256,
2648         SSL_kECDHe,
2649         SSL_aECDH,
2650         SSL_AES128,
2651         SSL_SHA256,
2652         SSL_TLSV1_2,
2653         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2654         SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
2655         128,
2656         128,
2657         },
2658
2659         /* Cipher C026 */
2660         {
2661         1,
2662         TLS1_TXT_ECDH_ECDSA_WITH_AES_256_SHA384,
2663         TLS1_CK_ECDH_ECDSA_WITH_AES_256_SHA384,
2664         SSL_kECDHe,
2665         SSL_aECDH,
2666         SSL_AES256,
2667         SSL_SHA384,
2668         SSL_TLSV1_2,
2669         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2670         SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
2671         256,
2672         256,
2673         },
2674
2675         /* Cipher C027 */
2676         {
2677         1,
2678         TLS1_TXT_ECDHE_RSA_WITH_AES_128_SHA256,
2679         TLS1_CK_ECDHE_RSA_WITH_AES_128_SHA256,
2680         SSL_kEECDH,
2681         SSL_aRSA,
2682         SSL_AES128,
2683         SSL_SHA256,
2684         SSL_TLSV1_2,
2685         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2686         SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
2687         128,
2688         128,
2689         },
2690
2691         /* Cipher C028 */
2692         {
2693         1,
2694         TLS1_TXT_ECDHE_RSA_WITH_AES_256_SHA384,
2695         TLS1_CK_ECDHE_RSA_WITH_AES_256_SHA384,
2696         SSL_kEECDH,
2697         SSL_aRSA,
2698         SSL_AES256,
2699         SSL_SHA384,
2700         SSL_TLSV1_2,
2701         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2702         SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
2703         256,
2704         256,
2705         },
2706
2707         /* Cipher C029 */
2708         {
2709         1,
2710         TLS1_TXT_ECDH_RSA_WITH_AES_128_SHA256,
2711         TLS1_CK_ECDH_RSA_WITH_AES_128_SHA256,
2712         SSL_kECDHr,
2713         SSL_aECDH,
2714         SSL_AES128,
2715         SSL_SHA256,
2716         SSL_TLSV1_2,
2717         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2718         SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
2719         128,
2720         128,
2721         },
2722
2723         /* Cipher C02A */
2724         {
2725         1,
2726         TLS1_TXT_ECDH_RSA_WITH_AES_256_SHA384,
2727         TLS1_CK_ECDH_RSA_WITH_AES_256_SHA384,
2728         SSL_kECDHr,
2729         SSL_aECDH,
2730         SSL_AES256,
2731         SSL_SHA384,
2732         SSL_TLSV1_2,
2733         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2734         SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
2735         256,
2736         256,
2737         },
2738
2739         /* GCM based TLS v1.2 ciphersuites from RFC5289 */
2740
2741         /* Cipher C02B */
2742         {
2743         1,
2744         TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
2745         TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
2746         SSL_kEECDH,
2747         SSL_aECDSA,
2748         SSL_AES128GCM,
2749         SSL_AEAD,
2750         SSL_TLSV1_2,
2751         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2752         SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256|SSL_CIPHER_ALGORITHM2_AEAD|
2753                 FIXED_NONCE_LEN(4)|
2754                 SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
2755         128,
2756         128,
2757         },
2758
2759         /* Cipher C02C */
2760         {
2761         1,
2762         TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
2763         TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
2764         SSL_kEECDH,
2765         SSL_aECDSA,
2766         SSL_AES256GCM,
2767         SSL_AEAD,
2768         SSL_TLSV1_2,
2769         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2770         SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384|SSL_CIPHER_ALGORITHM2_AEAD|
2771                 FIXED_NONCE_LEN(4)|
2772                 SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
2773         256,
2774         256,
2775         },
2776
2777         /* Cipher C02D */
2778         {
2779         1,
2780         TLS1_TXT_ECDH_ECDSA_WITH_AES_128_GCM_SHA256,
2781         TLS1_CK_ECDH_ECDSA_WITH_AES_128_GCM_SHA256,
2782         SSL_kECDHe,
2783         SSL_aECDH,
2784         SSL_AES128GCM,
2785         SSL_AEAD,
2786         SSL_TLSV1_2,
2787         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2788         SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256|SSL_CIPHER_ALGORITHM2_AEAD|
2789                 FIXED_NONCE_LEN(4)|
2790                 SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
2791         128,
2792         128,
2793         },
2794
2795         /* Cipher C02E */
2796         {
2797         1,
2798         TLS1_TXT_ECDH_ECDSA_WITH_AES_256_GCM_SHA384,
2799         TLS1_CK_ECDH_ECDSA_WITH_AES_256_GCM_SHA384,
2800         SSL_kECDHe,
2801         SSL_aECDH,
2802         SSL_AES256GCM,
2803         SSL_AEAD,
2804         SSL_TLSV1_2,
2805         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2806         SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384|SSL_CIPHER_ALGORITHM2_AEAD|
2807                 FIXED_NONCE_LEN(4)|
2808                 SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
2809         256,
2810         256,
2811         },
2812
2813         /* Cipher C02F */
2814         {
2815         1,
2816         TLS1_TXT_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
2817         TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
2818         SSL_kEECDH,
2819         SSL_aRSA,
2820         SSL_AES128GCM,
2821         SSL_AEAD,
2822         SSL_TLSV1_2,
2823         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2824         SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256|SSL_CIPHER_ALGORITHM2_AEAD|
2825                 FIXED_NONCE_LEN(4)|
2826                 SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
2827         128,
2828         128,
2829         },
2830
2831         /* Cipher C030 */
2832         {
2833         1,
2834         TLS1_TXT_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
2835         TLS1_CK_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
2836         SSL_kEECDH,
2837         SSL_aRSA,
2838         SSL_AES256GCM,
2839         SSL_AEAD,
2840         SSL_TLSV1_2,
2841         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2842         SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384|SSL_CIPHER_ALGORITHM2_AEAD|
2843                 FIXED_NONCE_LEN(4)|
2844                 SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
2845         256,
2846         256,
2847         },
2848
2849         /* Cipher C031 */
2850         {
2851         1,
2852         TLS1_TXT_ECDH_RSA_WITH_AES_128_GCM_SHA256,
2853         TLS1_CK_ECDH_RSA_WITH_AES_128_GCM_SHA256,
2854         SSL_kECDHr,
2855         SSL_aECDH,
2856         SSL_AES128GCM,
2857         SSL_AEAD,
2858         SSL_TLSV1_2,
2859         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2860         SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256|SSL_CIPHER_ALGORITHM2_AEAD|
2861                 FIXED_NONCE_LEN(4)|
2862                 SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
2863         128,
2864         128,
2865         },
2866
2867         /* Cipher C032 */
2868         {
2869         1,
2870         TLS1_TXT_ECDH_RSA_WITH_AES_256_GCM_SHA384,
2871         TLS1_CK_ECDH_RSA_WITH_AES_256_GCM_SHA384,
2872         SSL_kECDHr,
2873         SSL_aECDH,
2874         SSL_AES256GCM,
2875         SSL_AEAD,
2876         SSL_TLSV1_2,
2877         SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2878         SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384|SSL_CIPHER_ALGORITHM2_AEAD|
2879                 FIXED_NONCE_LEN(4)|
2880                 SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
2881         256,
2882         256,
2883         },
2884
2885 #endif /* OPENSSL_NO_ECDH */
2886
2887
2888 #ifdef TEMP_GOST_TLS
2889 /* Cipher FF00 */
2890         {
2891         1,
2892         "GOST-MD5",
2893         0x0300ff00,
2894         SSL_kRSA,
2895         SSL_aRSA,
2896         SSL_eGOST2814789CNT,
2897         SSL_MD5,
2898         SSL_TLSV1,
2899         SSL_NOT_EXP|SSL_HIGH,
2900         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2901         256,
2902         256,
2903         },
2904         {
2905         1,
2906         "GOST-GOST94",
2907         0x0300ff01,
2908         SSL_kRSA,
2909         SSL_aRSA,
2910         SSL_eGOST2814789CNT,
2911         SSL_GOST94,
2912         SSL_TLSV1,
2913         SSL_NOT_EXP|SSL_HIGH,
2914         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2915         256,
2916         256
2917         },
2918         {
2919         1,
2920         "GOST-GOST89MAC",
2921         0x0300ff02,
2922         SSL_kRSA,
2923         SSL_aRSA,
2924         SSL_eGOST2814789CNT,
2925         SSL_GOST89MAC,
2926         SSL_TLSV1,
2927         SSL_NOT_EXP|SSL_HIGH,
2928         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2929         256,
2930         256
2931         },
2932         {
2933         1,
2934         "GOST-GOST89STREAM",
2935         0x0300ff03,
2936         SSL_kRSA,
2937         SSL_aRSA,
2938         SSL_eGOST2814789CNT,
2939         SSL_GOST89MAC,
2940         SSL_TLSV1,
2941         SSL_NOT_EXP|SSL_HIGH,
2942         SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF|TLS1_STREAM_MAC,
2943         256,
2944         256
2945         },
2946 #endif
2947
2948 #if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305)
2949         {
2950         1,
2951         TLS1_TXT_ECDHE_RSA_WITH_CHACHA20_POLY1305,
2952         TLS1_CK_ECDHE_RSA_CHACHA20_POLY1305,
2953         SSL_kEECDH,
2954         SSL_aRSA,
2955         SSL_CHACHA20POLY1305,
2956         SSL_AEAD,
2957         SSL_TLSV1_2,
2958         SSL_NOT_EXP|SSL_HIGH,
2959         SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256|SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(0),
2960         256,
2961         0,
2962         },
2963
2964         {
2965         1,
2966         TLS1_TXT_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
2967         TLS1_CK_ECDHE_ECDSA_CHACHA20_POLY1305,
2968         SSL_kEECDH,
2969         SSL_aECDSA,
2970         SSL_CHACHA20POLY1305,
2971         SSL_AEAD,
2972         SSL_TLSV1_2,
2973         SSL_NOT_EXP|SSL_HIGH,
2974         SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256|SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(0),
2975         256,
2976         0,
2977         },
2978
2979         {
2980         1,
2981         TLS1_TXT_DHE_RSA_WITH_CHACHA20_POLY1305,
2982         TLS1_CK_DHE_RSA_CHACHA20_POLY1305,
2983         SSL_kEDH,
2984         SSL_aRSA,
2985         SSL_CHACHA20POLY1305,
2986         SSL_AEAD,
2987         SSL_TLSV1_2,
2988         SSL_NOT_EXP|SSL_HIGH,
2989         SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256|SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(0),
2990         256,
2991         0,
2992         },
2993 #endif
2994
2995 /* end of list */
2996         };
2997
2998 SSL3_ENC_METHOD SSLv3_enc_data={
2999         ssl3_enc,
3000         n_ssl3_mac,
3001         ssl3_setup_key_block,
3002         ssl3_generate_master_secret,
3003         ssl3_change_cipher_state,
3004         ssl3_final_finish_mac,
3005         MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH,
3006         ssl3_cert_verify_mac,
3007         SSL3_MD_CLIENT_FINISHED_CONST,4,
3008         SSL3_MD_SERVER_FINISHED_CONST,4,
3009         ssl3_alert_code,
3010         (int (*)(SSL *, unsigned char *, size_t, const char *,
3011                  size_t, const unsigned char *, size_t,
3012                  int use_context))ssl_undefined_function,
3013         0,
3014         SSL3_HM_HEADER_LENGTH,
3015         ssl3_set_handshake_header,
3016         ssl3_handshake_write
3017         };
3018
3019 long ssl3_default_timeout(void)
3020         {
3021         /* 2 hours, the 24 hours mentioned in the SSLv3 spec
3022          * is way too long for http, the cache would over fill */
3023         return(60*60*2);
3024         }
3025
3026 int ssl3_num_ciphers(void)
3027         {
3028         return(SSL3_NUM_CIPHERS);
3029         }
3030
3031 const SSL_CIPHER *ssl3_get_cipher(unsigned int u)
3032         {
3033         if (u < SSL3_NUM_CIPHERS)
3034                 return(&(ssl3_ciphers[SSL3_NUM_CIPHERS-1-u]));
3035         else
3036                 return(NULL);
3037         }
3038
3039 int ssl3_pending(const SSL *s)
3040         {
3041         if (s->rstate == SSL_ST_READ_BODY)
3042                 return 0;
3043         
3044         return (s->s3->rrec.type == SSL3_RT_APPLICATION_DATA) ? s->s3->rrec.length : 0;
3045         }
3046
3047 void ssl3_set_handshake_header(SSL *s, int htype, unsigned long len)
3048         {
3049         unsigned char *p = (unsigned char *)s->init_buf->data;
3050         *(p++) = htype;
3051         l2n3(len, p);
3052         s->init_num = (int)len + SSL3_HM_HEADER_LENGTH;
3053         s->init_off = 0;
3054         }
3055
3056 int ssl3_handshake_write(SSL *s)
3057         {
3058         return ssl3_do_write(s, SSL3_RT_HANDSHAKE);
3059         }
3060
3061 int ssl3_new(SSL *s)
3062         {
3063         SSL3_STATE *s3;
3064
3065         if ((s3=OPENSSL_malloc(sizeof *s3)) == NULL) goto err;
3066         memset(s3,0,sizeof *s3);
3067         memset(s3->rrec.seq_num,0,sizeof(s3->rrec.seq_num));
3068         memset(s3->wrec.seq_num,0,sizeof(s3->wrec.seq_num));
3069
3070         s->s3=s3;
3071
3072 #ifndef OPENSSL_NO_SRP
3073         SSL_SRP_CTX_init(s);
3074 #endif
3075         s->method->ssl_clear(s);
3076         return(1);
3077 err:
3078         return(0);
3079         }
3080
3081 void ssl3_free(SSL *s)
3082         {
3083         if(s == NULL)
3084             return;
3085
3086 #ifdef TLSEXT_TYPE_opaque_prf_input
3087         if (s->s3->client_opaque_prf_input != NULL)
3088                 OPENSSL_free(s->s3->client_opaque_prf_input);
3089         if (s->s3->server_opaque_prf_input != NULL)
3090                 OPENSSL_free(s->s3->server_opaque_prf_input);
3091 #endif
3092
3093         ssl3_cleanup_key_block(s);
3094         if (s->s3->rbuf.buf != NULL)
3095                 ssl3_release_read_buffer(s);
3096         if (s->s3->wbuf.buf != NULL)
3097                 ssl3_release_write_buffer(s);
3098         if (s->s3->rrec.comp != NULL)
3099                 OPENSSL_free(s->s3->rrec.comp);
3100 #ifndef OPENSSL_NO_DH
3101         if (s->s3->tmp.dh != NULL)
3102                 DH_free(s->s3->tmp.dh);
3103 #endif
3104 #ifndef OPENSSL_NO_ECDH
3105         if (s->s3->tmp.ecdh != NULL)
3106                 EC_KEY_free(s->s3->tmp.ecdh);
3107 #endif
3108
3109         if (s->s3->tmp.ca_names != NULL)
3110                 sk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free);
3111         if (s->s3->handshake_buffer) {
3112                 BIO_free(s->s3->handshake_buffer);
3113         }
3114         if (s->s3->handshake_dgst) ssl3_free_digest_list(s);
3115 #ifndef OPENSSL_NO_TLSEXT
3116         if (s->s3->alpn_selected)
3117                 OPENSSL_free(s->s3->alpn_selected);
3118 #endif
3119
3120 #ifndef OPENSSL_NO_SRP
3121         SSL_SRP_CTX_free(s);
3122 #endif
3123 #ifndef OPENSSL_NO_TLSEXT
3124         if (s->s3->tlsext_authz_client_types != NULL)
3125                 OPENSSL_free(s->s3->tlsext_authz_client_types);
3126         if (s->s3->tlsext_custom_types != NULL)
3127                 OPENSSL_free(s->s3->tlsext_custom_types);
3128 #endif
3129         OPENSSL_cleanse(s->s3,sizeof *s->s3);
3130         OPENSSL_free(s->s3);
3131         s->s3=NULL;
3132         }
3133
3134 void ssl3_clear(SSL *s)
3135         {
3136         unsigned char *rp,*wp;
3137         size_t rlen, wlen;
3138         int init_extra;
3139
3140 #ifdef TLSEXT_TYPE_opaque_prf_input
3141         if (s->s3->client_opaque_prf_input != NULL)
3142                 OPENSSL_free(s->s3->client_opaque_prf_input);
3143         s->s3->client_opaque_prf_input = NULL;
3144         if (s->s3->server_opaque_prf_input != NULL)
3145                 OPENSSL_free(s->s3->server_opaque_prf_input);
3146         s->s3->server_opaque_prf_input = NULL;
3147 #endif
3148
3149         ssl3_cleanup_key_block(s);
3150         if (s->s3->tmp.ca_names != NULL)
3151                 sk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free);
3152
3153         if (s->s3->rrec.comp != NULL)
3154                 {
3155                 OPENSSL_free(s->s3->rrec.comp);
3156                 s->s3->rrec.comp=NULL;
3157                 }
3158 #ifndef OPENSSL_NO_DH
3159         if (s->s3->tmp.dh != NULL)
3160                 {
3161                 DH_free(s->s3->tmp.dh);
3162                 s->s3->tmp.dh = NULL;
3163                 }
3164 #endif
3165 #ifndef OPENSSL_NO_ECDH
3166         if (s->s3->tmp.ecdh != NULL)
3167                 {
3168                 EC_KEY_free(s->s3->tmp.ecdh);
3169                 s->s3->tmp.ecdh = NULL;
3170                 }
3171 #endif
3172 #ifndef OPENSSL_NO_TLSEXT
3173         if (s->s3->tlsext_authz_client_types != NULL)
3174                 {
3175                 OPENSSL_free(s->s3->tlsext_authz_client_types);
3176                 s->s3->tlsext_authz_client_types = NULL;
3177                 }
3178         if (s->s3->tlsext_custom_types != NULL)
3179                 {
3180                 OPENSSL_free(s->s3->tlsext_custom_types);
3181                 s->s3->tlsext_custom_types = NULL;
3182                 }
3183         s->s3->tlsext_custom_types_count = 0;   
3184 #ifndef OPENSSL_NO_EC
3185         s->s3->is_probably_safari = 0;
3186 #endif /* !OPENSSL_NO_EC */
3187 #endif /* !OPENSSL_NO_TLSEXT */
3188
3189         rp = s->s3->rbuf.buf;
3190         wp = s->s3->wbuf.buf;
3191         rlen = s->s3->rbuf.len;
3192         wlen = s->s3->wbuf.len;
3193         init_extra = s->s3->init_extra;
3194         if (s->s3->handshake_buffer) {
3195                 BIO_free(s->s3->handshake_buffer);
3196                 s->s3->handshake_buffer = NULL;
3197         }
3198         if (s->s3->handshake_dgst) {
3199                 ssl3_free_digest_list(s);
3200         }       
3201
3202 #if !defined(OPENSSL_NO_TLSEXT)
3203         if (s->s3->alpn_selected)
3204                 {
3205                 free(s->s3->alpn_selected);
3206                 s->s3->alpn_selected = NULL;
3207                 }
3208 #endif
3209         memset(s->s3,0,sizeof *s->s3);
3210         s->s3->rbuf.buf = rp;
3211         s->s3->wbuf.buf = wp;
3212         s->s3->rbuf.len = rlen;
3213         s->s3->wbuf.len = wlen;
3214         s->s3->init_extra = init_extra;
3215
3216         ssl_free_wbio_buffer(s);
3217
3218         s->packet_length=0;
3219         s->s3->renegotiate=0;
3220         s->s3->total_renegotiations=0;
3221         s->s3->num_renegotiations=0;
3222         s->s3->in_read_app_data=0;
3223         s->version=SSL3_VERSION;
3224
3225 #if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
3226         if (s->next_proto_negotiated)
3227                 {
3228                 OPENSSL_free(s->next_proto_negotiated);
3229                 s->next_proto_negotiated = NULL;
3230                 s->next_proto_negotiated_len = 0;
3231                 }
3232 #endif
3233         }
3234
3235 #ifndef OPENSSL_NO_SRP
3236 static char * MS_CALLBACK srp_password_from_info_cb(SSL *s, void *arg)
3237         {
3238         return BUF_strdup(s->srp_ctx.info) ;
3239         }
3240 #endif
3241
3242 static int ssl3_set_req_cert_type(CERT *c, const unsigned char *p, size_t len);
3243
3244 long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg)
3245         {
3246         int ret=0;
3247
3248 #if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA)
3249         if (
3250 #ifndef OPENSSL_NO_RSA
3251             cmd == SSL_CTRL_SET_TMP_RSA ||
3252             cmd == SSL_CTRL_SET_TMP_RSA_CB ||
3253 #endif
3254 #ifndef OPENSSL_NO_DSA
3255             cmd == SSL_CTRL_SET_TMP_DH ||
3256             cmd == SSL_CTRL_SET_TMP_DH_CB ||
3257 #endif
3258                 0)
3259                 {
3260                 if (!ssl_cert_inst(&s->cert))
3261                         {
3262                         SSLerr(SSL_F_SSL3_CTRL, ERR_R_MALLOC_FAILURE);
3263                         return(0);
3264                         }
3265                 }
3266 #endif
3267
3268         switch (cmd)
3269                 {
3270         case SSL_CTRL_GET_SESSION_REUSED:
3271                 ret=s->hit;
3272                 break;
3273         case SSL_CTRL_GET_CLIENT_CERT_REQUEST:
3274                 break;
3275         case SSL_CTRL_GET_NUM_RENEGOTIATIONS:
3276                 ret=s->s3->num_renegotiations;
3277                 break;
3278         case SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS:
3279                 ret=s->s3->num_renegotiations;
3280                 s->s3->num_renegotiations=0;
3281                 break;
3282         case SSL_CTRL_GET_TOTAL_RENEGOTIATIONS:
3283                 ret=s->s3->total_renegotiations;
3284                 break;
3285         case SSL_CTRL_GET_FLAGS:
3286                 ret=(int)(s->s3->flags);
3287                 break;
3288 #ifndef OPENSSL_NO_RSA
3289         case SSL_CTRL_NEED_TMP_RSA:
3290                 if ((s->cert != NULL) && (s->cert->rsa_tmp == NULL) &&
3291                     ((s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) ||
3292                      (EVP_PKEY_size(s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey) > (512/8))))
3293                         ret = 1;
3294                 break;
3295         case SSL_CTRL_SET_TMP_RSA:
3296                 {
3297                         RSA *rsa = (RSA *)parg;
3298                         if (rsa == NULL)
3299                                 {
3300                                 SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
3301                                 return(ret);
3302                                 }
3303                         if ((rsa = RSAPrivateKey_dup(rsa)) == NULL)
3304                                 {
3305                                 SSLerr(SSL_F_SSL3_CTRL, ERR_R_RSA_LIB);
3306                                 return(ret);
3307                                 }
3308                         if (s->cert->rsa_tmp != NULL)
3309                                 RSA_free(s->cert->rsa_tmp);
3310                         s->cert->rsa_tmp = rsa;
3311                         ret = 1;
3312                 }
3313                 break;
3314         case SSL_CTRL_SET_TMP_RSA_CB:
3315                 {
3316                 SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3317                 return(ret);
3318                 }
3319                 break;
3320 #endif
3321 #ifndef OPENSSL_NO_DH
3322         case SSL_CTRL_SET_TMP_DH:
3323                 {
3324                         DH *dh = (DH *)parg;
3325                         if (dh == NULL)
3326                                 {
3327                                 SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
3328                                 return(ret);
3329                                 }
3330                         if ((dh = DHparams_dup(dh)) == NULL)
3331                                 {
3332                                 SSLerr(SSL_F_SSL3_CTRL, ERR_R_DH_LIB);
3333                                 return(ret);
3334                                 }
3335                         if (!(s->options & SSL_OP_SINGLE_DH_USE))
3336                                 {
3337                                 if (!DH_generate_key(dh))
3338                                         {
3339                                         DH_free(dh);
3340                                         SSLerr(SSL_F_SSL3_CTRL, ERR_R_DH_LIB);
3341                                         return(ret);
3342                                         }
3343                                 }
3344                         if (s->cert->dh_tmp != NULL)
3345                                 DH_free(s->cert->dh_tmp);
3346                         s->cert->dh_tmp = dh;
3347                         ret = 1;
3348                 }
3349                 break;
3350         case SSL_CTRL_SET_TMP_DH_CB:
3351                 {
3352                 SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3353                 return(ret);
3354                 }
3355                 break;
3356 #endif
3357 #ifndef OPENSSL_NO_ECDH
3358         case SSL_CTRL_SET_TMP_ECDH:
3359                 {
3360                 EC_KEY *ecdh = NULL;
3361                         
3362                 if (parg == NULL)
3363                         {
3364                         SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
3365                         return(ret);
3366                         }
3367                 if (!EC_KEY_up_ref((EC_KEY *)parg))
3368                         {
3369                         SSLerr(SSL_F_SSL3_CTRL,ERR_R_ECDH_LIB);
3370                         return(ret);
3371                         }
3372                 ecdh = (EC_KEY *)parg;
3373                 if (!(s->options & SSL_OP_SINGLE_ECDH_USE))
3374                         {
3375                         if (!EC_KEY_generate_key(ecdh))
3376                                 {
3377                                 EC_KEY_free(ecdh);
3378                                 SSLerr(SSL_F_SSL3_CTRL,ERR_R_ECDH_LIB);
3379                                 return(ret);
3380                                 }
3381                         }
3382                 if (s->cert->ecdh_tmp != NULL)
3383                         EC_KEY_free(s->cert->ecdh_tmp);
3384                 s->cert->ecdh_tmp = ecdh;
3385                 ret = 1;
3386                 }
3387                 break;
3388         case SSL_CTRL_SET_TMP_ECDH_CB:
3389                 {
3390                 SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3391                 return(ret);
3392                 }
3393                 break;
3394 #endif /* !OPENSSL_NO_ECDH */
3395 #ifndef OPENSSL_NO_TLSEXT
3396         case SSL_CTRL_SET_TLSEXT_HOSTNAME:
3397                 if (larg == TLSEXT_NAMETYPE_host_name)
3398                         {
3399                         if (s->tlsext_hostname != NULL) 
3400                                 OPENSSL_free(s->tlsext_hostname);
3401                         s->tlsext_hostname = NULL;
3402
3403                         ret = 1;
3404                         if (parg == NULL) 
3405                                 break;
3406                         if (strlen((char *)parg) > TLSEXT_MAXLEN_host_name)
3407                                 {
3408                                 SSLerr(SSL_F_SSL3_CTRL, SSL_R_SSL3_EXT_INVALID_SERVERNAME);
3409                                 return 0;
3410                                 }
3411                         if ((s->tlsext_hostname = BUF_strdup((char *)parg)) == NULL)
3412                                 {
3413                                 SSLerr(SSL_F_SSL3_CTRL, ERR_R_INTERNAL_ERROR);
3414                                 return 0;
3415                                 }
3416                         }
3417                 else
3418                         {
3419                         SSLerr(SSL_F_SSL3_CTRL, SSL_R_SSL3_EXT_INVALID_SERVERNAME_TYPE);
3420                         return 0;
3421                         }
3422                 break;
3423         case SSL_CTRL_SET_TLSEXT_DEBUG_ARG:
3424                 s->tlsext_debug_arg=parg;
3425                 ret = 1;
3426                 break;
3427
3428 #ifdef TLSEXT_TYPE_opaque_prf_input
3429         case SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT:
3430                 if (larg > 12288) /* actual internal limit is 2^16 for the complete hello message
3431                                    * (including the cert chain and everything) */
3432                         {
3433                         SSLerr(SSL_F_SSL3_CTRL, SSL_R_OPAQUE_PRF_INPUT_TOO_LONG);
3434                         break;
3435                         }
3436                 if (s->tlsext_opaque_prf_input != NULL)
3437                         OPENSSL_free(s->tlsext_opaque_prf_input);
3438                 if ((size_t)larg == 0)
3439                         s->tlsext_opaque_prf_input = OPENSSL_malloc(1); /* dummy byte just to get non-NULL */
3440                 else
3441                         s->tlsext_opaque_prf_input = BUF_memdup(parg, (size_t)larg);
3442                 if (s->tlsext_opaque_prf_input != NULL)
3443                         {
3444                         s->tlsext_opaque_prf_input_len = (size_t)larg;
3445                         ret = 1;
3446                         }
3447                 else
3448                         s->tlsext_opaque_prf_input_len = 0;
3449                 break;
3450 #endif
3451
3452         case SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE:
3453                 s->tlsext_status_type=larg;
3454                 ret = 1;
3455                 break;
3456
3457         case SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS:
3458                 *(STACK_OF(X509_EXTENSION) **)parg = s->tlsext_ocsp_exts;
3459                 ret = 1;
3460                 break;
3461
3462         case SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS:
3463                 s->tlsext_ocsp_exts = parg;
3464                 ret = 1;
3465                 break;
3466
3467         case SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS:
3468                 *(STACK_OF(OCSP_RESPID) **)parg = s->tlsext_ocsp_ids;
3469                 ret = 1;
3470                 break;
3471
3472         case SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS:
3473                 s->tlsext_ocsp_ids = parg;
3474                 ret = 1;
3475                 break;
3476
3477         case SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP:
3478                 *(unsigned char **)parg = s->tlsext_ocsp_resp;
3479                 return s->tlsext_ocsp_resplen;
3480                 
3481         case SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP:
3482                 if (s->tlsext_ocsp_resp)
3483                         OPENSSL_free(s->tlsext_ocsp_resp);
3484                 s->tlsext_ocsp_resp = parg;
3485                 s->tlsext_ocsp_resplen = larg;
3486                 ret = 1;
3487                 break;
3488
3489 #ifndef OPENSSL_NO_HEARTBEATS
3490         case SSL_CTRL_TLS_EXT_SEND_HEARTBEAT:
3491                 if (SSL_IS_DTLS(s))
3492                         ret = dtls1_heartbeat(s);
3493                 else
3494                         ret = tls1_heartbeat(s);
3495                 break;
3496
3497         case SSL_CTRL_GET_TLS_EXT_HEARTBEAT_PENDING:
3498                 ret = s->tlsext_hb_pending;
3499                 break;
3500
3501         case SSL_CTRL_SET_TLS_EXT_HEARTBEAT_NO_REQUESTS:
3502                 if (larg)
3503                         s->tlsext_heartbeat |= SSL_TLSEXT_HB_DONT_RECV_REQUESTS;
3504                 else
3505                         s->tlsext_heartbeat &= ~SSL_TLSEXT_HB_DONT_RECV_REQUESTS;
3506                 ret = 1;
3507                 break;
3508 #endif
3509
3510 #endif /* !OPENSSL_NO_TLSEXT */
3511
3512         case SSL_CTRL_CHAIN:
3513                 if (larg)
3514                         return ssl_cert_set1_chain(s->cert,
3515                                                 (STACK_OF (X509) *)parg);
3516                 else
3517                         return ssl_cert_set0_chain(s->cert,
3518                                                 (STACK_OF (X509) *)parg);
3519
3520         case SSL_CTRL_CHAIN_CERT:
3521                 if (larg)
3522                         return ssl_cert_add1_chain_cert(s->cert, (X509 *)parg);
3523                 else
3524                         return ssl_cert_add0_chain_cert(s->cert, (X509 *)parg);
3525
3526 #ifndef OPENSSL_NO_EC
3527         case SSL_CTRL_GET_CURVES:
3528                 {
3529                 unsigned char *clist;
3530                 size_t clistlen;
3531                 if (!s->session)
3532                         return 0;
3533                 clist = s->session->tlsext_ellipticcurvelist;
3534                 clistlen = s->session->tlsext_ellipticcurvelist_length / 2;
3535                 if (parg)
3536                         {
3537                         size_t i;
3538                         int *cptr = parg;
3539                         unsigned int cid, nid;
3540                         for (i = 0; i < clistlen; i++)
3541                                 {
3542                                 n2s(clist, cid);
3543                                 nid = tls1_ec_curve_id2nid(cid);
3544                                 if (nid != 0)
3545                                         cptr[i] = nid;
3546                                 else
3547                                         cptr[i] = TLSEXT_nid_unknown | cid;
3548                                 }
3549                         }
3550                 return (int)clistlen;
3551                 }
3552
3553         case SSL_CTRL_SET_CURVES:
3554                 return tls1_set_curves(&s->tlsext_ellipticcurvelist,
3555                                         &s->tlsext_ellipticcurvelist_length,
3556                                                                 parg, larg);
3557
3558         case SSL_CTRL_SET_CURVES_LIST:
3559                 return tls1_set_curves_list(&s->tlsext_ellipticcurvelist,
3560                                         &s->tlsext_ellipticcurvelist_length,
3561                                                                 parg);
3562
3563         case SSL_CTRL_GET_SHARED_CURVE:
3564                 return tls1_shared_curve(s, larg);
3565
3566         case SSL_CTRL_SET_ECDH_AUTO:
3567                 s->cert->ecdh_tmp_auto = larg;
3568                 return 1;
3569 #endif
3570         case SSL_CTRL_SET_SIGALGS:
3571                 return tls1_set_sigalgs(s->cert, parg, larg, 0);
3572
3573         case SSL_CTRL_SET_SIGALGS_LIST:
3574                 return tls1_set_sigalgs_list(s->cert, parg, 0);
3575
3576         case SSL_CTRL_SET_CLIENT_SIGALGS:
3577                 return tls1_set_sigalgs(s->cert, parg, larg, 1);
3578
3579         case SSL_CTRL_SET_CLIENT_SIGALGS_LIST:
3580                 return tls1_set_sigalgs_list(s->cert, parg, 1);
3581
3582         case SSL_CTRL_GET_CLIENT_CERT_TYPES:
3583                 {
3584                 const unsigned char **pctype = parg;
3585                 if (s->server || !s->s3->tmp.cert_req)
3586                         return 0;
3587                 if (s->cert->ctypes)
3588                         {
3589                         if (pctype)
3590                                 *pctype = s->cert->ctypes;
3591                         return (int)s->cert->ctype_num;
3592                         }
3593                 if (pctype)
3594                         *pctype = (unsigned char *)s->s3->tmp.ctype;
3595                 return s->s3->tmp.ctype_num;
3596                 }
3597
3598         case SSL_CTRL_SET_CLIENT_CERT_TYPES:
3599                 if (!s->server)
3600                         return 0;
3601                 return ssl3_set_req_cert_type(s->cert, parg, larg);
3602
3603         case SSL_CTRL_BUILD_CERT_CHAIN:
3604                 return ssl_build_cert_chain(s->cert, s->ctx->cert_store, larg);
3605
3606         case SSL_CTRL_SET_VERIFY_CERT_STORE:
3607                 return ssl_cert_set_cert_store(s->cert, parg, 0, larg);
3608
3609         case SSL_CTRL_SET_CHAIN_CERT_STORE:
3610                 return ssl_cert_set_cert_store(s->cert, parg, 1, larg);
3611
3612         case SSL_CTRL_GET_PEER_SIGNATURE_NID:
3613                 if (SSL_USE_SIGALGS(s))
3614                         {
3615                         if (s->session && s->session->sess_cert)
3616                                 {
3617                                 const EVP_MD *sig;
3618                                 sig = s->session->sess_cert->peer_key->digest;
3619                                 if (sig)
3620                                         {
3621                                         *(int *)parg = EVP_MD_type(sig);
3622                                         return 1;
3623                                         }
3624                                 }
3625                         return 0;
3626                         }
3627                 /* Might want to do something here for other versions */
3628                 else
3629                         return 0;
3630
3631         case SSL_CTRL_GET_SERVER_TMP_KEY:
3632                 if (s->server || !s->session || !s->session->sess_cert)
3633                         return 0;
3634                 else
3635                         {
3636                         SESS_CERT *sc;
3637                         EVP_PKEY *ptmp;
3638                         int rv = 0;
3639                         sc = s->session->sess_cert;
3640 #if !defined(OPENSSL_NO_RSA) && !defined(OPENSSL_NO_DH) && !defined(OPENSSL_NO_EC)
3641                         if (!sc->peer_rsa_tmp && !sc->peer_dh_tmp
3642                                                         && !sc->peer_ecdh_tmp)
3643                                 return 0;
3644 #endif
3645                         ptmp = EVP_PKEY_new();
3646                         if (!ptmp)
3647                                 return 0;
3648                         if (0);
3649 #ifndef OPENSSL_NO_RSA
3650                         else if (sc->peer_rsa_tmp)
3651                                 rv = EVP_PKEY_set1_RSA(ptmp, sc->peer_rsa_tmp);
3652 #endif
3653 #ifndef OPENSSL_NO_DH
3654                         else if (sc->peer_dh_tmp)
3655                                 rv = EVP_PKEY_set1_DH(ptmp, sc->peer_dh_tmp);
3656 #endif
3657 #ifndef OPENSSL_NO_ECDH
3658                         else if (sc->peer_ecdh_tmp)
3659                                 rv = EVP_PKEY_set1_EC_KEY(ptmp, sc->peer_ecdh_tmp);
3660 #endif
3661                         if (rv)
3662                                 {
3663                                 *(EVP_PKEY **)parg = ptmp;
3664                                 return 1;
3665                                 }
3666                         EVP_PKEY_free(ptmp);
3667                         return 0;
3668                         }
3669 #ifndef OPENSSL_NO_EC
3670         case SSL_CTRL_GET_EC_POINT_FORMATS:
3671                 {
3672                 SSL_SESSION *sess = s->session;
3673                 const unsigned char **pformat = parg;
3674                 if (!sess || !sess->tlsext_ecpointformatlist)
3675                         return 0;
3676                 *pformat = sess->tlsext_ecpointformatlist;
3677                 return (int)sess->tlsext_ecpointformatlist_length;
3678                 }
3679 #endif
3680         default:
3681                 break;
3682                 }
3683         return(ret);
3684         }
3685
3686 long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp)(void))
3687         {
3688         int ret=0;
3689
3690 #if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA)
3691         if (
3692 #ifndef OPENSSL_NO_RSA
3693             cmd == SSL_CTRL_SET_TMP_RSA_CB ||
3694 #endif
3695 #ifndef OPENSSL_NO_DSA
3696             cmd == SSL_CTRL_SET_TMP_DH_CB ||
3697 #endif
3698                 0)
3699                 {
3700                 if (!ssl_cert_inst(&s->cert))
3701                         {
3702                         SSLerr(SSL_F_SSL3_CALLBACK_CTRL, ERR_R_MALLOC_FAILURE);
3703                         return(0);
3704                         }
3705                 }
3706 #endif
3707
3708         switch (cmd)
3709                 {
3710 #ifndef OPENSSL_NO_RSA
3711         case SSL_CTRL_SET_TMP_RSA_CB:
3712                 {
3713                 s->cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
3714                 }
3715                 break;
3716 #endif
3717 #ifndef OPENSSL_NO_DH
3718         case SSL_CTRL_SET_TMP_DH_CB:
3719                 {
3720                 s->cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
3721                 }
3722                 break;
3723 #endif
3724 #ifndef OPENSSL_NO_ECDH
3725         case SSL_CTRL_SET_TMP_ECDH_CB:
3726                 {
3727                 s->cert->ecdh_tmp_cb = (EC_KEY *(*)(SSL *, int, int))fp;
3728                 }
3729                 break;
3730 #endif
3731 #ifndef OPENSSL_NO_TLSEXT
3732         case SSL_CTRL_SET_TLSEXT_DEBUG_CB:
3733                 s->tlsext_debug_cb=(void (*)(SSL *,int ,int,
3734                                         unsigned char *, int, void *))fp;
3735                 break;
3736 #endif
3737         default:
3738                 break;
3739                 }
3740         return(ret);
3741         }
3742
3743 long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg)
3744         {
3745         CERT *cert;
3746
3747         cert=ctx->cert;
3748
3749         switch (cmd)
3750                 {
3751 #ifndef OPENSSL_NO_RSA
3752         case SSL_CTRL_NEED_TMP_RSA:
3753                 if (    (cert->rsa_tmp == NULL) &&
3754                         ((cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) ||
3755                          (EVP_PKEY_size(cert->pkeys[SSL_PKEY_RSA_ENC].privatekey) > (512/8)))
3756                         )
3757                         return(1);
3758                 else
3759                         return(0);
3760                 /* break; */
3761         case SSL_CTRL_SET_TMP_RSA:
3762                 {
3763                 RSA *rsa;
3764                 int i;
3765
3766                 rsa=(RSA *)parg;
3767                 i=1;
3768                 if (rsa == NULL)
3769                         i=0;
3770                 else
3771                         {
3772                         if ((rsa=RSAPrivateKey_dup(rsa)) == NULL)