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 #include <openssl/md5.h>
156 #ifndef OPENSSL_NO_DH
157 # include <openssl/dh.h>
160 const char ssl3_version_str[] = "SSLv3" OPENSSL_VERSION_PTEXT;
162 #define SSL3_NUM_CIPHERS (sizeof(ssl3_ciphers)/sizeof(SSL_CIPHER))
164 /* list of available SSLv3 ciphers (sorted by id) */
165 OPENSSL_GLOBAL const SSL_CIPHER ssl3_ciphers[] = {
167 /* The RSA ciphers */
171 SSL3_TXT_RSA_NULL_MD5,
172 SSL3_CK_RSA_NULL_MD5,
178 SSL_NOT_EXP | SSL_STRONG_NONE,
179 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
187 SSL3_TXT_RSA_NULL_SHA,
188 SSL3_CK_RSA_NULL_SHA,
194 SSL_NOT_EXP | SSL_STRONG_NONE | SSL_FIPS,
195 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
203 SSL3_TXT_RSA_RC4_40_MD5,
204 SSL3_CK_RSA_RC4_40_MD5,
210 SSL_EXPORT | SSL_EXP40,
211 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
219 SSL3_TXT_RSA_RC4_128_MD5,
220 SSL3_CK_RSA_RC4_128_MD5,
226 SSL_NOT_EXP | SSL_MEDIUM,
227 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
235 SSL3_TXT_RSA_RC4_128_SHA,
236 SSL3_CK_RSA_RC4_128_SHA,
242 SSL_NOT_EXP | SSL_MEDIUM,
243 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
251 SSL3_TXT_RSA_RC2_40_MD5,
252 SSL3_CK_RSA_RC2_40_MD5,
258 SSL_EXPORT | SSL_EXP40,
259 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
265 #ifndef OPENSSL_NO_IDEA
268 SSL3_TXT_RSA_IDEA_128_SHA,
269 SSL3_CK_RSA_IDEA_128_SHA,
275 SSL_NOT_EXP | SSL_MEDIUM,
276 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
285 SSL3_TXT_RSA_DES_40_CBC_SHA,
286 SSL3_CK_RSA_DES_40_CBC_SHA,
292 SSL_EXPORT | SSL_EXP40,
293 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
301 SSL3_TXT_RSA_DES_64_CBC_SHA,
302 SSL3_CK_RSA_DES_64_CBC_SHA,
308 SSL_NOT_EXP | SSL_LOW,
309 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
317 SSL3_TXT_RSA_DES_192_CBC3_SHA,
318 SSL3_CK_RSA_DES_192_CBC3_SHA,
324 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
325 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
334 SSL3_TXT_DH_DSS_DES_40_CBC_SHA,
335 SSL3_CK_DH_DSS_DES_40_CBC_SHA,
341 SSL_EXPORT | SSL_EXP40,
342 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
350 SSL3_TXT_DH_DSS_DES_64_CBC_SHA,
351 SSL3_CK_DH_DSS_DES_64_CBC_SHA,
357 SSL_NOT_EXP | SSL_LOW,
358 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
366 SSL3_TXT_DH_DSS_DES_192_CBC3_SHA,
367 SSL3_CK_DH_DSS_DES_192_CBC3_SHA,
373 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
374 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
382 SSL3_TXT_DH_RSA_DES_40_CBC_SHA,
383 SSL3_CK_DH_RSA_DES_40_CBC_SHA,
389 SSL_EXPORT | SSL_EXP40,
390 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
398 SSL3_TXT_DH_RSA_DES_64_CBC_SHA,
399 SSL3_CK_DH_RSA_DES_64_CBC_SHA,
405 SSL_NOT_EXP | SSL_LOW,
406 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
414 SSL3_TXT_DH_RSA_DES_192_CBC3_SHA,
415 SSL3_CK_DH_RSA_DES_192_CBC3_SHA,
421 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
422 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
427 /* The Ephemeral DH ciphers */
431 SSL3_TXT_DHE_DSS_DES_40_CBC_SHA,
432 SSL3_CK_DHE_DSS_DES_40_CBC_SHA,
438 SSL_EXPORT | SSL_EXP40,
439 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
447 SSL3_TXT_DHE_DSS_DES_64_CBC_SHA,
448 SSL3_CK_DHE_DSS_DES_64_CBC_SHA,
454 SSL_NOT_EXP | SSL_LOW,
455 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
463 SSL3_TXT_DHE_DSS_DES_192_CBC3_SHA,
464 SSL3_CK_DHE_DSS_DES_192_CBC3_SHA,
470 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
471 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
479 SSL3_TXT_DHE_RSA_DES_40_CBC_SHA,
480 SSL3_CK_DHE_RSA_DES_40_CBC_SHA,
486 SSL_EXPORT | SSL_EXP40,
487 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
495 SSL3_TXT_DHE_RSA_DES_64_CBC_SHA,
496 SSL3_CK_DHE_RSA_DES_64_CBC_SHA,
502 SSL_NOT_EXP | SSL_LOW,
503 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
511 SSL3_TXT_DHE_RSA_DES_192_CBC3_SHA,
512 SSL3_CK_DHE_RSA_DES_192_CBC3_SHA,
518 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
519 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
527 SSL3_TXT_ADH_RC4_40_MD5,
528 SSL3_CK_ADH_RC4_40_MD5,
534 SSL_EXPORT | SSL_EXP40,
535 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
543 SSL3_TXT_ADH_RC4_128_MD5,
544 SSL3_CK_ADH_RC4_128_MD5,
550 SSL_NOT_EXP | SSL_MEDIUM,
551 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
559 SSL3_TXT_ADH_DES_40_CBC_SHA,
560 SSL3_CK_ADH_DES_40_CBC_SHA,
566 SSL_EXPORT | SSL_EXP40,
567 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
575 SSL3_TXT_ADH_DES_64_CBC_SHA,
576 SSL3_CK_ADH_DES_64_CBC_SHA,
582 SSL_NOT_EXP | SSL_LOW,
583 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
591 SSL3_TXT_ADH_DES_192_CBC_SHA,
592 SSL3_CK_ADH_DES_192_CBC_SHA,
598 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
599 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
604 #ifndef OPENSSL_NO_KRB5
605 /* The Kerberos ciphers*/
609 SSL3_TXT_KRB5_DES_64_CBC_SHA,
610 SSL3_CK_KRB5_DES_64_CBC_SHA,
616 SSL_NOT_EXP | SSL_LOW,
617 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
625 SSL3_TXT_KRB5_DES_192_CBC3_SHA,
626 SSL3_CK_KRB5_DES_192_CBC3_SHA,
632 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
633 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
641 SSL3_TXT_KRB5_RC4_128_SHA,
642 SSL3_CK_KRB5_RC4_128_SHA,
648 SSL_NOT_EXP | SSL_MEDIUM,
649 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
657 SSL3_TXT_KRB5_IDEA_128_CBC_SHA,
658 SSL3_CK_KRB5_IDEA_128_CBC_SHA,
664 SSL_NOT_EXP | SSL_MEDIUM,
665 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
673 SSL3_TXT_KRB5_DES_64_CBC_MD5,
674 SSL3_CK_KRB5_DES_64_CBC_MD5,
680 SSL_NOT_EXP | SSL_LOW,
681 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
689 SSL3_TXT_KRB5_DES_192_CBC3_MD5,
690 SSL3_CK_KRB5_DES_192_CBC3_MD5,
696 SSL_NOT_EXP | SSL_HIGH,
697 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
705 SSL3_TXT_KRB5_RC4_128_MD5,
706 SSL3_CK_KRB5_RC4_128_MD5,
712 SSL_NOT_EXP | SSL_MEDIUM,
713 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
721 SSL3_TXT_KRB5_IDEA_128_CBC_MD5,
722 SSL3_CK_KRB5_IDEA_128_CBC_MD5,
728 SSL_NOT_EXP | SSL_MEDIUM,
729 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
737 SSL3_TXT_KRB5_DES_40_CBC_SHA,
738 SSL3_CK_KRB5_DES_40_CBC_SHA,
744 SSL_EXPORT | SSL_EXP40,
745 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
753 SSL3_TXT_KRB5_RC2_40_CBC_SHA,
754 SSL3_CK_KRB5_RC2_40_CBC_SHA,
760 SSL_EXPORT | SSL_EXP40,
761 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
769 SSL3_TXT_KRB5_RC4_40_SHA,
770 SSL3_CK_KRB5_RC4_40_SHA,
776 SSL_EXPORT | SSL_EXP40,
777 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
785 SSL3_TXT_KRB5_DES_40_CBC_MD5,
786 SSL3_CK_KRB5_DES_40_CBC_MD5,
792 SSL_EXPORT | SSL_EXP40,
793 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
801 SSL3_TXT_KRB5_RC2_40_CBC_MD5,
802 SSL3_CK_KRB5_RC2_40_CBC_MD5,
808 SSL_EXPORT | SSL_EXP40,
809 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
817 SSL3_TXT_KRB5_RC4_40_MD5,
818 SSL3_CK_KRB5_RC4_40_MD5,
824 SSL_EXPORT | SSL_EXP40,
825 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
829 #endif /* OPENSSL_NO_KRB5 */
831 /* New AES ciphersuites */
835 TLS1_TXT_RSA_WITH_AES_128_SHA,
836 TLS1_CK_RSA_WITH_AES_128_SHA,
842 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
843 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
850 TLS1_TXT_DH_DSS_WITH_AES_128_SHA,
851 TLS1_CK_DH_DSS_WITH_AES_128_SHA,
857 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
858 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
865 TLS1_TXT_DH_RSA_WITH_AES_128_SHA,
866 TLS1_CK_DH_RSA_WITH_AES_128_SHA,
872 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
873 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
880 TLS1_TXT_DHE_DSS_WITH_AES_128_SHA,
881 TLS1_CK_DHE_DSS_WITH_AES_128_SHA,
887 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
888 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
895 TLS1_TXT_DHE_RSA_WITH_AES_128_SHA,
896 TLS1_CK_DHE_RSA_WITH_AES_128_SHA,
902 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
903 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
910 TLS1_TXT_ADH_WITH_AES_128_SHA,
911 TLS1_CK_ADH_WITH_AES_128_SHA,
917 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
918 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
926 TLS1_TXT_RSA_WITH_AES_256_SHA,
927 TLS1_CK_RSA_WITH_AES_256_SHA,
933 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
934 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
941 TLS1_TXT_DH_DSS_WITH_AES_256_SHA,
942 TLS1_CK_DH_DSS_WITH_AES_256_SHA,
948 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
949 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
957 TLS1_TXT_DH_RSA_WITH_AES_256_SHA,
958 TLS1_CK_DH_RSA_WITH_AES_256_SHA,
964 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
965 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
973 TLS1_TXT_DHE_DSS_WITH_AES_256_SHA,
974 TLS1_CK_DHE_DSS_WITH_AES_256_SHA,
980 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
981 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
989 TLS1_TXT_DHE_RSA_WITH_AES_256_SHA,
990 TLS1_CK_DHE_RSA_WITH_AES_256_SHA,
996 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
997 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1005 TLS1_TXT_ADH_WITH_AES_256_SHA,
1006 TLS1_CK_ADH_WITH_AES_256_SHA,
1012 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1013 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1018 /* TLS v1.2 ciphersuites */
1022 TLS1_TXT_RSA_WITH_NULL_SHA256,
1023 TLS1_CK_RSA_WITH_NULL_SHA256,
1029 SSL_NOT_EXP | SSL_STRONG_NONE | SSL_FIPS,
1030 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1038 TLS1_TXT_RSA_WITH_AES_128_SHA256,
1039 TLS1_CK_RSA_WITH_AES_128_SHA256,
1045 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1046 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1054 TLS1_TXT_RSA_WITH_AES_256_SHA256,
1055 TLS1_CK_RSA_WITH_AES_256_SHA256,
1061 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1062 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1070 TLS1_TXT_DH_DSS_WITH_AES_128_SHA256,
1071 TLS1_CK_DH_DSS_WITH_AES_128_SHA256,
1077 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1078 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1086 TLS1_TXT_DH_RSA_WITH_AES_128_SHA256,
1087 TLS1_CK_DH_RSA_WITH_AES_128_SHA256,
1093 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1094 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1102 TLS1_TXT_DHE_DSS_WITH_AES_128_SHA256,
1103 TLS1_CK_DHE_DSS_WITH_AES_128_SHA256,
1109 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1110 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1115 #ifndef OPENSSL_NO_CAMELLIA
1116 /* Camellia ciphersuites from RFC4132 (128-bit portion) */
1121 TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA,
1122 TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA,
1128 SSL_NOT_EXP | SSL_HIGH,
1129 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1137 TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA,
1138 TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA,
1144 SSL_NOT_EXP | SSL_HIGH,
1145 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1153 TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA,
1154 TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA,
1160 SSL_NOT_EXP | SSL_HIGH,
1161 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1169 TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA,
1170 TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA,
1176 SSL_NOT_EXP | SSL_HIGH,
1177 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1185 TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA,
1186 TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA,
1192 SSL_NOT_EXP | SSL_HIGH,
1193 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1201 TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA,
1202 TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA,
1208 SSL_NOT_EXP | SSL_HIGH,
1209 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1213 #endif /* OPENSSL_NO_CAMELLIA */
1215 /* TLS v1.2 ciphersuites */
1219 TLS1_TXT_DHE_RSA_WITH_AES_128_SHA256,
1220 TLS1_CK_DHE_RSA_WITH_AES_128_SHA256,
1226 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1227 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1235 TLS1_TXT_DH_DSS_WITH_AES_256_SHA256,
1236 TLS1_CK_DH_DSS_WITH_AES_256_SHA256,
1242 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1243 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1251 TLS1_TXT_DH_RSA_WITH_AES_256_SHA256,
1252 TLS1_CK_DH_RSA_WITH_AES_256_SHA256,
1258 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1259 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1267 TLS1_TXT_DHE_DSS_WITH_AES_256_SHA256,
1268 TLS1_CK_DHE_DSS_WITH_AES_256_SHA256,
1274 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1275 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1283 TLS1_TXT_DHE_RSA_WITH_AES_256_SHA256,
1284 TLS1_CK_DHE_RSA_WITH_AES_256_SHA256,
1290 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1291 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1299 TLS1_TXT_ADH_WITH_AES_128_SHA256,
1300 TLS1_CK_ADH_WITH_AES_128_SHA256,
1306 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1307 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1315 TLS1_TXT_ADH_WITH_AES_256_SHA256,
1316 TLS1_CK_ADH_WITH_AES_256_SHA256,
1322 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1323 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1328 /* GOST Ciphersuites */
1332 "GOST94-GOST89-GOST89",
1336 SSL_eGOST2814789CNT,
1339 SSL_NOT_EXP | SSL_HIGH,
1340 SSL_HANDSHAKE_MAC_GOST94 | TLS1_PRF_GOST94 | TLS1_STREAM_MAC,
1345 "GOST2001-GOST89-GOST89",
1349 SSL_eGOST2814789CNT,
1352 SSL_NOT_EXP | SSL_HIGH,
1353 SSL_HANDSHAKE_MAC_GOST94 | TLS1_PRF_GOST94 | TLS1_STREAM_MAC,
1358 "GOST94-NULL-GOST94",
1365 SSL_NOT_EXP | SSL_STRONG_NONE,
1366 SSL_HANDSHAKE_MAC_GOST94 | TLS1_PRF_GOST94,
1371 "GOST2001-NULL-GOST94",
1378 SSL_NOT_EXP | SSL_STRONG_NONE,
1379 SSL_HANDSHAKE_MAC_GOST94 | TLS1_PRF_GOST94,
1383 #ifndef OPENSSL_NO_CAMELLIA
1384 /* Camellia ciphersuites from RFC4132 (256-bit portion) */
1389 TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA,
1390 TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA,
1396 SSL_NOT_EXP | SSL_HIGH,
1397 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1404 TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA,
1405 TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA,
1411 SSL_NOT_EXP | SSL_HIGH,
1412 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1420 TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA,
1421 TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA,
1427 SSL_NOT_EXP | SSL_HIGH,
1428 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1436 TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA,
1437 TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA,
1443 SSL_NOT_EXP | SSL_HIGH,
1444 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1452 TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA,
1453 TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA,
1459 SSL_NOT_EXP | SSL_HIGH,
1460 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1468 TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA,
1469 TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA,
1475 SSL_NOT_EXP | SSL_HIGH,
1476 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1480 #endif /* OPENSSL_NO_CAMELLIA */
1482 #ifndef OPENSSL_NO_PSK
1486 TLS1_TXT_PSK_WITH_RC4_128_SHA,
1487 TLS1_CK_PSK_WITH_RC4_128_SHA,
1493 SSL_NOT_EXP | SSL_MEDIUM,
1494 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1502 TLS1_TXT_PSK_WITH_3DES_EDE_CBC_SHA,
1503 TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA,
1509 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1510 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1518 TLS1_TXT_PSK_WITH_AES_128_CBC_SHA,
1519 TLS1_CK_PSK_WITH_AES_128_CBC_SHA,
1525 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1526 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1534 TLS1_TXT_PSK_WITH_AES_256_CBC_SHA,
1535 TLS1_CK_PSK_WITH_AES_256_CBC_SHA,
1541 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1542 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1546 #endif /* OPENSSL_NO_PSK */
1548 #ifndef OPENSSL_NO_SEED
1549 /* SEED ciphersuites from RFC4162 */
1554 TLS1_TXT_RSA_WITH_SEED_SHA,
1555 TLS1_CK_RSA_WITH_SEED_SHA,
1561 SSL_NOT_EXP | SSL_MEDIUM,
1562 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1570 TLS1_TXT_DH_DSS_WITH_SEED_SHA,
1571 TLS1_CK_DH_DSS_WITH_SEED_SHA,
1577 SSL_NOT_EXP | SSL_MEDIUM,
1578 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1586 TLS1_TXT_DH_RSA_WITH_SEED_SHA,
1587 TLS1_CK_DH_RSA_WITH_SEED_SHA,
1593 SSL_NOT_EXP | SSL_MEDIUM,
1594 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1602 TLS1_TXT_DHE_DSS_WITH_SEED_SHA,
1603 TLS1_CK_DHE_DSS_WITH_SEED_SHA,
1609 SSL_NOT_EXP | SSL_MEDIUM,
1610 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1618 TLS1_TXT_DHE_RSA_WITH_SEED_SHA,
1619 TLS1_CK_DHE_RSA_WITH_SEED_SHA,
1625 SSL_NOT_EXP | SSL_MEDIUM,
1626 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1634 TLS1_TXT_ADH_WITH_SEED_SHA,
1635 TLS1_CK_ADH_WITH_SEED_SHA,
1641 SSL_NOT_EXP | SSL_MEDIUM,
1642 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1647 #endif /* OPENSSL_NO_SEED */
1649 /* GCM ciphersuites from RFC5288 */
1654 TLS1_TXT_RSA_WITH_AES_128_GCM_SHA256,
1655 TLS1_CK_RSA_WITH_AES_128_GCM_SHA256,
1661 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1662 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1670 TLS1_TXT_RSA_WITH_AES_256_GCM_SHA384,
1671 TLS1_CK_RSA_WITH_AES_256_GCM_SHA384,
1677 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1678 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
1686 TLS1_TXT_DHE_RSA_WITH_AES_128_GCM_SHA256,
1687 TLS1_CK_DHE_RSA_WITH_AES_128_GCM_SHA256,
1693 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1694 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1702 TLS1_TXT_DHE_RSA_WITH_AES_256_GCM_SHA384,
1703 TLS1_CK_DHE_RSA_WITH_AES_256_GCM_SHA384,
1709 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1710 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
1718 TLS1_TXT_DH_RSA_WITH_AES_128_GCM_SHA256,
1719 TLS1_CK_DH_RSA_WITH_AES_128_GCM_SHA256,
1725 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1726 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1734 TLS1_TXT_DH_RSA_WITH_AES_256_GCM_SHA384,
1735 TLS1_CK_DH_RSA_WITH_AES_256_GCM_SHA384,
1741 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1742 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
1750 TLS1_TXT_DHE_DSS_WITH_AES_128_GCM_SHA256,
1751 TLS1_CK_DHE_DSS_WITH_AES_128_GCM_SHA256,
1757 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1758 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1766 TLS1_TXT_DHE_DSS_WITH_AES_256_GCM_SHA384,
1767 TLS1_CK_DHE_DSS_WITH_AES_256_GCM_SHA384,
1773 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1774 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
1782 TLS1_TXT_DH_DSS_WITH_AES_128_GCM_SHA256,
1783 TLS1_CK_DH_DSS_WITH_AES_128_GCM_SHA256,
1789 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1790 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1798 TLS1_TXT_DH_DSS_WITH_AES_256_GCM_SHA384,
1799 TLS1_CK_DH_DSS_WITH_AES_256_GCM_SHA384,
1805 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1806 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
1814 TLS1_TXT_ADH_WITH_AES_128_GCM_SHA256,
1815 TLS1_CK_ADH_WITH_AES_128_GCM_SHA256,
1821 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1822 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1830 TLS1_TXT_ADH_WITH_AES_256_GCM_SHA384,
1831 TLS1_CK_ADH_WITH_AES_256_GCM_SHA384,
1837 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1838 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
1842 #ifdef OPENSSL_SSL_DEBUG_BROKEN_PROTOCOL
1858 #ifndef OPENSSL_NO_CAMELLIA
1859 /* TLS 1.2 Camellia SHA-256 ciphersuites from RFC5932 */
1864 TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA256,
1865 TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA256,
1871 SSL_NOT_EXP | SSL_HIGH,
1872 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1880 TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256,
1881 TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256,
1887 SSL_NOT_EXP | SSL_HIGH,
1888 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1896 TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256,
1897 TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256,
1903 SSL_NOT_EXP | SSL_HIGH,
1904 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1912 TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256,
1913 TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256,
1919 SSL_NOT_EXP | SSL_HIGH,
1920 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1928 TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256,
1929 TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256,
1935 SSL_NOT_EXP | SSL_HIGH,
1936 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1944 TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA256,
1945 TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA256,
1951 SSL_NOT_EXP | SSL_HIGH,
1952 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1960 TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA256,
1961 TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA256,
1967 SSL_NOT_EXP | SSL_HIGH,
1968 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1976 TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256,
1977 TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256,
1983 SSL_NOT_EXP | SSL_HIGH,
1984 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1992 TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256,
1993 TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256,
1999 SSL_NOT_EXP | SSL_HIGH,
2000 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2008 TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256,
2009 TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256,
2015 SSL_NOT_EXP | SSL_HIGH,
2016 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2024 TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256,
2025 TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256,
2031 SSL_NOT_EXP | SSL_HIGH,
2032 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2040 TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA256,
2041 TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA256,
2047 SSL_NOT_EXP | SSL_HIGH,
2048 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2054 #ifndef OPENSSL_NO_EC
2058 TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA,
2059 TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA,
2065 SSL_NOT_EXP | SSL_STRONG_NONE | SSL_FIPS,
2066 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2074 TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA,
2075 TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA,
2081 SSL_NOT_EXP | SSL_MEDIUM,
2082 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2090 TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA,
2091 TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA,
2097 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2098 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2106 TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA,
2107 TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA,
2113 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2114 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2122 TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA,
2123 TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA,
2129 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2130 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2138 TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA,
2139 TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA,
2145 SSL_NOT_EXP | SSL_STRONG_NONE | SSL_FIPS,
2146 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2154 TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA,
2155 TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA,
2161 SSL_NOT_EXP | SSL_MEDIUM,
2162 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2170 TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA,
2171 TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA,
2177 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2178 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2186 TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
2187 TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
2193 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2194 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2202 TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
2203 TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
2209 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2210 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2218 TLS1_TXT_ECDH_RSA_WITH_NULL_SHA,
2219 TLS1_CK_ECDH_RSA_WITH_NULL_SHA,
2225 SSL_NOT_EXP | SSL_STRONG_NONE | SSL_FIPS,
2226 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2234 TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA,
2235 TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA,
2241 SSL_NOT_EXP | SSL_MEDIUM,
2242 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2250 TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA,
2251 TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA,
2257 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2258 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2266 TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA,
2267 TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA,
2273 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2274 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2282 TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA,
2283 TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA,
2289 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2290 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2298 TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA,
2299 TLS1_CK_ECDHE_RSA_WITH_NULL_SHA,
2305 SSL_NOT_EXP | SSL_STRONG_NONE | SSL_FIPS,
2306 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2314 TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA,
2315 TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA,
2321 SSL_NOT_EXP | SSL_MEDIUM,
2322 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2330 TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA,
2331 TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA,
2337 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2338 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2346 TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA,
2347 TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA,
2353 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2354 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2362 TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA,
2363 TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA,
2369 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2370 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2378 TLS1_TXT_ECDH_anon_WITH_NULL_SHA,
2379 TLS1_CK_ECDH_anon_WITH_NULL_SHA,
2385 SSL_NOT_EXP | SSL_STRONG_NONE | SSL_FIPS,
2386 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2394 TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA,
2395 TLS1_CK_ECDH_anon_WITH_RC4_128_SHA,
2401 SSL_NOT_EXP | SSL_MEDIUM,
2402 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2410 TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA,
2411 TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA,
2417 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2418 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2426 TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA,
2427 TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA,
2433 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2434 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2442 TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA,
2443 TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA,
2449 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2450 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2454 #endif /* OPENSSL_NO_EC */
2456 #ifndef OPENSSL_NO_SRP
2460 TLS1_TXT_SRP_SHA_WITH_3DES_EDE_CBC_SHA,
2461 TLS1_CK_SRP_SHA_WITH_3DES_EDE_CBC_SHA,
2467 SSL_NOT_EXP | SSL_HIGH,
2468 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2476 TLS1_TXT_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA,
2477 TLS1_CK_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA,
2483 SSL_NOT_EXP | SSL_HIGH,
2484 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2492 TLS1_TXT_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA,
2493 TLS1_CK_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA,
2499 SSL_NOT_EXP | SSL_HIGH,
2500 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2508 TLS1_TXT_SRP_SHA_WITH_AES_128_CBC_SHA,
2509 TLS1_CK_SRP_SHA_WITH_AES_128_CBC_SHA,
2515 SSL_NOT_EXP | SSL_HIGH,
2516 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2524 TLS1_TXT_SRP_SHA_RSA_WITH_AES_128_CBC_SHA,
2525 TLS1_CK_SRP_SHA_RSA_WITH_AES_128_CBC_SHA,
2531 SSL_NOT_EXP | SSL_HIGH,
2532 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2540 TLS1_TXT_SRP_SHA_DSS_WITH_AES_128_CBC_SHA,
2541 TLS1_CK_SRP_SHA_DSS_WITH_AES_128_CBC_SHA,
2547 SSL_NOT_EXP | SSL_HIGH,
2548 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2556 TLS1_TXT_SRP_SHA_WITH_AES_256_CBC_SHA,
2557 TLS1_CK_SRP_SHA_WITH_AES_256_CBC_SHA,
2563 SSL_NOT_EXP | SSL_HIGH,
2564 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2572 TLS1_TXT_SRP_SHA_RSA_WITH_AES_256_CBC_SHA,
2573 TLS1_CK_SRP_SHA_RSA_WITH_AES_256_CBC_SHA,
2579 SSL_NOT_EXP | SSL_HIGH,
2580 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2588 TLS1_TXT_SRP_SHA_DSS_WITH_AES_256_CBC_SHA,
2589 TLS1_CK_SRP_SHA_DSS_WITH_AES_256_CBC_SHA,
2595 SSL_NOT_EXP | SSL_HIGH,
2596 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2600 #endif /* OPENSSL_NO_SRP */
2601 #ifndef OPENSSL_NO_EC
2603 /* HMAC based TLS v1.2 ciphersuites from RFC5289 */
2608 TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_SHA256,
2609 TLS1_CK_ECDHE_ECDSA_WITH_AES_128_SHA256,
2615 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2616 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2624 TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_SHA384,
2625 TLS1_CK_ECDHE_ECDSA_WITH_AES_256_SHA384,
2631 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2632 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
2640 TLS1_TXT_ECDH_ECDSA_WITH_AES_128_SHA256,
2641 TLS1_CK_ECDH_ECDSA_WITH_AES_128_SHA256,
2647 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2648 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2656 TLS1_TXT_ECDH_ECDSA_WITH_AES_256_SHA384,
2657 TLS1_CK_ECDH_ECDSA_WITH_AES_256_SHA384,
2663 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2664 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
2672 TLS1_TXT_ECDHE_RSA_WITH_AES_128_SHA256,
2673 TLS1_CK_ECDHE_RSA_WITH_AES_128_SHA256,
2679 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2680 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2688 TLS1_TXT_ECDHE_RSA_WITH_AES_256_SHA384,
2689 TLS1_CK_ECDHE_RSA_WITH_AES_256_SHA384,
2695 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2696 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
2704 TLS1_TXT_ECDH_RSA_WITH_AES_128_SHA256,
2705 TLS1_CK_ECDH_RSA_WITH_AES_128_SHA256,
2711 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2712 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2720 TLS1_TXT_ECDH_RSA_WITH_AES_256_SHA384,
2721 TLS1_CK_ECDH_RSA_WITH_AES_256_SHA384,
2727 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2728 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
2733 /* GCM based TLS v1.2 ciphersuites from RFC5289 */
2738 TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
2739 TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
2745 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2746 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2754 TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
2755 TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
2761 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2762 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
2770 TLS1_TXT_ECDH_ECDSA_WITH_AES_128_GCM_SHA256,
2771 TLS1_CK_ECDH_ECDSA_WITH_AES_128_GCM_SHA256,
2777 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2778 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2786 TLS1_TXT_ECDH_ECDSA_WITH_AES_256_GCM_SHA384,
2787 TLS1_CK_ECDH_ECDSA_WITH_AES_256_GCM_SHA384,
2793 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2794 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
2802 TLS1_TXT_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
2803 TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
2809 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2810 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2818 TLS1_TXT_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
2819 TLS1_CK_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
2825 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2826 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
2834 TLS1_TXT_ECDH_RSA_WITH_AES_128_GCM_SHA256,
2835 TLS1_CK_ECDH_RSA_WITH_AES_128_GCM_SHA256,
2841 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2842 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2850 TLS1_TXT_ECDH_RSA_WITH_AES_256_GCM_SHA384,
2851 TLS1_CK_ECDH_RSA_WITH_AES_256_GCM_SHA384,
2857 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2858 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
2863 # ifndef OPENSSL_NO_CAMELLIA
2866 TLS1_TXT_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256,
2867 TLS1_CK_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256,
2873 SSL_NOT_EXP | SSL_HIGH,
2874 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2880 TLS1_TXT_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384,
2881 TLS1_CK_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384,
2887 SSL_NOT_EXP | SSL_HIGH,
2888 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
2894 TLS1_TXT_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256,
2895 TLS1_CK_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256,
2901 SSL_NOT_EXP | SSL_HIGH,
2902 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2908 TLS1_TXT_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384,
2909 TLS1_CK_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384,
2915 SSL_NOT_EXP | SSL_HIGH,
2916 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
2922 TLS1_TXT_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256,
2923 TLS1_CK_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256,
2929 SSL_NOT_EXP | SSL_HIGH,
2930 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2936 TLS1_TXT_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384,
2937 TLS1_CK_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384,
2943 SSL_NOT_EXP | SSL_HIGH,
2944 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
2950 TLS1_TXT_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256,
2951 TLS1_CK_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256,
2957 SSL_NOT_EXP | SSL_HIGH,
2958 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2964 TLS1_TXT_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384,
2965 TLS1_CK_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384,
2971 SSL_NOT_EXP | SSL_HIGH,
2972 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
2975 # endif /* OPENSSL_NO_CAMELLIA */
2976 #endif /* OPENSSL_NO_EC */
2978 #ifdef TEMP_GOST_TLS
2986 SSL_eGOST2814789CNT,
2989 SSL_NOT_EXP | SSL_HIGH,
2990 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
3000 SSL_eGOST2814789CNT,
3003 SSL_NOT_EXP | SSL_HIGH,
3004 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
3013 SSL_eGOST2814789CNT,
3016 SSL_NOT_EXP | SSL_HIGH,
3017 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
3022 "GOST-GOST89STREAM",
3026 SSL_eGOST2814789CNT,
3029 SSL_NOT_EXP | SSL_HIGH,
3030 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF | TLS1_STREAM_MAC,
3038 const SSL3_ENC_METHOD SSLv3_enc_data = {
3041 ssl3_setup_key_block,
3042 ssl3_generate_master_secret,
3043 ssl3_change_cipher_state,
3044 ssl3_final_finish_mac,
3045 MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH,
3046 ssl3_cert_verify_mac,
3047 SSL3_MD_CLIENT_FINISHED_CONST, 4,
3048 SSL3_MD_SERVER_FINISHED_CONST, 4,
3050 (int (*)(SSL *, unsigned char *, size_t, const char *,
3051 size_t, const unsigned char *, size_t,
3052 int use_context))ssl_undefined_function,
3054 SSL3_HM_HEADER_LENGTH,
3055 ssl3_set_handshake_header,
3056 ssl3_handshake_write
3059 long ssl3_default_timeout(void)
3062 * 2 hours, the 24 hours mentioned in the SSLv3 spec is way too long for
3063 * http, the cache would over fill
3065 return (60 * 60 * 2);
3068 int ssl3_num_ciphers(void)
3070 return (SSL3_NUM_CIPHERS);
3073 const SSL_CIPHER *ssl3_get_cipher(unsigned int u)
3075 if (u < SSL3_NUM_CIPHERS)
3076 return (&(ssl3_ciphers[SSL3_NUM_CIPHERS - 1 - u]));
3081 int ssl3_set_handshake_header(SSL *s, int htype, unsigned long len)
3083 unsigned char *p = (unsigned char *)s->init_buf->data;
3086 s->init_num = (int)len + SSL3_HM_HEADER_LENGTH;
3092 int ssl3_handshake_write(SSL *s)
3094 return ssl3_do_write(s, SSL3_RT_HANDSHAKE);
3097 int ssl3_new(SSL *s)
3101 if ((s3 = OPENSSL_malloc(sizeof *s3)) == NULL)
3103 memset(s3, 0, sizeof *s3);
3106 #ifndef OPENSSL_NO_SRP
3107 if(!SSL_SRP_CTX_init(s))
3110 s->method->ssl_clear(s);
3116 void ssl3_free(SSL *s)
3121 ssl3_cleanup_key_block(s);
3122 #ifndef OPENSSL_NO_DH
3123 DH_free(s->s3->tmp.dh);
3125 #ifndef OPENSSL_NO_EC
3126 EC_KEY_free(s->s3->tmp.ecdh);
3129 if (s->s3->tmp.ca_names != NULL)
3130 sk_X509_NAME_pop_free(s->s3->tmp.ca_names, X509_NAME_free);
3131 BIO_free(s->s3->handshake_buffer);
3132 if (s->s3->handshake_dgst)
3133 ssl3_free_digest_list(s);
3134 #ifndef OPENSSL_NO_TLSEXT
3135 if (s->s3->alpn_selected)
3136 OPENSSL_free(s->s3->alpn_selected);
3139 #ifndef OPENSSL_NO_SRP
3140 SSL_SRP_CTX_free(s);
3142 OPENSSL_cleanse(s->s3, sizeof *s->s3);
3143 OPENSSL_free(s->s3);
3147 void ssl3_clear(SSL *s)
3151 ssl3_cleanup_key_block(s);
3152 if (s->s3->tmp.ca_names != NULL)
3153 sk_X509_NAME_pop_free(s->s3->tmp.ca_names, X509_NAME_free);
3155 #ifndef OPENSSL_NO_DH
3156 DH_free(s->s3->tmp.dh);
3157 s->s3->tmp.dh = NULL;
3159 #ifndef OPENSSL_NO_EC
3160 EC_KEY_free(s->s3->tmp.ecdh);
3161 s->s3->tmp.ecdh = NULL;
3163 #ifndef OPENSSL_NO_TLSEXT
3164 # ifndef OPENSSL_NO_EC
3165 s->s3->is_probably_safari = 0;
3166 # endif /* !OPENSSL_NO_EC */
3167 #endif /* !OPENSSL_NO_TLSEXT */
3169 init_extra = s->s3->init_extra;
3170 BIO_free(s->s3->handshake_buffer);
3171 s->s3->handshake_buffer = NULL;
3172 if (s->s3->handshake_dgst) {
3173 ssl3_free_digest_list(s);
3175 #if !defined(OPENSSL_NO_TLSEXT)
3176 if (s->s3->alpn_selected) {
3177 free(s->s3->alpn_selected);
3178 s->s3->alpn_selected = NULL;
3181 memset(s->s3, 0, sizeof *s->s3);
3182 s->s3->init_extra = init_extra;
3184 ssl_free_wbio_buffer(s);
3186 s->s3->renegotiate = 0;
3187 s->s3->total_renegotiations = 0;
3188 s->s3->num_renegotiations = 0;
3189 s->s3->in_read_app_data = 0;
3190 s->version = SSL3_VERSION;
3192 #if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
3193 if (s->next_proto_negotiated) {
3194 OPENSSL_free(s->next_proto_negotiated);
3195 s->next_proto_negotiated = NULL;
3196 s->next_proto_negotiated_len = 0;
3201 #ifndef OPENSSL_NO_SRP
3202 static char *srp_password_from_info_cb(SSL *s, void *arg)
3204 return BUF_strdup(s->srp_ctx.info);
3208 static int ssl3_set_req_cert_type(CERT *c, const unsigned char *p,
3211 long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg)
3216 case SSL_CTRL_GET_SESSION_REUSED:
3219 case SSL_CTRL_GET_CLIENT_CERT_REQUEST:
3221 case SSL_CTRL_GET_NUM_RENEGOTIATIONS:
3222 ret = s->s3->num_renegotiations;
3224 case SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS:
3225 ret = s->s3->num_renegotiations;
3226 s->s3->num_renegotiations = 0;
3228 case SSL_CTRL_GET_TOTAL_RENEGOTIATIONS:
3229 ret = s->s3->total_renegotiations;
3231 case SSL_CTRL_GET_FLAGS:
3232 ret = (int)(s->s3->flags);
3234 #ifndef OPENSSL_NO_RSA
3235 case SSL_CTRL_NEED_TMP_RSA:
3236 if ((s->cert != NULL) && (s->cert->rsa_tmp == NULL) &&
3237 ((s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) ||
3238 (EVP_PKEY_size(s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey) >
3242 case SSL_CTRL_SET_TMP_RSA:
3244 RSA *rsa = (RSA *)parg;
3246 SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
3249 if ((rsa = RSAPrivateKey_dup(rsa)) == NULL) {
3250 SSLerr(SSL_F_SSL3_CTRL, ERR_R_RSA_LIB);
3253 RSA_free(s->cert->rsa_tmp);
3254 s->cert->rsa_tmp = rsa;
3258 case SSL_CTRL_SET_TMP_RSA_CB:
3260 SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3264 #ifndef OPENSSL_NO_DH
3265 case SSL_CTRL_SET_TMP_DH:
3267 DH *dh = (DH *)parg;
3269 SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
3272 if (!ssl_security(s, SSL_SECOP_TMP_DH,
3273 DH_security_bits(dh), 0, dh)) {
3274 SSLerr(SSL_F_SSL3_CTRL, SSL_R_DH_KEY_TOO_SMALL);
3277 if ((dh = DHparams_dup(dh)) == NULL) {
3278 SSLerr(SSL_F_SSL3_CTRL, ERR_R_DH_LIB);
3281 if (!(s->options & SSL_OP_SINGLE_DH_USE)) {
3282 if (!DH_generate_key(dh)) {
3284 SSLerr(SSL_F_SSL3_CTRL, ERR_R_DH_LIB);
3288 DH_free(s->cert->dh_tmp);
3289 s->cert->dh_tmp = dh;
3293 case SSL_CTRL_SET_TMP_DH_CB:
3295 SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3298 case SSL_CTRL_SET_DH_AUTO:
3299 s->cert->dh_tmp_auto = larg;
3302 #ifndef OPENSSL_NO_EC
3303 case SSL_CTRL_SET_TMP_ECDH:
3305 EC_KEY *ecdh = NULL;
3308 SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
3311 if (!EC_KEY_up_ref((EC_KEY *)parg)) {
3312 SSLerr(SSL_F_SSL3_CTRL, ERR_R_ECDH_LIB);
3315 ecdh = (EC_KEY *)parg;
3316 if (!(s->options & SSL_OP_SINGLE_ECDH_USE)) {
3317 if (!EC_KEY_generate_key(ecdh)) {
3319 SSLerr(SSL_F_SSL3_CTRL, ERR_R_ECDH_LIB);
3323 EC_KEY_free(s->cert->ecdh_tmp);
3324 s->cert->ecdh_tmp = ecdh;
3328 case SSL_CTRL_SET_TMP_ECDH_CB:
3330 SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3333 #endif /* !OPENSSL_NO_EC */
3334 #ifndef OPENSSL_NO_TLSEXT
3335 case SSL_CTRL_SET_TLSEXT_HOSTNAME:
3336 if (larg == TLSEXT_NAMETYPE_host_name) {
3337 if (s->tlsext_hostname != NULL)
3338 OPENSSL_free(s->tlsext_hostname);
3339 s->tlsext_hostname = NULL;
3344 if (strlen((char *)parg) > TLSEXT_MAXLEN_host_name) {
3345 SSLerr(SSL_F_SSL3_CTRL, SSL_R_SSL3_EXT_INVALID_SERVERNAME);
3348 if ((s->tlsext_hostname = BUF_strdup((char *)parg)) == NULL) {
3349 SSLerr(SSL_F_SSL3_CTRL, ERR_R_INTERNAL_ERROR);
3353 SSLerr(SSL_F_SSL3_CTRL, SSL_R_SSL3_EXT_INVALID_SERVERNAME_TYPE);
3357 case SSL_CTRL_SET_TLSEXT_DEBUG_ARG:
3358 s->tlsext_debug_arg = parg;
3362 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE:
3363 s->tlsext_status_type = larg;
3367 case SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS:
3368 *(STACK_OF(X509_EXTENSION) **)parg = s->tlsext_ocsp_exts;
3372 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS:
3373 s->tlsext_ocsp_exts = parg;
3377 case SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS:
3378 *(STACK_OF(OCSP_RESPID) **)parg = s->tlsext_ocsp_ids;
3382 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS:
3383 s->tlsext_ocsp_ids = parg;
3387 case SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP:
3388 *(unsigned char **)parg = s->tlsext_ocsp_resp;
3389 return s->tlsext_ocsp_resplen;
3391 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP:
3392 if (s->tlsext_ocsp_resp)
3393 OPENSSL_free(s->tlsext_ocsp_resp);
3394 s->tlsext_ocsp_resp = parg;
3395 s->tlsext_ocsp_resplen = larg;
3399 # ifndef OPENSSL_NO_HEARTBEATS
3400 case SSL_CTRL_TLS_EXT_SEND_HEARTBEAT:
3402 ret = dtls1_heartbeat(s);
3404 ret = tls1_heartbeat(s);
3407 case SSL_CTRL_GET_TLS_EXT_HEARTBEAT_PENDING:
3408 ret = s->tlsext_hb_pending;
3411 case SSL_CTRL_SET_TLS_EXT_HEARTBEAT_NO_REQUESTS:
3413 s->tlsext_heartbeat |= SSL_TLSEXT_HB_DONT_RECV_REQUESTS;
3415 s->tlsext_heartbeat &= ~SSL_TLSEXT_HB_DONT_RECV_REQUESTS;
3420 #endif /* !OPENSSL_NO_TLSEXT */
3422 case SSL_CTRL_CHAIN:
3424 return ssl_cert_set1_chain(s, NULL, (STACK_OF(X509) *)parg);
3426 return ssl_cert_set0_chain(s, NULL, (STACK_OF(X509) *)parg);
3428 case SSL_CTRL_CHAIN_CERT:
3430 return ssl_cert_add1_chain_cert(s, NULL, (X509 *)parg);
3432 return ssl_cert_add0_chain_cert(s, NULL, (X509 *)parg);
3434 case SSL_CTRL_GET_CHAIN_CERTS:
3435 *(STACK_OF(X509) **)parg = s->cert->key->chain;
3438 case SSL_CTRL_SELECT_CURRENT_CERT:
3439 return ssl_cert_select_current(s->cert, (X509 *)parg);
3441 case SSL_CTRL_SET_CURRENT_CERT:
3442 if (larg == SSL_CERT_SET_SERVER) {
3444 const SSL_CIPHER *cipher;
3447 cipher = s->s3->tmp.new_cipher;
3451 * No certificate for unauthenticated ciphersuites or using SRP
3454 if (cipher->algorithm_auth & (SSL_aNULL | SSL_aSRP))
3456 cpk = ssl_get_server_send_pkey(s);
3462 return ssl_cert_set_current(s->cert, larg);
3464 #ifndef OPENSSL_NO_EC
3465 case SSL_CTRL_GET_CURVES:
3467 unsigned char *clist;
3471 clist = s->session->tlsext_ellipticcurvelist;
3472 clistlen = s->session->tlsext_ellipticcurvelist_length / 2;
3476 unsigned int cid, nid;
3477 for (i = 0; i < clistlen; i++) {
3479 nid = tls1_ec_curve_id2nid(cid);
3483 cptr[i] = TLSEXT_nid_unknown | cid;
3486 return (int)clistlen;
3489 case SSL_CTRL_SET_CURVES:
3490 return tls1_set_curves(&s->tlsext_ellipticcurvelist,
3491 &s->tlsext_ellipticcurvelist_length,
3494 case SSL_CTRL_SET_CURVES_LIST:
3495 return tls1_set_curves_list(&s->tlsext_ellipticcurvelist,
3496 &s->tlsext_ellipticcurvelist_length,
3499 case SSL_CTRL_GET_SHARED_CURVE:
3500 return tls1_shared_curve(s, larg);
3502 # ifndef OPENSSL_NO_EC
3503 case SSL_CTRL_SET_ECDH_AUTO:
3504 s->cert->ecdh_tmp_auto = larg;
3508 case SSL_CTRL_SET_SIGALGS:
3509 return tls1_set_sigalgs(s->cert, parg, larg, 0);
3511 case SSL_CTRL_SET_SIGALGS_LIST:
3512 return tls1_set_sigalgs_list(s->cert, parg, 0);
3514 case SSL_CTRL_SET_CLIENT_SIGALGS:
3515 return tls1_set_sigalgs(s->cert, parg, larg, 1);
3517 case SSL_CTRL_SET_CLIENT_SIGALGS_LIST:
3518 return tls1_set_sigalgs_list(s->cert, parg, 1);
3520 case SSL_CTRL_GET_CLIENT_CERT_TYPES:
3522 const unsigned char **pctype = parg;
3523 if (s->server || !s->s3->tmp.cert_req)
3525 if (s->cert->ctypes) {
3527 *pctype = s->cert->ctypes;
3528 return (int)s->cert->ctype_num;
3531 *pctype = (unsigned char *)s->s3->tmp.ctype;
3532 return s->s3->tmp.ctype_num;
3535 case SSL_CTRL_SET_CLIENT_CERT_TYPES:
3538 return ssl3_set_req_cert_type(s->cert, parg, larg);
3540 case SSL_CTRL_BUILD_CERT_CHAIN:
3541 return ssl_build_cert_chain(s, NULL, larg);
3543 case SSL_CTRL_SET_VERIFY_CERT_STORE:
3544 return ssl_cert_set_cert_store(s->cert, parg, 0, larg);
3546 case SSL_CTRL_SET_CHAIN_CERT_STORE:
3547 return ssl_cert_set_cert_store(s->cert, parg, 1, larg);
3549 case SSL_CTRL_GET_PEER_SIGNATURE_NID:
3550 if (SSL_USE_SIGALGS(s)) {
3551 if (s->session && s->session->sess_cert) {
3553 sig = s->session->sess_cert->peer_key->digest;
3555 *(int *)parg = EVP_MD_type(sig);
3561 /* Might want to do something here for other versions */
3565 case SSL_CTRL_GET_SERVER_TMP_KEY:
3566 if (s->server || !s->session || !s->session->sess_cert)
3572 sc = s->session->sess_cert;
3573 #if !defined(OPENSSL_NO_RSA) && !defined(OPENSSL_NO_DH) && !defined(OPENSSL_NO_EC)
3574 if (!sc->peer_rsa_tmp && !sc->peer_dh_tmp && !sc->peer_ecdh_tmp)
3577 ptmp = EVP_PKEY_new();
3581 #ifndef OPENSSL_NO_RSA
3582 else if (sc->peer_rsa_tmp)
3583 rv = EVP_PKEY_set1_RSA(ptmp, sc->peer_rsa_tmp);
3585 #ifndef OPENSSL_NO_DH
3586 else if (sc->peer_dh_tmp)
3587 rv = EVP_PKEY_set1_DH(ptmp, sc->peer_dh_tmp);
3589 #ifndef OPENSSL_NO_EC
3590 else if (sc->peer_ecdh_tmp)
3591 rv = EVP_PKEY_set1_EC_KEY(ptmp, sc->peer_ecdh_tmp);
3594 *(EVP_PKEY **)parg = ptmp;
3597 EVP_PKEY_free(ptmp);
3600 #ifndef OPENSSL_NO_EC
3601 case SSL_CTRL_GET_EC_POINT_FORMATS:
3603 SSL_SESSION *sess = s->session;
3604 const unsigned char **pformat = parg;
3605 if (!sess || !sess->tlsext_ecpointformatlist)
3607 *pformat = sess->tlsext_ecpointformatlist;
3608 return (int)sess->tlsext_ecpointformatlist_length;
3612 case SSL_CTRL_CHECK_PROTO_VERSION:
3614 * For library-internal use; checks that the current protocol is the
3615 * highest enabled version (according to s->ctx->method, as version
3616 * negotiation may have changed s->method).
3618 if (s->version == s->ctx->method->version)
3621 * Apparently we're using a version-flexible SSL_METHOD (not at its
3622 * highest protocol version).
3624 if (s->ctx->method->version == SSLv23_method()->version) {
3625 #if TLS_MAX_VERSION != TLS1_2_VERSION
3626 # error Code needs update for SSLv23_method() support beyond TLS1_2_VERSION.
3628 if (!(s->options & SSL_OP_NO_TLSv1_2))
3629 return s->version == TLS1_2_VERSION;
3630 if (!(s->options & SSL_OP_NO_TLSv1_1))
3631 return s->version == TLS1_1_VERSION;
3632 if (!(s->options & SSL_OP_NO_TLSv1))
3633 return s->version == TLS1_VERSION;
3634 if (!(s->options & SSL_OP_NO_SSLv3))
3635 return s->version == SSL3_VERSION;
3637 return 0; /* Unexpected state; fail closed. */
3645 long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp) (void))
3650 #ifndef OPENSSL_NO_RSA
3651 case SSL_CTRL_SET_TMP_RSA_CB:
3653 s->cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
3657 #ifndef OPENSSL_NO_DH
3658 case SSL_CTRL_SET_TMP_DH_CB:
3660 s->cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
3664 #ifndef OPENSSL_NO_EC
3665 case SSL_CTRL_SET_TMP_ECDH_CB:
3667 s->cert->ecdh_tmp_cb = (EC_KEY *(*)(SSL *, int, int))fp;
3671 #ifndef OPENSSL_NO_TLSEXT
3672 case SSL_CTRL_SET_TLSEXT_DEBUG_CB:
3673 s->tlsext_debug_cb = (void (*)(SSL *, int, int,
3674 unsigned char *, int, void *))fp;
3677 case SSL_CTRL_SET_NOT_RESUMABLE_SESS_CB:
3679 s->not_resumable_session_cb = (int (*)(SSL *, int))fp;
3688 long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg)
3695 #ifndef OPENSSL_NO_RSA
3696 case SSL_CTRL_NEED_TMP_RSA:
3697 if ((cert->rsa_tmp == NULL) &&
3698 ((cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) ||
3699 (EVP_PKEY_size(cert->pkeys[SSL_PKEY_RSA_ENC].privatekey) >
3706 case SSL_CTRL_SET_TMP_RSA:
3716 if ((rsa = RSAPrivateKey_dup(rsa)) == NULL)
3720 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_RSA_LIB);
3723 RSA_free(cert->rsa_tmp);
3724 cert->rsa_tmp = rsa;
3729 case SSL_CTRL_SET_TMP_RSA_CB:
3731 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3735 #ifndef OPENSSL_NO_DH
3736 case SSL_CTRL_SET_TMP_DH:
3738 DH *new = NULL, *dh;
3741 if (!ssl_ctx_security(ctx, SSL_SECOP_TMP_DH,
3742 DH_security_bits(dh), 0, dh)) {
3743 SSLerr(SSL_F_SSL3_CTX_CTRL, SSL_R_DH_KEY_TOO_SMALL);
3746 if ((new = DHparams_dup(dh)) == NULL) {
3747 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_DH_LIB);
3750 if (!(ctx->options & SSL_OP_SINGLE_DH_USE)) {
3751 if (!DH_generate_key(new)) {
3752 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_DH_LIB);
3757 DH_free(cert->dh_tmp);
3764 case SSL_CTRL_SET_TMP_DH_CB:
3766 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3769 case SSL_CTRL_SET_DH_AUTO:
3770 ctx->cert->dh_tmp_auto = larg;
3773 #ifndef OPENSSL_NO_EC
3774 case SSL_CTRL_SET_TMP_ECDH:
3776 EC_KEY *ecdh = NULL;
3779 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_ECDH_LIB);
3782 ecdh = EC_KEY_dup((EC_KEY *)parg);
3784 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_EC_LIB);
3787 if (!(ctx->options & SSL_OP_SINGLE_ECDH_USE)) {
3788 if (!EC_KEY_generate_key(ecdh)) {
3790 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_ECDH_LIB);
3795 EC_KEY_free(cert->ecdh_tmp);
3796 cert->ecdh_tmp = ecdh;
3800 case SSL_CTRL_SET_TMP_ECDH_CB:
3802 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3805 #endif /* !OPENSSL_NO_EC */
3806 #ifndef OPENSSL_NO_TLSEXT
3807 case SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG:
3808 ctx->tlsext_servername_arg = parg;
3810 case SSL_CTRL_SET_TLSEXT_TICKET_KEYS:
3811 case SSL_CTRL_GET_TLSEXT_TICKET_KEYS:
3813 unsigned char *keys = parg;
3817 SSLerr(SSL_F_SSL3_CTX_CTRL, SSL_R_INVALID_TICKET_KEYS_LENGTH);
3820 if (cmd == SSL_CTRL_SET_TLSEXT_TICKET_KEYS) {
3821 memcpy(ctx->tlsext_tick_key_name, keys, 16);
3822 memcpy(ctx->tlsext_tick_hmac_key, keys + 16, 16);
3823 memcpy(ctx->tlsext_tick_aes_key, keys + 32, 16);
3825 memcpy(keys, ctx->tlsext_tick_key_name, 16);
3826 memcpy(keys + 16, ctx->tlsext_tick_hmac_key, 16);
3827 memcpy(keys + 32, ctx->tlsext_tick_aes_key, 16);
3832 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG:
3833 ctx->tlsext_status_arg = parg;
3836 # ifndef OPENSSL_NO_SRP
3837 case SSL_CTRL_SET_TLS_EXT_SRP_USERNAME:
3838 ctx->srp_ctx.srp_Mask |= SSL_kSRP;
3839 if (ctx->srp_ctx.login != NULL)
3840 OPENSSL_free(ctx->srp_ctx.login);
3841 ctx->srp_ctx.login = NULL;
3844 if (strlen((const char *)parg) > 255
3845 || strlen((const char *)parg) < 1) {
3846 SSLerr(SSL_F_SSL3_CTX_CTRL, SSL_R_INVALID_SRP_USERNAME);
3849 if ((ctx->srp_ctx.login = BUF_strdup((char *)parg)) == NULL) {
3850 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_INTERNAL_ERROR);
3854 case SSL_CTRL_SET_TLS_EXT_SRP_PASSWORD:
3855 ctx->srp_ctx.SRP_give_srp_client_pwd_callback =
3856 srp_password_from_info_cb;
3857 ctx->srp_ctx.info = parg;
3859 case SSL_CTRL_SET_SRP_ARG:
3860 ctx->srp_ctx.srp_Mask |= SSL_kSRP;
3861 ctx->srp_ctx.SRP_cb_arg = parg;
3864 case SSL_CTRL_SET_TLS_EXT_SRP_STRENGTH:
3865 ctx->srp_ctx.strength = larg;
3869 # ifndef OPENSSL_NO_EC
3870 case SSL_CTRL_SET_CURVES:
3871 return tls1_set_curves(&ctx->tlsext_ellipticcurvelist,
3872 &ctx->tlsext_ellipticcurvelist_length,
3875 case SSL_CTRL_SET_CURVES_LIST:
3876 return tls1_set_curves_list(&ctx->tlsext_ellipticcurvelist,
3877 &ctx->tlsext_ellipticcurvelist_length,
3879 # ifndef OPENSSL_NO_EC
3880 case SSL_CTRL_SET_ECDH_AUTO:
3881 ctx->cert->ecdh_tmp_auto = larg;
3885 case SSL_CTRL_SET_SIGALGS:
3886 return tls1_set_sigalgs(ctx->cert, parg, larg, 0);
3888 case SSL_CTRL_SET_SIGALGS_LIST:
3889 return tls1_set_sigalgs_list(ctx->cert, parg, 0);
3891 case SSL_CTRL_SET_CLIENT_SIGALGS:
3892 return tls1_set_sigalgs(ctx->cert, parg, larg, 1);
3894 case SSL_CTRL_SET_CLIENT_SIGALGS_LIST:
3895 return tls1_set_sigalgs_list(ctx->cert, parg, 1);
3897 case SSL_CTRL_SET_CLIENT_CERT_TYPES:
3898 return ssl3_set_req_cert_type(ctx->cert, parg, larg);
3900 case SSL_CTRL_BUILD_CERT_CHAIN:
3901 return ssl_build_cert_chain(NULL, ctx, larg);
3903 case SSL_CTRL_SET_VERIFY_CERT_STORE:
3904 return ssl_cert_set_cert_store(ctx->cert, parg, 0, larg);
3906 case SSL_CTRL_SET_CHAIN_CERT_STORE:
3907 return ssl_cert_set_cert_store(ctx->cert, parg, 1, larg);
3909 #endif /* !OPENSSL_NO_TLSEXT */
3911 /* A Thawte special :-) */
3912 case SSL_CTRL_EXTRA_CHAIN_CERT:
3913 if (ctx->extra_certs == NULL) {
3914 if ((ctx->extra_certs = sk_X509_new_null()) == NULL)
3917 sk_X509_push(ctx->extra_certs, (X509 *)parg);
3920 case SSL_CTRL_GET_EXTRA_CHAIN_CERTS:
3921 if (ctx->extra_certs == NULL && larg == 0)
3922 *(STACK_OF(X509) **)parg = ctx->cert->key->chain;
3924 *(STACK_OF(X509) **)parg = ctx->extra_certs;
3927 case SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS:
3928 if (ctx->extra_certs) {
3929 sk_X509_pop_free(ctx->extra_certs, X509_free);
3930 ctx->extra_certs = NULL;
3934 case SSL_CTRL_CHAIN:
3936 return ssl_cert_set1_chain(NULL, ctx, (STACK_OF(X509) *)parg);
3938 return ssl_cert_set0_chain(NULL, ctx, (STACK_OF(X509) *)parg);
3940 case SSL_CTRL_CHAIN_CERT:
3942 return ssl_cert_add1_chain_cert(NULL, ctx, (X509 *)parg);
3944 return ssl_cert_add0_chain_cert(NULL, ctx, (X509 *)parg);
3946 case SSL_CTRL_GET_CHAIN_CERTS:
3947 *(STACK_OF(X509) **)parg = ctx->cert->key->chain;
3950 case SSL_CTRL_SELECT_CURRENT_CERT:
3951 return ssl_cert_select_current(ctx->cert, (X509 *)parg);
3953 case SSL_CTRL_SET_CURRENT_CERT:
3954 return ssl_cert_set_current(ctx->cert, larg);
3962 long ssl3_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp) (void))
3969 #ifndef OPENSSL_NO_RSA
3970 case SSL_CTRL_SET_TMP_RSA_CB:
3972 cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
3976 #ifndef OPENSSL_NO_DH
3977 case SSL_CTRL_SET_TMP_DH_CB:
3979 cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
3983 #ifndef OPENSSL_NO_EC
3984 case SSL_CTRL_SET_TMP_ECDH_CB:
3986 cert->ecdh_tmp_cb = (EC_KEY *(*)(SSL *, int, int))fp;
3990 #ifndef OPENSSL_NO_TLSEXT
3991 case SSL_CTRL_SET_TLSEXT_SERVERNAME_CB:
3992 ctx->tlsext_servername_callback = (int (*)(SSL *, int *, void *))fp;
3995 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB:
3996 ctx->tlsext_status_cb = (int (*)(SSL *, void *))fp;
3999 case SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB:
4000 ctx->tlsext_ticket_key_cb = (int (*)(SSL *, unsigned char *,
4003 HMAC_CTX *, int))fp;
4006 # ifndef OPENSSL_NO_SRP
4007 case SSL_CTRL_SET_SRP_VERIFY_PARAM_CB:
4008 ctx->srp_ctx.srp_Mask |= SSL_kSRP;
4009 ctx->srp_ctx.SRP_verify_param_callback = (int (*)(SSL *, void *))fp;
4011 case SSL_CTRL_SET_TLS_EXT_SRP_USERNAME_CB:
4012 ctx->srp_ctx.srp_Mask |= SSL_kSRP;
4013 ctx->srp_ctx.TLS_ext_srp_username_callback =
4014 (int (*)(SSL *, int *, void *))fp;
4016 case SSL_CTRL_SET_SRP_GIVE_CLIENT_PWD_CB:
4017 ctx->srp_ctx.srp_Mask |= SSL_kSRP;
4018 ctx->srp_ctx.SRP_give_srp_client_pwd_callback =
4019 (char *(*)(SSL *, void *))fp;
4023 case SSL_CTRL_SET_NOT_RESUMABLE_SESS_CB:
4025 ctx->not_resumable_session_cb = (int (*)(SSL *, int))fp;
4035 * This function needs to check if the ciphers required are actually
4038 const SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p)
4041 const SSL_CIPHER *cp;
4044 id = 0x03000000L | ((unsigned long)p[0] << 8L) | (unsigned long)p[1];
4046 cp = OBJ_bsearch_ssl_cipher_id(&c, ssl3_ciphers, SSL3_NUM_CIPHERS);
4047 #ifdef DEBUG_PRINT_UNKNOWN_CIPHERSUITES
4049 fprintf(stderr, "Unknown cipher ID %x\n", (p[0] << 8) | p[1]);
4054 int ssl3_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p)
4060 if ((l & 0xff000000) != 0x03000000)
4062 p[0] = ((unsigned char)(l >> 8L)) & 0xFF;
4063 p[1] = ((unsigned char)(l)) & 0xFF;
4068 SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt,
4069 STACK_OF(SSL_CIPHER) *srvr)
4071 SSL_CIPHER *c, *ret = NULL;
4072 STACK_OF(SSL_CIPHER) *prio, *allow;
4075 unsigned long alg_k, alg_a, mask_k, mask_a, emask_k, emask_a;
4077 /* Let's see which ciphers we can support */
4082 * Do not set the compare functions, because this may lead to a
4083 * reordering by "id". We want to keep the original ordering. We may pay
4084 * a price in performance during sk_SSL_CIPHER_find(), but would have to
4085 * pay with the price of sk_SSL_CIPHER_dup().
4087 sk_SSL_CIPHER_set_cmp_func(srvr, ssl_cipher_ptr_id_cmp);
4088 sk_SSL_CIPHER_set_cmp_func(clnt, ssl_cipher_ptr_id_cmp);
4092 fprintf(stderr, "Server has %d from %p:\n", sk_SSL_CIPHER_num(srvr),
4094 for (i = 0; i < sk_SSL_CIPHER_num(srvr); ++i) {
4095 c = sk_SSL_CIPHER_value(srvr, i);
4096 fprintf(stderr, "%p:%s\n", (void *)c, c->name);
4098 fprintf(stderr, "Client sent %d from %p:\n", sk_SSL_CIPHER_num(clnt),
4100 for (i = 0; i < sk_SSL_CIPHER_num(clnt); ++i) {
4101 c = sk_SSL_CIPHER_value(clnt, i);
4102 fprintf(stderr, "%p:%s\n", (void *)c, c->name);
4106 if (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE || tls1_suiteb(s)) {
4114 tls1_set_cert_validity(s);
4116 for (i = 0; i < sk_SSL_CIPHER_num(prio); i++) {
4117 c = sk_SSL_CIPHER_value(prio, i);
4119 /* Skip TLS v1.2 only ciphersuites if not supported */
4120 if ((c->algorithm_ssl & SSL_TLSV1_2) && !SSL_USE_TLS1_2_CIPHERS(s))
4123 ssl_set_cert_masks(cert, c);
4124 mask_k = cert->mask_k;
4125 mask_a = cert->mask_a;
4126 emask_k = cert->export_mask_k;
4127 emask_a = cert->export_mask_a;
4128 #ifndef OPENSSL_NO_SRP
4129 if (s->srp_ctx.srp_Mask & SSL_kSRP) {
4131 emask_k |= SSL_kSRP;
4133 emask_a |= SSL_aSRP;
4139 * fprintf(stderr,"ssl3_choose_cipher %d alg= %lx\n",
4142 #endif /* KSSL_DEBUG */
4144 alg_k = c->algorithm_mkey;
4145 alg_a = c->algorithm_auth;
4147 #ifndef OPENSSL_NO_KRB5
4148 if (alg_k & SSL_kKRB5) {
4149 if (!kssl_keytab_is_available(s->kssl_ctx))
4152 #endif /* OPENSSL_NO_KRB5 */
4153 #ifndef OPENSSL_NO_PSK
4154 /* with PSK there must be server callback set */
4155 if ((alg_k & SSL_kPSK) && s->psk_server_callback == NULL)
4157 #endif /* OPENSSL_NO_PSK */
4159 if (SSL_C_IS_EXPORT(c)) {
4160 ok = (alg_k & emask_k) && (alg_a & emask_a);
4162 fprintf(stderr, "%d:[%08lX:%08lX:%08lX:%08lX]%p:%s (export)\n",
4163 ok, alg_k, alg_a, emask_k, emask_a, (void *)c, c->name);
4166 ok = (alg_k & mask_k) && (alg_a & mask_a);
4168 fprintf(stderr, "%d:[%08lX:%08lX:%08lX:%08lX]%p:%s\n", ok, alg_k,
4169 alg_a, mask_k, mask_a, (void *)c, c->name);
4173 #ifndef OPENSSL_NO_TLSEXT
4174 # ifndef OPENSSL_NO_EC
4176 * if we are considering an ECC cipher suite that uses an ephemeral
4179 if (alg_k & SSL_kECDHE)
4180 ok = ok && tls1_check_ec_tmp_key(s, c->id);
4181 # endif /* OPENSSL_NO_EC */
4182 #endif /* OPENSSL_NO_TLSEXT */
4186 ii = sk_SSL_CIPHER_find(allow, c);
4188 /* Check security callback permits this cipher */
4189 if (!ssl_security(s, SSL_SECOP_CIPHER_SHARED,
4190 c->strength_bits, 0, c))
4192 #if !defined(OPENSSL_NO_EC) && !defined(OPENSSL_NO_TLSEXT)
4193 if ((alg_k & SSL_kECDHE) && (alg_a & SSL_aECDSA)
4194 && s->s3->is_probably_safari) {
4196 ret = sk_SSL_CIPHER_value(allow, ii);
4200 ret = sk_SSL_CIPHER_value(allow, ii);
4207 int ssl3_get_req_cert_type(SSL *s, unsigned char *p)
4211 unsigned long alg_k, alg_a = 0;
4213 /* If we have custom certificate types set, use them */
4214 if (s->cert->ctypes) {
4215 memcpy(p, s->cert->ctypes, s->cert->ctype_num);
4216 return (int)s->cert->ctype_num;
4218 /* Get mask of algorithms disabled by signature list */
4219 ssl_set_sig_mask(&alg_a, s, SSL_SECOP_SIGALG_MASK);
4220 if (s->cert->cert_flags & SSL_CERT_FLAGS_CHECK_TLS_STRICT)
4223 alg_k = s->s3->tmp.new_cipher->algorithm_mkey;
4225 #ifndef OPENSSL_NO_GOST
4226 if (s->version >= TLS1_VERSION) {
4227 if (alg_k & SSL_kGOST) {
4228 p[ret++] = TLS_CT_GOST94_SIGN;
4229 p[ret++] = TLS_CT_GOST01_SIGN;
4235 #ifndef OPENSSL_NO_DH
4236 if (alg_k & (SSL_kDHr | SSL_kDHE)) {
4237 # ifndef OPENSSL_NO_RSA
4239 * Since this refers to a certificate signed with an RSA algorithm,
4240 * only check for rsa signing in strict mode.
4242 if (nostrict || !(alg_a & SSL_aRSA))
4243 p[ret++] = SSL3_CT_RSA_FIXED_DH;
4245 # ifndef OPENSSL_NO_DSA
4246 if (nostrict || !(alg_a & SSL_aDSS))
4247 p[ret++] = SSL3_CT_DSS_FIXED_DH;
4250 if ((s->version == SSL3_VERSION) &&
4251 (alg_k & (SSL_kDHE | SSL_kDHd | SSL_kDHr))) {
4252 # ifndef OPENSSL_NO_RSA
4253 p[ret++] = SSL3_CT_RSA_EPHEMERAL_DH;
4255 # ifndef OPENSSL_NO_DSA
4256 p[ret++] = SSL3_CT_DSS_EPHEMERAL_DH;
4259 #endif /* !OPENSSL_NO_DH */
4260 #ifndef OPENSSL_NO_RSA
4261 if (!(alg_a & SSL_aRSA))
4262 p[ret++] = SSL3_CT_RSA_SIGN;
4264 #ifndef OPENSSL_NO_DSA
4265 if (!(alg_a & SSL_aDSS))
4266 p[ret++] = SSL3_CT_DSS_SIGN;
4268 #ifndef OPENSSL_NO_EC
4269 if ((alg_k & (SSL_kECDHr | SSL_kECDHe)) && (s->version >= TLS1_VERSION)) {
4270 if (nostrict || !(alg_a & SSL_aRSA))
4271 p[ret++] = TLS_CT_RSA_FIXED_ECDH;
4272 if (nostrict || !(alg_a & SSL_aECDSA))
4273 p[ret++] = TLS_CT_ECDSA_FIXED_ECDH;
4276 * ECDSA certs can be used with RSA cipher suites as well so we don't
4277 * need to check for SSL_kECDH or SSL_kECDHE
4279 if (s->version >= TLS1_VERSION) {
4280 if (!(alg_a & SSL_aECDSA))
4281 p[ret++] = TLS_CT_ECDSA_SIGN;
4287 static int ssl3_set_req_cert_type(CERT *c, const unsigned char *p, size_t len)
4290 OPENSSL_free(c->ctypes);
4297 c->ctypes = OPENSSL_malloc(len);
4300 memcpy(c->ctypes, p, len);
4305 int ssl3_shutdown(SSL *s)
4310 * Don't do anything much if we have not done the handshake or we don't
4311 * want to send messages :-)
4313 if ((s->quiet_shutdown) || (s->state == SSL_ST_BEFORE)) {
4314 s->shutdown = (SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN);
4318 if (!(s->shutdown & SSL_SENT_SHUTDOWN)) {
4319 s->shutdown |= SSL_SENT_SHUTDOWN;
4320 ssl3_send_alert(s, SSL3_AL_WARNING, SSL_AD_CLOSE_NOTIFY);
4322 * our shutdown alert has been sent now, and if it still needs to be
4323 * written, s->s3->alert_dispatch will be true
4325 if (s->s3->alert_dispatch)
4326 return (-1); /* return WANT_WRITE */
4327 } else if (s->s3->alert_dispatch) {
4328 /* resend it if not sent */
4329 ret = s->method->ssl_dispatch_alert(s);
4332 * we only get to return -1 here the 2nd/Nth invocation, we must
4333 * have already signalled return 0 upon a previous invoation,
4338 } else if (!(s->shutdown & SSL_RECEIVED_SHUTDOWN)) {
4340 * If we are waiting for a close from our peer, we are closed
4342 s->method->ssl_read_bytes(s, 0, NULL, 0, 0);
4343 if (!(s->shutdown & SSL_RECEIVED_SHUTDOWN)) {
4344 return (-1); /* return WANT_READ */
4348 if ((s->shutdown == (SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN)) &&
4349 !s->s3->alert_dispatch)
4355 int ssl3_write(SSL *s, const void *buf, int len)
4360 if (s->shutdown & SSL_SEND_SHUTDOWN) {
4361 s->rwstate = SSL_NOTHING;
4366 if (s->s3->renegotiate)
4367 ssl3_renegotiate_check(s);
4370 * This is an experimental flag that sends the last handshake message in
4371 * the same packet as the first use data - used to see if it helps the
4372 * TCP protocol during session-id reuse
4374 /* The second test is because the buffer may have been removed */
4375 if ((s->s3->flags & SSL3_FLAGS_POP_BUFFER) && (s->wbio == s->bbio)) {
4376 /* First time through, we write into the buffer */
4377 if (s->s3->delay_buf_pop_ret == 0) {
4378 ret = ssl3_write_bytes(s, SSL3_RT_APPLICATION_DATA, buf, len);
4382 s->s3->delay_buf_pop_ret = ret;
4385 s->rwstate = SSL_WRITING;
4386 n = BIO_flush(s->wbio);
4389 s->rwstate = SSL_NOTHING;
4391 /* We have flushed the buffer, so remove it */
4392 ssl_free_wbio_buffer(s);
4393 s->s3->flags &= ~SSL3_FLAGS_POP_BUFFER;
4395 ret = s->s3->delay_buf_pop_ret;
4396 s->s3->delay_buf_pop_ret = 0;
4398 ret = s->method->ssl_write_bytes(s, SSL3_RT_APPLICATION_DATA,
4407 static int ssl3_read_internal(SSL *s, void *buf, int len, int peek)
4412 if (s->s3->renegotiate)
4413 ssl3_renegotiate_check(s);
4414 s->s3->in_read_app_data = 1;
4416 s->method->ssl_read_bytes(s, SSL3_RT_APPLICATION_DATA, buf, len,
4418 if ((ret == -1) && (s->s3->in_read_app_data == 2)) {
4420 * ssl3_read_bytes decided to call s->handshake_func, which called
4421 * ssl3_read_bytes to read handshake data. However, ssl3_read_bytes
4422 * actually found application data and thinks that application data
4423 * makes sense here; so disable handshake processing and try to read
4424 * application data again.
4428 s->method->ssl_read_bytes(s, SSL3_RT_APPLICATION_DATA, buf, len,
4432 s->s3->in_read_app_data = 0;
4437 int ssl3_read(SSL *s, void *buf, int len)
4439 return ssl3_read_internal(s, buf, len, 0);
4442 int ssl3_peek(SSL *s, void *buf, int len)
4444 return ssl3_read_internal(s, buf, len, 1);
4447 int ssl3_renegotiate(SSL *s)
4449 if (s->handshake_func == NULL)
4452 if (s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS)
4455 s->s3->renegotiate = 1;
4459 int ssl3_renegotiate_check(SSL *s)
4463 if (s->s3->renegotiate) {
4464 if (!RECORD_LAYER_read_pending(&s->rlayer)
4465 && !RECORD_LAYER_write_pending(&s->rlayer)
4466 && !SSL_in_init(s)) {
4468 * if we are the server, and we have sent a 'RENEGOTIATE'
4469 * message, we need to go to SSL_ST_ACCEPT.
4472 s->state = SSL_ST_RENEGOTIATE;
4473 s->s3->renegotiate = 0;
4474 s->s3->num_renegotiations++;
4475 s->s3->total_renegotiations++;
4483 * If we are using default SHA1+MD5 algorithms switch to new SHA256 PRF and
4484 * handshake macs if required.
4486 long ssl_get_algorithm2(SSL *s)
4488 long alg2 = s->s3->tmp.new_cipher->algorithm2;
4489 if (s->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_SHA256_PRF
4490 && alg2 == (SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF))
4491 return SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256;