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 sk_X509_NAME_pop_free(s->s3->tmp.ca_names, X509_NAME_free);
3130 BIO_free(s->s3->handshake_buffer);
3131 if (s->s3->handshake_dgst)
3132 ssl3_free_digest_list(s);
3133 #ifndef OPENSSL_NO_TLSEXT
3134 if (s->s3->alpn_selected)
3135 OPENSSL_free(s->s3->alpn_selected);
3138 #ifndef OPENSSL_NO_SRP
3139 SSL_SRP_CTX_free(s);
3141 OPENSSL_clear_free(s->s3, sizeof *s->s3);
3145 void ssl3_clear(SSL *s)
3149 ssl3_cleanup_key_block(s);
3150 sk_X509_NAME_pop_free(s->s3->tmp.ca_names, X509_NAME_free);
3152 #ifndef OPENSSL_NO_DH
3153 DH_free(s->s3->tmp.dh);
3154 s->s3->tmp.dh = NULL;
3156 #ifndef OPENSSL_NO_EC
3157 EC_KEY_free(s->s3->tmp.ecdh);
3158 s->s3->tmp.ecdh = NULL;
3160 #ifndef OPENSSL_NO_TLSEXT
3161 # ifndef OPENSSL_NO_EC
3162 s->s3->is_probably_safari = 0;
3163 # endif /* !OPENSSL_NO_EC */
3164 #endif /* !OPENSSL_NO_TLSEXT */
3166 init_extra = s->s3->init_extra;
3167 BIO_free(s->s3->handshake_buffer);
3168 s->s3->handshake_buffer = NULL;
3169 if (s->s3->handshake_dgst) {
3170 ssl3_free_digest_list(s);
3172 #if !defined(OPENSSL_NO_TLSEXT)
3173 if (s->s3->alpn_selected) {
3174 free(s->s3->alpn_selected);
3175 s->s3->alpn_selected = NULL;
3178 memset(s->s3, 0, sizeof *s->s3);
3179 s->s3->init_extra = init_extra;
3181 ssl_free_wbio_buffer(s);
3183 s->s3->renegotiate = 0;
3184 s->s3->total_renegotiations = 0;
3185 s->s3->num_renegotiations = 0;
3186 s->s3->in_read_app_data = 0;
3187 s->version = SSL3_VERSION;
3189 #if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
3190 if (s->next_proto_negotiated) {
3191 OPENSSL_free(s->next_proto_negotiated);
3192 s->next_proto_negotiated = NULL;
3193 s->next_proto_negotiated_len = 0;
3198 #ifndef OPENSSL_NO_SRP
3199 static char *srp_password_from_info_cb(SSL *s, void *arg)
3201 return BUF_strdup(s->srp_ctx.info);
3205 static int ssl3_set_req_cert_type(CERT *c, const unsigned char *p,
3208 long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg)
3213 case SSL_CTRL_GET_SESSION_REUSED:
3216 case SSL_CTRL_GET_CLIENT_CERT_REQUEST:
3218 case SSL_CTRL_GET_NUM_RENEGOTIATIONS:
3219 ret = s->s3->num_renegotiations;
3221 case SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS:
3222 ret = s->s3->num_renegotiations;
3223 s->s3->num_renegotiations = 0;
3225 case SSL_CTRL_GET_TOTAL_RENEGOTIATIONS:
3226 ret = s->s3->total_renegotiations;
3228 case SSL_CTRL_GET_FLAGS:
3229 ret = (int)(s->s3->flags);
3231 #ifndef OPENSSL_NO_RSA
3232 case SSL_CTRL_NEED_TMP_RSA:
3233 if ((s->cert != NULL) && (s->cert->rsa_tmp == NULL) &&
3234 ((s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) ||
3235 (EVP_PKEY_size(s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey) >
3239 case SSL_CTRL_SET_TMP_RSA:
3241 RSA *rsa = (RSA *)parg;
3243 SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
3246 if ((rsa = RSAPrivateKey_dup(rsa)) == NULL) {
3247 SSLerr(SSL_F_SSL3_CTRL, ERR_R_RSA_LIB);
3250 RSA_free(s->cert->rsa_tmp);
3251 s->cert->rsa_tmp = rsa;
3255 case SSL_CTRL_SET_TMP_RSA_CB:
3257 SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3261 #ifndef OPENSSL_NO_DH
3262 case SSL_CTRL_SET_TMP_DH:
3264 DH *dh = (DH *)parg;
3266 SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
3269 if (!ssl_security(s, SSL_SECOP_TMP_DH,
3270 DH_security_bits(dh), 0, dh)) {
3271 SSLerr(SSL_F_SSL3_CTRL, SSL_R_DH_KEY_TOO_SMALL);
3274 if ((dh = DHparams_dup(dh)) == NULL) {
3275 SSLerr(SSL_F_SSL3_CTRL, ERR_R_DH_LIB);
3278 if (!(s->options & SSL_OP_SINGLE_DH_USE)) {
3279 if (!DH_generate_key(dh)) {
3281 SSLerr(SSL_F_SSL3_CTRL, ERR_R_DH_LIB);
3285 DH_free(s->cert->dh_tmp);
3286 s->cert->dh_tmp = dh;
3290 case SSL_CTRL_SET_TMP_DH_CB:
3292 SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3295 case SSL_CTRL_SET_DH_AUTO:
3296 s->cert->dh_tmp_auto = larg;
3299 #ifndef OPENSSL_NO_EC
3300 case SSL_CTRL_SET_TMP_ECDH:
3302 EC_KEY *ecdh = NULL;
3305 SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
3308 if (!EC_KEY_up_ref((EC_KEY *)parg)) {
3309 SSLerr(SSL_F_SSL3_CTRL, ERR_R_ECDH_LIB);
3312 ecdh = (EC_KEY *)parg;
3313 if (!(s->options & SSL_OP_SINGLE_ECDH_USE)) {
3314 if (!EC_KEY_generate_key(ecdh)) {
3316 SSLerr(SSL_F_SSL3_CTRL, ERR_R_ECDH_LIB);
3320 EC_KEY_free(s->cert->ecdh_tmp);
3321 s->cert->ecdh_tmp = ecdh;
3325 case SSL_CTRL_SET_TMP_ECDH_CB:
3327 SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3330 #endif /* !OPENSSL_NO_EC */
3331 #ifndef OPENSSL_NO_TLSEXT
3332 case SSL_CTRL_SET_TLSEXT_HOSTNAME:
3333 if (larg == TLSEXT_NAMETYPE_host_name) {
3334 if (s->tlsext_hostname != NULL)
3335 OPENSSL_free(s->tlsext_hostname);
3336 s->tlsext_hostname = NULL;
3341 if (strlen((char *)parg) > TLSEXT_MAXLEN_host_name) {
3342 SSLerr(SSL_F_SSL3_CTRL, SSL_R_SSL3_EXT_INVALID_SERVERNAME);
3345 if ((s->tlsext_hostname = BUF_strdup((char *)parg)) == NULL) {
3346 SSLerr(SSL_F_SSL3_CTRL, ERR_R_INTERNAL_ERROR);
3350 SSLerr(SSL_F_SSL3_CTRL, SSL_R_SSL3_EXT_INVALID_SERVERNAME_TYPE);
3354 case SSL_CTRL_SET_TLSEXT_DEBUG_ARG:
3355 s->tlsext_debug_arg = parg;
3359 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE:
3360 s->tlsext_status_type = larg;
3364 case SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS:
3365 *(STACK_OF(X509_EXTENSION) **)parg = s->tlsext_ocsp_exts;
3369 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS:
3370 s->tlsext_ocsp_exts = parg;
3374 case SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS:
3375 *(STACK_OF(OCSP_RESPID) **)parg = s->tlsext_ocsp_ids;
3379 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS:
3380 s->tlsext_ocsp_ids = parg;
3384 case SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP:
3385 *(unsigned char **)parg = s->tlsext_ocsp_resp;
3386 return s->tlsext_ocsp_resplen;
3388 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP:
3389 if (s->tlsext_ocsp_resp)
3390 OPENSSL_free(s->tlsext_ocsp_resp);
3391 s->tlsext_ocsp_resp = parg;
3392 s->tlsext_ocsp_resplen = larg;
3396 # ifndef OPENSSL_NO_HEARTBEATS
3397 case SSL_CTRL_TLS_EXT_SEND_HEARTBEAT:
3399 ret = dtls1_heartbeat(s);
3401 ret = tls1_heartbeat(s);
3404 case SSL_CTRL_GET_TLS_EXT_HEARTBEAT_PENDING:
3405 ret = s->tlsext_hb_pending;
3408 case SSL_CTRL_SET_TLS_EXT_HEARTBEAT_NO_REQUESTS:
3410 s->tlsext_heartbeat |= SSL_TLSEXT_HB_DONT_RECV_REQUESTS;
3412 s->tlsext_heartbeat &= ~SSL_TLSEXT_HB_DONT_RECV_REQUESTS;
3417 #endif /* !OPENSSL_NO_TLSEXT */
3419 case SSL_CTRL_CHAIN:
3421 return ssl_cert_set1_chain(s, NULL, (STACK_OF(X509) *)parg);
3423 return ssl_cert_set0_chain(s, NULL, (STACK_OF(X509) *)parg);
3425 case SSL_CTRL_CHAIN_CERT:
3427 return ssl_cert_add1_chain_cert(s, NULL, (X509 *)parg);
3429 return ssl_cert_add0_chain_cert(s, NULL, (X509 *)parg);
3431 case SSL_CTRL_GET_CHAIN_CERTS:
3432 *(STACK_OF(X509) **)parg = s->cert->key->chain;
3435 case SSL_CTRL_SELECT_CURRENT_CERT:
3436 return ssl_cert_select_current(s->cert, (X509 *)parg);
3438 case SSL_CTRL_SET_CURRENT_CERT:
3439 if (larg == SSL_CERT_SET_SERVER) {
3441 const SSL_CIPHER *cipher;
3444 cipher = s->s3->tmp.new_cipher;
3448 * No certificate for unauthenticated ciphersuites or using SRP
3451 if (cipher->algorithm_auth & (SSL_aNULL | SSL_aSRP))
3453 cpk = ssl_get_server_send_pkey(s);
3459 return ssl_cert_set_current(s->cert, larg);
3461 #ifndef OPENSSL_NO_EC
3462 case SSL_CTRL_GET_CURVES:
3464 unsigned char *clist;
3468 clist = s->session->tlsext_ellipticcurvelist;
3469 clistlen = s->session->tlsext_ellipticcurvelist_length / 2;
3473 unsigned int cid, nid;
3474 for (i = 0; i < clistlen; i++) {
3476 nid = tls1_ec_curve_id2nid(cid);
3480 cptr[i] = TLSEXT_nid_unknown | cid;
3483 return (int)clistlen;
3486 case SSL_CTRL_SET_CURVES:
3487 return tls1_set_curves(&s->tlsext_ellipticcurvelist,
3488 &s->tlsext_ellipticcurvelist_length,
3491 case SSL_CTRL_SET_CURVES_LIST:
3492 return tls1_set_curves_list(&s->tlsext_ellipticcurvelist,
3493 &s->tlsext_ellipticcurvelist_length,
3496 case SSL_CTRL_GET_SHARED_CURVE:
3497 return tls1_shared_curve(s, larg);
3499 # ifndef OPENSSL_NO_EC
3500 case SSL_CTRL_SET_ECDH_AUTO:
3501 s->cert->ecdh_tmp_auto = larg;
3505 case SSL_CTRL_SET_SIGALGS:
3506 return tls1_set_sigalgs(s->cert, parg, larg, 0);
3508 case SSL_CTRL_SET_SIGALGS_LIST:
3509 return tls1_set_sigalgs_list(s->cert, parg, 0);
3511 case SSL_CTRL_SET_CLIENT_SIGALGS:
3512 return tls1_set_sigalgs(s->cert, parg, larg, 1);
3514 case SSL_CTRL_SET_CLIENT_SIGALGS_LIST:
3515 return tls1_set_sigalgs_list(s->cert, parg, 1);
3517 case SSL_CTRL_GET_CLIENT_CERT_TYPES:
3519 const unsigned char **pctype = parg;
3520 if (s->server || !s->s3->tmp.cert_req)
3522 if (s->cert->ctypes) {
3524 *pctype = s->cert->ctypes;
3525 return (int)s->cert->ctype_num;
3528 *pctype = (unsigned char *)s->s3->tmp.ctype;
3529 return s->s3->tmp.ctype_num;
3532 case SSL_CTRL_SET_CLIENT_CERT_TYPES:
3535 return ssl3_set_req_cert_type(s->cert, parg, larg);
3537 case SSL_CTRL_BUILD_CERT_CHAIN:
3538 return ssl_build_cert_chain(s, NULL, larg);
3540 case SSL_CTRL_SET_VERIFY_CERT_STORE:
3541 return ssl_cert_set_cert_store(s->cert, parg, 0, larg);
3543 case SSL_CTRL_SET_CHAIN_CERT_STORE:
3544 return ssl_cert_set_cert_store(s->cert, parg, 1, larg);
3546 case SSL_CTRL_GET_PEER_SIGNATURE_NID:
3547 if (SSL_USE_SIGALGS(s)) {
3548 if (s->session && s->session->sess_cert) {
3550 sig = s->session->sess_cert->peer_key->digest;
3552 *(int *)parg = EVP_MD_type(sig);
3558 /* Might want to do something here for other versions */
3562 case SSL_CTRL_GET_SERVER_TMP_KEY:
3563 if (s->server || !s->session || !s->session->sess_cert)
3569 sc = s->session->sess_cert;
3570 #if !defined(OPENSSL_NO_RSA) && !defined(OPENSSL_NO_DH) && !defined(OPENSSL_NO_EC)
3571 if (!sc->peer_rsa_tmp && !sc->peer_dh_tmp && !sc->peer_ecdh_tmp)
3574 ptmp = EVP_PKEY_new();
3578 #ifndef OPENSSL_NO_RSA
3579 else if (sc->peer_rsa_tmp)
3580 rv = EVP_PKEY_set1_RSA(ptmp, sc->peer_rsa_tmp);
3582 #ifndef OPENSSL_NO_DH
3583 else if (sc->peer_dh_tmp)
3584 rv = EVP_PKEY_set1_DH(ptmp, sc->peer_dh_tmp);
3586 #ifndef OPENSSL_NO_EC
3587 else if (sc->peer_ecdh_tmp)
3588 rv = EVP_PKEY_set1_EC_KEY(ptmp, sc->peer_ecdh_tmp);
3591 *(EVP_PKEY **)parg = ptmp;
3594 EVP_PKEY_free(ptmp);
3597 #ifndef OPENSSL_NO_EC
3598 case SSL_CTRL_GET_EC_POINT_FORMATS:
3600 SSL_SESSION *sess = s->session;
3601 const unsigned char **pformat = parg;
3602 if (!sess || !sess->tlsext_ecpointformatlist)
3604 *pformat = sess->tlsext_ecpointformatlist;
3605 return (int)sess->tlsext_ecpointformatlist_length;
3609 case SSL_CTRL_CHECK_PROTO_VERSION:
3611 * For library-internal use; checks that the current protocol is the
3612 * highest enabled version (according to s->ctx->method, as version
3613 * negotiation may have changed s->method).
3615 if (s->version == s->ctx->method->version)
3618 * Apparently we're using a version-flexible SSL_METHOD (not at its
3619 * highest protocol version).
3621 if (s->ctx->method->version == SSLv23_method()->version) {
3622 #if TLS_MAX_VERSION != TLS1_2_VERSION
3623 # error Code needs update for SSLv23_method() support beyond TLS1_2_VERSION.
3625 if (!(s->options & SSL_OP_NO_TLSv1_2))
3626 return s->version == TLS1_2_VERSION;
3627 if (!(s->options & SSL_OP_NO_TLSv1_1))
3628 return s->version == TLS1_1_VERSION;
3629 if (!(s->options & SSL_OP_NO_TLSv1))
3630 return s->version == TLS1_VERSION;
3631 if (!(s->options & SSL_OP_NO_SSLv3))
3632 return s->version == SSL3_VERSION;
3634 return 0; /* Unexpected state; fail closed. */
3642 long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp) (void))
3647 #ifndef OPENSSL_NO_RSA
3648 case SSL_CTRL_SET_TMP_RSA_CB:
3650 s->cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
3654 #ifndef OPENSSL_NO_DH
3655 case SSL_CTRL_SET_TMP_DH_CB:
3657 s->cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
3661 #ifndef OPENSSL_NO_EC
3662 case SSL_CTRL_SET_TMP_ECDH_CB:
3664 s->cert->ecdh_tmp_cb = (EC_KEY *(*)(SSL *, int, int))fp;
3668 #ifndef OPENSSL_NO_TLSEXT
3669 case SSL_CTRL_SET_TLSEXT_DEBUG_CB:
3670 s->tlsext_debug_cb = (void (*)(SSL *, int, int,
3671 unsigned char *, int, void *))fp;
3674 case SSL_CTRL_SET_NOT_RESUMABLE_SESS_CB:
3676 s->not_resumable_session_cb = (int (*)(SSL *, int))fp;
3685 long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg)
3692 #ifndef OPENSSL_NO_RSA
3693 case SSL_CTRL_NEED_TMP_RSA:
3694 if ((cert->rsa_tmp == NULL) &&
3695 ((cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) ||
3696 (EVP_PKEY_size(cert->pkeys[SSL_PKEY_RSA_ENC].privatekey) >
3703 case SSL_CTRL_SET_TMP_RSA:
3713 if ((rsa = RSAPrivateKey_dup(rsa)) == NULL)
3717 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_RSA_LIB);
3720 RSA_free(cert->rsa_tmp);
3721 cert->rsa_tmp = rsa;
3726 case SSL_CTRL_SET_TMP_RSA_CB:
3728 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3732 #ifndef OPENSSL_NO_DH
3733 case SSL_CTRL_SET_TMP_DH:
3735 DH *new = NULL, *dh;
3738 if (!ssl_ctx_security(ctx, SSL_SECOP_TMP_DH,
3739 DH_security_bits(dh), 0, dh)) {
3740 SSLerr(SSL_F_SSL3_CTX_CTRL, SSL_R_DH_KEY_TOO_SMALL);
3743 if ((new = DHparams_dup(dh)) == NULL) {
3744 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_DH_LIB);
3747 if (!(ctx->options & SSL_OP_SINGLE_DH_USE)) {
3748 if (!DH_generate_key(new)) {
3749 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_DH_LIB);
3754 DH_free(cert->dh_tmp);
3761 case SSL_CTRL_SET_TMP_DH_CB:
3763 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3766 case SSL_CTRL_SET_DH_AUTO:
3767 ctx->cert->dh_tmp_auto = larg;
3770 #ifndef OPENSSL_NO_EC
3771 case SSL_CTRL_SET_TMP_ECDH:
3773 EC_KEY *ecdh = NULL;
3776 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_ECDH_LIB);
3779 ecdh = EC_KEY_dup((EC_KEY *)parg);
3781 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_EC_LIB);
3784 if (!(ctx->options & SSL_OP_SINGLE_ECDH_USE)) {
3785 if (!EC_KEY_generate_key(ecdh)) {
3787 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_ECDH_LIB);
3792 EC_KEY_free(cert->ecdh_tmp);
3793 cert->ecdh_tmp = ecdh;
3797 case SSL_CTRL_SET_TMP_ECDH_CB:
3799 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3802 #endif /* !OPENSSL_NO_EC */
3803 #ifndef OPENSSL_NO_TLSEXT
3804 case SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG:
3805 ctx->tlsext_servername_arg = parg;
3807 case SSL_CTRL_SET_TLSEXT_TICKET_KEYS:
3808 case SSL_CTRL_GET_TLSEXT_TICKET_KEYS:
3810 unsigned char *keys = parg;
3814 SSLerr(SSL_F_SSL3_CTX_CTRL, SSL_R_INVALID_TICKET_KEYS_LENGTH);
3817 if (cmd == SSL_CTRL_SET_TLSEXT_TICKET_KEYS) {
3818 memcpy(ctx->tlsext_tick_key_name, keys, 16);
3819 memcpy(ctx->tlsext_tick_hmac_key, keys + 16, 16);
3820 memcpy(ctx->tlsext_tick_aes_key, keys + 32, 16);
3822 memcpy(keys, ctx->tlsext_tick_key_name, 16);
3823 memcpy(keys + 16, ctx->tlsext_tick_hmac_key, 16);
3824 memcpy(keys + 32, ctx->tlsext_tick_aes_key, 16);
3829 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG:
3830 ctx->tlsext_status_arg = parg;
3833 # ifndef OPENSSL_NO_SRP
3834 case SSL_CTRL_SET_TLS_EXT_SRP_USERNAME:
3835 ctx->srp_ctx.srp_Mask |= SSL_kSRP;
3836 if (ctx->srp_ctx.login != NULL)
3837 OPENSSL_free(ctx->srp_ctx.login);
3838 ctx->srp_ctx.login = NULL;
3841 if (strlen((const char *)parg) > 255
3842 || strlen((const char *)parg) < 1) {
3843 SSLerr(SSL_F_SSL3_CTX_CTRL, SSL_R_INVALID_SRP_USERNAME);
3846 if ((ctx->srp_ctx.login = BUF_strdup((char *)parg)) == NULL) {
3847 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_INTERNAL_ERROR);
3851 case SSL_CTRL_SET_TLS_EXT_SRP_PASSWORD:
3852 ctx->srp_ctx.SRP_give_srp_client_pwd_callback =
3853 srp_password_from_info_cb;
3854 ctx->srp_ctx.info = parg;
3856 case SSL_CTRL_SET_SRP_ARG:
3857 ctx->srp_ctx.srp_Mask |= SSL_kSRP;
3858 ctx->srp_ctx.SRP_cb_arg = parg;
3861 case SSL_CTRL_SET_TLS_EXT_SRP_STRENGTH:
3862 ctx->srp_ctx.strength = larg;
3866 # ifndef OPENSSL_NO_EC
3867 case SSL_CTRL_SET_CURVES:
3868 return tls1_set_curves(&ctx->tlsext_ellipticcurvelist,
3869 &ctx->tlsext_ellipticcurvelist_length,
3872 case SSL_CTRL_SET_CURVES_LIST:
3873 return tls1_set_curves_list(&ctx->tlsext_ellipticcurvelist,
3874 &ctx->tlsext_ellipticcurvelist_length,
3876 # ifndef OPENSSL_NO_EC
3877 case SSL_CTRL_SET_ECDH_AUTO:
3878 ctx->cert->ecdh_tmp_auto = larg;
3882 case SSL_CTRL_SET_SIGALGS:
3883 return tls1_set_sigalgs(ctx->cert, parg, larg, 0);
3885 case SSL_CTRL_SET_SIGALGS_LIST:
3886 return tls1_set_sigalgs_list(ctx->cert, parg, 0);
3888 case SSL_CTRL_SET_CLIENT_SIGALGS:
3889 return tls1_set_sigalgs(ctx->cert, parg, larg, 1);
3891 case SSL_CTRL_SET_CLIENT_SIGALGS_LIST:
3892 return tls1_set_sigalgs_list(ctx->cert, parg, 1);
3894 case SSL_CTRL_SET_CLIENT_CERT_TYPES:
3895 return ssl3_set_req_cert_type(ctx->cert, parg, larg);
3897 case SSL_CTRL_BUILD_CERT_CHAIN:
3898 return ssl_build_cert_chain(NULL, ctx, larg);
3900 case SSL_CTRL_SET_VERIFY_CERT_STORE:
3901 return ssl_cert_set_cert_store(ctx->cert, parg, 0, larg);
3903 case SSL_CTRL_SET_CHAIN_CERT_STORE:
3904 return ssl_cert_set_cert_store(ctx->cert, parg, 1, larg);
3906 #endif /* !OPENSSL_NO_TLSEXT */
3908 /* A Thawte special :-) */
3909 case SSL_CTRL_EXTRA_CHAIN_CERT:
3910 if (ctx->extra_certs == NULL) {
3911 if ((ctx->extra_certs = sk_X509_new_null()) == NULL)
3914 sk_X509_push(ctx->extra_certs, (X509 *)parg);
3917 case SSL_CTRL_GET_EXTRA_CHAIN_CERTS:
3918 if (ctx->extra_certs == NULL && larg == 0)
3919 *(STACK_OF(X509) **)parg = ctx->cert->key->chain;
3921 *(STACK_OF(X509) **)parg = ctx->extra_certs;
3924 case SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS:
3925 sk_X509_pop_free(ctx->extra_certs, X509_free);
3926 ctx->extra_certs = NULL;
3929 case SSL_CTRL_CHAIN:
3931 return ssl_cert_set1_chain(NULL, ctx, (STACK_OF(X509) *)parg);
3933 return ssl_cert_set0_chain(NULL, ctx, (STACK_OF(X509) *)parg);
3935 case SSL_CTRL_CHAIN_CERT:
3937 return ssl_cert_add1_chain_cert(NULL, ctx, (X509 *)parg);
3939 return ssl_cert_add0_chain_cert(NULL, ctx, (X509 *)parg);
3941 case SSL_CTRL_GET_CHAIN_CERTS:
3942 *(STACK_OF(X509) **)parg = ctx->cert->key->chain;
3945 case SSL_CTRL_SELECT_CURRENT_CERT:
3946 return ssl_cert_select_current(ctx->cert, (X509 *)parg);
3948 case SSL_CTRL_SET_CURRENT_CERT:
3949 return ssl_cert_set_current(ctx->cert, larg);
3957 long ssl3_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp) (void))
3964 #ifndef OPENSSL_NO_RSA
3965 case SSL_CTRL_SET_TMP_RSA_CB:
3967 cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
3971 #ifndef OPENSSL_NO_DH
3972 case SSL_CTRL_SET_TMP_DH_CB:
3974 cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
3978 #ifndef OPENSSL_NO_EC
3979 case SSL_CTRL_SET_TMP_ECDH_CB:
3981 cert->ecdh_tmp_cb = (EC_KEY *(*)(SSL *, int, int))fp;
3985 #ifndef OPENSSL_NO_TLSEXT
3986 case SSL_CTRL_SET_TLSEXT_SERVERNAME_CB:
3987 ctx->tlsext_servername_callback = (int (*)(SSL *, int *, void *))fp;
3990 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB:
3991 ctx->tlsext_status_cb = (int (*)(SSL *, void *))fp;
3994 case SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB:
3995 ctx->tlsext_ticket_key_cb = (int (*)(SSL *, unsigned char *,
3998 HMAC_CTX *, int))fp;
4001 # ifndef OPENSSL_NO_SRP
4002 case SSL_CTRL_SET_SRP_VERIFY_PARAM_CB:
4003 ctx->srp_ctx.srp_Mask |= SSL_kSRP;
4004 ctx->srp_ctx.SRP_verify_param_callback = (int (*)(SSL *, void *))fp;
4006 case SSL_CTRL_SET_TLS_EXT_SRP_USERNAME_CB:
4007 ctx->srp_ctx.srp_Mask |= SSL_kSRP;
4008 ctx->srp_ctx.TLS_ext_srp_username_callback =
4009 (int (*)(SSL *, int *, void *))fp;
4011 case SSL_CTRL_SET_SRP_GIVE_CLIENT_PWD_CB:
4012 ctx->srp_ctx.srp_Mask |= SSL_kSRP;
4013 ctx->srp_ctx.SRP_give_srp_client_pwd_callback =
4014 (char *(*)(SSL *, void *))fp;
4018 case SSL_CTRL_SET_NOT_RESUMABLE_SESS_CB:
4020 ctx->not_resumable_session_cb = (int (*)(SSL *, int))fp;
4030 * This function needs to check if the ciphers required are actually
4033 const SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p)
4036 const SSL_CIPHER *cp;
4039 id = 0x03000000L | ((unsigned long)p[0] << 8L) | (unsigned long)p[1];
4041 cp = OBJ_bsearch_ssl_cipher_id(&c, ssl3_ciphers, SSL3_NUM_CIPHERS);
4042 #ifdef DEBUG_PRINT_UNKNOWN_CIPHERSUITES
4044 fprintf(stderr, "Unknown cipher ID %x\n", (p[0] << 8) | p[1]);
4049 int ssl3_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p)
4055 if ((l & 0xff000000) != 0x03000000)
4057 p[0] = ((unsigned char)(l >> 8L)) & 0xFF;
4058 p[1] = ((unsigned char)(l)) & 0xFF;
4063 SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt,
4064 STACK_OF(SSL_CIPHER) *srvr)
4066 SSL_CIPHER *c, *ret = NULL;
4067 STACK_OF(SSL_CIPHER) *prio, *allow;
4070 unsigned long alg_k, alg_a, mask_k, mask_a, emask_k, emask_a;
4072 /* Let's see which ciphers we can support */
4077 * Do not set the compare functions, because this may lead to a
4078 * reordering by "id". We want to keep the original ordering. We may pay
4079 * a price in performance during sk_SSL_CIPHER_find(), but would have to
4080 * pay with the price of sk_SSL_CIPHER_dup().
4082 sk_SSL_CIPHER_set_cmp_func(srvr, ssl_cipher_ptr_id_cmp);
4083 sk_SSL_CIPHER_set_cmp_func(clnt, ssl_cipher_ptr_id_cmp);
4087 fprintf(stderr, "Server has %d from %p:\n", sk_SSL_CIPHER_num(srvr),
4089 for (i = 0; i < sk_SSL_CIPHER_num(srvr); ++i) {
4090 c = sk_SSL_CIPHER_value(srvr, i);
4091 fprintf(stderr, "%p:%s\n", (void *)c, c->name);
4093 fprintf(stderr, "Client sent %d from %p:\n", sk_SSL_CIPHER_num(clnt),
4095 for (i = 0; i < sk_SSL_CIPHER_num(clnt); ++i) {
4096 c = sk_SSL_CIPHER_value(clnt, i);
4097 fprintf(stderr, "%p:%s\n", (void *)c, c->name);
4101 if (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE || tls1_suiteb(s)) {
4109 tls1_set_cert_validity(s);
4111 for (i = 0; i < sk_SSL_CIPHER_num(prio); i++) {
4112 c = sk_SSL_CIPHER_value(prio, i);
4114 /* Skip TLS v1.2 only ciphersuites if not supported */
4115 if ((c->algorithm_ssl & SSL_TLSV1_2) && !SSL_USE_TLS1_2_CIPHERS(s))
4118 ssl_set_cert_masks(cert, c);
4119 mask_k = cert->mask_k;
4120 mask_a = cert->mask_a;
4121 emask_k = cert->export_mask_k;
4122 emask_a = cert->export_mask_a;
4123 #ifndef OPENSSL_NO_SRP
4124 if (s->srp_ctx.srp_Mask & SSL_kSRP) {
4126 emask_k |= SSL_kSRP;
4128 emask_a |= SSL_aSRP;
4134 * fprintf(stderr,"ssl3_choose_cipher %d alg= %lx\n",
4137 #endif /* KSSL_DEBUG */
4139 alg_k = c->algorithm_mkey;
4140 alg_a = c->algorithm_auth;
4142 #ifndef OPENSSL_NO_KRB5
4143 if (alg_k & SSL_kKRB5) {
4144 if (!kssl_keytab_is_available(s->kssl_ctx))
4147 #endif /* OPENSSL_NO_KRB5 */
4148 #ifndef OPENSSL_NO_PSK
4149 /* with PSK there must be server callback set */
4150 if ((alg_k & SSL_kPSK) && s->psk_server_callback == NULL)
4152 #endif /* OPENSSL_NO_PSK */
4154 if (SSL_C_IS_EXPORT(c)) {
4155 ok = (alg_k & emask_k) && (alg_a & emask_a);
4157 fprintf(stderr, "%d:[%08lX:%08lX:%08lX:%08lX]%p:%s (export)\n",
4158 ok, alg_k, alg_a, emask_k, emask_a, (void *)c, c->name);
4161 ok = (alg_k & mask_k) && (alg_a & mask_a);
4163 fprintf(stderr, "%d:[%08lX:%08lX:%08lX:%08lX]%p:%s\n", ok, alg_k,
4164 alg_a, mask_k, mask_a, (void *)c, c->name);
4168 #ifndef OPENSSL_NO_TLSEXT
4169 # ifndef OPENSSL_NO_EC
4171 * if we are considering an ECC cipher suite that uses an ephemeral
4174 if (alg_k & SSL_kECDHE)
4175 ok = ok && tls1_check_ec_tmp_key(s, c->id);
4176 # endif /* OPENSSL_NO_EC */
4177 #endif /* OPENSSL_NO_TLSEXT */
4181 ii = sk_SSL_CIPHER_find(allow, c);
4183 /* Check security callback permits this cipher */
4184 if (!ssl_security(s, SSL_SECOP_CIPHER_SHARED,
4185 c->strength_bits, 0, c))
4187 #if !defined(OPENSSL_NO_EC) && !defined(OPENSSL_NO_TLSEXT)
4188 if ((alg_k & SSL_kECDHE) && (alg_a & SSL_aECDSA)
4189 && s->s3->is_probably_safari) {
4191 ret = sk_SSL_CIPHER_value(allow, ii);
4195 ret = sk_SSL_CIPHER_value(allow, ii);
4202 int ssl3_get_req_cert_type(SSL *s, unsigned char *p)
4206 unsigned long alg_k, alg_a = 0;
4208 /* If we have custom certificate types set, use them */
4209 if (s->cert->ctypes) {
4210 memcpy(p, s->cert->ctypes, s->cert->ctype_num);
4211 return (int)s->cert->ctype_num;
4213 /* Get mask of algorithms disabled by signature list */
4214 ssl_set_sig_mask(&alg_a, s, SSL_SECOP_SIGALG_MASK);
4215 if (s->cert->cert_flags & SSL_CERT_FLAGS_CHECK_TLS_STRICT)
4218 alg_k = s->s3->tmp.new_cipher->algorithm_mkey;
4220 #ifndef OPENSSL_NO_GOST
4221 if (s->version >= TLS1_VERSION) {
4222 if (alg_k & SSL_kGOST) {
4223 p[ret++] = TLS_CT_GOST94_SIGN;
4224 p[ret++] = TLS_CT_GOST01_SIGN;
4230 #ifndef OPENSSL_NO_DH
4231 if (alg_k & (SSL_kDHr | SSL_kDHE)) {
4232 # ifndef OPENSSL_NO_RSA
4234 * Since this refers to a certificate signed with an RSA algorithm,
4235 * only check for rsa signing in strict mode.
4237 if (nostrict || !(alg_a & SSL_aRSA))
4238 p[ret++] = SSL3_CT_RSA_FIXED_DH;
4240 # ifndef OPENSSL_NO_DSA
4241 if (nostrict || !(alg_a & SSL_aDSS))
4242 p[ret++] = SSL3_CT_DSS_FIXED_DH;
4245 if ((s->version == SSL3_VERSION) &&
4246 (alg_k & (SSL_kDHE | SSL_kDHd | SSL_kDHr))) {
4247 # ifndef OPENSSL_NO_RSA
4248 p[ret++] = SSL3_CT_RSA_EPHEMERAL_DH;
4250 # ifndef OPENSSL_NO_DSA
4251 p[ret++] = SSL3_CT_DSS_EPHEMERAL_DH;
4254 #endif /* !OPENSSL_NO_DH */
4255 #ifndef OPENSSL_NO_RSA
4256 if (!(alg_a & SSL_aRSA))
4257 p[ret++] = SSL3_CT_RSA_SIGN;
4259 #ifndef OPENSSL_NO_DSA
4260 if (!(alg_a & SSL_aDSS))
4261 p[ret++] = SSL3_CT_DSS_SIGN;
4263 #ifndef OPENSSL_NO_EC
4264 if ((alg_k & (SSL_kECDHr | SSL_kECDHe)) && (s->version >= TLS1_VERSION)) {
4265 if (nostrict || !(alg_a & SSL_aRSA))
4266 p[ret++] = TLS_CT_RSA_FIXED_ECDH;
4267 if (nostrict || !(alg_a & SSL_aECDSA))
4268 p[ret++] = TLS_CT_ECDSA_FIXED_ECDH;
4271 * ECDSA certs can be used with RSA cipher suites as well so we don't
4272 * need to check for SSL_kECDH or SSL_kECDHE
4274 if (s->version >= TLS1_VERSION) {
4275 if (!(alg_a & SSL_aECDSA))
4276 p[ret++] = TLS_CT_ECDSA_SIGN;
4282 static int ssl3_set_req_cert_type(CERT *c, const unsigned char *p, size_t len)
4285 OPENSSL_free(c->ctypes);
4292 c->ctypes = OPENSSL_malloc(len);
4295 memcpy(c->ctypes, p, len);
4300 int ssl3_shutdown(SSL *s)
4305 * Don't do anything much if we have not done the handshake or we don't
4306 * want to send messages :-)
4308 if ((s->quiet_shutdown) || (s->state == SSL_ST_BEFORE)) {
4309 s->shutdown = (SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN);
4313 if (!(s->shutdown & SSL_SENT_SHUTDOWN)) {
4314 s->shutdown |= SSL_SENT_SHUTDOWN;
4315 ssl3_send_alert(s, SSL3_AL_WARNING, SSL_AD_CLOSE_NOTIFY);
4317 * our shutdown alert has been sent now, and if it still needs to be
4318 * written, s->s3->alert_dispatch will be true
4320 if (s->s3->alert_dispatch)
4321 return (-1); /* return WANT_WRITE */
4322 } else if (s->s3->alert_dispatch) {
4323 /* resend it if not sent */
4324 ret = s->method->ssl_dispatch_alert(s);
4327 * we only get to return -1 here the 2nd/Nth invocation, we must
4328 * have already signalled return 0 upon a previous invoation,
4333 } else if (!(s->shutdown & SSL_RECEIVED_SHUTDOWN)) {
4335 * If we are waiting for a close from our peer, we are closed
4337 s->method->ssl_read_bytes(s, 0, NULL, 0, 0);
4338 if (!(s->shutdown & SSL_RECEIVED_SHUTDOWN)) {
4339 return (-1); /* return WANT_READ */
4343 if ((s->shutdown == (SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN)) &&
4344 !s->s3->alert_dispatch)
4350 int ssl3_write(SSL *s, const void *buf, int len)
4355 if (s->shutdown & SSL_SEND_SHUTDOWN) {
4356 s->rwstate = SSL_NOTHING;
4361 if (s->s3->renegotiate)
4362 ssl3_renegotiate_check(s);
4365 * This is an experimental flag that sends the last handshake message in
4366 * the same packet as the first use data - used to see if it helps the
4367 * TCP protocol during session-id reuse
4369 /* The second test is because the buffer may have been removed */
4370 if ((s->s3->flags & SSL3_FLAGS_POP_BUFFER) && (s->wbio == s->bbio)) {
4371 /* First time through, we write into the buffer */
4372 if (s->s3->delay_buf_pop_ret == 0) {
4373 ret = ssl3_write_bytes(s, SSL3_RT_APPLICATION_DATA, buf, len);
4377 s->s3->delay_buf_pop_ret = ret;
4380 s->rwstate = SSL_WRITING;
4381 n = BIO_flush(s->wbio);
4384 s->rwstate = SSL_NOTHING;
4386 /* We have flushed the buffer, so remove it */
4387 ssl_free_wbio_buffer(s);
4388 s->s3->flags &= ~SSL3_FLAGS_POP_BUFFER;
4390 ret = s->s3->delay_buf_pop_ret;
4391 s->s3->delay_buf_pop_ret = 0;
4393 ret = s->method->ssl_write_bytes(s, SSL3_RT_APPLICATION_DATA,
4402 static int ssl3_read_internal(SSL *s, void *buf, int len, int peek)
4407 if (s->s3->renegotiate)
4408 ssl3_renegotiate_check(s);
4409 s->s3->in_read_app_data = 1;
4411 s->method->ssl_read_bytes(s, SSL3_RT_APPLICATION_DATA, buf, len,
4413 if ((ret == -1) && (s->s3->in_read_app_data == 2)) {
4415 * ssl3_read_bytes decided to call s->handshake_func, which called
4416 * ssl3_read_bytes to read handshake data. However, ssl3_read_bytes
4417 * actually found application data and thinks that application data
4418 * makes sense here; so disable handshake processing and try to read
4419 * application data again.
4423 s->method->ssl_read_bytes(s, SSL3_RT_APPLICATION_DATA, buf, len,
4427 s->s3->in_read_app_data = 0;
4432 int ssl3_read(SSL *s, void *buf, int len)
4434 return ssl3_read_internal(s, buf, len, 0);
4437 int ssl3_peek(SSL *s, void *buf, int len)
4439 return ssl3_read_internal(s, buf, len, 1);
4442 int ssl3_renegotiate(SSL *s)
4444 if (s->handshake_func == NULL)
4447 if (s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS)
4450 s->s3->renegotiate = 1;
4454 int ssl3_renegotiate_check(SSL *s)
4458 if (s->s3->renegotiate) {
4459 if (!RECORD_LAYER_read_pending(&s->rlayer)
4460 && !RECORD_LAYER_write_pending(&s->rlayer)
4461 && !SSL_in_init(s)) {
4463 * if we are the server, and we have sent a 'RENEGOTIATE'
4464 * message, we need to go to SSL_ST_ACCEPT.
4467 s->state = SSL_ST_RENEGOTIATE;
4468 s->s3->renegotiate = 0;
4469 s->s3->num_renegotiations++;
4470 s->s3->total_renegotiations++;
4478 * If we are using default SHA1+MD5 algorithms switch to new SHA256 PRF and
4479 * handshake macs if required.
4481 long ssl_get_algorithm2(SSL *s)
4483 long alg2 = s->s3->tmp.new_cipher->algorithm2;
4484 if (s->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_SHA256_PRF
4485 && alg2 == (SSL_HANDSHAKE_MAC_DEFAULT | TLS1_PRF))
4486 return SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256;