2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
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.
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).
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.
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
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)"
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
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.]
58 /* ====================================================================
59 * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved.
61 * Redistribution and use in source and binary forms, with or without
62 * modification, are permitted provided that the following conditions
65 * 1. Redistributions of source code must retain the above copyright
66 * notice, this list of conditions and the following disclaimer.
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
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/)"
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.
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.
87 * 6. Redistributions of any form whatsoever must retain the following
89 * "This product includes software developed by the OpenSSL Project
90 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
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 * ====================================================================
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).
111 /* ====================================================================
112 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
114 * Portions of the attached software ("Contribution") are developed by
115 * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
117 * The Contribution is licensed pursuant to the OpenSSL open source
118 * license provided above.
120 * ECC cipher suite support in OpenSSL originally written by
121 * Vipul Gupta and Sumit Gupta of Sun Microsystems Laboratories.
124 /* ====================================================================
125 * Copyright 2005 Nokia. All rights reserved.
127 * The portions of the attached software ("Contribution") is developed by
128 * Nokia Corporation and is licensed pursuant to the OpenSSL open source
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.
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.
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.
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
152 #include <openssl/objects.h>
153 #include "ssl_locl.h"
154 #include "kssl_lcl.h"
155 #ifndef OPENSSL_NO_TLSEXT
156 # ifndef OPENSSL_NO_EC
157 # include "../crypto/ec/ec_lcl.h"
158 # endif /* OPENSSL_NO_EC */
159 #endif /* OPENSSL_NO_TLSEXT */
160 #include <openssl/md5.h>
161 #ifndef OPENSSL_NO_DH
162 # include <openssl/dh.h>
165 const char ssl3_version_str
[] = "SSLv3" OPENSSL_VERSION_PTEXT
;
167 #define SSL3_NUM_CIPHERS (sizeof(ssl3_ciphers)/sizeof(SSL_CIPHER))
169 /* list of available SSLv3 ciphers (sorted by id) */
170 OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers
[] = {
172 /* The RSA ciphers */
176 SSL3_TXT_RSA_NULL_MD5
,
177 SSL3_CK_RSA_NULL_MD5
,
183 SSL_NOT_EXP
| SSL_STRONG_NONE
,
184 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
192 SSL3_TXT_RSA_NULL_SHA
,
193 SSL3_CK_RSA_NULL_SHA
,
199 SSL_NOT_EXP
| SSL_STRONG_NONE
| SSL_FIPS
,
200 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
208 SSL3_TXT_RSA_RC4_40_MD5
,
209 SSL3_CK_RSA_RC4_40_MD5
,
215 SSL_EXPORT
| SSL_EXP40
,
216 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
224 SSL3_TXT_RSA_RC4_128_MD5
,
225 SSL3_CK_RSA_RC4_128_MD5
,
231 SSL_NOT_EXP
| SSL_MEDIUM
,
232 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
240 SSL3_TXT_RSA_RC4_128_SHA
,
241 SSL3_CK_RSA_RC4_128_SHA
,
247 SSL_NOT_EXP
| SSL_MEDIUM
,
248 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
256 SSL3_TXT_RSA_RC2_40_MD5
,
257 SSL3_CK_RSA_RC2_40_MD5
,
263 SSL_EXPORT
| SSL_EXP40
,
264 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
270 #ifndef OPENSSL_NO_IDEA
273 SSL3_TXT_RSA_IDEA_128_SHA
,
274 SSL3_CK_RSA_IDEA_128_SHA
,
280 SSL_NOT_EXP
| SSL_MEDIUM
,
281 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
290 SSL3_TXT_RSA_DES_40_CBC_SHA
,
291 SSL3_CK_RSA_DES_40_CBC_SHA
,
297 SSL_EXPORT
| SSL_EXP40
,
298 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
306 SSL3_TXT_RSA_DES_64_CBC_SHA
,
307 SSL3_CK_RSA_DES_64_CBC_SHA
,
313 SSL_NOT_EXP
| SSL_LOW
,
314 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
322 SSL3_TXT_RSA_DES_192_CBC3_SHA
,
323 SSL3_CK_RSA_DES_192_CBC3_SHA
,
329 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
330 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
339 SSL3_TXT_DH_DSS_DES_40_CBC_SHA
,
340 SSL3_CK_DH_DSS_DES_40_CBC_SHA
,
346 SSL_EXPORT
| SSL_EXP40
,
347 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
354 0, /* not implemented (non-ephemeral DH) */
355 SSL3_TXT_DH_DSS_DES_64_CBC_SHA
,
356 SSL3_CK_DH_DSS_DES_64_CBC_SHA
,
362 SSL_NOT_EXP
| SSL_LOW
,
363 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
370 0, /* not implemented (non-ephemeral DH) */
371 SSL3_TXT_DH_DSS_DES_192_CBC3_SHA
,
372 SSL3_CK_DH_DSS_DES_192_CBC3_SHA
,
378 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
379 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
386 0, /* not implemented (non-ephemeral DH) */
387 SSL3_TXT_DH_RSA_DES_40_CBC_SHA
,
388 SSL3_CK_DH_RSA_DES_40_CBC_SHA
,
394 SSL_EXPORT
| SSL_EXP40
,
395 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
402 0, /* not implemented (non-ephemeral DH) */
403 SSL3_TXT_DH_RSA_DES_64_CBC_SHA
,
404 SSL3_CK_DH_RSA_DES_64_CBC_SHA
,
410 SSL_NOT_EXP
| SSL_LOW
,
411 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
418 0, /* not implemented (non-ephemeral DH) */
419 SSL3_TXT_DH_RSA_DES_192_CBC3_SHA
,
420 SSL3_CK_DH_RSA_DES_192_CBC3_SHA
,
426 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
427 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
432 /* The Ephemeral DH ciphers */
436 SSL3_TXT_EDH_DSS_DES_40_CBC_SHA
,
437 SSL3_CK_EDH_DSS_DES_40_CBC_SHA
,
443 SSL_EXPORT
| SSL_EXP40
,
444 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
452 SSL3_TXT_EDH_DSS_DES_64_CBC_SHA
,
453 SSL3_CK_EDH_DSS_DES_64_CBC_SHA
,
459 SSL_NOT_EXP
| SSL_LOW
,
460 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
468 SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA
,
469 SSL3_CK_EDH_DSS_DES_192_CBC3_SHA
,
475 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
476 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
484 SSL3_TXT_EDH_RSA_DES_40_CBC_SHA
,
485 SSL3_CK_EDH_RSA_DES_40_CBC_SHA
,
491 SSL_EXPORT
| SSL_EXP40
,
492 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
500 SSL3_TXT_EDH_RSA_DES_64_CBC_SHA
,
501 SSL3_CK_EDH_RSA_DES_64_CBC_SHA
,
507 SSL_NOT_EXP
| SSL_LOW
,
508 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
516 SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA
,
517 SSL3_CK_EDH_RSA_DES_192_CBC3_SHA
,
523 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
524 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
532 SSL3_TXT_ADH_RC4_40_MD5
,
533 SSL3_CK_ADH_RC4_40_MD5
,
539 SSL_EXPORT
| SSL_EXP40
,
540 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
548 SSL3_TXT_ADH_RC4_128_MD5
,
549 SSL3_CK_ADH_RC4_128_MD5
,
555 SSL_NOT_EXP
| SSL_MEDIUM
,
556 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
564 SSL3_TXT_ADH_DES_40_CBC_SHA
,
565 SSL3_CK_ADH_DES_40_CBC_SHA
,
571 SSL_EXPORT
| SSL_EXP40
,
572 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
580 SSL3_TXT_ADH_DES_64_CBC_SHA
,
581 SSL3_CK_ADH_DES_64_CBC_SHA
,
587 SSL_NOT_EXP
| SSL_LOW
,
588 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
596 SSL3_TXT_ADH_DES_192_CBC_SHA
,
597 SSL3_CK_ADH_DES_192_CBC_SHA
,
603 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
604 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
609 /* Fortezza ciphersuite from SSL 3.0 spec */
614 SSL3_TXT_FZA_DMS_NULL_SHA
,
615 SSL3_CK_FZA_DMS_NULL_SHA
,
621 SSL_NOT_EXP
| SSL_STRONG_NONE
,
622 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
630 SSL3_TXT_FZA_DMS_FZA_SHA
,
631 SSL3_CK_FZA_DMS_FZA_SHA
,
637 SSL_NOT_EXP
| SSL_STRONG_NONE
,
638 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
646 SSL3_TXT_FZA_DMS_RC4_SHA
,
647 SSL3_CK_FZA_DMS_RC4_SHA
,
653 SSL_NOT_EXP
| SSL_MEDIUM
,
654 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
660 #ifndef OPENSSL_NO_KRB5
661 /* The Kerberos ciphers*/
665 SSL3_TXT_KRB5_DES_64_CBC_SHA
,
666 SSL3_CK_KRB5_DES_64_CBC_SHA
,
672 SSL_NOT_EXP
| SSL_LOW
,
673 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
681 SSL3_TXT_KRB5_DES_192_CBC3_SHA
,
682 SSL3_CK_KRB5_DES_192_CBC3_SHA
,
688 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
689 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
697 SSL3_TXT_KRB5_RC4_128_SHA
,
698 SSL3_CK_KRB5_RC4_128_SHA
,
704 SSL_NOT_EXP
| SSL_MEDIUM
,
705 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
713 SSL3_TXT_KRB5_IDEA_128_CBC_SHA
,
714 SSL3_CK_KRB5_IDEA_128_CBC_SHA
,
720 SSL_NOT_EXP
| SSL_MEDIUM
,
721 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
729 SSL3_TXT_KRB5_DES_64_CBC_MD5
,
730 SSL3_CK_KRB5_DES_64_CBC_MD5
,
736 SSL_NOT_EXP
| SSL_LOW
,
737 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
745 SSL3_TXT_KRB5_DES_192_CBC3_MD5
,
746 SSL3_CK_KRB5_DES_192_CBC3_MD5
,
752 SSL_NOT_EXP
| SSL_HIGH
,
753 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
761 SSL3_TXT_KRB5_RC4_128_MD5
,
762 SSL3_CK_KRB5_RC4_128_MD5
,
768 SSL_NOT_EXP
| SSL_MEDIUM
,
769 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
777 SSL3_TXT_KRB5_IDEA_128_CBC_MD5
,
778 SSL3_CK_KRB5_IDEA_128_CBC_MD5
,
784 SSL_NOT_EXP
| SSL_MEDIUM
,
785 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
793 SSL3_TXT_KRB5_DES_40_CBC_SHA
,
794 SSL3_CK_KRB5_DES_40_CBC_SHA
,
800 SSL_EXPORT
| SSL_EXP40
,
801 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
809 SSL3_TXT_KRB5_RC2_40_CBC_SHA
,
810 SSL3_CK_KRB5_RC2_40_CBC_SHA
,
816 SSL_EXPORT
| SSL_EXP40
,
817 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
825 SSL3_TXT_KRB5_RC4_40_SHA
,
826 SSL3_CK_KRB5_RC4_40_SHA
,
832 SSL_EXPORT
| SSL_EXP40
,
833 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
841 SSL3_TXT_KRB5_DES_40_CBC_MD5
,
842 SSL3_CK_KRB5_DES_40_CBC_MD5
,
848 SSL_EXPORT
| SSL_EXP40
,
849 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
857 SSL3_TXT_KRB5_RC2_40_CBC_MD5
,
858 SSL3_CK_KRB5_RC2_40_CBC_MD5
,
864 SSL_EXPORT
| SSL_EXP40
,
865 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
873 SSL3_TXT_KRB5_RC4_40_MD5
,
874 SSL3_CK_KRB5_RC4_40_MD5
,
880 SSL_EXPORT
| SSL_EXP40
,
881 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
885 #endif /* OPENSSL_NO_KRB5 */
887 /* New AES ciphersuites */
891 TLS1_TXT_RSA_WITH_AES_128_SHA
,
892 TLS1_CK_RSA_WITH_AES_128_SHA
,
898 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
899 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
906 TLS1_TXT_DH_DSS_WITH_AES_128_SHA
,
907 TLS1_CK_DH_DSS_WITH_AES_128_SHA
,
913 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
914 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
921 TLS1_TXT_DH_RSA_WITH_AES_128_SHA
,
922 TLS1_CK_DH_RSA_WITH_AES_128_SHA
,
928 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
929 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
936 TLS1_TXT_DHE_DSS_WITH_AES_128_SHA
,
937 TLS1_CK_DHE_DSS_WITH_AES_128_SHA
,
943 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
944 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
951 TLS1_TXT_DHE_RSA_WITH_AES_128_SHA
,
952 TLS1_CK_DHE_RSA_WITH_AES_128_SHA
,
958 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
959 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
966 TLS1_TXT_ADH_WITH_AES_128_SHA
,
967 TLS1_CK_ADH_WITH_AES_128_SHA
,
973 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
974 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
982 TLS1_TXT_RSA_WITH_AES_256_SHA
,
983 TLS1_CK_RSA_WITH_AES_256_SHA
,
989 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
990 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
997 TLS1_TXT_DH_DSS_WITH_AES_256_SHA
,
998 TLS1_CK_DH_DSS_WITH_AES_256_SHA
,
1004 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1005 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1012 0, /* not implemented (non-ephemeral DH) */
1013 TLS1_TXT_DH_RSA_WITH_AES_256_SHA
,
1014 TLS1_CK_DH_RSA_WITH_AES_256_SHA
,
1020 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1021 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1029 TLS1_TXT_DHE_DSS_WITH_AES_256_SHA
,
1030 TLS1_CK_DHE_DSS_WITH_AES_256_SHA
,
1036 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1037 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1045 TLS1_TXT_DHE_RSA_WITH_AES_256_SHA
,
1046 TLS1_CK_DHE_RSA_WITH_AES_256_SHA
,
1052 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1053 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1061 TLS1_TXT_ADH_WITH_AES_256_SHA
,
1062 TLS1_CK_ADH_WITH_AES_256_SHA
,
1068 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1069 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1074 /* TLS v1.2 ciphersuites */
1078 TLS1_TXT_RSA_WITH_NULL_SHA256
,
1079 TLS1_CK_RSA_WITH_NULL_SHA256
,
1085 SSL_NOT_EXP
| SSL_STRONG_NONE
| SSL_FIPS
,
1086 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1094 TLS1_TXT_RSA_WITH_AES_128_SHA256
,
1095 TLS1_CK_RSA_WITH_AES_128_SHA256
,
1101 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1102 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1110 TLS1_TXT_RSA_WITH_AES_256_SHA256
,
1111 TLS1_CK_RSA_WITH_AES_256_SHA256
,
1117 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1118 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1125 0, /* not implemented (non-ephemeral DH) */
1126 TLS1_TXT_DH_DSS_WITH_AES_128_SHA256
,
1127 TLS1_CK_DH_DSS_WITH_AES_128_SHA256
,
1133 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1134 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1141 0, /* not implemented (non-ephemeral DH) */
1142 TLS1_TXT_DH_RSA_WITH_AES_128_SHA256
,
1143 TLS1_CK_DH_RSA_WITH_AES_128_SHA256
,
1149 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1150 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1158 TLS1_TXT_DHE_DSS_WITH_AES_128_SHA256
,
1159 TLS1_CK_DHE_DSS_WITH_AES_128_SHA256
,
1165 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1166 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1171 #ifndef OPENSSL_NO_CAMELLIA
1172 /* Camellia ciphersuites from RFC4132 (128-bit portion) */
1177 TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA
,
1178 TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA
,
1184 SSL_NOT_EXP
| SSL_HIGH
,
1185 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1192 0, /* not implemented (non-ephemeral DH) */
1193 TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA
,
1194 TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA
,
1200 SSL_NOT_EXP
| SSL_HIGH
,
1201 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1208 0, /* not implemented (non-ephemeral DH) */
1209 TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA
,
1210 TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA
,
1216 SSL_NOT_EXP
| SSL_HIGH
,
1217 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1225 TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA
,
1226 TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA
,
1232 SSL_NOT_EXP
| SSL_HIGH
,
1233 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1241 TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA
,
1242 TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA
,
1248 SSL_NOT_EXP
| SSL_HIGH
,
1249 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1257 TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA
,
1258 TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA
,
1264 SSL_NOT_EXP
| SSL_HIGH
,
1265 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1269 #endif /* OPENSSL_NO_CAMELLIA */
1271 #if TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES
1272 /* New TLS Export CipherSuites from expired ID */
1277 TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5
,
1278 TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5
,
1284 SSL_EXPORT
| SSL_EXP56
,
1285 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1293 TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5
,
1294 TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5
,
1300 SSL_EXPORT
| SSL_EXP56
,
1301 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1310 TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA
,
1311 TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA
,
1317 SSL_EXPORT
| SSL_EXP56
,
1318 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1326 TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA
,
1327 TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA
,
1333 SSL_EXPORT
| SSL_EXP56
,
1334 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1342 TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA
,
1343 TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA
,
1349 SSL_EXPORT
| SSL_EXP56
,
1350 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1358 TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA
,
1359 TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA
,
1365 SSL_EXPORT
| SSL_EXP56
,
1366 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1374 TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA
,
1375 TLS1_CK_DHE_DSS_WITH_RC4_128_SHA
,
1381 SSL_NOT_EXP
| SSL_MEDIUM
,
1382 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1388 /* TLS v1.2 ciphersuites */
1392 TLS1_TXT_DHE_RSA_WITH_AES_128_SHA256
,
1393 TLS1_CK_DHE_RSA_WITH_AES_128_SHA256
,
1399 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1400 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1407 0, /* not implemented (non-ephemeral DH) */
1408 TLS1_TXT_DH_DSS_WITH_AES_256_SHA256
,
1409 TLS1_CK_DH_DSS_WITH_AES_256_SHA256
,
1415 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1416 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1423 0, /* not implemented (non-ephemeral DH) */
1424 TLS1_TXT_DH_RSA_WITH_AES_256_SHA256
,
1425 TLS1_CK_DH_RSA_WITH_AES_256_SHA256
,
1431 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1432 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1440 TLS1_TXT_DHE_DSS_WITH_AES_256_SHA256
,
1441 TLS1_CK_DHE_DSS_WITH_AES_256_SHA256
,
1447 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1448 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1456 TLS1_TXT_DHE_RSA_WITH_AES_256_SHA256
,
1457 TLS1_CK_DHE_RSA_WITH_AES_256_SHA256
,
1463 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1464 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1472 TLS1_TXT_ADH_WITH_AES_128_SHA256
,
1473 TLS1_CK_ADH_WITH_AES_128_SHA256
,
1479 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1480 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1488 TLS1_TXT_ADH_WITH_AES_256_SHA256
,
1489 TLS1_CK_ADH_WITH_AES_256_SHA256
,
1495 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1496 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1501 /* GOST Ciphersuites */
1505 "GOST94-GOST89-GOST89",
1509 SSL_eGOST2814789CNT
,
1512 SSL_NOT_EXP
| SSL_HIGH
,
1513 SSL_HANDSHAKE_MAC_GOST94
| TLS1_PRF_GOST94
| TLS1_STREAM_MAC
,
1518 "GOST2001-GOST89-GOST89",
1522 SSL_eGOST2814789CNT
,
1525 SSL_NOT_EXP
| SSL_HIGH
,
1526 SSL_HANDSHAKE_MAC_GOST94
| TLS1_PRF_GOST94
| TLS1_STREAM_MAC
,
1531 "GOST94-NULL-GOST94",
1538 SSL_NOT_EXP
| SSL_STRONG_NONE
,
1539 SSL_HANDSHAKE_MAC_GOST94
| TLS1_PRF_GOST94
,
1544 "GOST2001-NULL-GOST94",
1551 SSL_NOT_EXP
| SSL_STRONG_NONE
,
1552 SSL_HANDSHAKE_MAC_GOST94
| TLS1_PRF_GOST94
,
1556 #ifndef OPENSSL_NO_CAMELLIA
1557 /* Camellia ciphersuites from RFC4132 (256-bit portion) */
1562 TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA
,
1563 TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA
,
1569 SSL_NOT_EXP
| SSL_HIGH
,
1570 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1576 0, /* not implemented (non-ephemeral DH) */
1577 TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA
,
1578 TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA
,
1584 SSL_NOT_EXP
| SSL_HIGH
,
1585 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1592 0, /* not implemented (non-ephemeral DH) */
1593 TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA
,
1594 TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA
,
1600 SSL_NOT_EXP
| SSL_HIGH
,
1601 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1609 TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA
,
1610 TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA
,
1616 SSL_NOT_EXP
| SSL_HIGH
,
1617 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1625 TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA
,
1626 TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA
,
1632 SSL_NOT_EXP
| SSL_HIGH
,
1633 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1641 TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA
,
1642 TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA
,
1648 SSL_NOT_EXP
| SSL_HIGH
,
1649 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1653 #endif /* OPENSSL_NO_CAMELLIA */
1655 #ifndef OPENSSL_NO_PSK
1659 TLS1_TXT_PSK_WITH_RC4_128_SHA
,
1660 TLS1_CK_PSK_WITH_RC4_128_SHA
,
1666 SSL_NOT_EXP
| SSL_MEDIUM
,
1667 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1675 TLS1_TXT_PSK_WITH_3DES_EDE_CBC_SHA
,
1676 TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA
,
1682 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1683 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1691 TLS1_TXT_PSK_WITH_AES_128_CBC_SHA
,
1692 TLS1_CK_PSK_WITH_AES_128_CBC_SHA
,
1698 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1699 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1707 TLS1_TXT_PSK_WITH_AES_256_CBC_SHA
,
1708 TLS1_CK_PSK_WITH_AES_256_CBC_SHA
,
1714 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1715 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1719 #endif /* OPENSSL_NO_PSK */
1721 #ifndef OPENSSL_NO_SEED
1722 /* SEED ciphersuites from RFC4162 */
1727 TLS1_TXT_RSA_WITH_SEED_SHA
,
1728 TLS1_CK_RSA_WITH_SEED_SHA
,
1734 SSL_NOT_EXP
| SSL_MEDIUM
,
1735 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1742 0, /* not implemented (non-ephemeral DH) */
1743 TLS1_TXT_DH_DSS_WITH_SEED_SHA
,
1744 TLS1_CK_DH_DSS_WITH_SEED_SHA
,
1750 SSL_NOT_EXP
| SSL_MEDIUM
,
1751 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1758 0, /* not implemented (non-ephemeral DH) */
1759 TLS1_TXT_DH_RSA_WITH_SEED_SHA
,
1760 TLS1_CK_DH_RSA_WITH_SEED_SHA
,
1766 SSL_NOT_EXP
| SSL_MEDIUM
,
1767 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1775 TLS1_TXT_DHE_DSS_WITH_SEED_SHA
,
1776 TLS1_CK_DHE_DSS_WITH_SEED_SHA
,
1782 SSL_NOT_EXP
| SSL_MEDIUM
,
1783 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1791 TLS1_TXT_DHE_RSA_WITH_SEED_SHA
,
1792 TLS1_CK_DHE_RSA_WITH_SEED_SHA
,
1798 SSL_NOT_EXP
| SSL_MEDIUM
,
1799 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1807 TLS1_TXT_ADH_WITH_SEED_SHA
,
1808 TLS1_CK_ADH_WITH_SEED_SHA
,
1814 SSL_NOT_EXP
| SSL_MEDIUM
,
1815 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
1820 #endif /* OPENSSL_NO_SEED */
1822 /* GCM ciphersuites from RFC5288 */
1827 TLS1_TXT_RSA_WITH_AES_128_GCM_SHA256
,
1828 TLS1_CK_RSA_WITH_AES_128_GCM_SHA256
,
1834 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1835 SSL_HANDSHAKE_MAC_SHA256
| TLS1_PRF_SHA256
,
1843 TLS1_TXT_RSA_WITH_AES_256_GCM_SHA384
,
1844 TLS1_CK_RSA_WITH_AES_256_GCM_SHA384
,
1850 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1851 SSL_HANDSHAKE_MAC_SHA384
| TLS1_PRF_SHA384
,
1859 TLS1_TXT_DHE_RSA_WITH_AES_128_GCM_SHA256
,
1860 TLS1_CK_DHE_RSA_WITH_AES_128_GCM_SHA256
,
1866 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1867 SSL_HANDSHAKE_MAC_SHA256
| TLS1_PRF_SHA256
,
1875 TLS1_TXT_DHE_RSA_WITH_AES_256_GCM_SHA384
,
1876 TLS1_CK_DHE_RSA_WITH_AES_256_GCM_SHA384
,
1882 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1883 SSL_HANDSHAKE_MAC_SHA384
| TLS1_PRF_SHA384
,
1891 TLS1_TXT_DH_RSA_WITH_AES_128_GCM_SHA256
,
1892 TLS1_CK_DH_RSA_WITH_AES_128_GCM_SHA256
,
1898 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1899 SSL_HANDSHAKE_MAC_SHA256
| TLS1_PRF_SHA256
,
1907 TLS1_TXT_DH_RSA_WITH_AES_256_GCM_SHA384
,
1908 TLS1_CK_DH_RSA_WITH_AES_256_GCM_SHA384
,
1914 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1915 SSL_HANDSHAKE_MAC_SHA384
| TLS1_PRF_SHA384
,
1923 TLS1_TXT_DHE_DSS_WITH_AES_128_GCM_SHA256
,
1924 TLS1_CK_DHE_DSS_WITH_AES_128_GCM_SHA256
,
1930 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1931 SSL_HANDSHAKE_MAC_SHA256
| TLS1_PRF_SHA256
,
1939 TLS1_TXT_DHE_DSS_WITH_AES_256_GCM_SHA384
,
1940 TLS1_CK_DHE_DSS_WITH_AES_256_GCM_SHA384
,
1946 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1947 SSL_HANDSHAKE_MAC_SHA384
| TLS1_PRF_SHA384
,
1955 TLS1_TXT_DH_DSS_WITH_AES_128_GCM_SHA256
,
1956 TLS1_CK_DH_DSS_WITH_AES_128_GCM_SHA256
,
1962 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1963 SSL_HANDSHAKE_MAC_SHA256
| TLS1_PRF_SHA256
,
1971 TLS1_TXT_DH_DSS_WITH_AES_256_GCM_SHA384
,
1972 TLS1_CK_DH_DSS_WITH_AES_256_GCM_SHA384
,
1978 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1979 SSL_HANDSHAKE_MAC_SHA384
| TLS1_PRF_SHA384
,
1987 TLS1_TXT_ADH_WITH_AES_128_GCM_SHA256
,
1988 TLS1_CK_ADH_WITH_AES_128_GCM_SHA256
,
1994 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
1995 SSL_HANDSHAKE_MAC_SHA256
| TLS1_PRF_SHA256
,
2003 TLS1_TXT_ADH_WITH_AES_256_GCM_SHA384
,
2004 TLS1_CK_ADH_WITH_AES_256_GCM_SHA384
,
2010 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2011 SSL_HANDSHAKE_MAC_SHA384
| TLS1_PRF_SHA384
,
2016 #ifndef OPENSSL_NO_ECDH
2020 TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA
,
2021 TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA
,
2027 SSL_NOT_EXP
| SSL_STRONG_NONE
| SSL_FIPS
,
2028 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2036 TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA
,
2037 TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA
,
2043 SSL_NOT_EXP
| SSL_MEDIUM
,
2044 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2052 TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA
,
2053 TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA
,
2059 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2060 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2068 TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA
,
2069 TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA
,
2075 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2076 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2084 TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA
,
2085 TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA
,
2091 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2092 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2100 TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA
,
2101 TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA
,
2107 SSL_NOT_EXP
| SSL_STRONG_NONE
| SSL_FIPS
,
2108 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2116 TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA
,
2117 TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA
,
2123 SSL_NOT_EXP
| SSL_MEDIUM
,
2124 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2132 TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA
,
2133 TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA
,
2139 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2140 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2148 TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
,
2149 TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
,
2155 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2156 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2164 TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
,
2165 TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
,
2171 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2172 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2180 TLS1_TXT_ECDH_RSA_WITH_NULL_SHA
,
2181 TLS1_CK_ECDH_RSA_WITH_NULL_SHA
,
2187 SSL_NOT_EXP
| SSL_STRONG_NONE
| SSL_FIPS
,
2188 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2196 TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA
,
2197 TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA
,
2203 SSL_NOT_EXP
| SSL_MEDIUM
,
2204 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2212 TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA
,
2213 TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA
,
2219 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2220 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2228 TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA
,
2229 TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA
,
2235 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2236 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2244 TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA
,
2245 TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA
,
2251 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2252 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2260 TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA
,
2261 TLS1_CK_ECDHE_RSA_WITH_NULL_SHA
,
2267 SSL_NOT_EXP
| SSL_STRONG_NONE
| SSL_FIPS
,
2268 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2276 TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA
,
2277 TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA
,
2283 SSL_NOT_EXP
| SSL_MEDIUM
,
2284 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2292 TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA
,
2293 TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA
,
2299 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2300 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2308 TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA
,
2309 TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA
,
2315 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2316 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2324 TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA
,
2325 TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA
,
2331 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2332 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2340 TLS1_TXT_ECDH_anon_WITH_NULL_SHA
,
2341 TLS1_CK_ECDH_anon_WITH_NULL_SHA
,
2347 SSL_NOT_EXP
| SSL_STRONG_NONE
| SSL_FIPS
,
2348 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2356 TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA
,
2357 TLS1_CK_ECDH_anon_WITH_RC4_128_SHA
,
2363 SSL_NOT_EXP
| SSL_MEDIUM
,
2364 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2372 TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA
,
2373 TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA
,
2379 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2380 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2388 TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA
,
2389 TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA
,
2395 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2396 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2404 TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA
,
2405 TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA
,
2411 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2412 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2416 #endif /* OPENSSL_NO_ECDH */
2418 #ifndef OPENSSL_NO_SRP
2422 TLS1_TXT_SRP_SHA_WITH_3DES_EDE_CBC_SHA
,
2423 TLS1_CK_SRP_SHA_WITH_3DES_EDE_CBC_SHA
,
2429 SSL_NOT_EXP
| SSL_HIGH
,
2430 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2438 TLS1_TXT_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA
,
2439 TLS1_CK_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA
,
2445 SSL_NOT_EXP
| SSL_HIGH
,
2446 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2454 TLS1_TXT_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA
,
2455 TLS1_CK_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA
,
2461 SSL_NOT_EXP
| SSL_HIGH
,
2462 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2470 TLS1_TXT_SRP_SHA_WITH_AES_128_CBC_SHA
,
2471 TLS1_CK_SRP_SHA_WITH_AES_128_CBC_SHA
,
2477 SSL_NOT_EXP
| SSL_HIGH
,
2478 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2486 TLS1_TXT_SRP_SHA_RSA_WITH_AES_128_CBC_SHA
,
2487 TLS1_CK_SRP_SHA_RSA_WITH_AES_128_CBC_SHA
,
2493 SSL_NOT_EXP
| SSL_HIGH
,
2494 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2502 TLS1_TXT_SRP_SHA_DSS_WITH_AES_128_CBC_SHA
,
2503 TLS1_CK_SRP_SHA_DSS_WITH_AES_128_CBC_SHA
,
2509 SSL_NOT_EXP
| SSL_HIGH
,
2510 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2518 TLS1_TXT_SRP_SHA_WITH_AES_256_CBC_SHA
,
2519 TLS1_CK_SRP_SHA_WITH_AES_256_CBC_SHA
,
2525 SSL_NOT_EXP
| SSL_HIGH
,
2526 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2534 TLS1_TXT_SRP_SHA_RSA_WITH_AES_256_CBC_SHA
,
2535 TLS1_CK_SRP_SHA_RSA_WITH_AES_256_CBC_SHA
,
2541 SSL_NOT_EXP
| SSL_HIGH
,
2542 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2550 TLS1_TXT_SRP_SHA_DSS_WITH_AES_256_CBC_SHA
,
2551 TLS1_CK_SRP_SHA_DSS_WITH_AES_256_CBC_SHA
,
2557 SSL_NOT_EXP
| SSL_HIGH
,
2558 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2562 #endif /* OPENSSL_NO_SRP */
2563 #ifndef OPENSSL_NO_ECDH
2565 /* HMAC based TLS v1.2 ciphersuites from RFC5289 */
2570 TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_SHA256
,
2571 TLS1_CK_ECDHE_ECDSA_WITH_AES_128_SHA256
,
2577 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2578 SSL_HANDSHAKE_MAC_SHA256
| TLS1_PRF_SHA256
,
2586 TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_SHA384
,
2587 TLS1_CK_ECDHE_ECDSA_WITH_AES_256_SHA384
,
2593 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2594 SSL_HANDSHAKE_MAC_SHA384
| TLS1_PRF_SHA384
,
2602 TLS1_TXT_ECDH_ECDSA_WITH_AES_128_SHA256
,
2603 TLS1_CK_ECDH_ECDSA_WITH_AES_128_SHA256
,
2609 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2610 SSL_HANDSHAKE_MAC_SHA256
| TLS1_PRF_SHA256
,
2618 TLS1_TXT_ECDH_ECDSA_WITH_AES_256_SHA384
,
2619 TLS1_CK_ECDH_ECDSA_WITH_AES_256_SHA384
,
2625 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2626 SSL_HANDSHAKE_MAC_SHA384
| TLS1_PRF_SHA384
,
2634 TLS1_TXT_ECDHE_RSA_WITH_AES_128_SHA256
,
2635 TLS1_CK_ECDHE_RSA_WITH_AES_128_SHA256
,
2641 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2642 SSL_HANDSHAKE_MAC_SHA256
| TLS1_PRF_SHA256
,
2650 TLS1_TXT_ECDHE_RSA_WITH_AES_256_SHA384
,
2651 TLS1_CK_ECDHE_RSA_WITH_AES_256_SHA384
,
2657 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2658 SSL_HANDSHAKE_MAC_SHA384
| TLS1_PRF_SHA384
,
2666 TLS1_TXT_ECDH_RSA_WITH_AES_128_SHA256
,
2667 TLS1_CK_ECDH_RSA_WITH_AES_128_SHA256
,
2673 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2674 SSL_HANDSHAKE_MAC_SHA256
| TLS1_PRF_SHA256
,
2682 TLS1_TXT_ECDH_RSA_WITH_AES_256_SHA384
,
2683 TLS1_CK_ECDH_RSA_WITH_AES_256_SHA384
,
2689 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2690 SSL_HANDSHAKE_MAC_SHA384
| TLS1_PRF_SHA384
,
2695 /* GCM based TLS v1.2 ciphersuites from RFC5289 */
2700 TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
,
2701 TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
,
2707 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2708 SSL_HANDSHAKE_MAC_SHA256
| TLS1_PRF_SHA256
,
2716 TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
,
2717 TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
,
2723 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2724 SSL_HANDSHAKE_MAC_SHA384
| TLS1_PRF_SHA384
,
2732 TLS1_TXT_ECDH_ECDSA_WITH_AES_128_GCM_SHA256
,
2733 TLS1_CK_ECDH_ECDSA_WITH_AES_128_GCM_SHA256
,
2739 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2740 SSL_HANDSHAKE_MAC_SHA256
| TLS1_PRF_SHA256
,
2748 TLS1_TXT_ECDH_ECDSA_WITH_AES_256_GCM_SHA384
,
2749 TLS1_CK_ECDH_ECDSA_WITH_AES_256_GCM_SHA384
,
2755 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2756 SSL_HANDSHAKE_MAC_SHA384
| TLS1_PRF_SHA384
,
2764 TLS1_TXT_ECDHE_RSA_WITH_AES_128_GCM_SHA256
,
2765 TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256
,
2771 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2772 SSL_HANDSHAKE_MAC_SHA256
| TLS1_PRF_SHA256
,
2780 TLS1_TXT_ECDHE_RSA_WITH_AES_256_GCM_SHA384
,
2781 TLS1_CK_ECDHE_RSA_WITH_AES_256_GCM_SHA384
,
2787 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2788 SSL_HANDSHAKE_MAC_SHA384
| TLS1_PRF_SHA384
,
2796 TLS1_TXT_ECDH_RSA_WITH_AES_128_GCM_SHA256
,
2797 TLS1_CK_ECDH_RSA_WITH_AES_128_GCM_SHA256
,
2803 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2804 SSL_HANDSHAKE_MAC_SHA256
| TLS1_PRF_SHA256
,
2812 TLS1_TXT_ECDH_RSA_WITH_AES_256_GCM_SHA384
,
2813 TLS1_CK_ECDH_RSA_WITH_AES_256_GCM_SHA384
,
2819 SSL_NOT_EXP
| SSL_HIGH
| SSL_FIPS
,
2820 SSL_HANDSHAKE_MAC_SHA384
| TLS1_PRF_SHA384
,
2825 #endif /* OPENSSL_NO_ECDH */
2827 #ifdef TEMP_GOST_TLS
2835 SSL_eGOST2814789CNT
,
2838 SSL_NOT_EXP
| SSL_HIGH
,
2839 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2849 SSL_eGOST2814789CNT
,
2852 SSL_NOT_EXP
| SSL_HIGH
,
2853 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2862 SSL_eGOST2814789CNT
,
2865 SSL_NOT_EXP
| SSL_HIGH
,
2866 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
,
2871 "GOST-GOST89STREAM",
2875 SSL_eGOST2814789CNT
,
2878 SSL_NOT_EXP
| SSL_HIGH
,
2879 SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
| TLS1_STREAM_MAC
,
2887 SSL3_ENC_METHOD SSLv3_enc_data
= {
2890 ssl3_setup_key_block
,
2891 ssl3_generate_master_secret
,
2892 ssl3_change_cipher_state
,
2893 ssl3_final_finish_mac
,
2894 MD5_DIGEST_LENGTH
+ SHA_DIGEST_LENGTH
,
2895 ssl3_cert_verify_mac
,
2896 SSL3_MD_CLIENT_FINISHED_CONST
, 4,
2897 SSL3_MD_SERVER_FINISHED_CONST
, 4,
2899 (int (*)(SSL
*, unsigned char *, size_t, const char *,
2900 size_t, const unsigned char *, size_t,
2901 int use_context
))ssl_undefined_function
,
2904 long ssl3_default_timeout(void)
2907 * 2 hours, the 24 hours mentioned in the SSLv3 spec is way too long for
2908 * http, the cache would over fill
2910 return (60 * 60 * 2);
2913 int ssl3_num_ciphers(void)
2915 return (SSL3_NUM_CIPHERS
);
2918 const SSL_CIPHER
*ssl3_get_cipher(unsigned int u
)
2920 if (u
< SSL3_NUM_CIPHERS
)
2921 return (&(ssl3_ciphers
[SSL3_NUM_CIPHERS
- 1 - u
]));
2926 int ssl3_pending(const SSL
*s
)
2928 if (s
->rstate
== SSL_ST_READ_BODY
)
2931 return (s
->s3
->rrec
.type
==
2932 SSL3_RT_APPLICATION_DATA
) ? s
->s3
->rrec
.length
: 0;
2935 int ssl3_new(SSL
*s
)
2939 if ((s3
= OPENSSL_malloc(sizeof *s3
)) == NULL
)
2941 memset(s3
, 0, sizeof *s3
);
2942 memset(s3
->rrec
.seq_num
, 0, sizeof(s3
->rrec
.seq_num
));
2943 memset(s3
->wrec
.seq_num
, 0, sizeof(s3
->wrec
.seq_num
));
2947 #ifndef OPENSSL_NO_SRP
2948 SSL_SRP_CTX_init(s
);
2950 s
->method
->ssl_clear(s
);
2956 void ssl3_free(SSL
*s
)
2961 #ifdef TLSEXT_TYPE_opaque_prf_input
2962 if (s
->s3
->client_opaque_prf_input
!= NULL
)
2963 OPENSSL_free(s
->s3
->client_opaque_prf_input
);
2964 if (s
->s3
->server_opaque_prf_input
!= NULL
)
2965 OPENSSL_free(s
->s3
->server_opaque_prf_input
);
2968 ssl3_cleanup_key_block(s
);
2969 if (s
->s3
->rbuf
.buf
!= NULL
)
2970 ssl3_release_read_buffer(s
);
2971 if (s
->s3
->wbuf
.buf
!= NULL
)
2972 ssl3_release_write_buffer(s
);
2973 if (s
->s3
->rrec
.comp
!= NULL
)
2974 OPENSSL_free(s
->s3
->rrec
.comp
);
2975 #ifndef OPENSSL_NO_DH
2976 if (s
->s3
->tmp
.dh
!= NULL
)
2977 DH_free(s
->s3
->tmp
.dh
);
2979 #ifndef OPENSSL_NO_ECDH
2980 if (s
->s3
->tmp
.ecdh
!= NULL
)
2981 EC_KEY_free(s
->s3
->tmp
.ecdh
);
2984 if (s
->s3
->tmp
.ca_names
!= NULL
)
2985 sk_X509_NAME_pop_free(s
->s3
->tmp
.ca_names
, X509_NAME_free
);
2986 if (s
->s3
->handshake_buffer
) {
2987 BIO_free(s
->s3
->handshake_buffer
);
2989 if (s
->s3
->handshake_dgst
)
2990 ssl3_free_digest_list(s
);
2991 #ifndef OPENSSL_NO_SRP
2992 SSL_SRP_CTX_free(s
);
2994 OPENSSL_cleanse(s
->s3
, sizeof *s
->s3
);
2995 OPENSSL_free(s
->s3
);
2999 void ssl3_clear(SSL
*s
)
3001 unsigned char *rp
, *wp
;
3005 #ifdef TLSEXT_TYPE_opaque_prf_input
3006 if (s
->s3
->client_opaque_prf_input
!= NULL
)
3007 OPENSSL_free(s
->s3
->client_opaque_prf_input
);
3008 s
->s3
->client_opaque_prf_input
= NULL
;
3009 if (s
->s3
->server_opaque_prf_input
!= NULL
)
3010 OPENSSL_free(s
->s3
->server_opaque_prf_input
);
3011 s
->s3
->server_opaque_prf_input
= NULL
;
3014 ssl3_cleanup_key_block(s
);
3015 if (s
->s3
->tmp
.ca_names
!= NULL
)
3016 sk_X509_NAME_pop_free(s
->s3
->tmp
.ca_names
, X509_NAME_free
);
3018 if (s
->s3
->rrec
.comp
!= NULL
) {
3019 OPENSSL_free(s
->s3
->rrec
.comp
);
3020 s
->s3
->rrec
.comp
= NULL
;
3022 #ifndef OPENSSL_NO_DH
3023 if (s
->s3
->tmp
.dh
!= NULL
) {
3024 DH_free(s
->s3
->tmp
.dh
);
3025 s
->s3
->tmp
.dh
= NULL
;
3028 #ifndef OPENSSL_NO_ECDH
3029 if (s
->s3
->tmp
.ecdh
!= NULL
) {
3030 EC_KEY_free(s
->s3
->tmp
.ecdh
);
3031 s
->s3
->tmp
.ecdh
= NULL
;
3034 #ifndef OPENSSL_NO_TLSEXT
3035 # ifndef OPENSSL_NO_EC
3036 s
->s3
->is_probably_safari
= 0;
3037 # endif /* !OPENSSL_NO_EC */
3038 #endif /* !OPENSSL_NO_TLSEXT */
3040 rp
= s
->s3
->rbuf
.buf
;
3041 wp
= s
->s3
->wbuf
.buf
;
3042 rlen
= s
->s3
->rbuf
.len
;
3043 wlen
= s
->s3
->wbuf
.len
;
3044 init_extra
= s
->s3
->init_extra
;
3045 if (s
->s3
->handshake_buffer
) {
3046 BIO_free(s
->s3
->handshake_buffer
);
3047 s
->s3
->handshake_buffer
= NULL
;
3049 if (s
->s3
->handshake_dgst
) {
3050 ssl3_free_digest_list(s
);
3052 memset(s
->s3
, 0, sizeof *s
->s3
);
3053 s
->s3
->rbuf
.buf
= rp
;
3054 s
->s3
->wbuf
.buf
= wp
;
3055 s
->s3
->rbuf
.len
= rlen
;
3056 s
->s3
->wbuf
.len
= wlen
;
3057 s
->s3
->init_extra
= init_extra
;
3059 ssl_free_wbio_buffer(s
);
3061 s
->packet_length
= 0;
3062 s
->s3
->renegotiate
= 0;
3063 s
->s3
->total_renegotiations
= 0;
3064 s
->s3
->num_renegotiations
= 0;
3065 s
->s3
->in_read_app_data
= 0;
3066 s
->version
= SSL3_VERSION
;
3068 #if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
3069 if (s
->next_proto_negotiated
) {
3070 OPENSSL_free(s
->next_proto_negotiated
);
3071 s
->next_proto_negotiated
= NULL
;
3072 s
->next_proto_negotiated_len
= 0;
3077 #ifndef OPENSSL_NO_SRP
3078 static char *MS_CALLBACK
srp_password_from_info_cb(SSL
*s
, void *arg
)
3080 return BUF_strdup(s
->srp_ctx
.info
);
3084 long ssl3_ctrl(SSL
*s
, int cmd
, long larg
, void *parg
)
3088 #if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA)
3090 # ifndef OPENSSL_NO_RSA
3091 cmd
== SSL_CTRL_SET_TMP_RSA
|| cmd
== SSL_CTRL_SET_TMP_RSA_CB
||
3093 # ifndef OPENSSL_NO_DSA
3094 cmd
== SSL_CTRL_SET_TMP_DH
|| cmd
== SSL_CTRL_SET_TMP_DH_CB
||
3097 if (!ssl_cert_inst(&s
->cert
)) {
3098 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_MALLOC_FAILURE
);
3105 case SSL_CTRL_GET_SESSION_REUSED
:
3108 case SSL_CTRL_GET_CLIENT_CERT_REQUEST
:
3110 case SSL_CTRL_GET_NUM_RENEGOTIATIONS
:
3111 ret
= s
->s3
->num_renegotiations
;
3113 case SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS
:
3114 ret
= s
->s3
->num_renegotiations
;
3115 s
->s3
->num_renegotiations
= 0;
3117 case SSL_CTRL_GET_TOTAL_RENEGOTIATIONS
:
3118 ret
= s
->s3
->total_renegotiations
;
3120 case SSL_CTRL_GET_FLAGS
:
3121 ret
= (int)(s
->s3
->flags
);
3123 #ifndef OPENSSL_NO_RSA
3124 case SSL_CTRL_NEED_TMP_RSA
:
3125 if ((s
->cert
!= NULL
) && (s
->cert
->rsa_tmp
== NULL
) &&
3126 ((s
->cert
->pkeys
[SSL_PKEY_RSA_ENC
].privatekey
== NULL
) ||
3127 (EVP_PKEY_size(s
->cert
->pkeys
[SSL_PKEY_RSA_ENC
].privatekey
) >
3131 case SSL_CTRL_SET_TMP_RSA
:
3133 RSA
*rsa
= (RSA
*)parg
;
3135 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_PASSED_NULL_PARAMETER
);
3138 if ((rsa
= RSAPrivateKey_dup(rsa
)) == NULL
) {
3139 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_RSA_LIB
);
3142 if (s
->cert
->rsa_tmp
!= NULL
)
3143 RSA_free(s
->cert
->rsa_tmp
);
3144 s
->cert
->rsa_tmp
= rsa
;
3148 case SSL_CTRL_SET_TMP_RSA_CB
:
3150 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED
);
3155 #ifndef OPENSSL_NO_DH
3156 case SSL_CTRL_SET_TMP_DH
:
3158 DH
*dh
= (DH
*)parg
;
3160 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_PASSED_NULL_PARAMETER
);
3163 if ((dh
= DHparams_dup(dh
)) == NULL
) {
3164 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_DH_LIB
);
3167 if (!(s
->options
& SSL_OP_SINGLE_DH_USE
)) {
3168 if (!DH_generate_key(dh
)) {
3170 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_DH_LIB
);
3174 if (s
->cert
->dh_tmp
!= NULL
)
3175 DH_free(s
->cert
->dh_tmp
);
3176 s
->cert
->dh_tmp
= dh
;
3180 case SSL_CTRL_SET_TMP_DH_CB
:
3182 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED
);
3187 #ifndef OPENSSL_NO_ECDH
3188 case SSL_CTRL_SET_TMP_ECDH
:
3190 EC_KEY
*ecdh
= NULL
;
3193 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_PASSED_NULL_PARAMETER
);
3196 if (!EC_KEY_up_ref((EC_KEY
*)parg
)) {
3197 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_ECDH_LIB
);
3200 ecdh
= (EC_KEY
*)parg
;
3201 if (!(s
->options
& SSL_OP_SINGLE_ECDH_USE
)) {
3202 if (!EC_KEY_generate_key(ecdh
)) {
3204 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_ECDH_LIB
);
3208 if (s
->cert
->ecdh_tmp
!= NULL
)
3209 EC_KEY_free(s
->cert
->ecdh_tmp
);
3210 s
->cert
->ecdh_tmp
= ecdh
;
3214 case SSL_CTRL_SET_TMP_ECDH_CB
:
3216 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED
);
3220 #endif /* !OPENSSL_NO_ECDH */
3221 #ifndef OPENSSL_NO_TLSEXT
3222 case SSL_CTRL_SET_TLSEXT_HOSTNAME
:
3223 if (larg
== TLSEXT_NAMETYPE_host_name
) {
3224 if (s
->tlsext_hostname
!= NULL
)
3225 OPENSSL_free(s
->tlsext_hostname
);
3226 s
->tlsext_hostname
= NULL
;
3231 if (strlen((char *)parg
) > TLSEXT_MAXLEN_host_name
) {
3232 SSLerr(SSL_F_SSL3_CTRL
, SSL_R_SSL3_EXT_INVALID_SERVERNAME
);
3235 if ((s
->tlsext_hostname
= BUF_strdup((char *)parg
)) == NULL
) {
3236 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_INTERNAL_ERROR
);
3240 SSLerr(SSL_F_SSL3_CTRL
, SSL_R_SSL3_EXT_INVALID_SERVERNAME_TYPE
);
3244 case SSL_CTRL_SET_TLSEXT_DEBUG_ARG
:
3245 s
->tlsext_debug_arg
= parg
;
3249 # ifdef TLSEXT_TYPE_opaque_prf_input
3250 case SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT
:
3251 if (larg
> 12288) { /* actual internal limit is 2^16 for the
3252 * complete hello message * (including the
3253 * cert chain and everything) */
3254 SSLerr(SSL_F_SSL3_CTRL
, SSL_R_OPAQUE_PRF_INPUT_TOO_LONG
);
3257 if (s
->tlsext_opaque_prf_input
!= NULL
)
3258 OPENSSL_free(s
->tlsext_opaque_prf_input
);
3259 if ((size_t)larg
== 0)
3260 s
->tlsext_opaque_prf_input
= OPENSSL_malloc(1); /* dummy byte
3264 s
->tlsext_opaque_prf_input
= BUF_memdup(parg
, (size_t)larg
);
3265 if (s
->tlsext_opaque_prf_input
!= NULL
) {
3266 s
->tlsext_opaque_prf_input_len
= (size_t)larg
;
3269 s
->tlsext_opaque_prf_input_len
= 0;
3273 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE
:
3274 s
->tlsext_status_type
= larg
;
3278 case SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS
:
3279 *(STACK_OF(X509_EXTENSION
) **)parg
= s
->tlsext_ocsp_exts
;
3283 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS
:
3284 s
->tlsext_ocsp_exts
= parg
;
3288 case SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS
:
3289 *(STACK_OF(OCSP_RESPID
) **)parg
= s
->tlsext_ocsp_ids
;
3293 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS
:
3294 s
->tlsext_ocsp_ids
= parg
;
3298 case SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP
:
3299 *(unsigned char **)parg
= s
->tlsext_ocsp_resp
;
3300 return s
->tlsext_ocsp_resplen
;
3302 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP
:
3303 if (s
->tlsext_ocsp_resp
)
3304 OPENSSL_free(s
->tlsext_ocsp_resp
);
3305 s
->tlsext_ocsp_resp
= parg
;
3306 s
->tlsext_ocsp_resplen
= larg
;
3310 # ifndef OPENSSL_NO_HEARTBEATS
3311 case SSL_CTRL_TLS_EXT_SEND_HEARTBEAT
:
3312 if (SSL_version(s
) == DTLS1_VERSION
3313 || SSL_version(s
) == DTLS1_BAD_VER
)
3314 ret
= dtls1_heartbeat(s
);
3316 ret
= tls1_heartbeat(s
);
3319 case SSL_CTRL_GET_TLS_EXT_HEARTBEAT_PENDING
:
3320 ret
= s
->tlsext_hb_pending
;
3323 case SSL_CTRL_SET_TLS_EXT_HEARTBEAT_NO_REQUESTS
:
3325 s
->tlsext_heartbeat
|= SSL_TLSEXT_HB_DONT_RECV_REQUESTS
;
3327 s
->tlsext_heartbeat
&= ~SSL_TLSEXT_HB_DONT_RECV_REQUESTS
;
3332 #endif /* !OPENSSL_NO_TLSEXT */
3334 case SSL_CTRL_CHECK_PROTO_VERSION
:
3336 * For library-internal use; checks that the current protocol is the
3337 * highest enabled version (according to s->ctx->method, as version
3338 * negotiation may have changed s->method).
3340 if (s
->version
== s
->ctx
->method
->version
)
3343 * Apparently we're using a version-flexible SSL_METHOD (not at its
3344 * highest protocol version).
3346 if (s
->ctx
->method
->version
== SSLv23_method()->version
) {
3347 #if TLS_MAX_VERSION != TLS1_2_VERSION
3348 # error Code needs update for SSLv23_method() support beyond TLS1_2_VERSION.
3350 if (!(s
->options
& SSL_OP_NO_TLSv1_2
))
3351 return s
->version
== TLS1_2_VERSION
;
3352 if (!(s
->options
& SSL_OP_NO_TLSv1_1
))
3353 return s
->version
== TLS1_1_VERSION
;
3354 if (!(s
->options
& SSL_OP_NO_TLSv1
))
3355 return s
->version
== TLS1_VERSION
;
3356 if (!(s
->options
& SSL_OP_NO_SSLv3
))
3357 return s
->version
== SSL3_VERSION
;
3358 if (!(s
->options
& SSL_OP_NO_SSLv2
))
3359 return s
->version
== SSL2_VERSION
;
3361 return 0; /* Unexpected state; fail closed. */
3369 long ssl3_callback_ctrl(SSL
*s
, int cmd
, void (*fp
) (void))
3373 #if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA)
3375 # ifndef OPENSSL_NO_RSA
3376 cmd
== SSL_CTRL_SET_TMP_RSA_CB
||
3378 # ifndef OPENSSL_NO_DSA
3379 cmd
== SSL_CTRL_SET_TMP_DH_CB
||
3382 if (!ssl_cert_inst(&s
->cert
)) {
3383 SSLerr(SSL_F_SSL3_CALLBACK_CTRL
, ERR_R_MALLOC_FAILURE
);
3390 #ifndef OPENSSL_NO_RSA
3391 case SSL_CTRL_SET_TMP_RSA_CB
:
3393 s
->cert
->rsa_tmp_cb
= (RSA
*(*)(SSL
*, int, int))fp
;
3397 #ifndef OPENSSL_NO_DH
3398 case SSL_CTRL_SET_TMP_DH_CB
:
3400 s
->cert
->dh_tmp_cb
= (DH
*(*)(SSL
*, int, int))fp
;
3404 #ifndef OPENSSL_NO_ECDH
3405 case SSL_CTRL_SET_TMP_ECDH_CB
:
3407 s
->cert
->ecdh_tmp_cb
= (EC_KEY
*(*)(SSL
*, int, int))fp
;
3411 #ifndef OPENSSL_NO_TLSEXT
3412 case SSL_CTRL_SET_TLSEXT_DEBUG_CB
:
3413 s
->tlsext_debug_cb
= (void (*)(SSL
*, int, int,
3414 unsigned char *, int, void *))fp
;
3423 long ssl3_ctx_ctrl(SSL_CTX
*ctx
, int cmd
, long larg
, void *parg
)
3430 #ifndef OPENSSL_NO_RSA
3431 case SSL_CTRL_NEED_TMP_RSA
:
3432 if ((cert
->rsa_tmp
== NULL
) &&
3433 ((cert
->pkeys
[SSL_PKEY_RSA_ENC
].privatekey
== NULL
) ||
3434 (EVP_PKEY_size(cert
->pkeys
[SSL_PKEY_RSA_ENC
].privatekey
) >
3441 case SSL_CTRL_SET_TMP_RSA
:
3451 if ((rsa
= RSAPrivateKey_dup(rsa
)) == NULL
)
3455 SSLerr(SSL_F_SSL3_CTX_CTRL
, ERR_R_RSA_LIB
);
3458 if (cert
->rsa_tmp
!= NULL
)
3459 RSA_free(cert
->rsa_tmp
);
3460 cert
->rsa_tmp
= rsa
;
3465 case SSL_CTRL_SET_TMP_RSA_CB
:
3467 SSLerr(SSL_F_SSL3_CTX_CTRL
, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED
);
3472 #ifndef OPENSSL_NO_DH
3473 case SSL_CTRL_SET_TMP_DH
:
3475 DH
*new = NULL
, *dh
;
3478 if ((new = DHparams_dup(dh
)) == NULL
) {
3479 SSLerr(SSL_F_SSL3_CTX_CTRL
, ERR_R_DH_LIB
);
3482 if (!(ctx
->options
& SSL_OP_SINGLE_DH_USE
)) {
3483 if (!DH_generate_key(new)) {
3484 SSLerr(SSL_F_SSL3_CTX_CTRL
, ERR_R_DH_LIB
);
3489 if (cert
->dh_tmp
!= NULL
)
3490 DH_free(cert
->dh_tmp
);
3497 case SSL_CTRL_SET_TMP_DH_CB
:
3499 SSLerr(SSL_F_SSL3_CTX_CTRL
, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED
);
3504 #ifndef OPENSSL_NO_ECDH
3505 case SSL_CTRL_SET_TMP_ECDH
:
3507 EC_KEY
*ecdh
= NULL
;
3510 SSLerr(SSL_F_SSL3_CTX_CTRL
, ERR_R_ECDH_LIB
);
3513 ecdh
= EC_KEY_dup((EC_KEY
*)parg
);
3515 SSLerr(SSL_F_SSL3_CTX_CTRL
, ERR_R_EC_LIB
);
3518 if (!(ctx
->options
& SSL_OP_SINGLE_ECDH_USE
)) {
3519 if (!EC_KEY_generate_key(ecdh
)) {
3521 SSLerr(SSL_F_SSL3_CTX_CTRL
, ERR_R_ECDH_LIB
);
3526 if (cert
->ecdh_tmp
!= NULL
) {
3527 EC_KEY_free(cert
->ecdh_tmp
);
3529 cert
->ecdh_tmp
= ecdh
;
3533 case SSL_CTRL_SET_TMP_ECDH_CB
:
3535 SSLerr(SSL_F_SSL3_CTX_CTRL
, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED
);
3539 #endif /* !OPENSSL_NO_ECDH */
3540 #ifndef OPENSSL_NO_TLSEXT
3541 case SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG
:
3542 ctx
->tlsext_servername_arg
= parg
;
3544 case SSL_CTRL_SET_TLSEXT_TICKET_KEYS
:
3545 case SSL_CTRL_GET_TLSEXT_TICKET_KEYS
:
3547 unsigned char *keys
= parg
;
3551 SSLerr(SSL_F_SSL3_CTX_CTRL
, SSL_R_INVALID_TICKET_KEYS_LENGTH
);
3554 if (cmd
== SSL_CTRL_SET_TLSEXT_TICKET_KEYS
) {
3555 memcpy(ctx
->tlsext_tick_key_name
, keys
, 16);
3556 memcpy(ctx
->tlsext_tick_hmac_key
, keys
+ 16, 16);
3557 memcpy(ctx
->tlsext_tick_aes_key
, keys
+ 32, 16);
3559 memcpy(keys
, ctx
->tlsext_tick_key_name
, 16);
3560 memcpy(keys
+ 16, ctx
->tlsext_tick_hmac_key
, 16);
3561 memcpy(keys
+ 32, ctx
->tlsext_tick_aes_key
, 16);
3566 # ifdef TLSEXT_TYPE_opaque_prf_input
3567 case SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB_ARG
:
3568 ctx
->tlsext_opaque_prf_input_callback_arg
= parg
;
3572 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG
:
3573 ctx
->tlsext_status_arg
= parg
;
3577 # ifndef OPENSSL_NO_SRP
3578 case SSL_CTRL_SET_TLS_EXT_SRP_USERNAME
:
3579 ctx
->srp_ctx
.srp_Mask
|= SSL_kSRP
;
3580 if (ctx
->srp_ctx
.login
!= NULL
)
3581 OPENSSL_free(ctx
->srp_ctx
.login
);
3582 ctx
->srp_ctx
.login
= NULL
;
3585 if (strlen((const char *)parg
) > 255
3586 || strlen((const char *)parg
) < 1) {
3587 SSLerr(SSL_F_SSL3_CTX_CTRL
, SSL_R_INVALID_SRP_USERNAME
);
3590 if ((ctx
->srp_ctx
.login
= BUF_strdup((char *)parg
)) == NULL
) {
3591 SSLerr(SSL_F_SSL3_CTX_CTRL
, ERR_R_INTERNAL_ERROR
);
3595 case SSL_CTRL_SET_TLS_EXT_SRP_PASSWORD
:
3596 ctx
->srp_ctx
.SRP_give_srp_client_pwd_callback
=
3597 srp_password_from_info_cb
;
3598 ctx
->srp_ctx
.info
= parg
;
3600 case SSL_CTRL_SET_SRP_ARG
:
3601 ctx
->srp_ctx
.srp_Mask
|= SSL_kSRP
;
3602 ctx
->srp_ctx
.SRP_cb_arg
= parg
;
3605 case SSL_CTRL_SET_TLS_EXT_SRP_STRENGTH
:
3606 ctx
->srp_ctx
.strength
= larg
;
3609 #endif /* !OPENSSL_NO_TLSEXT */
3611 /* A Thawte special :-) */
3612 case SSL_CTRL_EXTRA_CHAIN_CERT
:
3613 if (ctx
->extra_certs
== NULL
) {
3614 if ((ctx
->extra_certs
= sk_X509_new_null()) == NULL
)
3617 sk_X509_push(ctx
->extra_certs
, (X509
*)parg
);
3620 case SSL_CTRL_GET_EXTRA_CHAIN_CERTS
:
3621 *(STACK_OF(X509
) **)parg
= ctx
->extra_certs
;
3624 case SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS
:
3625 if (ctx
->extra_certs
) {
3626 sk_X509_pop_free(ctx
->extra_certs
, X509_free
);
3627 ctx
->extra_certs
= NULL
;
3637 long ssl3_ctx_callback_ctrl(SSL_CTX
*ctx
, int cmd
, void (*fp
) (void))
3644 #ifndef OPENSSL_NO_RSA
3645 case SSL_CTRL_SET_TMP_RSA_CB
:
3647 cert
->rsa_tmp_cb
= (RSA
*(*)(SSL
*, int, int))fp
;
3651 #ifndef OPENSSL_NO_DH
3652 case SSL_CTRL_SET_TMP_DH_CB
:
3654 cert
->dh_tmp_cb
= (DH
*(*)(SSL
*, int, int))fp
;
3658 #ifndef OPENSSL_NO_ECDH
3659 case SSL_CTRL_SET_TMP_ECDH_CB
:
3661 cert
->ecdh_tmp_cb
= (EC_KEY
*(*)(SSL
*, int, int))fp
;
3665 #ifndef OPENSSL_NO_TLSEXT
3666 case SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
:
3667 ctx
->tlsext_servername_callback
= (int (*)(SSL
*, int *, void *))fp
;
3670 # ifdef TLSEXT_TYPE_opaque_prf_input
3671 case SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB
:
3672 ctx
->tlsext_opaque_prf_input_callback
=
3673 (int (*)(SSL
*, void *, size_t, void *))fp
;
3677 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB
:
3678 ctx
->tlsext_status_cb
= (int (*)(SSL
*, void *))fp
;
3681 case SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB
:
3682 ctx
->tlsext_ticket_key_cb
= (int (*)(SSL
*, unsigned char *,
3685 HMAC_CTX
*, int))fp
;
3688 # ifndef OPENSSL_NO_SRP
3689 case SSL_CTRL_SET_SRP_VERIFY_PARAM_CB
:
3690 ctx
->srp_ctx
.srp_Mask
|= SSL_kSRP
;
3691 ctx
->srp_ctx
.SRP_verify_param_callback
= (int (*)(SSL
*, void *))fp
;
3693 case SSL_CTRL_SET_TLS_EXT_SRP_USERNAME_CB
:
3694 ctx
->srp_ctx
.srp_Mask
|= SSL_kSRP
;
3695 ctx
->srp_ctx
.TLS_ext_srp_username_callback
=
3696 (int (*)(SSL
*, int *, void *))fp
;
3698 case SSL_CTRL_SET_SRP_GIVE_CLIENT_PWD_CB
:
3699 ctx
->srp_ctx
.srp_Mask
|= SSL_kSRP
;
3700 ctx
->srp_ctx
.SRP_give_srp_client_pwd_callback
=
3701 (char *(*)(SSL
*, void *))fp
;
3713 * This function needs to check if the ciphers required are actually
3716 const SSL_CIPHER
*ssl3_get_cipher_by_char(const unsigned char *p
)
3719 const SSL_CIPHER
*cp
;
3722 id
= 0x03000000L
| ((unsigned long)p
[0] << 8L) | (unsigned long)p
[1];
3724 cp
= OBJ_bsearch_ssl_cipher_id(&c
, ssl3_ciphers
, SSL3_NUM_CIPHERS
);
3725 #ifdef DEBUG_PRINT_UNKNOWN_CIPHERSUITES
3727 fprintf(stderr
, "Unknown cipher ID %x\n", (p
[0] << 8) | p
[1]);
3729 if (cp
== NULL
|| cp
->valid
== 0)
3735 int ssl3_put_cipher_by_char(const SSL_CIPHER
*c
, unsigned char *p
)
3741 if ((l
& 0xff000000) != 0x03000000)
3743 p
[0] = ((unsigned char)(l
>> 8L)) & 0xFF;
3744 p
[1] = ((unsigned char)(l
)) & 0xFF;
3749 SSL_CIPHER
*ssl3_choose_cipher(SSL
*s
, STACK_OF(SSL_CIPHER
) *clnt
,
3750 STACK_OF(SSL_CIPHER
) *srvr
)
3752 SSL_CIPHER
*c
, *ret
= NULL
;
3753 STACK_OF(SSL_CIPHER
) *prio
, *allow
;
3755 #if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_EC)
3758 unsigned char ec_search1
= 0, ec_search2
= 0;
3761 unsigned long alg_k
, alg_a
, mask_k
, mask_a
, emask_k
, emask_a
;
3763 /* Let's see which ciphers we can support */
3768 * Do not set the compare functions, because this may lead to a
3769 * reordering by "id". We want to keep the original ordering. We may pay
3770 * a price in performance during sk_SSL_CIPHER_find(), but would have to
3771 * pay with the price of sk_SSL_CIPHER_dup().
3773 sk_SSL_CIPHER_set_cmp_func(srvr
, ssl_cipher_ptr_id_cmp
);
3774 sk_SSL_CIPHER_set_cmp_func(clnt
, ssl_cipher_ptr_id_cmp
);
3778 fprintf(stderr
, "Server has %d from %p:\n", sk_SSL_CIPHER_num(srvr
),
3780 for (i
= 0; i
< sk_SSL_CIPHER_num(srvr
); ++i
) {
3781 c
= sk_SSL_CIPHER_value(srvr
, i
);
3782 fprintf(stderr
, "%p:%s\n", (void *)c
, c
->name
);
3784 fprintf(stderr
, "Client sent %d from %p:\n", sk_SSL_CIPHER_num(clnt
),
3786 for (i
= 0; i
< sk_SSL_CIPHER_num(clnt
); ++i
) {
3787 c
= sk_SSL_CIPHER_value(clnt
, i
);
3788 fprintf(stderr
, "%p:%s\n", (void *)c
, c
->name
);
3792 if (s
->options
& SSL_OP_CIPHER_SERVER_PREFERENCE
) {
3800 for (i
= 0; i
< sk_SSL_CIPHER_num(prio
); i
++) {
3801 c
= sk_SSL_CIPHER_value(prio
, i
);
3803 /* Skip TLS v1.2 only ciphersuites if lower than v1.2 */
3804 if ((c
->algorithm_ssl
& SSL_TLSV1_2
) &&
3805 (TLS1_get_version(s
) < TLS1_2_VERSION
))
3808 ssl_set_cert_masks(cert
, c
);
3809 mask_k
= cert
->mask_k
;
3810 mask_a
= cert
->mask_a
;
3811 emask_k
= cert
->export_mask_k
;
3812 emask_a
= cert
->export_mask_a
;
3813 #ifndef OPENSSL_NO_SRP
3814 if (s
->srp_ctx
.srp_Mask
& SSL_kSRP
) {
3816 emask_k
|= SSL_kSRP
;
3818 emask_a
|= SSL_aSRP
;
3824 * fprintf(stderr,"ssl3_choose_cipher %d alg= %lx\n",
3827 #endif /* KSSL_DEBUG */
3829 alg_k
= c
->algorithm_mkey
;
3830 alg_a
= c
->algorithm_auth
;
3832 #ifndef OPENSSL_NO_KRB5
3833 if (alg_k
& SSL_kKRB5
) {
3834 if (!kssl_keytab_is_available(s
->kssl_ctx
))
3837 #endif /* OPENSSL_NO_KRB5 */
3838 #ifndef OPENSSL_NO_PSK
3839 /* with PSK there must be server callback set */
3840 if ((alg_k
& SSL_kPSK
) && s
->psk_server_callback
== NULL
)
3842 #endif /* OPENSSL_NO_PSK */
3844 if (SSL_C_IS_EXPORT(c
)) {
3845 ok
= (alg_k
& emask_k
) && (alg_a
& emask_a
);
3847 fprintf(stderr
, "%d:[%08lX:%08lX:%08lX:%08lX]%p:%s (export)\n",
3848 ok
, alg_k
, alg_a
, emask_k
, emask_a
, (void *)c
, c
->name
);
3851 ok
= (alg_k
& mask_k
) && (alg_a
& mask_a
);
3853 fprintf(stderr
, "%d:[%08lX:%08lX:%08lX:%08lX]%p:%s\n", ok
, alg_k
,
3854 alg_a
, mask_k
, mask_a
, (void *)c
, c
->name
);
3858 #ifndef OPENSSL_NO_TLSEXT
3859 # ifndef OPENSSL_NO_EC
3862 * if we are considering an ECC cipher suite that uses our
3865 (alg_a
& SSL_aECDSA
|| alg_a
& SSL_aECDH
)
3866 /* and we have an ECC certificate */
3867 && (s
->cert
->pkeys
[SSL_PKEY_ECC
].x509
!= NULL
)
3869 * and the client specified a Supported Point Formats
3872 && ((s
->session
->tlsext_ecpointformatlist_length
> 0)
3873 && (s
->session
->tlsext_ecpointformatlist
!= NULL
))
3874 /* and our certificate's point is compressed */
3875 && ((s
->cert
->pkeys
[SSL_PKEY_ECC
].x509
->cert_info
!= NULL
)
3876 && (s
->cert
->pkeys
[SSL_PKEY_ECC
].x509
->cert_info
->key
!=
3878 && (s
->cert
->pkeys
[SSL_PKEY_ECC
].x509
->cert_info
->
3879 key
->public_key
!= NULL
)
3880 && (s
->cert
->pkeys
[SSL_PKEY_ECC
].x509
->cert_info
->
3881 key
->public_key
->data
!= NULL
)
3884 (s
->cert
->pkeys
[SSL_PKEY_ECC
].x509
->cert_info
->
3885 key
->public_key
->data
) == POINT_CONVERSION_COMPRESSED
)
3888 (s
->cert
->pkeys
[SSL_PKEY_ECC
].x509
->cert_info
->
3889 key
->public_key
->data
) ==
3890 POINT_CONVERSION_COMPRESSED
+ 1)
3896 * if our certificate's curve is over a field type that the
3897 * client does not support then do not allow this cipher suite to
3900 if ((s
->cert
->pkeys
[SSL_PKEY_ECC
].privatekey
->pkey
.ec
!= NULL
)
3901 && (s
->cert
->pkeys
[SSL_PKEY_ECC
].privatekey
->pkey
.ec
->group
!=
3903 && (s
->cert
->pkeys
[SSL_PKEY_ECC
].privatekey
->pkey
.ec
->
3904 group
->meth
!= NULL
)
3906 (EC_METHOD_get_field_type
3907 (s
->cert
->pkeys
[SSL_PKEY_ECC
].privatekey
->pkey
.ec
->
3908 group
->meth
) == NID_X9_62_prime_field
)
3910 for (j
= 0; j
< s
->session
->tlsext_ecpointformatlist_length
;
3912 if (s
->session
->tlsext_ecpointformatlist
[j
] ==
3913 TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime
) {
3919 if (EC_METHOD_get_field_type
3920 (s
->cert
->pkeys
[SSL_PKEY_ECC
].privatekey
->pkey
.ec
->
3921 group
->meth
) == NID_X9_62_characteristic_two_field
) {
3922 for (j
= 0; j
< s
->session
->tlsext_ecpointformatlist_length
;
3924 if (s
->session
->tlsext_ecpointformatlist
[j
] ==
3925 TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2
) {
3935 * if we are considering an ECC cipher suite that uses our
3938 (alg_a
& SSL_aECDSA
|| alg_a
& SSL_aECDH
)
3939 /* and we have an ECC certificate */
3940 && (s
->cert
->pkeys
[SSL_PKEY_ECC
].x509
!= NULL
)
3942 * and the client specified an EllipticCurves extension
3944 && ((s
->session
->tlsext_ellipticcurvelist_length
> 0)
3945 && (s
->session
->tlsext_ellipticcurvelist
!= NULL
))
3948 if ((s
->cert
->pkeys
[SSL_PKEY_ECC
].privatekey
->pkey
.ec
!= NULL
)
3949 && (s
->cert
->pkeys
[SSL_PKEY_ECC
].privatekey
->pkey
.ec
->group
!=
3953 EC_GROUP_get_curve_name(s
->cert
->
3954 pkeys
[SSL_PKEY_ECC
].privatekey
->
3957 && (s
->cert
->pkeys
[SSL_PKEY_ECC
].privatekey
->pkey
.
3958 ec
->group
->meth
!= NULL
)
3960 if (EC_METHOD_get_field_type
3961 (s
->cert
->pkeys
[SSL_PKEY_ECC
].privatekey
->pkey
.
3962 ec
->group
->meth
) == NID_X9_62_prime_field
) {
3966 if (EC_METHOD_get_field_type
3967 (s
->cert
->pkeys
[SSL_PKEY_ECC
].privatekey
->
3968 pkey
.ec
->group
->meth
) ==
3969 NID_X9_62_characteristic_two_field
) {
3975 ec_search2
= tls1_ec_nid2curve_id(ec_nid
);
3977 if ((ec_search1
!= 0) || (ec_search2
!= 0)) {
3979 j
< s
->session
->tlsext_ellipticcurvelist_length
/ 2;
3981 if ((s
->session
->tlsext_ellipticcurvelist
[2 * j
] ==
3983 && (s
->session
->tlsext_ellipticcurvelist
[2 * j
+
3994 # ifndef OPENSSL_NO_ECDH
3997 * if we are considering an ECC cipher suite that uses an
4000 (alg_k
& SSL_kEECDH
)
4001 /* and we have an ephemeral EC key */
4002 && (s
->cert
->ecdh_tmp
!= NULL
)
4004 * and the client specified an EllipticCurves extension
4006 && ((s
->session
->tlsext_ellipticcurvelist_length
> 0)
4007 && (s
->session
->tlsext_ellipticcurvelist
!= NULL
))
4010 if (s
->cert
->ecdh_tmp
->group
!= NULL
) {
4011 ec_nid
= EC_GROUP_get_curve_name(s
->cert
->ecdh_tmp
->group
);
4013 && (s
->cert
->ecdh_tmp
->group
->meth
!= NULL
)
4015 if (EC_METHOD_get_field_type
4016 (s
->cert
->ecdh_tmp
->group
->meth
) ==
4017 NID_X9_62_prime_field
) {
4021 if (EC_METHOD_get_field_type
4022 (s
->cert
->ecdh_tmp
->group
->meth
) ==
4023 NID_X9_62_characteristic_two_field
) {
4029 ec_search2
= tls1_ec_nid2curve_id(ec_nid
);
4031 if ((ec_search1
!= 0) || (ec_search2
!= 0)) {
4033 j
< s
->session
->tlsext_ellipticcurvelist_length
/ 2;
4035 if ((s
->session
->tlsext_ellipticcurvelist
[2 * j
] ==
4037 && (s
->session
->tlsext_ellipticcurvelist
[2 * j
+
4048 # endif /* OPENSSL_NO_ECDH */
4049 # endif /* OPENSSL_NO_EC */
4050 #endif /* OPENSSL_NO_TLSEXT */
4054 ii
= sk_SSL_CIPHER_find(allow
, c
);
4056 #if !defined(OPENSSL_NO_EC) && !defined(OPENSSL_NO_TLSEXT)
4057 if ((alg_k
& SSL_kEECDH
) && (alg_a
& SSL_aECDSA
)
4058 && s
->s3
->is_probably_safari
) {
4060 ret
= sk_SSL_CIPHER_value(allow
, ii
);
4064 ret
= sk_SSL_CIPHER_value(allow
, ii
);
4071 int ssl3_get_req_cert_type(SSL
*s
, unsigned char *p
)
4074 unsigned long alg_k
;
4076 alg_k
= s
->s3
->tmp
.new_cipher
->algorithm_mkey
;
4078 #ifndef OPENSSL_NO_GOST
4079 if (s
->version
>= TLS1_VERSION
) {
4080 if (alg_k
& SSL_kGOST
) {
4081 p
[ret
++] = TLS_CT_GOST94_SIGN
;
4082 p
[ret
++] = TLS_CT_GOST01_SIGN
;
4088 #ifndef OPENSSL_NO_DH
4089 if (alg_k
& (SSL_kDHr
| SSL_kEDH
)) {
4090 # ifndef OPENSSL_NO_RSA
4091 p
[ret
++] = SSL3_CT_RSA_FIXED_DH
;
4093 # ifndef OPENSSL_NO_DSA
4094 p
[ret
++] = SSL3_CT_DSS_FIXED_DH
;
4097 if ((s
->version
== SSL3_VERSION
) &&
4098 (alg_k
& (SSL_kEDH
| SSL_kDHd
| SSL_kDHr
))) {
4099 # ifndef OPENSSL_NO_RSA
4100 p
[ret
++] = SSL3_CT_RSA_EPHEMERAL_DH
;
4102 # ifndef OPENSSL_NO_DSA
4103 p
[ret
++] = SSL3_CT_DSS_EPHEMERAL_DH
;
4106 #endif /* !OPENSSL_NO_DH */
4107 #ifndef OPENSSL_NO_RSA
4108 p
[ret
++] = SSL3_CT_RSA_SIGN
;
4110 #ifndef OPENSSL_NO_DSA
4111 p
[ret
++] = SSL3_CT_DSS_SIGN
;
4113 #ifndef OPENSSL_NO_ECDH
4114 if ((alg_k
& (SSL_kECDHr
| SSL_kECDHe
)) && (s
->version
>= TLS1_VERSION
)) {
4115 p
[ret
++] = TLS_CT_RSA_FIXED_ECDH
;
4116 p
[ret
++] = TLS_CT_ECDSA_FIXED_ECDH
;
4120 #ifndef OPENSSL_NO_ECDSA
4122 * ECDSA certs can be used with RSA cipher suites as well so we don't
4123 * need to check for SSL_kECDH or SSL_kEECDH
4125 if (s
->version
>= TLS1_VERSION
) {
4126 p
[ret
++] = TLS_CT_ECDSA_SIGN
;
4132 int ssl3_shutdown(SSL
*s
)
4137 * Don't do anything much if we have not done the handshake or we don't
4138 * want to send messages :-)
4140 if ((s
->quiet_shutdown
) || (s
->state
== SSL_ST_BEFORE
)) {
4141 s
->shutdown
= (SSL_SENT_SHUTDOWN
| SSL_RECEIVED_SHUTDOWN
);
4145 if (!(s
->shutdown
& SSL_SENT_SHUTDOWN
)) {
4146 s
->shutdown
|= SSL_SENT_SHUTDOWN
;
4148 ssl3_send_alert(s
, SSL3_AL_WARNING
, SSL_AD_CLOSE_NOTIFY
);
4151 * our shutdown alert has been sent now, and if it still needs to be
4152 * written, s->s3->alert_dispatch will be true
4154 if (s
->s3
->alert_dispatch
)
4155 return (-1); /* return WANT_WRITE */
4156 } else if (s
->s3
->alert_dispatch
) {
4157 /* resend it if not sent */
4159 ret
= s
->method
->ssl_dispatch_alert(s
);
4162 * we only get to return -1 here the 2nd/Nth invocation, we must
4163 * have already signalled return 0 upon a previous invoation,
4169 } else if (!(s
->shutdown
& SSL_RECEIVED_SHUTDOWN
)) {
4171 * If we are waiting for a close from our peer, we are closed
4173 s
->method
->ssl_read_bytes(s
, 0, NULL
, 0, 0);
4174 if (!(s
->shutdown
& SSL_RECEIVED_SHUTDOWN
)) {
4175 return (-1); /* return WANT_READ */
4179 if ((s
->shutdown
== (SSL_SENT_SHUTDOWN
| SSL_RECEIVED_SHUTDOWN
)) &&
4180 !s
->s3
->alert_dispatch
)
4186 int ssl3_write(SSL
*s
, const void *buf
, int len
)
4191 if (s
->shutdown
& SSL_SEND_SHUTDOWN
) {
4192 s
->rwstate
= SSL_NOTHING
;
4197 if (s
->s3
->renegotiate
)
4198 ssl3_renegotiate_check(s
);
4201 * This is an experimental flag that sends the last handshake message in
4202 * the same packet as the first use data - used to see if it helps the
4203 * TCP protocol during session-id reuse
4205 /* The second test is because the buffer may have been removed */
4206 if ((s
->s3
->flags
& SSL3_FLAGS_POP_BUFFER
) && (s
->wbio
== s
->bbio
)) {
4207 /* First time through, we write into the buffer */
4208 if (s
->s3
->delay_buf_pop_ret
== 0) {
4209 ret
= ssl3_write_bytes(s
, SSL3_RT_APPLICATION_DATA
, buf
, len
);
4213 s
->s3
->delay_buf_pop_ret
= ret
;
4216 s
->rwstate
= SSL_WRITING
;
4217 n
= BIO_flush(s
->wbio
);
4220 s
->rwstate
= SSL_NOTHING
;
4222 /* We have flushed the buffer, so remove it */
4223 ssl_free_wbio_buffer(s
);
4224 s
->s3
->flags
&= ~SSL3_FLAGS_POP_BUFFER
;
4226 ret
= s
->s3
->delay_buf_pop_ret
;
4227 s
->s3
->delay_buf_pop_ret
= 0;
4229 ret
= s
->method
->ssl_write_bytes(s
, SSL3_RT_APPLICATION_DATA
,
4238 static int ssl3_read_internal(SSL
*s
, void *buf
, int len
, int peek
)
4243 if (s
->s3
->renegotiate
)
4244 ssl3_renegotiate_check(s
);
4245 s
->s3
->in_read_app_data
= 1;
4247 s
->method
->ssl_read_bytes(s
, SSL3_RT_APPLICATION_DATA
, buf
, len
,
4249 if ((ret
== -1) && (s
->s3
->in_read_app_data
== 2)) {
4251 * ssl3_read_bytes decided to call s->handshake_func, which called
4252 * ssl3_read_bytes to read handshake data. However, ssl3_read_bytes
4253 * actually found application data and thinks that application data
4254 * makes sense here; so disable handshake processing and try to read
4255 * application data again.
4259 s
->method
->ssl_read_bytes(s
, SSL3_RT_APPLICATION_DATA
, buf
, len
,
4263 s
->s3
->in_read_app_data
= 0;
4268 int ssl3_read(SSL
*s
, void *buf
, int len
)
4270 return ssl3_read_internal(s
, buf
, len
, 0);
4273 int ssl3_peek(SSL
*s
, void *buf
, int len
)
4275 return ssl3_read_internal(s
, buf
, len
, 1);
4278 int ssl3_renegotiate(SSL
*s
)
4280 if (s
->handshake_func
== NULL
)
4283 if (s
->s3
->flags
& SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS
)
4286 s
->s3
->renegotiate
= 1;
4290 int ssl3_renegotiate_check(SSL
*s
)
4294 if (s
->s3
->renegotiate
) {
4295 if ((s
->s3
->rbuf
.left
== 0) &&
4296 (s
->s3
->wbuf
.left
== 0) && !SSL_in_init(s
)) {
4298 * if we are the server, and we have sent a 'RENEGOTIATE'
4299 * message, we need to go to SSL_ST_ACCEPT.
4302 s
->state
= SSL_ST_RENEGOTIATE
;
4303 s
->s3
->renegotiate
= 0;
4304 s
->s3
->num_renegotiations
++;
4305 s
->s3
->total_renegotiations
++;
4313 * If we are using TLS v1.2 or later and default SHA1+MD5 algorithms switch
4314 * to new SHA256 PRF and handshake macs
4316 long ssl_get_algorithm2(SSL
*s
)
4318 long alg2
= s
->s3
->tmp
.new_cipher
->algorithm2
;
4319 if (s
->method
->version
== TLS1_2_VERSION
&&
4320 alg2
== (SSL_HANDSHAKE_MAC_DEFAULT
| TLS1_PRF
))
4321 return SSL_HANDSHAKE_MAC_SHA256
| TLS1_PRF_SHA256
;