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 <openssl/md5.h>
155 #ifndef OPENSSL_NO_DH
156 # include <openssl/dh.h>
158 #include <openssl/rand.h>
160 const char ssl3_version_str[] = "SSLv3" OPENSSL_VERSION_PTEXT;
162 #define SSL3_NUM_CIPHERS OSSL_NELEM(ssl3_ciphers)
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 /* New AES ciphersuites */
608 TLS1_TXT_RSA_WITH_AES_128_SHA,
609 TLS1_CK_RSA_WITH_AES_128_SHA,
615 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
616 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
623 TLS1_TXT_DH_DSS_WITH_AES_128_SHA,
624 TLS1_CK_DH_DSS_WITH_AES_128_SHA,
630 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
631 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
638 TLS1_TXT_DH_RSA_WITH_AES_128_SHA,
639 TLS1_CK_DH_RSA_WITH_AES_128_SHA,
645 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
646 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
653 TLS1_TXT_DHE_DSS_WITH_AES_128_SHA,
654 TLS1_CK_DHE_DSS_WITH_AES_128_SHA,
660 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
661 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
668 TLS1_TXT_DHE_RSA_WITH_AES_128_SHA,
669 TLS1_CK_DHE_RSA_WITH_AES_128_SHA,
675 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
676 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
683 TLS1_TXT_ADH_WITH_AES_128_SHA,
684 TLS1_CK_ADH_WITH_AES_128_SHA,
690 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
691 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
699 TLS1_TXT_RSA_WITH_AES_256_SHA,
700 TLS1_CK_RSA_WITH_AES_256_SHA,
706 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
707 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
714 TLS1_TXT_DH_DSS_WITH_AES_256_SHA,
715 TLS1_CK_DH_DSS_WITH_AES_256_SHA,
721 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
722 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
730 TLS1_TXT_DH_RSA_WITH_AES_256_SHA,
731 TLS1_CK_DH_RSA_WITH_AES_256_SHA,
737 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
738 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
746 TLS1_TXT_DHE_DSS_WITH_AES_256_SHA,
747 TLS1_CK_DHE_DSS_WITH_AES_256_SHA,
753 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
754 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
762 TLS1_TXT_DHE_RSA_WITH_AES_256_SHA,
763 TLS1_CK_DHE_RSA_WITH_AES_256_SHA,
769 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
770 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
778 TLS1_TXT_ADH_WITH_AES_256_SHA,
779 TLS1_CK_ADH_WITH_AES_256_SHA,
785 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
786 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
791 /* TLS v1.2 ciphersuites */
795 TLS1_TXT_RSA_WITH_NULL_SHA256,
796 TLS1_CK_RSA_WITH_NULL_SHA256,
802 SSL_NOT_EXP | SSL_STRONG_NONE | SSL_FIPS,
803 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
811 TLS1_TXT_RSA_WITH_AES_128_SHA256,
812 TLS1_CK_RSA_WITH_AES_128_SHA256,
818 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
819 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
827 TLS1_TXT_RSA_WITH_AES_256_SHA256,
828 TLS1_CK_RSA_WITH_AES_256_SHA256,
834 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
835 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
843 TLS1_TXT_DH_DSS_WITH_AES_128_SHA256,
844 TLS1_CK_DH_DSS_WITH_AES_128_SHA256,
850 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
851 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
859 TLS1_TXT_DH_RSA_WITH_AES_128_SHA256,
860 TLS1_CK_DH_RSA_WITH_AES_128_SHA256,
866 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
867 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
875 TLS1_TXT_DHE_DSS_WITH_AES_128_SHA256,
876 TLS1_CK_DHE_DSS_WITH_AES_128_SHA256,
882 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
883 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
888 #ifndef OPENSSL_NO_CAMELLIA
889 /* Camellia ciphersuites from RFC4132 (128-bit portion) */
894 TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA,
895 TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA,
901 SSL_NOT_EXP | SSL_HIGH,
902 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
910 TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA,
911 TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA,
917 SSL_NOT_EXP | SSL_HIGH,
918 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
926 TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA,
927 TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA,
933 SSL_NOT_EXP | SSL_HIGH,
934 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
942 TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA,
943 TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA,
949 SSL_NOT_EXP | SSL_HIGH,
950 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
958 TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA,
959 TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA,
965 SSL_NOT_EXP | SSL_HIGH,
966 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
974 TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA,
975 TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA,
981 SSL_NOT_EXP | SSL_HIGH,
982 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
986 #endif /* OPENSSL_NO_CAMELLIA */
988 /* TLS v1.2 ciphersuites */
992 TLS1_TXT_DHE_RSA_WITH_AES_128_SHA256,
993 TLS1_CK_DHE_RSA_WITH_AES_128_SHA256,
999 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1000 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1008 TLS1_TXT_DH_DSS_WITH_AES_256_SHA256,
1009 TLS1_CK_DH_DSS_WITH_AES_256_SHA256,
1015 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1016 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1024 TLS1_TXT_DH_RSA_WITH_AES_256_SHA256,
1025 TLS1_CK_DH_RSA_WITH_AES_256_SHA256,
1031 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1032 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1040 TLS1_TXT_DHE_DSS_WITH_AES_256_SHA256,
1041 TLS1_CK_DHE_DSS_WITH_AES_256_SHA256,
1047 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1048 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1056 TLS1_TXT_DHE_RSA_WITH_AES_256_SHA256,
1057 TLS1_CK_DHE_RSA_WITH_AES_256_SHA256,
1063 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1064 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1072 TLS1_TXT_ADH_WITH_AES_128_SHA256,
1073 TLS1_CK_ADH_WITH_AES_128_SHA256,
1079 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1080 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1088 TLS1_TXT_ADH_WITH_AES_256_SHA256,
1089 TLS1_CK_ADH_WITH_AES_256_SHA256,
1095 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1096 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1101 /* GOST Ciphersuites */
1105 "GOST94-GOST89-GOST89",
1109 SSL_eGOST2814789CNT,
1112 SSL_NOT_EXP | SSL_HIGH,
1113 SSL_HANDSHAKE_MAC_GOST94 | TLS1_PRF_GOST94 | TLS1_STREAM_MAC,
1118 "GOST2001-GOST89-GOST89",
1122 SSL_eGOST2814789CNT,
1125 SSL_NOT_EXP | SSL_HIGH,
1126 SSL_HANDSHAKE_MAC_GOST94 | TLS1_PRF_GOST94 | TLS1_STREAM_MAC,
1131 "GOST94-NULL-GOST94",
1138 SSL_NOT_EXP | SSL_STRONG_NONE,
1139 SSL_HANDSHAKE_MAC_GOST94 | TLS1_PRF_GOST94,
1144 "GOST2001-NULL-GOST94",
1151 SSL_NOT_EXP | SSL_STRONG_NONE,
1152 SSL_HANDSHAKE_MAC_GOST94 | TLS1_PRF_GOST94,
1156 #ifndef OPENSSL_NO_CAMELLIA
1157 /* Camellia ciphersuites from RFC4132 (256-bit portion) */
1162 TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA,
1163 TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA,
1169 SSL_NOT_EXP | SSL_HIGH,
1170 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1177 TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA,
1178 TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA,
1184 SSL_NOT_EXP | SSL_HIGH,
1185 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1193 TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA,
1194 TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA,
1200 SSL_NOT_EXP | SSL_HIGH,
1201 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1209 TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA,
1210 TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA,
1216 SSL_NOT_EXP | SSL_HIGH,
1217 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1225 TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA,
1226 TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA,
1232 SSL_NOT_EXP | SSL_HIGH,
1233 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1241 TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA,
1242 TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA,
1248 SSL_NOT_EXP | SSL_HIGH,
1249 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1253 #endif /* OPENSSL_NO_CAMELLIA */
1255 #ifndef OPENSSL_NO_PSK
1259 TLS1_TXT_PSK_WITH_RC4_128_SHA,
1260 TLS1_CK_PSK_WITH_RC4_128_SHA,
1266 SSL_NOT_EXP | SSL_MEDIUM,
1267 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1275 TLS1_TXT_PSK_WITH_3DES_EDE_CBC_SHA,
1276 TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA,
1282 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1283 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1291 TLS1_TXT_PSK_WITH_AES_128_CBC_SHA,
1292 TLS1_CK_PSK_WITH_AES_128_CBC_SHA,
1298 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1299 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1307 TLS1_TXT_PSK_WITH_AES_256_CBC_SHA,
1308 TLS1_CK_PSK_WITH_AES_256_CBC_SHA,
1314 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1315 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1319 #endif /* OPENSSL_NO_PSK */
1321 #ifndef OPENSSL_NO_SEED
1322 /* SEED ciphersuites from RFC4162 */
1327 TLS1_TXT_RSA_WITH_SEED_SHA,
1328 TLS1_CK_RSA_WITH_SEED_SHA,
1334 SSL_NOT_EXP | SSL_MEDIUM,
1335 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1343 TLS1_TXT_DH_DSS_WITH_SEED_SHA,
1344 TLS1_CK_DH_DSS_WITH_SEED_SHA,
1350 SSL_NOT_EXP | SSL_MEDIUM,
1351 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1359 TLS1_TXT_DH_RSA_WITH_SEED_SHA,
1360 TLS1_CK_DH_RSA_WITH_SEED_SHA,
1366 SSL_NOT_EXP | SSL_MEDIUM,
1367 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1375 TLS1_TXT_DHE_DSS_WITH_SEED_SHA,
1376 TLS1_CK_DHE_DSS_WITH_SEED_SHA,
1382 SSL_NOT_EXP | SSL_MEDIUM,
1383 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1391 TLS1_TXT_DHE_RSA_WITH_SEED_SHA,
1392 TLS1_CK_DHE_RSA_WITH_SEED_SHA,
1398 SSL_NOT_EXP | SSL_MEDIUM,
1399 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1407 TLS1_TXT_ADH_WITH_SEED_SHA,
1408 TLS1_CK_ADH_WITH_SEED_SHA,
1414 SSL_NOT_EXP | SSL_MEDIUM,
1415 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1420 #endif /* OPENSSL_NO_SEED */
1422 /* GCM ciphersuites from RFC5288 */
1427 TLS1_TXT_RSA_WITH_AES_128_GCM_SHA256,
1428 TLS1_CK_RSA_WITH_AES_128_GCM_SHA256,
1434 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1435 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1443 TLS1_TXT_RSA_WITH_AES_256_GCM_SHA384,
1444 TLS1_CK_RSA_WITH_AES_256_GCM_SHA384,
1450 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1451 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
1459 TLS1_TXT_DHE_RSA_WITH_AES_128_GCM_SHA256,
1460 TLS1_CK_DHE_RSA_WITH_AES_128_GCM_SHA256,
1466 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1467 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1475 TLS1_TXT_DHE_RSA_WITH_AES_256_GCM_SHA384,
1476 TLS1_CK_DHE_RSA_WITH_AES_256_GCM_SHA384,
1482 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1483 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
1491 TLS1_TXT_DH_RSA_WITH_AES_128_GCM_SHA256,
1492 TLS1_CK_DH_RSA_WITH_AES_128_GCM_SHA256,
1498 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1499 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1507 TLS1_TXT_DH_RSA_WITH_AES_256_GCM_SHA384,
1508 TLS1_CK_DH_RSA_WITH_AES_256_GCM_SHA384,
1514 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1515 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
1523 TLS1_TXT_DHE_DSS_WITH_AES_128_GCM_SHA256,
1524 TLS1_CK_DHE_DSS_WITH_AES_128_GCM_SHA256,
1530 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1531 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1539 TLS1_TXT_DHE_DSS_WITH_AES_256_GCM_SHA384,
1540 TLS1_CK_DHE_DSS_WITH_AES_256_GCM_SHA384,
1546 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1547 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
1555 TLS1_TXT_DH_DSS_WITH_AES_128_GCM_SHA256,
1556 TLS1_CK_DH_DSS_WITH_AES_128_GCM_SHA256,
1562 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1563 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1571 TLS1_TXT_DH_DSS_WITH_AES_256_GCM_SHA384,
1572 TLS1_CK_DH_DSS_WITH_AES_256_GCM_SHA384,
1578 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1579 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
1587 TLS1_TXT_ADH_WITH_AES_128_GCM_SHA256,
1588 TLS1_CK_ADH_WITH_AES_128_GCM_SHA256,
1594 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1595 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1603 TLS1_TXT_ADH_WITH_AES_256_GCM_SHA384,
1604 TLS1_CK_ADH_WITH_AES_256_GCM_SHA384,
1610 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1611 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
1616 #ifndef OPENSSL_NO_CAMELLIA
1617 /* TLS 1.2 Camellia SHA-256 ciphersuites from RFC5932 */
1622 TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA256,
1623 TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA256,
1629 SSL_NOT_EXP | SSL_HIGH,
1630 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1638 TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256,
1639 TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256,
1645 SSL_NOT_EXP | SSL_HIGH,
1646 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1654 TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256,
1655 TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256,
1661 SSL_NOT_EXP | SSL_HIGH,
1662 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1670 TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256,
1671 TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256,
1677 SSL_NOT_EXP | SSL_HIGH,
1678 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1686 TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256,
1687 TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256,
1693 SSL_NOT_EXP | SSL_HIGH,
1694 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1702 TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA256,
1703 TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA256,
1709 SSL_NOT_EXP | SSL_HIGH,
1710 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1718 TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA256,
1719 TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA256,
1725 SSL_NOT_EXP | SSL_HIGH,
1726 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1734 TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256,
1735 TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256,
1741 SSL_NOT_EXP | SSL_HIGH,
1742 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1750 TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256,
1751 TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256,
1757 SSL_NOT_EXP | SSL_HIGH,
1758 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1766 TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256,
1767 TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256,
1773 SSL_NOT_EXP | SSL_HIGH,
1774 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1782 TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256,
1783 TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256,
1789 SSL_NOT_EXP | SSL_HIGH,
1790 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1798 TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA256,
1799 TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA256,
1805 SSL_NOT_EXP | SSL_HIGH,
1806 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
1812 #ifdef OPENSSL_SSL_DEBUG_BROKEN_PROTOCOL
1829 #ifndef OPENSSL_NO_EC
1833 TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA,
1834 TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA,
1840 SSL_NOT_EXP | SSL_STRONG_NONE | SSL_FIPS,
1841 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1849 TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA,
1850 TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA,
1856 SSL_NOT_EXP | SSL_MEDIUM,
1857 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1865 TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA,
1866 TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA,
1872 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1873 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1881 TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA,
1882 TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA,
1888 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1889 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1897 TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA,
1898 TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA,
1904 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1905 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1913 TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA,
1914 TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA,
1920 SSL_NOT_EXP | SSL_STRONG_NONE | SSL_FIPS,
1921 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1929 TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA,
1930 TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA,
1936 SSL_NOT_EXP | SSL_MEDIUM,
1937 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1945 TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA,
1946 TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA,
1952 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1953 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1961 TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
1962 TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
1968 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1969 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1977 TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
1978 TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
1984 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
1985 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
1993 TLS1_TXT_ECDH_RSA_WITH_NULL_SHA,
1994 TLS1_CK_ECDH_RSA_WITH_NULL_SHA,
2000 SSL_NOT_EXP | SSL_STRONG_NONE | SSL_FIPS,
2001 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2009 TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA,
2010 TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA,
2016 SSL_NOT_EXP | SSL_MEDIUM,
2017 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2025 TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA,
2026 TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA,
2032 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2033 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2041 TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA,
2042 TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA,
2048 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2049 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2057 TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA,
2058 TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA,
2064 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2065 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2073 TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA,
2074 TLS1_CK_ECDHE_RSA_WITH_NULL_SHA,
2080 SSL_NOT_EXP | SSL_STRONG_NONE | SSL_FIPS,
2081 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2089 TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA,
2090 TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA,
2096 SSL_NOT_EXP | SSL_MEDIUM,
2097 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2105 TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA,
2106 TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA,
2112 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2113 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2121 TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA,
2122 TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA,
2128 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2129 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2137 TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA,
2138 TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA,
2144 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2145 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2153 TLS1_TXT_ECDH_anon_WITH_NULL_SHA,
2154 TLS1_CK_ECDH_anon_WITH_NULL_SHA,
2160 SSL_NOT_EXP | SSL_STRONG_NONE | SSL_FIPS,
2161 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2169 TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA,
2170 TLS1_CK_ECDH_anon_WITH_RC4_128_SHA,
2176 SSL_NOT_EXP | SSL_MEDIUM,
2177 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2185 TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA,
2186 TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA,
2192 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2193 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2201 TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA,
2202 TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA,
2208 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2209 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2217 TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA,
2218 TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA,
2224 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2225 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2229 #endif /* OPENSSL_NO_EC */
2231 #ifndef OPENSSL_NO_SRP
2235 TLS1_TXT_SRP_SHA_WITH_3DES_EDE_CBC_SHA,
2236 TLS1_CK_SRP_SHA_WITH_3DES_EDE_CBC_SHA,
2242 SSL_NOT_EXP | SSL_HIGH,
2243 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2251 TLS1_TXT_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA,
2252 TLS1_CK_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA,
2258 SSL_NOT_EXP | SSL_HIGH,
2259 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2267 TLS1_TXT_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA,
2268 TLS1_CK_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA,
2274 SSL_NOT_EXP | SSL_HIGH,
2275 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2283 TLS1_TXT_SRP_SHA_WITH_AES_128_CBC_SHA,
2284 TLS1_CK_SRP_SHA_WITH_AES_128_CBC_SHA,
2290 SSL_NOT_EXP | SSL_HIGH,
2291 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2299 TLS1_TXT_SRP_SHA_RSA_WITH_AES_128_CBC_SHA,
2300 TLS1_CK_SRP_SHA_RSA_WITH_AES_128_CBC_SHA,
2306 SSL_NOT_EXP | SSL_HIGH,
2307 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2315 TLS1_TXT_SRP_SHA_DSS_WITH_AES_128_CBC_SHA,
2316 TLS1_CK_SRP_SHA_DSS_WITH_AES_128_CBC_SHA,
2322 SSL_NOT_EXP | SSL_HIGH,
2323 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2331 TLS1_TXT_SRP_SHA_WITH_AES_256_CBC_SHA,
2332 TLS1_CK_SRP_SHA_WITH_AES_256_CBC_SHA,
2338 SSL_NOT_EXP | SSL_HIGH,
2339 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2347 TLS1_TXT_SRP_SHA_RSA_WITH_AES_256_CBC_SHA,
2348 TLS1_CK_SRP_SHA_RSA_WITH_AES_256_CBC_SHA,
2354 SSL_NOT_EXP | SSL_HIGH,
2355 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2363 TLS1_TXT_SRP_SHA_DSS_WITH_AES_256_CBC_SHA,
2364 TLS1_CK_SRP_SHA_DSS_WITH_AES_256_CBC_SHA,
2370 SSL_NOT_EXP | SSL_HIGH,
2371 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2375 #endif /* OPENSSL_NO_SRP */
2376 #ifndef OPENSSL_NO_EC
2378 /* HMAC based TLS v1.2 ciphersuites from RFC5289 */
2383 TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_SHA256,
2384 TLS1_CK_ECDHE_ECDSA_WITH_AES_128_SHA256,
2390 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2391 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2399 TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_SHA384,
2400 TLS1_CK_ECDHE_ECDSA_WITH_AES_256_SHA384,
2406 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2407 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
2415 TLS1_TXT_ECDH_ECDSA_WITH_AES_128_SHA256,
2416 TLS1_CK_ECDH_ECDSA_WITH_AES_128_SHA256,
2422 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2423 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2431 TLS1_TXT_ECDH_ECDSA_WITH_AES_256_SHA384,
2432 TLS1_CK_ECDH_ECDSA_WITH_AES_256_SHA384,
2438 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2439 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
2447 TLS1_TXT_ECDHE_RSA_WITH_AES_128_SHA256,
2448 TLS1_CK_ECDHE_RSA_WITH_AES_128_SHA256,
2454 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2455 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2463 TLS1_TXT_ECDHE_RSA_WITH_AES_256_SHA384,
2464 TLS1_CK_ECDHE_RSA_WITH_AES_256_SHA384,
2470 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2471 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
2479 TLS1_TXT_ECDH_RSA_WITH_AES_128_SHA256,
2480 TLS1_CK_ECDH_RSA_WITH_AES_128_SHA256,
2486 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2487 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2495 TLS1_TXT_ECDH_RSA_WITH_AES_256_SHA384,
2496 TLS1_CK_ECDH_RSA_WITH_AES_256_SHA384,
2502 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2503 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
2508 /* GCM based TLS v1.2 ciphersuites from RFC5289 */
2513 TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
2514 TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
2520 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2521 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2529 TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
2530 TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
2536 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2537 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
2545 TLS1_TXT_ECDH_ECDSA_WITH_AES_128_GCM_SHA256,
2546 TLS1_CK_ECDH_ECDSA_WITH_AES_128_GCM_SHA256,
2552 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2553 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2561 TLS1_TXT_ECDH_ECDSA_WITH_AES_256_GCM_SHA384,
2562 TLS1_CK_ECDH_ECDSA_WITH_AES_256_GCM_SHA384,
2568 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2569 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
2577 TLS1_TXT_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
2578 TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
2584 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2585 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2593 TLS1_TXT_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
2594 TLS1_CK_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
2600 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2601 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
2609 TLS1_TXT_ECDH_RSA_WITH_AES_128_GCM_SHA256,
2610 TLS1_CK_ECDH_RSA_WITH_AES_128_GCM_SHA256,
2616 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2617 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2625 TLS1_TXT_ECDH_RSA_WITH_AES_256_GCM_SHA384,
2626 TLS1_CK_ECDH_RSA_WITH_AES_256_GCM_SHA384,
2632 SSL_NOT_EXP | SSL_HIGH | SSL_FIPS,
2633 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
2638 # ifndef OPENSSL_NO_CAMELLIA
2641 TLS1_TXT_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256,
2642 TLS1_CK_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256,
2648 SSL_NOT_EXP | SSL_HIGH,
2649 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2655 TLS1_TXT_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384,
2656 TLS1_CK_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384,
2662 SSL_NOT_EXP | SSL_HIGH,
2663 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
2669 TLS1_TXT_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256,
2670 TLS1_CK_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256,
2676 SSL_NOT_EXP | SSL_HIGH,
2677 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2683 TLS1_TXT_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384,
2684 TLS1_CK_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384,
2690 SSL_NOT_EXP | SSL_HIGH,
2691 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
2697 TLS1_TXT_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256,
2698 TLS1_CK_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256,
2704 SSL_NOT_EXP | SSL_HIGH,
2705 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2711 TLS1_TXT_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384,
2712 TLS1_CK_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384,
2718 SSL_NOT_EXP | SSL_HIGH,
2719 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
2725 TLS1_TXT_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256,
2726 TLS1_CK_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256,
2732 SSL_NOT_EXP | SSL_HIGH,
2733 SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256,
2739 TLS1_TXT_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384,
2740 TLS1_CK_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384,
2746 SSL_NOT_EXP | SSL_HIGH,
2747 SSL_HANDSHAKE_MAC_SHA384 | TLS1_PRF_SHA384,
2750 # endif /* OPENSSL_NO_CAMELLIA */
2751 #endif /* OPENSSL_NO_EC */
2753 #ifdef TEMP_GOST_TLS
2761 SSL_eGOST2814789CNT,
2764 SSL_NOT_EXP | SSL_HIGH,
2765 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2775 SSL_eGOST2814789CNT,
2778 SSL_NOT_EXP | SSL_HIGH,
2779 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2788 SSL_eGOST2814789CNT,
2791 SSL_NOT_EXP | SSL_HIGH,
2792 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF,
2797 "GOST-GOST89STREAM",
2801 SSL_eGOST2814789CNT,
2804 SSL_NOT_EXP | SSL_HIGH,
2805 SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF | TLS1_STREAM_MAC,
2813 const SSL3_ENC_METHOD SSLv3_enc_data = {
2816 ssl3_setup_key_block,
2817 ssl3_generate_master_secret,
2818 ssl3_change_cipher_state,
2819 ssl3_final_finish_mac,
2820 MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH,
2821 ssl3_cert_verify_mac,
2822 SSL3_MD_CLIENT_FINISHED_CONST, 4,
2823 SSL3_MD_SERVER_FINISHED_CONST, 4,
2825 (int (*)(SSL *, unsigned char *, size_t, const char *,
2826 size_t, const unsigned char *, size_t,
2827 int use_context))ssl_undefined_function,
2829 SSL3_HM_HEADER_LENGTH,
2830 ssl3_set_handshake_header,
2831 ssl3_handshake_write
2834 long ssl3_default_timeout(void)
2837 * 2 hours, the 24 hours mentioned in the SSLv3 spec is way too long for
2838 * http, the cache would over fill
2840 return (60 * 60 * 2);
2843 int ssl3_num_ciphers(void)
2845 return (SSL3_NUM_CIPHERS);
2848 const SSL_CIPHER *ssl3_get_cipher(unsigned int u)
2850 if (u < SSL3_NUM_CIPHERS)
2851 return (&(ssl3_ciphers[SSL3_NUM_CIPHERS - 1 - u]));
2856 int ssl3_set_handshake_header(SSL *s, int htype, unsigned long len)
2858 unsigned char *p = (unsigned char *)s->init_buf->data;
2861 s->init_num = (int)len + SSL3_HM_HEADER_LENGTH;
2867 int ssl3_handshake_write(SSL *s)
2869 return ssl3_do_write(s, SSL3_RT_HANDSHAKE);
2872 int ssl3_new(SSL *s)
2876 if ((s3 = OPENSSL_malloc(sizeof(*s3))) == NULL)
2878 memset(s3, 0, sizeof(*s3));
2881 #ifndef OPENSSL_NO_SRP
2882 if (!SSL_SRP_CTX_init(s))
2885 s->method->ssl_clear(s);
2891 void ssl3_free(SSL *s)
2896 ssl3_cleanup_key_block(s);
2897 #ifndef OPENSSL_NO_DH
2898 DH_free(s->s3->tmp.dh);
2900 #ifndef OPENSSL_NO_EC
2901 EC_KEY_free(s->s3->tmp.ecdh);
2904 sk_X509_NAME_pop_free(s->s3->tmp.ca_names, X509_NAME_free);
2905 OPENSSL_free(s->s3->tmp.ciphers_raw);
2906 OPENSSL_clear_free(s->s3->tmp.pms, s->s3->tmp.pmslen);
2907 OPENSSL_free(s->s3->tmp.peer_sigalgs);
2908 BIO_free(s->s3->handshake_buffer);
2909 if (s->s3->handshake_dgst)
2910 ssl3_free_digest_list(s);
2911 OPENSSL_free(s->s3->alpn_selected);
2913 #ifndef OPENSSL_NO_SRP
2914 SSL_SRP_CTX_free(s);
2916 OPENSSL_clear_free(s->s3, sizeof(*s->s3));
2920 void ssl3_clear(SSL *s)
2924 ssl3_cleanup_key_block(s);
2925 sk_X509_NAME_pop_free(s->s3->tmp.ca_names, X509_NAME_free);
2926 OPENSSL_free(s->s3->tmp.ciphers_raw);
2927 s->s3->tmp.ciphers_raw = NULL;
2928 OPENSSL_clear_free(s->s3->tmp.pms, s->s3->tmp.pmslen);
2929 s->s3->tmp.pms = NULL;
2930 OPENSSL_free(s->s3->tmp.peer_sigalgs);
2931 s->s3->tmp.peer_sigalgs = NULL;
2933 #ifndef OPENSSL_NO_DH
2934 DH_free(s->s3->tmp.dh);
2935 s->s3->tmp.dh = NULL;
2937 #ifndef OPENSSL_NO_EC
2938 EC_KEY_free(s->s3->tmp.ecdh);
2939 s->s3->tmp.ecdh = NULL;
2940 s->s3->is_probably_safari = 0;
2941 #endif /* !OPENSSL_NO_EC */
2943 init_extra = s->s3->init_extra;
2944 BIO_free(s->s3->handshake_buffer);
2945 s->s3->handshake_buffer = NULL;
2946 if (s->s3->handshake_dgst) {
2947 ssl3_free_digest_list(s);
2950 if (s->s3->alpn_selected) {
2951 free(s->s3->alpn_selected);
2952 s->s3->alpn_selected = NULL;
2955 memset(s->s3, 0, sizeof(*s->s3));
2956 s->s3->init_extra = init_extra;
2958 ssl_free_wbio_buffer(s);
2960 s->s3->renegotiate = 0;
2961 s->s3->total_renegotiations = 0;
2962 s->s3->num_renegotiations = 0;
2963 s->s3->in_read_app_data = 0;
2964 s->version = SSL3_VERSION;
2966 #if !defined(OPENSSL_NO_NEXTPROTONEG)
2967 OPENSSL_free(s->next_proto_negotiated);
2968 s->next_proto_negotiated = NULL;
2969 s->next_proto_negotiated_len = 0;
2973 #ifndef OPENSSL_NO_SRP
2974 static char *srp_password_from_info_cb(SSL *s, void *arg)
2976 return BUF_strdup(s->srp_ctx.info);
2980 static int ssl3_set_req_cert_type(CERT *c, const unsigned char *p,
2983 long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg)
2988 case SSL_CTRL_GET_SESSION_REUSED:
2991 case SSL_CTRL_GET_CLIENT_CERT_REQUEST:
2993 case SSL_CTRL_GET_NUM_RENEGOTIATIONS:
2994 ret = s->s3->num_renegotiations;
2996 case SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS:
2997 ret = s->s3->num_renegotiations;
2998 s->s3->num_renegotiations = 0;
3000 case SSL_CTRL_GET_TOTAL_RENEGOTIATIONS:
3001 ret = s->s3->total_renegotiations;
3003 case SSL_CTRL_GET_FLAGS:
3004 ret = (int)(s->s3->flags);
3006 #ifndef OPENSSL_NO_RSA
3007 case SSL_CTRL_NEED_TMP_RSA:
3008 if ((s->cert != NULL) && (s->cert->rsa_tmp == NULL) &&
3009 ((s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) ||
3010 (EVP_PKEY_size(s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey) >
3014 case SSL_CTRL_SET_TMP_RSA:
3016 RSA *rsa = (RSA *)parg;
3018 SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
3021 if ((rsa = RSAPrivateKey_dup(rsa)) == NULL) {
3022 SSLerr(SSL_F_SSL3_CTRL, ERR_R_RSA_LIB);
3025 RSA_free(s->cert->rsa_tmp);
3026 s->cert->rsa_tmp = rsa;
3030 case SSL_CTRL_SET_TMP_RSA_CB:
3032 SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3036 #ifndef OPENSSL_NO_DH
3037 case SSL_CTRL_SET_TMP_DH:
3039 DH *dh = (DH *)parg;
3041 SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
3044 if (!ssl_security(s, SSL_SECOP_TMP_DH,
3045 DH_security_bits(dh), 0, dh)) {
3046 SSLerr(SSL_F_SSL3_CTRL, SSL_R_DH_KEY_TOO_SMALL);
3049 if ((dh = DHparams_dup(dh)) == NULL) {
3050 SSLerr(SSL_F_SSL3_CTRL, ERR_R_DH_LIB);
3053 if (!(s->options & SSL_OP_SINGLE_DH_USE)) {
3054 if (!DH_generate_key(dh)) {
3056 SSLerr(SSL_F_SSL3_CTRL, ERR_R_DH_LIB);
3060 DH_free(s->cert->dh_tmp);
3061 s->cert->dh_tmp = dh;
3065 case SSL_CTRL_SET_TMP_DH_CB:
3067 SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3070 case SSL_CTRL_SET_DH_AUTO:
3071 s->cert->dh_tmp_auto = larg;
3074 #ifndef OPENSSL_NO_EC
3075 case SSL_CTRL_SET_TMP_ECDH:
3077 EC_KEY *ecdh = NULL;
3080 SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
3083 if (!EC_KEY_up_ref((EC_KEY *)parg)) {
3084 SSLerr(SSL_F_SSL3_CTRL, ERR_R_ECDH_LIB);
3087 ecdh = (EC_KEY *)parg;
3088 if (!(s->options & SSL_OP_SINGLE_ECDH_USE)) {
3089 if (!EC_KEY_generate_key(ecdh)) {
3091 SSLerr(SSL_F_SSL3_CTRL, ERR_R_ECDH_LIB);
3095 EC_KEY_free(s->cert->ecdh_tmp);
3096 s->cert->ecdh_tmp = ecdh;
3100 case SSL_CTRL_SET_TMP_ECDH_CB:
3102 SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3105 #endif /* !OPENSSL_NO_EC */
3106 case SSL_CTRL_SET_TLSEXT_HOSTNAME:
3107 if (larg == TLSEXT_NAMETYPE_host_name) {
3108 OPENSSL_free(s->tlsext_hostname);
3109 s->tlsext_hostname = NULL;
3114 if (strlen((char *)parg) > TLSEXT_MAXLEN_host_name) {
3115 SSLerr(SSL_F_SSL3_CTRL, SSL_R_SSL3_EXT_INVALID_SERVERNAME);
3118 if ((s->tlsext_hostname = BUF_strdup((char *)parg)) == NULL) {
3119 SSLerr(SSL_F_SSL3_CTRL, ERR_R_INTERNAL_ERROR);
3123 SSLerr(SSL_F_SSL3_CTRL, SSL_R_SSL3_EXT_INVALID_SERVERNAME_TYPE);
3127 case SSL_CTRL_SET_TLSEXT_DEBUG_ARG:
3128 s->tlsext_debug_arg = parg;
3132 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE:
3133 s->tlsext_status_type = larg;
3137 case SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS:
3138 *(STACK_OF(X509_EXTENSION) **)parg = s->tlsext_ocsp_exts;
3142 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS:
3143 s->tlsext_ocsp_exts = parg;
3147 case SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS:
3148 *(STACK_OF(OCSP_RESPID) **)parg = s->tlsext_ocsp_ids;
3152 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS:
3153 s->tlsext_ocsp_ids = parg;
3157 case SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP:
3158 *(unsigned char **)parg = s->tlsext_ocsp_resp;
3159 return s->tlsext_ocsp_resplen;
3161 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP:
3162 OPENSSL_free(s->tlsext_ocsp_resp);
3163 s->tlsext_ocsp_resp = parg;
3164 s->tlsext_ocsp_resplen = larg;
3168 #ifndef OPENSSL_NO_HEARTBEATS
3169 case SSL_CTRL_TLS_EXT_SEND_HEARTBEAT:
3171 ret = dtls1_heartbeat(s);
3173 ret = tls1_heartbeat(s);
3176 case SSL_CTRL_GET_TLS_EXT_HEARTBEAT_PENDING:
3177 ret = s->tlsext_hb_pending;
3180 case SSL_CTRL_SET_TLS_EXT_HEARTBEAT_NO_REQUESTS:
3182 s->tlsext_heartbeat |= SSL_TLSEXT_HB_DONT_RECV_REQUESTS;
3184 s->tlsext_heartbeat &= ~SSL_TLSEXT_HB_DONT_RECV_REQUESTS;
3189 case SSL_CTRL_CHAIN:
3191 return ssl_cert_set1_chain(s, NULL, (STACK_OF(X509) *)parg);
3193 return ssl_cert_set0_chain(s, NULL, (STACK_OF(X509) *)parg);
3195 case SSL_CTRL_CHAIN_CERT:
3197 return ssl_cert_add1_chain_cert(s, NULL, (X509 *)parg);
3199 return ssl_cert_add0_chain_cert(s, NULL, (X509 *)parg);
3201 case SSL_CTRL_GET_CHAIN_CERTS:
3202 *(STACK_OF(X509) **)parg = s->cert->key->chain;
3205 case SSL_CTRL_SELECT_CURRENT_CERT:
3206 return ssl_cert_select_current(s->cert, (X509 *)parg);
3208 case SSL_CTRL_SET_CURRENT_CERT:
3209 if (larg == SSL_CERT_SET_SERVER) {
3211 const SSL_CIPHER *cipher;
3214 cipher = s->s3->tmp.new_cipher;
3218 * No certificate for unauthenticated ciphersuites or using SRP
3221 if (cipher->algorithm_auth & (SSL_aNULL | SSL_aSRP))
3223 cpk = ssl_get_server_send_pkey(s);
3229 return ssl_cert_set_current(s->cert, larg);
3231 #ifndef OPENSSL_NO_EC
3232 case SSL_CTRL_GET_CURVES:
3234 unsigned char *clist;
3238 clist = s->session->tlsext_ellipticcurvelist;
3239 clistlen = s->session->tlsext_ellipticcurvelist_length / 2;
3243 unsigned int cid, nid;
3244 for (i = 0; i < clistlen; i++) {
3246 nid = tls1_ec_curve_id2nid(cid);
3250 cptr[i] = TLSEXT_nid_unknown | cid;
3253 return (int)clistlen;
3256 case SSL_CTRL_SET_CURVES:
3257 return tls1_set_curves(&s->tlsext_ellipticcurvelist,
3258 &s->tlsext_ellipticcurvelist_length,
3261 case SSL_CTRL_SET_CURVES_LIST:
3262 return tls1_set_curves_list(&s->tlsext_ellipticcurvelist,
3263 &s->tlsext_ellipticcurvelist_length,
3266 case SSL_CTRL_GET_SHARED_CURVE:
3267 return tls1_shared_curve(s, larg);
3269 # ifndef OPENSSL_NO_EC
3270 case SSL_CTRL_SET_ECDH_AUTO:
3271 s->cert->ecdh_tmp_auto = larg;
3275 case SSL_CTRL_SET_SIGALGS:
3276 return tls1_set_sigalgs(s->cert, parg, larg, 0);
3278 case SSL_CTRL_SET_SIGALGS_LIST:
3279 return tls1_set_sigalgs_list(s->cert, parg, 0);
3281 case SSL_CTRL_SET_CLIENT_SIGALGS:
3282 return tls1_set_sigalgs(s->cert, parg, larg, 1);
3284 case SSL_CTRL_SET_CLIENT_SIGALGS_LIST:
3285 return tls1_set_sigalgs_list(s->cert, parg, 1);
3287 case SSL_CTRL_GET_CLIENT_CERT_TYPES:
3289 const unsigned char **pctype = parg;
3290 if (s->server || !s->s3->tmp.cert_req)
3292 if (s->cert->ctypes) {
3294 *pctype = s->cert->ctypes;
3295 return (int)s->cert->ctype_num;
3298 *pctype = (unsigned char *)s->s3->tmp.ctype;
3299 return s->s3->tmp.ctype_num;
3302 case SSL_CTRL_SET_CLIENT_CERT_TYPES:
3305 return ssl3_set_req_cert_type(s->cert, parg, larg);
3307 case SSL_CTRL_BUILD_CERT_CHAIN:
3308 return ssl_build_cert_chain(s, NULL, larg);
3310 case SSL_CTRL_SET_VERIFY_CERT_STORE:
3311 return ssl_cert_set_cert_store(s->cert, parg, 0, larg);
3313 case SSL_CTRL_SET_CHAIN_CERT_STORE:
3314 return ssl_cert_set_cert_store(s->cert, parg, 1, larg);
3316 case SSL_CTRL_GET_PEER_SIGNATURE_NID:
3317 if (SSL_USE_SIGALGS(s)) {
3318 if (s->session && s->session->sess_cert) {
3320 sig = s->s3->tmp.peer_md;
3322 *(int *)parg = EVP_MD_type(sig);
3328 /* Might want to do something here for other versions */
3332 case SSL_CTRL_GET_SERVER_TMP_KEY:
3333 if (s->server || !s->session || !s->session->sess_cert)
3339 sc = s->session->sess_cert;
3340 #if !defined(OPENSSL_NO_RSA) && !defined(OPENSSL_NO_DH) && !defined(OPENSSL_NO_EC)
3341 if (!sc->peer_rsa_tmp && !sc->peer_dh_tmp && !sc->peer_ecdh_tmp)
3344 ptmp = EVP_PKEY_new();
3347 #ifndef OPENSSL_NO_RSA
3348 else if (sc->peer_rsa_tmp)
3349 rv = EVP_PKEY_set1_RSA(ptmp, sc->peer_rsa_tmp);
3351 #ifndef OPENSSL_NO_DH
3352 else if (sc->peer_dh_tmp)
3353 rv = EVP_PKEY_set1_DH(ptmp, sc->peer_dh_tmp);
3355 #ifndef OPENSSL_NO_EC
3356 else if (sc->peer_ecdh_tmp)
3357 rv = EVP_PKEY_set1_EC_KEY(ptmp, sc->peer_ecdh_tmp);
3360 *(EVP_PKEY **)parg = ptmp;
3363 EVP_PKEY_free(ptmp);
3366 #ifndef OPENSSL_NO_EC
3367 case SSL_CTRL_GET_EC_POINT_FORMATS:
3369 SSL_SESSION *sess = s->session;
3370 const unsigned char **pformat = parg;
3371 if (!sess || !sess->tlsext_ecpointformatlist)
3373 *pformat = sess->tlsext_ecpointformatlist;
3374 return (int)sess->tlsext_ecpointformatlist_length;
3378 case SSL_CTRL_CHECK_PROTO_VERSION:
3380 * For library-internal use; checks that the current protocol is the
3381 * highest enabled version (according to s->ctx->method, as version
3382 * negotiation may have changed s->method).
3384 if (s->version == s->ctx->method->version)
3387 * Apparently we're using a version-flexible SSL_METHOD (not at its
3388 * highest protocol version).
3390 if (s->ctx->method->version == TLS_method()->version) {
3391 #if TLS_MAX_VERSION != TLS1_2_VERSION
3392 # error Code needs update for TLS_method() support beyond TLS1_2_VERSION.
3394 if (!(s->options & SSL_OP_NO_TLSv1_2))
3395 return s->version == TLS1_2_VERSION;
3396 if (!(s->options & SSL_OP_NO_TLSv1_1))
3397 return s->version == TLS1_1_VERSION;
3398 if (!(s->options & SSL_OP_NO_TLSv1))
3399 return s->version == TLS1_VERSION;
3400 if (!(s->options & SSL_OP_NO_SSLv3))
3401 return s->version == SSL3_VERSION;
3403 return 0; /* Unexpected state; fail closed. */
3411 long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp) (void))
3416 #ifndef OPENSSL_NO_RSA
3417 case SSL_CTRL_SET_TMP_RSA_CB:
3419 s->cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
3423 #ifndef OPENSSL_NO_DH
3424 case SSL_CTRL_SET_TMP_DH_CB:
3426 s->cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
3430 #ifndef OPENSSL_NO_EC
3431 case SSL_CTRL_SET_TMP_ECDH_CB:
3433 s->cert->ecdh_tmp_cb = (EC_KEY *(*)(SSL *, int, int))fp;
3437 case SSL_CTRL_SET_TLSEXT_DEBUG_CB:
3438 s->tlsext_debug_cb = (void (*)(SSL *, int, int,
3439 unsigned char *, int, void *))fp;
3442 case SSL_CTRL_SET_NOT_RESUMABLE_SESS_CB:
3444 s->not_resumable_session_cb = (int (*)(SSL *, int))fp;
3453 long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg)
3460 #ifndef OPENSSL_NO_RSA
3461 case SSL_CTRL_NEED_TMP_RSA:
3462 if ((cert->rsa_tmp == NULL) &&
3463 ((cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) ||
3464 (EVP_PKEY_size(cert->pkeys[SSL_PKEY_RSA_ENC].privatekey) >
3471 case SSL_CTRL_SET_TMP_RSA:
3481 if ((rsa = RSAPrivateKey_dup(rsa)) == NULL)
3485 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_RSA_LIB);
3488 RSA_free(cert->rsa_tmp);
3489 cert->rsa_tmp = rsa;
3494 case SSL_CTRL_SET_TMP_RSA_CB:
3496 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3500 #ifndef OPENSSL_NO_DH
3501 case SSL_CTRL_SET_TMP_DH:
3503 DH *new = NULL, *dh;
3506 if (!ssl_ctx_security(ctx, SSL_SECOP_TMP_DH,
3507 DH_security_bits(dh), 0, dh)) {
3508 SSLerr(SSL_F_SSL3_CTX_CTRL, SSL_R_DH_KEY_TOO_SMALL);
3511 if ((new = DHparams_dup(dh)) == NULL) {
3512 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_DH_LIB);
3515 if (!(ctx->options & SSL_OP_SINGLE_DH_USE)) {
3516 if (!DH_generate_key(new)) {
3517 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_DH_LIB);
3522 DH_free(cert->dh_tmp);
3529 case SSL_CTRL_SET_TMP_DH_CB:
3531 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3534 case SSL_CTRL_SET_DH_AUTO:
3535 ctx->cert->dh_tmp_auto = larg;
3538 #ifndef OPENSSL_NO_EC
3539 case SSL_CTRL_SET_TMP_ECDH:
3541 EC_KEY *ecdh = NULL;
3544 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_ECDH_LIB);
3547 ecdh = EC_KEY_dup((EC_KEY *)parg);
3549 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_EC_LIB);
3552 if (!(ctx->options & SSL_OP_SINGLE_ECDH_USE)) {
3553 if (!EC_KEY_generate_key(ecdh)) {
3555 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_ECDH_LIB);
3560 EC_KEY_free(cert->ecdh_tmp);
3561 cert->ecdh_tmp = ecdh;
3565 case SSL_CTRL_SET_TMP_ECDH_CB:
3567 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3570 #endif /* !OPENSSL_NO_EC */
3571 case SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG:
3572 ctx->tlsext_servername_arg = parg;
3574 case SSL_CTRL_SET_TLSEXT_TICKET_KEYS:
3575 case SSL_CTRL_GET_TLSEXT_TICKET_KEYS:
3577 unsigned char *keys = parg;
3581 SSLerr(SSL_F_SSL3_CTX_CTRL, SSL_R_INVALID_TICKET_KEYS_LENGTH);
3584 if (cmd == SSL_CTRL_SET_TLSEXT_TICKET_KEYS) {
3585 memcpy(ctx->tlsext_tick_key_name, keys, 16);
3586 memcpy(ctx->tlsext_tick_hmac_key, keys + 16, 16);
3587 memcpy(ctx->tlsext_tick_aes_key, keys + 32, 16);
3589 memcpy(keys, ctx->tlsext_tick_key_name, 16);
3590 memcpy(keys + 16, ctx->tlsext_tick_hmac_key, 16);
3591 memcpy(keys + 32, ctx->tlsext_tick_aes_key, 16);
3596 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG:
3597 ctx->tlsext_status_arg = parg;
3600 #ifndef OPENSSL_NO_SRP
3601 case SSL_CTRL_SET_TLS_EXT_SRP_USERNAME:
3602 ctx->srp_ctx.srp_Mask |= SSL_kSRP;
3603 OPENSSL_free(ctx->srp_ctx.login);
3604 ctx->srp_ctx.login = NULL;
3607 if (strlen((const char *)parg) > 255
3608 || strlen((const char *)parg) < 1) {
3609 SSLerr(SSL_F_SSL3_CTX_CTRL, SSL_R_INVALID_SRP_USERNAME);
3612 if ((ctx->srp_ctx.login = BUF_strdup((char *)parg)) == NULL) {
3613 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_INTERNAL_ERROR);
3617 case SSL_CTRL_SET_TLS_EXT_SRP_PASSWORD:
3618 ctx->srp_ctx.SRP_give_srp_client_pwd_callback =
3619 srp_password_from_info_cb;
3620 ctx->srp_ctx.info = parg;
3622 case SSL_CTRL_SET_SRP_ARG:
3623 ctx->srp_ctx.srp_Mask |= SSL_kSRP;
3624 ctx->srp_ctx.SRP_cb_arg = parg;
3627 case SSL_CTRL_SET_TLS_EXT_SRP_STRENGTH:
3628 ctx->srp_ctx.strength = larg;
3632 #ifndef OPENSSL_NO_EC
3633 case SSL_CTRL_SET_CURVES:
3634 return tls1_set_curves(&ctx->tlsext_ellipticcurvelist,
3635 &ctx->tlsext_ellipticcurvelist_length,
3638 case SSL_CTRL_SET_CURVES_LIST:
3639 return tls1_set_curves_list(&ctx->tlsext_ellipticcurvelist,
3640 &ctx->tlsext_ellipticcurvelist_length,
3642 case SSL_CTRL_SET_ECDH_AUTO:
3643 ctx->cert->ecdh_tmp_auto = larg;
3646 case SSL_CTRL_SET_SIGALGS:
3647 return tls1_set_sigalgs(ctx->cert, parg, larg, 0);
3649 case SSL_CTRL_SET_SIGALGS_LIST:
3650 return tls1_set_sigalgs_list(ctx->cert, parg, 0);
3652 case SSL_CTRL_SET_CLIENT_SIGALGS:
3653 return tls1_set_sigalgs(ctx->cert, parg, larg, 1);
3655 case SSL_CTRL_SET_CLIENT_SIGALGS_LIST:
3656 return tls1_set_sigalgs_list(ctx->cert, parg, 1);
3658 case SSL_CTRL_SET_CLIENT_CERT_TYPES:
3659 return ssl3_set_req_cert_type(ctx->cert, parg, larg);
3661 case SSL_CTRL_BUILD_CERT_CHAIN:
3662 return ssl_build_cert_chain(NULL, ctx, larg);
3664 case SSL_CTRL_SET_VERIFY_CERT_STORE:
3665 return ssl_cert_set_cert_store(ctx->cert, parg, 0, larg);
3667 case SSL_CTRL_SET_CHAIN_CERT_STORE:
3668 return ssl_cert_set_cert_store(ctx->cert, parg, 1, larg);
3670 /* A Thawte special :-) */
3671 case SSL_CTRL_EXTRA_CHAIN_CERT:
3672 if (ctx->extra_certs == NULL) {
3673 if ((ctx->extra_certs = sk_X509_new_null()) == NULL)
3676 sk_X509_push(ctx->extra_certs, (X509 *)parg);
3679 case SSL_CTRL_GET_EXTRA_CHAIN_CERTS:
3680 if (ctx->extra_certs == NULL && larg == 0)
3681 *(STACK_OF(X509) **)parg = ctx->cert->key->chain;
3683 *(STACK_OF(X509) **)parg = ctx->extra_certs;
3686 case SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS:
3687 sk_X509_pop_free(ctx->extra_certs, X509_free);
3688 ctx->extra_certs = NULL;
3691 case SSL_CTRL_CHAIN:
3693 return ssl_cert_set1_chain(NULL, ctx, (STACK_OF(X509) *)parg);
3695 return ssl_cert_set0_chain(NULL, ctx, (STACK_OF(X509) *)parg);
3697 case SSL_CTRL_CHAIN_CERT:
3699 return ssl_cert_add1_chain_cert(NULL, ctx, (X509 *)parg);
3701 return ssl_cert_add0_chain_cert(NULL, ctx, (X509 *)parg);
3703 case SSL_CTRL_GET_CHAIN_CERTS:
3704 *(STACK_OF(X509) **)parg = ctx->cert->key->chain;
3707 case SSL_CTRL_SELECT_CURRENT_CERT:
3708 return ssl_cert_select_current(ctx->cert, (X509 *)parg);
3710 case SSL_CTRL_SET_CURRENT_CERT:
3711 return ssl_cert_set_current(ctx->cert, larg);
3719 long ssl3_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp) (void))
3726 #ifndef OPENSSL_NO_RSA
3727 case SSL_CTRL_SET_TMP_RSA_CB:
3729 cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
3733 #ifndef OPENSSL_NO_DH
3734 case SSL_CTRL_SET_TMP_DH_CB:
3736 cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
3740 #ifndef OPENSSL_NO_EC
3741 case SSL_CTRL_SET_TMP_ECDH_CB:
3743 cert->ecdh_tmp_cb = (EC_KEY *(*)(SSL *, int, int))fp;
3747 case SSL_CTRL_SET_TLSEXT_SERVERNAME_CB:
3748 ctx->tlsext_servername_callback = (int (*)(SSL *, int *, void *))fp;
3751 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB:
3752 ctx->tlsext_status_cb = (int (*)(SSL *, void *))fp;
3755 case SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB:
3756 ctx->tlsext_ticket_key_cb = (int (*)(SSL *, unsigned char *,
3759 HMAC_CTX *, int))fp;
3762 #ifndef OPENSSL_NO_SRP
3763 case SSL_CTRL_SET_SRP_VERIFY_PARAM_CB:
3764 ctx->srp_ctx.srp_Mask |= SSL_kSRP;
3765 ctx->srp_ctx.SRP_verify_param_callback = (int (*)(SSL *, void *))fp;
3767 case SSL_CTRL_SET_TLS_EXT_SRP_USERNAME_CB:
3768 ctx->srp_ctx.srp_Mask |= SSL_kSRP;
3769 ctx->srp_ctx.TLS_ext_srp_username_callback =
3770 (int (*)(SSL *, int *, void *))fp;
3772 case SSL_CTRL_SET_SRP_GIVE_CLIENT_PWD_CB:
3773 ctx->srp_ctx.srp_Mask |= SSL_kSRP;
3774 ctx->srp_ctx.SRP_give_srp_client_pwd_callback =
3775 (char *(*)(SSL *, void *))fp;
3778 case SSL_CTRL_SET_NOT_RESUMABLE_SESS_CB:
3780 ctx->not_resumable_session_cb = (int (*)(SSL *, int))fp;
3790 * This function needs to check if the ciphers required are actually
3793 const SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p)
3796 const SSL_CIPHER *cp;
3799 id = 0x03000000L | ((unsigned long)p[0] << 8L) | (unsigned long)p[1];
3801 cp = OBJ_bsearch_ssl_cipher_id(&c, ssl3_ciphers, SSL3_NUM_CIPHERS);
3802 #ifdef DEBUG_PRINT_UNKNOWN_CIPHERSUITES
3804 fprintf(stderr, "Unknown cipher ID %x\n", (p[0] << 8) | p[1]);
3809 int ssl3_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p)
3815 if ((l & 0xff000000) != 0x03000000)
3817 p[0] = ((unsigned char)(l >> 8L)) & 0xFF;
3818 p[1] = ((unsigned char)(l)) & 0xFF;
3823 SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt,
3824 STACK_OF(SSL_CIPHER) *srvr)
3826 SSL_CIPHER *c, *ret = NULL;
3827 STACK_OF(SSL_CIPHER) *prio, *allow;
3829 unsigned long alg_k, alg_a, mask_k, mask_a, emask_k, emask_a;
3831 /* Let's see which ciphers we can support */
3835 * Do not set the compare functions, because this may lead to a
3836 * reordering by "id". We want to keep the original ordering. We may pay
3837 * a price in performance during sk_SSL_CIPHER_find(), but would have to
3838 * pay with the price of sk_SSL_CIPHER_dup().
3840 sk_SSL_CIPHER_set_cmp_func(srvr, ssl_cipher_ptr_id_cmp);
3841 sk_SSL_CIPHER_set_cmp_func(clnt, ssl_cipher_ptr_id_cmp);
3845 fprintf(stderr, "Server has %d from %p:\n", sk_SSL_CIPHER_num(srvr),
3847 for (i = 0; i < sk_SSL_CIPHER_num(srvr); ++i) {
3848 c = sk_SSL_CIPHER_value(srvr, i);
3849 fprintf(stderr, "%p:%s\n", (void *)c, c->name);
3851 fprintf(stderr, "Client sent %d from %p:\n", sk_SSL_CIPHER_num(clnt),
3853 for (i = 0; i < sk_SSL_CIPHER_num(clnt); ++i) {
3854 c = sk_SSL_CIPHER_value(clnt, i);
3855 fprintf(stderr, "%p:%s\n", (void *)c, c->name);
3859 if (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE || tls1_suiteb(s)) {
3867 tls1_set_cert_validity(s);
3869 for (i = 0; i < sk_SSL_CIPHER_num(prio); i++) {
3870 c = sk_SSL_CIPHER_value(prio, i);
3872 /* Skip TLS v1.2 only ciphersuites if not supported */
3873 if ((c->algorithm_ssl & SSL_TLSV1_2) && !SSL_USE_TLS1_2_CIPHERS(s))
3876 ssl_set_masks(s, c);
3877 mask_k = s->s3->tmp.mask_k;
3878 mask_a = s->s3->tmp.mask_a;
3879 emask_k = s->s3->tmp.export_mask_k;
3880 emask_a = s->s3->tmp.export_mask_a;
3881 #ifndef OPENSSL_NO_SRP
3882 if (s->srp_ctx.srp_Mask & SSL_kSRP) {
3884 emask_k |= SSL_kSRP;
3886 emask_a |= SSL_aSRP;
3890 alg_k = c->algorithm_mkey;
3891 alg_a = c->algorithm_auth;
3893 #ifndef OPENSSL_NO_PSK
3894 /* with PSK there must be server callback set */
3895 if ((alg_k & SSL_kPSK) && s->psk_server_callback == NULL)
3897 #endif /* OPENSSL_NO_PSK */
3899 if (SSL_C_IS_EXPORT(c)) {
3900 ok = (alg_k & emask_k) && (alg_a & emask_a);
3902 fprintf(stderr, "%d:[%08lX:%08lX:%08lX:%08lX]%p:%s (export)\n",
3903 ok, alg_k, alg_a, emask_k, emask_a, (void *)c, c->name);
3906 ok = (alg_k & mask_k) && (alg_a & mask_a);
3908 fprintf(stderr, "%d:[%08lX:%08lX:%08lX:%08lX]%p:%s\n", ok, alg_k,
3909 alg_a, mask_k, mask_a, (void *)c, c->name);
3913 # ifndef OPENSSL_NO_EC
3915 * if we are considering an ECC cipher suite that uses an ephemeral
3918 if (alg_k & SSL_kECDHE)
3919 ok = ok && tls1_check_ec_tmp_key(s, c->id);
3920 # endif /* OPENSSL_NO_EC */
3924 ii = sk_SSL_CIPHER_find(allow, c);
3926 /* Check security callback permits this cipher */
3927 if (!ssl_security(s, SSL_SECOP_CIPHER_SHARED,
3928 c->strength_bits, 0, c))
3930 #if !defined(OPENSSL_NO_EC)
3931 if ((alg_k & SSL_kECDHE) && (alg_a & SSL_aECDSA)
3932 && s->s3->is_probably_safari) {
3934 ret = sk_SSL_CIPHER_value(allow, ii);
3938 ret = sk_SSL_CIPHER_value(allow, ii);
3945 int ssl3_get_req_cert_type(SSL *s, unsigned char *p)
3949 unsigned long alg_k, alg_a = 0;
3951 /* If we have custom certificate types set, use them */
3952 if (s->cert->ctypes) {
3953 memcpy(p, s->cert->ctypes, s->cert->ctype_num);
3954 return (int)s->cert->ctype_num;
3956 /* Get mask of algorithms disabled by signature list */
3957 ssl_set_sig_mask(&alg_a, s, SSL_SECOP_SIGALG_MASK);
3958 if (s->cert->cert_flags & SSL_CERT_FLAGS_CHECK_TLS_STRICT)
3961 alg_k = s->s3->tmp.new_cipher->algorithm_mkey;
3963 #ifndef OPENSSL_NO_GOST
3964 if (s->version >= TLS1_VERSION) {
3965 if (alg_k & SSL_kGOST) {
3966 p[ret++] = TLS_CT_GOST94_SIGN;
3967 p[ret++] = TLS_CT_GOST01_SIGN;
3973 #ifndef OPENSSL_NO_DH
3974 if (alg_k & (SSL_kDHr | SSL_kDHE)) {
3975 # ifndef OPENSSL_NO_RSA
3977 * Since this refers to a certificate signed with an RSA algorithm,
3978 * only check for rsa signing in strict mode.
3980 if (nostrict || !(alg_a & SSL_aRSA))
3981 p[ret++] = SSL3_CT_RSA_FIXED_DH;
3983 # ifndef OPENSSL_NO_DSA
3984 if (nostrict || !(alg_a & SSL_aDSS))
3985 p[ret++] = SSL3_CT_DSS_FIXED_DH;
3988 if ((s->version == SSL3_VERSION) &&
3989 (alg_k & (SSL_kDHE | SSL_kDHd | SSL_kDHr))) {
3990 # ifndef OPENSSL_NO_RSA
3991 p[ret++] = SSL3_CT_RSA_EPHEMERAL_DH;
3993 # ifndef OPENSSL_NO_DSA
3994 p[ret++] = SSL3_CT_DSS_EPHEMERAL_DH;
3997 #endif /* !OPENSSL_NO_DH */
3998 #ifndef OPENSSL_NO_RSA
3999 if (!(alg_a & SSL_aRSA))
4000 p[ret++] = SSL3_CT_RSA_SIGN;
4002 #ifndef OPENSSL_NO_DSA
4003 if (!(alg_a & SSL_aDSS))
4004 p[ret++] = SSL3_CT_DSS_SIGN;
4006 #ifndef OPENSSL_NO_EC
4007 if ((alg_k & (SSL_kECDHr | SSL_kECDHe)) && (s->version >= TLS1_VERSION)) {
4008 if (nostrict || !(alg_a & SSL_aRSA))
4009 p[ret++] = TLS_CT_RSA_FIXED_ECDH;
4010 if (nostrict || !(alg_a & SSL_aECDSA))
4011 p[ret++] = TLS_CT_ECDSA_FIXED_ECDH;
4014 * ECDSA certs can be used with RSA cipher suites as well so we don't
4015 * need to check for SSL_kECDH or SSL_kECDHE
4017 if (s->version >= TLS1_VERSION) {
4018 if (!(alg_a & SSL_aECDSA))
4019 p[ret++] = TLS_CT_ECDSA_SIGN;
4025 static int ssl3_set_req_cert_type(CERT *c, const unsigned char *p, size_t len)
4027 OPENSSL_free(c->ctypes);
4033 c->ctypes = OPENSSL_malloc(len);
4036 memcpy(c->ctypes, p, len);
4041 int ssl3_shutdown(SSL *s)
4046 * Don't do anything much if we have not done the handshake or we don't
4047 * want to send messages :-)
4049 if ((s->quiet_shutdown) || (s->state == SSL_ST_BEFORE)) {
4050 s->shutdown = (SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN);
4054 if (!(s->shutdown & SSL_SENT_SHUTDOWN)) {
4055 s->shutdown |= SSL_SENT_SHUTDOWN;
4056 ssl3_send_alert(s, SSL3_AL_WARNING, SSL_AD_CLOSE_NOTIFY);
4058 * our shutdown alert has been sent now, and if it still needs to be
4059 * written, s->s3->alert_dispatch will be true
4061 if (s->s3->alert_dispatch)
4062 return (-1); /* return WANT_WRITE */
4063 } else if (s->s3->alert_dispatch) {
4064 /* resend it if not sent */
4065 ret = s->method->ssl_dispatch_alert(s);
4068 * we only get to return -1 here the 2nd/Nth invocation, we must
4069 * have already signalled return 0 upon a previous invoation,
4074 } else if (!(s->shutdown & SSL_RECEIVED_SHUTDOWN)) {
4076 * If we are waiting for a close from our peer, we are closed
4078 s->method->ssl_read_bytes(s, 0, NULL, 0, 0);
4079 if (!(s->shutdown & SSL_RECEIVED_SHUTDOWN)) {
4080 return (-1); /* return WANT_READ */
4084 if ((s->shutdown == (SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN)) &&
4085 !s->s3->alert_dispatch)
4091 int ssl3_write(SSL *s, const void *buf, int len)
4096 if (s->shutdown & SSL_SEND_SHUTDOWN) {
4097 s->rwstate = SSL_NOTHING;
4102 if (s->s3->renegotiate)
4103 ssl3_renegotiate_check(s);
4106 * This is an experimental flag that sends the last handshake message in
4107 * the same packet as the first use data - used to see if it helps the
4108 * TCP protocol during session-id reuse
4110 /* The second test is because the buffer may have been removed */
4111 if ((s->s3->flags & SSL3_FLAGS_POP_BUFFER) && (s->wbio == s->bbio)) {
4112 /* First time through, we write into the buffer */
4113 if (s->s3->delay_buf_pop_ret == 0) {
4114 ret = ssl3_write_bytes(s, SSL3_RT_APPLICATION_DATA, buf, len);
4118 s->s3->delay_buf_pop_ret = ret;
4121 s->rwstate = SSL_WRITING;
4122 n = BIO_flush(s->wbio);
4125 s->rwstate = SSL_NOTHING;
4127 /* We have flushed the buffer, so remove it */
4128 ssl_free_wbio_buffer(s);
4129 s->s3->flags &= ~SSL3_FLAGS_POP_BUFFER;
4131 ret = s->s3->delay_buf_pop_ret;
4132 s->s3->delay_buf_pop_ret = 0;
4134 ret = s->method->ssl_write_bytes(s, SSL3_RT_APPLICATION_DATA,
4143 static int ssl3_read_internal(SSL *s, void *buf, int len, int peek)
4148 if (s->s3->renegotiate)
4149 ssl3_renegotiate_check(s);
4150 s->s3->in_read_app_data = 1;
4152 s->method->ssl_read_bytes(s, SSL3_RT_APPLICATION_DATA, buf, len,
4154 if ((ret == -1) && (s->s3->in_read_app_data == 2)) {
4156 * ssl3_read_bytes decided to call s->handshake_func, which called
4157 * ssl3_read_bytes to read handshake data. However, ssl3_read_bytes
4158 * actually found application data and thinks that application data
4159 * makes sense here; so disable handshake processing and try to read
4160 * application data again.
4164 s->method->ssl_read_bytes(s, SSL3_RT_APPLICATION_DATA, buf, len,
4168 s->s3->in_read_app_data = 0;
4173 int ssl3_read(SSL *s, void *buf, int len)
4175 return ssl3_read_internal(s, buf, len, 0);
4178 int ssl3_peek(SSL *s, void *buf, int len)
4180 return ssl3_read_internal(s, buf, len, 1);
4183 int ssl3_renegotiate(SSL *s)
4185 if (s->handshake_func == NULL)
4188 if (s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS)
4191 s->s3->renegotiate = 1;
4195 int ssl3_renegotiate_check(SSL *s)
4199 if (s->s3->renegotiate) {
4200 if (!RECORD_LAYER_read_pending(&s->rlayer)
4201 && !RECORD_LAYER_write_pending(&s->rlayer)
4202 && !SSL_in_init(s)) {
4204 * if we are the server, and we have sent a 'RENEGOTIATE'
4205 * message, we need to go to SSL_ST_ACCEPT.
4208 s->state = SSL_ST_RENEGOTIATE;
4209 s->s3->renegotiate = 0;
4210 s->s3->num_renegotiations++;
4211 s->s3->total_renegotiations++;
4219 * If we are using default SHA1+MD5 algorithms switch to new SHA256 PRF and
4220 * handshake macs if required.
4222 long ssl_get_algorithm2(SSL *s)
4224 long alg2 = s->s3->tmp.new_cipher->algorithm2;
4225 if (s->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_SHA256_PRF
4226 && alg2 == (SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF))
4227 return SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256;
4232 * Fill a ClientRandom or ServerRandom field of length len. Returns <= 0 on
4233 * failure, 1 on success.
4235 int ssl_fill_hello_random(SSL *s, int server, unsigned char *result, int len)
4242 send_time = (s->mode & SSL_MODE_SEND_SERVERHELLO_TIME) != 0;
4244 send_time = (s->mode & SSL_MODE_SEND_CLIENTHELLO_TIME) != 0;
4246 unsigned long Time = (unsigned long)time(NULL);
4247 unsigned char *p = result;
4249 return RAND_bytes(p, len - 4);
4251 return RAND_bytes(result, len);