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 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,
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,
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,
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_EDH_DSS_DES_40_CBC_SHA,
432 SSL3_CK_EDH_DSS_DES_40_CBC_SHA,
438 SSL_EXPORT|SSL_EXP40,
439 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
447 SSL3_TXT_EDH_DSS_DES_64_CBC_SHA,
448 SSL3_CK_EDH_DSS_DES_64_CBC_SHA,
455 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
463 SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA,
464 SSL3_CK_EDH_DSS_DES_192_CBC3_SHA,
470 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
471 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
479 SSL3_TXT_EDH_RSA_DES_40_CBC_SHA,
480 SSL3_CK_EDH_RSA_DES_40_CBC_SHA,
486 SSL_EXPORT|SSL_EXP40,
487 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
495 SSL3_TXT_EDH_RSA_DES_64_CBC_SHA,
496 SSL3_CK_EDH_RSA_DES_64_CBC_SHA,
503 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
511 SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA,
512 SSL3_CK_EDH_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,
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 /* Fortezza ciphersuite from SSL 3.0 spec */
609 SSL3_TXT_FZA_DMS_NULL_SHA,
610 SSL3_CK_FZA_DMS_NULL_SHA,
616 SSL_NOT_EXP|SSL_STRONG_NONE,
617 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
625 SSL3_TXT_FZA_DMS_FZA_SHA,
626 SSL3_CK_FZA_DMS_FZA_SHA,
632 SSL_NOT_EXP|SSL_STRONG_NONE,
633 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
641 SSL3_TXT_FZA_DMS_RC4_SHA,
642 SSL3_CK_FZA_DMS_RC4_SHA,
648 SSL_NOT_EXP|SSL_MEDIUM,
649 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
655 #ifndef OPENSSL_NO_KRB5
656 /* The Kerberos ciphers*/
660 SSL3_TXT_KRB5_DES_64_CBC_SHA,
661 SSL3_CK_KRB5_DES_64_CBC_SHA,
668 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
676 SSL3_TXT_KRB5_DES_192_CBC3_SHA,
677 SSL3_CK_KRB5_DES_192_CBC3_SHA,
683 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
684 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
692 SSL3_TXT_KRB5_RC4_128_SHA,
693 SSL3_CK_KRB5_RC4_128_SHA,
699 SSL_NOT_EXP|SSL_MEDIUM,
700 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
708 SSL3_TXT_KRB5_IDEA_128_CBC_SHA,
709 SSL3_CK_KRB5_IDEA_128_CBC_SHA,
715 SSL_NOT_EXP|SSL_MEDIUM,
716 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
724 SSL3_TXT_KRB5_DES_64_CBC_MD5,
725 SSL3_CK_KRB5_DES_64_CBC_MD5,
732 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
740 SSL3_TXT_KRB5_DES_192_CBC3_MD5,
741 SSL3_CK_KRB5_DES_192_CBC3_MD5,
747 SSL_NOT_EXP|SSL_HIGH,
748 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
756 SSL3_TXT_KRB5_RC4_128_MD5,
757 SSL3_CK_KRB5_RC4_128_MD5,
763 SSL_NOT_EXP|SSL_MEDIUM,
764 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
772 SSL3_TXT_KRB5_IDEA_128_CBC_MD5,
773 SSL3_CK_KRB5_IDEA_128_CBC_MD5,
779 SSL_NOT_EXP|SSL_MEDIUM,
780 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
788 SSL3_TXT_KRB5_DES_40_CBC_SHA,
789 SSL3_CK_KRB5_DES_40_CBC_SHA,
795 SSL_EXPORT|SSL_EXP40,
796 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
804 SSL3_TXT_KRB5_RC2_40_CBC_SHA,
805 SSL3_CK_KRB5_RC2_40_CBC_SHA,
811 SSL_EXPORT|SSL_EXP40,
812 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
820 SSL3_TXT_KRB5_RC4_40_SHA,
821 SSL3_CK_KRB5_RC4_40_SHA,
827 SSL_EXPORT|SSL_EXP40,
828 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
836 SSL3_TXT_KRB5_DES_40_CBC_MD5,
837 SSL3_CK_KRB5_DES_40_CBC_MD5,
843 SSL_EXPORT|SSL_EXP40,
844 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
852 SSL3_TXT_KRB5_RC2_40_CBC_MD5,
853 SSL3_CK_KRB5_RC2_40_CBC_MD5,
859 SSL_EXPORT|SSL_EXP40,
860 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
868 SSL3_TXT_KRB5_RC4_40_MD5,
869 SSL3_CK_KRB5_RC4_40_MD5,
875 SSL_EXPORT|SSL_EXP40,
876 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
880 #endif /* OPENSSL_NO_KRB5 */
882 /* New AES ciphersuites */
886 TLS1_TXT_RSA_WITH_AES_128_SHA,
887 TLS1_CK_RSA_WITH_AES_128_SHA,
893 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
894 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
901 TLS1_TXT_DH_DSS_WITH_AES_128_SHA,
902 TLS1_CK_DH_DSS_WITH_AES_128_SHA,
908 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
909 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
916 TLS1_TXT_DH_RSA_WITH_AES_128_SHA,
917 TLS1_CK_DH_RSA_WITH_AES_128_SHA,
923 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
924 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
931 TLS1_TXT_DHE_DSS_WITH_AES_128_SHA,
932 TLS1_CK_DHE_DSS_WITH_AES_128_SHA,
938 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
939 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
946 TLS1_TXT_DHE_RSA_WITH_AES_128_SHA,
947 TLS1_CK_DHE_RSA_WITH_AES_128_SHA,
953 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
954 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
961 TLS1_TXT_ADH_WITH_AES_128_SHA,
962 TLS1_CK_ADH_WITH_AES_128_SHA,
968 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
969 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
977 TLS1_TXT_RSA_WITH_AES_256_SHA,
978 TLS1_CK_RSA_WITH_AES_256_SHA,
984 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
985 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
992 TLS1_TXT_DH_DSS_WITH_AES_256_SHA,
993 TLS1_CK_DH_DSS_WITH_AES_256_SHA,
999 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1000 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1008 TLS1_TXT_DH_RSA_WITH_AES_256_SHA,
1009 TLS1_CK_DH_RSA_WITH_AES_256_SHA,
1015 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1016 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1024 TLS1_TXT_DHE_DSS_WITH_AES_256_SHA,
1025 TLS1_CK_DHE_DSS_WITH_AES_256_SHA,
1031 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1032 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1040 TLS1_TXT_DHE_RSA_WITH_AES_256_SHA,
1041 TLS1_CK_DHE_RSA_WITH_AES_256_SHA,
1047 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1048 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1056 TLS1_TXT_ADH_WITH_AES_256_SHA,
1057 TLS1_CK_ADH_WITH_AES_256_SHA,
1063 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1064 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1069 /* TLS v1.2 ciphersuites */
1073 TLS1_TXT_RSA_WITH_NULL_SHA256,
1074 TLS1_CK_RSA_WITH_NULL_SHA256,
1080 SSL_NOT_EXP|SSL_STRONG_NONE|SSL_FIPS,
1081 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1089 TLS1_TXT_RSA_WITH_AES_128_SHA256,
1090 TLS1_CK_RSA_WITH_AES_128_SHA256,
1096 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1097 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1105 TLS1_TXT_RSA_WITH_AES_256_SHA256,
1106 TLS1_CK_RSA_WITH_AES_256_SHA256,
1112 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1113 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1121 TLS1_TXT_DH_DSS_WITH_AES_128_SHA256,
1122 TLS1_CK_DH_DSS_WITH_AES_128_SHA256,
1128 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1129 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1137 TLS1_TXT_DH_RSA_WITH_AES_128_SHA256,
1138 TLS1_CK_DH_RSA_WITH_AES_128_SHA256,
1144 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1145 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1153 TLS1_TXT_DHE_DSS_WITH_AES_128_SHA256,
1154 TLS1_CK_DHE_DSS_WITH_AES_128_SHA256,
1160 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1161 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1166 #ifndef OPENSSL_NO_CAMELLIA
1167 /* Camellia ciphersuites from RFC4132 (128-bit portion) */
1172 TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA,
1173 TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA,
1179 SSL_NOT_EXP|SSL_HIGH,
1180 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1188 TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA,
1189 TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA,
1195 SSL_NOT_EXP|SSL_HIGH,
1196 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1204 TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA,
1205 TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA,
1211 SSL_NOT_EXP|SSL_HIGH,
1212 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1220 TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA,
1221 TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA,
1227 SSL_NOT_EXP|SSL_HIGH,
1228 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1236 TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA,
1237 TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA,
1243 SSL_NOT_EXP|SSL_HIGH,
1244 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1252 TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA,
1253 TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA,
1259 SSL_NOT_EXP|SSL_HIGH,
1260 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1264 #endif /* OPENSSL_NO_CAMELLIA */
1266 #if TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES
1267 /* New TLS Export CipherSuites from expired ID */
1272 TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5,
1273 TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5,
1279 SSL_EXPORT|SSL_EXP56,
1280 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1288 TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5,
1289 TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5,
1295 SSL_EXPORT|SSL_EXP56,
1296 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1305 TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA,
1306 TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA,
1312 SSL_EXPORT|SSL_EXP56,
1313 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1321 TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA,
1322 TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA,
1328 SSL_EXPORT|SSL_EXP56,
1329 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1337 TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA,
1338 TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA,
1344 SSL_EXPORT|SSL_EXP56,
1345 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1353 TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA,
1354 TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA,
1360 SSL_EXPORT|SSL_EXP56,
1361 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1369 TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA,
1370 TLS1_CK_DHE_DSS_WITH_RC4_128_SHA,
1376 SSL_NOT_EXP|SSL_MEDIUM,
1377 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1383 /* TLS v1.2 ciphersuites */
1387 TLS1_TXT_DHE_RSA_WITH_AES_128_SHA256,
1388 TLS1_CK_DHE_RSA_WITH_AES_128_SHA256,
1394 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1395 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1403 TLS1_TXT_DH_DSS_WITH_AES_256_SHA256,
1404 TLS1_CK_DH_DSS_WITH_AES_256_SHA256,
1410 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1411 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1419 TLS1_TXT_DH_RSA_WITH_AES_256_SHA256,
1420 TLS1_CK_DH_RSA_WITH_AES_256_SHA256,
1426 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1427 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1435 TLS1_TXT_DHE_DSS_WITH_AES_256_SHA256,
1436 TLS1_CK_DHE_DSS_WITH_AES_256_SHA256,
1442 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1443 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1451 TLS1_TXT_DHE_RSA_WITH_AES_256_SHA256,
1452 TLS1_CK_DHE_RSA_WITH_AES_256_SHA256,
1458 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1459 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1467 TLS1_TXT_ADH_WITH_AES_128_SHA256,
1468 TLS1_CK_ADH_WITH_AES_128_SHA256,
1474 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1475 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1483 TLS1_TXT_ADH_WITH_AES_256_SHA256,
1484 TLS1_CK_ADH_WITH_AES_256_SHA256,
1490 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1491 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1496 /* GOST Ciphersuites */
1500 "GOST94-GOST89-GOST89",
1504 SSL_eGOST2814789CNT,
1507 SSL_NOT_EXP|SSL_HIGH,
1508 SSL_HANDSHAKE_MAC_GOST94|TLS1_PRF_GOST94|TLS1_STREAM_MAC,
1514 "GOST2001-GOST89-GOST89",
1518 SSL_eGOST2814789CNT,
1521 SSL_NOT_EXP|SSL_HIGH,
1522 SSL_HANDSHAKE_MAC_GOST94|TLS1_PRF_GOST94|TLS1_STREAM_MAC,
1528 "GOST94-NULL-GOST94",
1535 SSL_NOT_EXP|SSL_STRONG_NONE,
1536 SSL_HANDSHAKE_MAC_GOST94|TLS1_PRF_GOST94,
1542 "GOST2001-NULL-GOST94",
1549 SSL_NOT_EXP|SSL_STRONG_NONE,
1550 SSL_HANDSHAKE_MAC_GOST94|TLS1_PRF_GOST94,
1555 #ifndef OPENSSL_NO_CAMELLIA
1556 /* Camellia ciphersuites from RFC4132 (256-bit portion) */
1561 TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA,
1562 TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA,
1568 SSL_NOT_EXP|SSL_HIGH,
1569 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1576 TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA,
1577 TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA,
1583 SSL_NOT_EXP|SSL_HIGH,
1584 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1592 TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA,
1593 TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA,
1599 SSL_NOT_EXP|SSL_HIGH,
1600 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1608 TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA,
1609 TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA,
1615 SSL_NOT_EXP|SSL_HIGH,
1616 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1624 TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA,
1625 TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA,
1631 SSL_NOT_EXP|SSL_HIGH,
1632 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1640 TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA,
1641 TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA,
1647 SSL_NOT_EXP|SSL_HIGH,
1648 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1652 #endif /* OPENSSL_NO_CAMELLIA */
1654 #ifndef OPENSSL_NO_PSK
1658 TLS1_TXT_PSK_WITH_RC4_128_SHA,
1659 TLS1_CK_PSK_WITH_RC4_128_SHA,
1665 SSL_NOT_EXP|SSL_MEDIUM,
1666 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1674 TLS1_TXT_PSK_WITH_3DES_EDE_CBC_SHA,
1675 TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA,
1681 SSL_NOT_EXP|SSL_HIGH,
1682 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1690 TLS1_TXT_PSK_WITH_AES_128_CBC_SHA,
1691 TLS1_CK_PSK_WITH_AES_128_CBC_SHA,
1697 SSL_NOT_EXP|SSL_HIGH,
1698 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1706 TLS1_TXT_PSK_WITH_AES_256_CBC_SHA,
1707 TLS1_CK_PSK_WITH_AES_256_CBC_SHA,
1713 SSL_NOT_EXP|SSL_HIGH,
1714 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1718 #endif /* OPENSSL_NO_PSK */
1720 #ifndef OPENSSL_NO_SEED
1721 /* SEED ciphersuites from RFC4162 */
1726 TLS1_TXT_RSA_WITH_SEED_SHA,
1727 TLS1_CK_RSA_WITH_SEED_SHA,
1733 SSL_NOT_EXP|SSL_MEDIUM,
1734 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1742 TLS1_TXT_DH_DSS_WITH_SEED_SHA,
1743 TLS1_CK_DH_DSS_WITH_SEED_SHA,
1749 SSL_NOT_EXP|SSL_MEDIUM,
1750 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1758 TLS1_TXT_DH_RSA_WITH_SEED_SHA,
1759 TLS1_CK_DH_RSA_WITH_SEED_SHA,
1765 SSL_NOT_EXP|SSL_MEDIUM,
1766 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1774 TLS1_TXT_DHE_DSS_WITH_SEED_SHA,
1775 TLS1_CK_DHE_DSS_WITH_SEED_SHA,
1781 SSL_NOT_EXP|SSL_MEDIUM,
1782 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1790 TLS1_TXT_DHE_RSA_WITH_SEED_SHA,
1791 TLS1_CK_DHE_RSA_WITH_SEED_SHA,
1797 SSL_NOT_EXP|SSL_MEDIUM,
1798 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1806 TLS1_TXT_ADH_WITH_SEED_SHA,
1807 TLS1_CK_ADH_WITH_SEED_SHA,
1813 SSL_NOT_EXP|SSL_MEDIUM,
1814 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
1819 #endif /* OPENSSL_NO_SEED */
1821 /* GCM ciphersuites from RFC5288 */
1826 TLS1_TXT_RSA_WITH_AES_128_GCM_SHA256,
1827 TLS1_CK_RSA_WITH_AES_128_GCM_SHA256,
1833 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1834 SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
1842 TLS1_TXT_RSA_WITH_AES_256_GCM_SHA384,
1843 TLS1_CK_RSA_WITH_AES_256_GCM_SHA384,
1849 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1850 SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
1858 TLS1_TXT_DHE_RSA_WITH_AES_128_GCM_SHA256,
1859 TLS1_CK_DHE_RSA_WITH_AES_128_GCM_SHA256,
1865 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1866 SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
1874 TLS1_TXT_DHE_RSA_WITH_AES_256_GCM_SHA384,
1875 TLS1_CK_DHE_RSA_WITH_AES_256_GCM_SHA384,
1881 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1882 SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
1890 TLS1_TXT_DH_RSA_WITH_AES_128_GCM_SHA256,
1891 TLS1_CK_DH_RSA_WITH_AES_128_GCM_SHA256,
1897 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1898 SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
1906 TLS1_TXT_DH_RSA_WITH_AES_256_GCM_SHA384,
1907 TLS1_CK_DH_RSA_WITH_AES_256_GCM_SHA384,
1913 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1914 SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
1922 TLS1_TXT_DHE_DSS_WITH_AES_128_GCM_SHA256,
1923 TLS1_CK_DHE_DSS_WITH_AES_128_GCM_SHA256,
1929 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1930 SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
1938 TLS1_TXT_DHE_DSS_WITH_AES_256_GCM_SHA384,
1939 TLS1_CK_DHE_DSS_WITH_AES_256_GCM_SHA384,
1945 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1946 SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
1954 TLS1_TXT_DH_DSS_WITH_AES_128_GCM_SHA256,
1955 TLS1_CK_DH_DSS_WITH_AES_128_GCM_SHA256,
1961 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1962 SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
1970 TLS1_TXT_DH_DSS_WITH_AES_256_GCM_SHA384,
1971 TLS1_CK_DH_DSS_WITH_AES_256_GCM_SHA384,
1977 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1978 SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
1986 TLS1_TXT_ADH_WITH_AES_128_GCM_SHA256,
1987 TLS1_CK_ADH_WITH_AES_128_GCM_SHA256,
1993 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
1994 SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
2002 TLS1_TXT_ADH_WITH_AES_256_GCM_SHA384,
2003 TLS1_CK_ADH_WITH_AES_256_GCM_SHA384,
2009 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2010 SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
2014 #ifdef OPENSSL_SSL_DEBUG_BROKEN_PROTOCOL
2031 #ifndef OPENSSL_NO_ECDH
2035 TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA,
2036 TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA,
2042 SSL_NOT_EXP|SSL_STRONG_NONE|SSL_FIPS,
2043 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2051 TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA,
2052 TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA,
2058 SSL_NOT_EXP|SSL_MEDIUM,
2059 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2067 TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA,
2068 TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA,
2074 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2075 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2083 TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA,
2084 TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA,
2090 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2091 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2099 TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA,
2100 TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA,
2106 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2107 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2115 TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA,
2116 TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA,
2122 SSL_NOT_EXP|SSL_STRONG_NONE|SSL_FIPS,
2123 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2131 TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA,
2132 TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA,
2138 SSL_NOT_EXP|SSL_MEDIUM,
2139 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2147 TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA,
2148 TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA,
2154 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2155 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2163 TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
2164 TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
2170 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2171 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2179 TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
2180 TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
2186 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2187 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2195 TLS1_TXT_ECDH_RSA_WITH_NULL_SHA,
2196 TLS1_CK_ECDH_RSA_WITH_NULL_SHA,
2202 SSL_NOT_EXP|SSL_STRONG_NONE|SSL_FIPS,
2203 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2211 TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA,
2212 TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA,
2218 SSL_NOT_EXP|SSL_MEDIUM,
2219 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2227 TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA,
2228 TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA,
2234 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2235 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2243 TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA,
2244 TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA,
2250 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2251 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2259 TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA,
2260 TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA,
2266 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2267 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2275 TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA,
2276 TLS1_CK_ECDHE_RSA_WITH_NULL_SHA,
2282 SSL_NOT_EXP|SSL_STRONG_NONE|SSL_FIPS,
2283 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2291 TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA,
2292 TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA,
2298 SSL_NOT_EXP|SSL_MEDIUM,
2299 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2307 TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA,
2308 TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA,
2314 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2315 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2323 TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA,
2324 TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA,
2330 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2331 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2339 TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA,
2340 TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA,
2346 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2347 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2355 TLS1_TXT_ECDH_anon_WITH_NULL_SHA,
2356 TLS1_CK_ECDH_anon_WITH_NULL_SHA,
2362 SSL_NOT_EXP|SSL_STRONG_NONE|SSL_FIPS,
2363 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2371 TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA,
2372 TLS1_CK_ECDH_anon_WITH_RC4_128_SHA,
2378 SSL_NOT_EXP|SSL_MEDIUM,
2379 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2387 TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA,
2388 TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA,
2394 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2395 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2403 TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA,
2404 TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA,
2410 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2411 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2419 TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA,
2420 TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA,
2426 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2427 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2431 #endif /* OPENSSL_NO_ECDH */
2433 #ifndef OPENSSL_NO_SRP
2437 TLS1_TXT_SRP_SHA_WITH_3DES_EDE_CBC_SHA,
2438 TLS1_CK_SRP_SHA_WITH_3DES_EDE_CBC_SHA,
2444 SSL_NOT_EXP|SSL_HIGH,
2445 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2453 TLS1_TXT_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA,
2454 TLS1_CK_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA,
2460 SSL_NOT_EXP|SSL_HIGH,
2461 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2469 TLS1_TXT_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA,
2470 TLS1_CK_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA,
2476 SSL_NOT_EXP|SSL_HIGH,
2477 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2485 TLS1_TXT_SRP_SHA_WITH_AES_128_CBC_SHA,
2486 TLS1_CK_SRP_SHA_WITH_AES_128_CBC_SHA,
2492 SSL_NOT_EXP|SSL_HIGH,
2493 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2501 TLS1_TXT_SRP_SHA_RSA_WITH_AES_128_CBC_SHA,
2502 TLS1_CK_SRP_SHA_RSA_WITH_AES_128_CBC_SHA,
2508 SSL_NOT_EXP|SSL_HIGH,
2509 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2517 TLS1_TXT_SRP_SHA_DSS_WITH_AES_128_CBC_SHA,
2518 TLS1_CK_SRP_SHA_DSS_WITH_AES_128_CBC_SHA,
2524 SSL_NOT_EXP|SSL_HIGH,
2525 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2533 TLS1_TXT_SRP_SHA_WITH_AES_256_CBC_SHA,
2534 TLS1_CK_SRP_SHA_WITH_AES_256_CBC_SHA,
2540 SSL_NOT_EXP|SSL_HIGH,
2541 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2549 TLS1_TXT_SRP_SHA_RSA_WITH_AES_256_CBC_SHA,
2550 TLS1_CK_SRP_SHA_RSA_WITH_AES_256_CBC_SHA,
2556 SSL_NOT_EXP|SSL_HIGH,
2557 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2565 TLS1_TXT_SRP_SHA_DSS_WITH_AES_256_CBC_SHA,
2566 TLS1_CK_SRP_SHA_DSS_WITH_AES_256_CBC_SHA,
2572 SSL_NOT_EXP|SSL_HIGH,
2573 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2577 #endif /* OPENSSL_NO_SRP */
2578 #ifndef OPENSSL_NO_ECDH
2580 /* HMAC based TLS v1.2 ciphersuites from RFC5289 */
2585 TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_SHA256,
2586 TLS1_CK_ECDHE_ECDSA_WITH_AES_128_SHA256,
2592 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2593 SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
2601 TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_SHA384,
2602 TLS1_CK_ECDHE_ECDSA_WITH_AES_256_SHA384,
2608 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2609 SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
2617 TLS1_TXT_ECDH_ECDSA_WITH_AES_128_SHA256,
2618 TLS1_CK_ECDH_ECDSA_WITH_AES_128_SHA256,
2624 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2625 SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
2633 TLS1_TXT_ECDH_ECDSA_WITH_AES_256_SHA384,
2634 TLS1_CK_ECDH_ECDSA_WITH_AES_256_SHA384,
2640 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2641 SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
2649 TLS1_TXT_ECDHE_RSA_WITH_AES_128_SHA256,
2650 TLS1_CK_ECDHE_RSA_WITH_AES_128_SHA256,
2656 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2657 SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
2665 TLS1_TXT_ECDHE_RSA_WITH_AES_256_SHA384,
2666 TLS1_CK_ECDHE_RSA_WITH_AES_256_SHA384,
2672 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2673 SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
2681 TLS1_TXT_ECDH_RSA_WITH_AES_128_SHA256,
2682 TLS1_CK_ECDH_RSA_WITH_AES_128_SHA256,
2688 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2689 SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
2697 TLS1_TXT_ECDH_RSA_WITH_AES_256_SHA384,
2698 TLS1_CK_ECDH_RSA_WITH_AES_256_SHA384,
2704 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2705 SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
2710 /* GCM based TLS v1.2 ciphersuites from RFC5289 */
2715 TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
2716 TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
2722 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2723 SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
2731 TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
2732 TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
2738 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2739 SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
2747 TLS1_TXT_ECDH_ECDSA_WITH_AES_128_GCM_SHA256,
2748 TLS1_CK_ECDH_ECDSA_WITH_AES_128_GCM_SHA256,
2754 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2755 SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
2763 TLS1_TXT_ECDH_ECDSA_WITH_AES_256_GCM_SHA384,
2764 TLS1_CK_ECDH_ECDSA_WITH_AES_256_GCM_SHA384,
2770 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2771 SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
2779 TLS1_TXT_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
2780 TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
2786 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2787 SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
2795 TLS1_TXT_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
2796 TLS1_CK_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
2802 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2803 SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
2811 TLS1_TXT_ECDH_RSA_WITH_AES_128_GCM_SHA256,
2812 TLS1_CK_ECDH_RSA_WITH_AES_128_GCM_SHA256,
2818 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2819 SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
2827 TLS1_TXT_ECDH_RSA_WITH_AES_256_GCM_SHA384,
2828 TLS1_CK_ECDH_RSA_WITH_AES_256_GCM_SHA384,
2834 SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
2835 SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
2840 #endif /* OPENSSL_NO_ECDH */
2843 #ifdef TEMP_GOST_TLS
2851 SSL_eGOST2814789CNT,
2854 SSL_NOT_EXP|SSL_HIGH,
2855 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2865 SSL_eGOST2814789CNT,
2868 SSL_NOT_EXP|SSL_HIGH,
2869 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2879 SSL_eGOST2814789CNT,
2882 SSL_NOT_EXP|SSL_HIGH,
2883 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF,
2889 "GOST-GOST89STREAM",
2893 SSL_eGOST2814789CNT,
2896 SSL_NOT_EXP|SSL_HIGH,
2897 SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF|TLS1_STREAM_MAC,
2906 SSL3_ENC_METHOD SSLv3_enc_data={
2909 ssl3_setup_key_block,
2910 ssl3_generate_master_secret,
2911 ssl3_change_cipher_state,
2912 ssl3_final_finish_mac,
2913 MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH,
2914 ssl3_cert_verify_mac,
2915 SSL3_MD_CLIENT_FINISHED_CONST,4,
2916 SSL3_MD_SERVER_FINISHED_CONST,4,
2918 (int (*)(SSL *, unsigned char *, size_t, const char *,
2919 size_t, const unsigned char *, size_t,
2920 int use_context))ssl_undefined_function,
2922 SSL3_HM_HEADER_LENGTH,
2923 ssl3_set_handshake_header,
2924 ssl3_handshake_write
2927 long ssl3_default_timeout(void)
2929 /* 2 hours, the 24 hours mentioned in the SSLv3 spec
2930 * is way too long for http, the cache would over fill */
2934 int ssl3_num_ciphers(void)
2936 return(SSL3_NUM_CIPHERS);
2939 const SSL_CIPHER *ssl3_get_cipher(unsigned int u)
2941 if (u < SSL3_NUM_CIPHERS)
2942 return(&(ssl3_ciphers[SSL3_NUM_CIPHERS-1-u]));
2947 int ssl3_pending(const SSL *s)
2949 if (s->rstate == SSL_ST_READ_BODY)
2952 return (s->s3->rrec.type == SSL3_RT_APPLICATION_DATA) ? s->s3->rrec.length : 0;
2955 void ssl3_set_handshake_header(SSL *s, int htype, unsigned long len)
2957 unsigned char *p = (unsigned char *)s->init_buf->data;
2960 s->init_num = (int)len + SSL3_HM_HEADER_LENGTH;
2964 int ssl3_handshake_write(SSL *s)
2966 return ssl3_do_write(s, SSL3_RT_HANDSHAKE);
2969 int ssl3_new(SSL *s)
2973 if ((s3=OPENSSL_malloc(sizeof *s3)) == NULL) goto err;
2974 memset(s3,0,sizeof *s3);
2975 memset(s3->rrec.seq_num,0,sizeof(s3->rrec.seq_num));
2976 memset(s3->wrec.seq_num,0,sizeof(s3->wrec.seq_num));
2980 #ifndef OPENSSL_NO_SRP
2981 SSL_SRP_CTX_init(s);
2983 s->method->ssl_clear(s);
2989 void ssl3_free(SSL *s)
2994 #ifdef TLSEXT_TYPE_opaque_prf_input
2995 if (s->s3->client_opaque_prf_input != NULL)
2996 OPENSSL_free(s->s3->client_opaque_prf_input);
2997 if (s->s3->server_opaque_prf_input != NULL)
2998 OPENSSL_free(s->s3->server_opaque_prf_input);
3001 ssl3_cleanup_key_block(s);
3002 if (s->s3->rbuf.buf != NULL)
3003 ssl3_release_read_buffer(s);
3004 if (s->s3->wbuf.buf != NULL)
3005 ssl3_release_write_buffer(s);
3006 if (s->s3->rrec.comp != NULL)
3007 OPENSSL_free(s->s3->rrec.comp);
3008 #ifndef OPENSSL_NO_DH
3009 if (s->s3->tmp.dh != NULL)
3010 DH_free(s->s3->tmp.dh);
3012 #ifndef OPENSSL_NO_ECDH
3013 if (s->s3->tmp.ecdh != NULL)
3014 EC_KEY_free(s->s3->tmp.ecdh);
3017 if (s->s3->tmp.ca_names != NULL)
3018 sk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free);
3019 if (s->s3->handshake_buffer) {
3020 BIO_free(s->s3->handshake_buffer);
3022 if (s->s3->handshake_dgst) ssl3_free_digest_list(s);
3023 #ifndef OPENSSL_NO_TLSEXT
3024 if (s->s3->alpn_selected)
3025 OPENSSL_free(s->s3->alpn_selected);
3028 #ifndef OPENSSL_NO_SRP
3029 SSL_SRP_CTX_free(s);
3031 #ifndef OPENSSL_NO_TLSEXT
3032 if (s->s3->tlsext_authz_client_types != NULL)
3033 OPENSSL_free(s->s3->tlsext_authz_client_types);
3034 if (s->s3->tlsext_custom_types != NULL)
3035 OPENSSL_free(s->s3->tlsext_custom_types);
3037 OPENSSL_cleanse(s->s3,sizeof *s->s3);
3038 OPENSSL_free(s->s3);
3042 void ssl3_clear(SSL *s)
3044 unsigned char *rp,*wp;
3048 #ifdef TLSEXT_TYPE_opaque_prf_input
3049 if (s->s3->client_opaque_prf_input != NULL)
3050 OPENSSL_free(s->s3->client_opaque_prf_input);
3051 s->s3->client_opaque_prf_input = NULL;
3052 if (s->s3->server_opaque_prf_input != NULL)
3053 OPENSSL_free(s->s3->server_opaque_prf_input);
3054 s->s3->server_opaque_prf_input = NULL;
3057 ssl3_cleanup_key_block(s);
3058 if (s->s3->tmp.ca_names != NULL)
3059 sk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free);
3061 if (s->s3->rrec.comp != NULL)
3063 OPENSSL_free(s->s3->rrec.comp);
3064 s->s3->rrec.comp=NULL;
3066 #ifndef OPENSSL_NO_DH
3067 if (s->s3->tmp.dh != NULL)
3069 DH_free(s->s3->tmp.dh);
3070 s->s3->tmp.dh = NULL;
3073 #ifndef OPENSSL_NO_ECDH
3074 if (s->s3->tmp.ecdh != NULL)
3076 EC_KEY_free(s->s3->tmp.ecdh);
3077 s->s3->tmp.ecdh = NULL;
3080 #ifndef OPENSSL_NO_TLSEXT
3081 if (s->s3->tlsext_authz_client_types != NULL)
3083 OPENSSL_free(s->s3->tlsext_authz_client_types);
3084 s->s3->tlsext_authz_client_types = NULL;
3086 if (s->s3->tlsext_custom_types != NULL)
3088 OPENSSL_free(s->s3->tlsext_custom_types);
3089 s->s3->tlsext_custom_types = NULL;
3091 s->s3->tlsext_custom_types_count = 0;
3094 rp = s->s3->rbuf.buf;
3095 wp = s->s3->wbuf.buf;
3096 rlen = s->s3->rbuf.len;
3097 wlen = s->s3->wbuf.len;
3098 init_extra = s->s3->init_extra;
3099 if (s->s3->handshake_buffer) {
3100 BIO_free(s->s3->handshake_buffer);
3101 s->s3->handshake_buffer = NULL;
3103 if (s->s3->handshake_dgst) {
3104 ssl3_free_digest_list(s);
3107 #if !defined(OPENSSL_NO_TLSEXT)
3108 if (s->s3->alpn_selected)
3110 free(s->s3->alpn_selected);
3111 s->s3->alpn_selected = NULL;
3114 memset(s->s3,0,sizeof *s->s3);
3115 s->s3->rbuf.buf = rp;
3116 s->s3->wbuf.buf = wp;
3117 s->s3->rbuf.len = rlen;
3118 s->s3->wbuf.len = wlen;
3119 s->s3->init_extra = init_extra;
3121 ssl_free_wbio_buffer(s);
3124 s->s3->renegotiate=0;
3125 s->s3->total_renegotiations=0;
3126 s->s3->num_renegotiations=0;
3127 s->s3->in_read_app_data=0;
3128 s->version=SSL3_VERSION;
3130 #if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
3131 if (s->next_proto_negotiated)
3133 OPENSSL_free(s->next_proto_negotiated);
3134 s->next_proto_negotiated = NULL;
3135 s->next_proto_negotiated_len = 0;
3140 #ifndef OPENSSL_NO_SRP
3141 static char * MS_CALLBACK srp_password_from_info_cb(SSL *s, void *arg)
3143 return BUF_strdup(s->srp_ctx.info) ;
3147 static int ssl3_set_req_cert_type(CERT *c, const unsigned char *p, size_t len);
3149 long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg)
3153 #if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA)
3155 #ifndef OPENSSL_NO_RSA
3156 cmd == SSL_CTRL_SET_TMP_RSA ||
3157 cmd == SSL_CTRL_SET_TMP_RSA_CB ||
3159 #ifndef OPENSSL_NO_DSA
3160 cmd == SSL_CTRL_SET_TMP_DH ||
3161 cmd == SSL_CTRL_SET_TMP_DH_CB ||
3165 if (!ssl_cert_inst(&s->cert))
3167 SSLerr(SSL_F_SSL3_CTRL, ERR_R_MALLOC_FAILURE);
3175 case SSL_CTRL_GET_SESSION_REUSED:
3178 case SSL_CTRL_GET_CLIENT_CERT_REQUEST:
3180 case SSL_CTRL_GET_NUM_RENEGOTIATIONS:
3181 ret=s->s3->num_renegotiations;
3183 case SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS:
3184 ret=s->s3->num_renegotiations;
3185 s->s3->num_renegotiations=0;
3187 case SSL_CTRL_GET_TOTAL_RENEGOTIATIONS:
3188 ret=s->s3->total_renegotiations;
3190 case SSL_CTRL_GET_FLAGS:
3191 ret=(int)(s->s3->flags);
3193 #ifndef OPENSSL_NO_RSA
3194 case SSL_CTRL_NEED_TMP_RSA:
3195 if ((s->cert != NULL) && (s->cert->rsa_tmp == NULL) &&
3196 ((s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) ||
3197 (EVP_PKEY_size(s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey) > (512/8))))
3200 case SSL_CTRL_SET_TMP_RSA:
3202 RSA *rsa = (RSA *)parg;
3205 SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
3208 if ((rsa = RSAPrivateKey_dup(rsa)) == NULL)
3210 SSLerr(SSL_F_SSL3_CTRL, ERR_R_RSA_LIB);
3213 if (s->cert->rsa_tmp != NULL)
3214 RSA_free(s->cert->rsa_tmp);
3215 s->cert->rsa_tmp = rsa;
3219 case SSL_CTRL_SET_TMP_RSA_CB:
3221 SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3226 #ifndef OPENSSL_NO_DH
3227 case SSL_CTRL_SET_TMP_DH:
3229 DH *dh = (DH *)parg;
3232 SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
3235 if ((dh = DHparams_dup(dh)) == NULL)
3237 SSLerr(SSL_F_SSL3_CTRL, ERR_R_DH_LIB);
3240 if (!(s->options & SSL_OP_SINGLE_DH_USE))
3242 if (!DH_generate_key(dh))
3245 SSLerr(SSL_F_SSL3_CTRL, ERR_R_DH_LIB);
3249 if (s->cert->dh_tmp != NULL)
3250 DH_free(s->cert->dh_tmp);
3251 s->cert->dh_tmp = dh;
3255 case SSL_CTRL_SET_TMP_DH_CB:
3257 SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3262 #ifndef OPENSSL_NO_ECDH
3263 case SSL_CTRL_SET_TMP_ECDH:
3265 EC_KEY *ecdh = NULL;
3269 SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER);
3272 if (!EC_KEY_up_ref((EC_KEY *)parg))
3274 SSLerr(SSL_F_SSL3_CTRL,ERR_R_ECDH_LIB);
3277 ecdh = (EC_KEY *)parg;
3278 if (!(s->options & SSL_OP_SINGLE_ECDH_USE))
3280 if (!EC_KEY_generate_key(ecdh))
3283 SSLerr(SSL_F_SSL3_CTRL,ERR_R_ECDH_LIB);
3287 if (s->cert->ecdh_tmp != NULL)
3288 EC_KEY_free(s->cert->ecdh_tmp);
3289 s->cert->ecdh_tmp = ecdh;
3293 case SSL_CTRL_SET_TMP_ECDH_CB:
3295 SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3299 #endif /* !OPENSSL_NO_ECDH */
3300 #ifndef OPENSSL_NO_TLSEXT
3301 case SSL_CTRL_SET_TLSEXT_HOSTNAME:
3302 if (larg == TLSEXT_NAMETYPE_host_name)
3304 if (s->tlsext_hostname != NULL)
3305 OPENSSL_free(s->tlsext_hostname);
3306 s->tlsext_hostname = NULL;
3311 if (strlen((char *)parg) > TLSEXT_MAXLEN_host_name)
3313 SSLerr(SSL_F_SSL3_CTRL, SSL_R_SSL3_EXT_INVALID_SERVERNAME);
3316 if ((s->tlsext_hostname = BUF_strdup((char *)parg)) == NULL)
3318 SSLerr(SSL_F_SSL3_CTRL, ERR_R_INTERNAL_ERROR);
3324 SSLerr(SSL_F_SSL3_CTRL, SSL_R_SSL3_EXT_INVALID_SERVERNAME_TYPE);
3328 case SSL_CTRL_SET_TLSEXT_DEBUG_ARG:
3329 s->tlsext_debug_arg=parg;
3333 #ifdef TLSEXT_TYPE_opaque_prf_input
3334 case SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT:
3335 if (larg > 12288) /* actual internal limit is 2^16 for the complete hello message
3336 * (including the cert chain and everything) */
3338 SSLerr(SSL_F_SSL3_CTRL, SSL_R_OPAQUE_PRF_INPUT_TOO_LONG);
3341 if (s->tlsext_opaque_prf_input != NULL)
3342 OPENSSL_free(s->tlsext_opaque_prf_input);
3343 if ((size_t)larg == 0)
3344 s->tlsext_opaque_prf_input = OPENSSL_malloc(1); /* dummy byte just to get non-NULL */
3346 s->tlsext_opaque_prf_input = BUF_memdup(parg, (size_t)larg);
3347 if (s->tlsext_opaque_prf_input != NULL)
3349 s->tlsext_opaque_prf_input_len = (size_t)larg;
3353 s->tlsext_opaque_prf_input_len = 0;
3357 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE:
3358 s->tlsext_status_type=larg;
3362 case SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS:
3363 *(STACK_OF(X509_EXTENSION) **)parg = s->tlsext_ocsp_exts;
3367 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS:
3368 s->tlsext_ocsp_exts = parg;
3372 case SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS:
3373 *(STACK_OF(OCSP_RESPID) **)parg = s->tlsext_ocsp_ids;
3377 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS:
3378 s->tlsext_ocsp_ids = parg;
3382 case SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP:
3383 *(unsigned char **)parg = s->tlsext_ocsp_resp;
3384 return s->tlsext_ocsp_resplen;
3386 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP:
3387 if (s->tlsext_ocsp_resp)
3388 OPENSSL_free(s->tlsext_ocsp_resp);
3389 s->tlsext_ocsp_resp = parg;
3390 s->tlsext_ocsp_resplen = larg;
3394 #ifndef OPENSSL_NO_HEARTBEATS
3395 case SSL_CTRL_TLS_EXT_SEND_HEARTBEAT:
3397 ret = dtls1_heartbeat(s);
3399 ret = tls1_heartbeat(s);
3402 case SSL_CTRL_GET_TLS_EXT_HEARTBEAT_PENDING:
3403 ret = s->tlsext_hb_pending;
3406 case SSL_CTRL_SET_TLS_EXT_HEARTBEAT_NO_REQUESTS:
3408 s->tlsext_heartbeat |= SSL_TLSEXT_HB_DONT_RECV_REQUESTS;
3410 s->tlsext_heartbeat &= ~SSL_TLSEXT_HB_DONT_RECV_REQUESTS;
3415 #endif /* !OPENSSL_NO_TLSEXT */
3417 case SSL_CTRL_CHAIN:
3419 return ssl_cert_set1_chain(s->cert,
3420 (STACK_OF (X509) *)parg);
3422 return ssl_cert_set0_chain(s->cert,
3423 (STACK_OF (X509) *)parg);
3425 case SSL_CTRL_CHAIN_CERT:
3427 return ssl_cert_add1_chain_cert(s->cert, (X509 *)parg);
3429 return ssl_cert_add0_chain_cert(s->cert, (X509 *)parg);
3431 #ifndef OPENSSL_NO_EC
3432 case SSL_CTRL_GET_CURVES:
3434 unsigned char *clist;
3438 clist = s->session->tlsext_ellipticcurvelist;
3439 clistlen = s->session->tlsext_ellipticcurvelist_length / 2;
3444 unsigned int cid, nid;
3445 for (i = 0; i < clistlen; i++)
3448 nid = tls1_ec_curve_id2nid(cid);
3452 cptr[i] = TLSEXT_nid_unknown | cid;
3455 return (int)clistlen;
3458 case SSL_CTRL_SET_CURVES:
3459 return tls1_set_curves(&s->tlsext_ellipticcurvelist,
3460 &s->tlsext_ellipticcurvelist_length,
3463 case SSL_CTRL_SET_CURVES_LIST:
3464 return tls1_set_curves_list(&s->tlsext_ellipticcurvelist,
3465 &s->tlsext_ellipticcurvelist_length,
3468 case SSL_CTRL_GET_SHARED_CURVE:
3469 return tls1_shared_curve(s, larg);
3471 case SSL_CTRL_SET_ECDH_AUTO:
3472 s->cert->ecdh_tmp_auto = larg;
3475 case SSL_CTRL_SET_SIGALGS:
3476 return tls1_set_sigalgs(s->cert, parg, larg, 0);
3478 case SSL_CTRL_SET_SIGALGS_LIST:
3479 return tls1_set_sigalgs_list(s->cert, parg, 0);
3481 case SSL_CTRL_SET_CLIENT_SIGALGS:
3482 return tls1_set_sigalgs(s->cert, parg, larg, 1);
3484 case SSL_CTRL_SET_CLIENT_SIGALGS_LIST:
3485 return tls1_set_sigalgs_list(s->cert, parg, 1);
3487 case SSL_CTRL_GET_CLIENT_CERT_TYPES:
3489 const unsigned char **pctype = parg;
3490 if (s->server || !s->s3->tmp.cert_req)
3492 if (s->cert->ctypes)
3495 *pctype = s->cert->ctypes;
3496 return (int)s->cert->ctype_num;
3499 *pctype = (unsigned char *)s->s3->tmp.ctype;
3500 return s->s3->tmp.ctype_num;
3503 case SSL_CTRL_SET_CLIENT_CERT_TYPES:
3506 return ssl3_set_req_cert_type(s->cert, parg, larg);
3508 case SSL_CTRL_BUILD_CERT_CHAIN:
3509 return ssl_build_cert_chain(s->cert, s->ctx->cert_store, larg);
3511 case SSL_CTRL_SET_VERIFY_CERT_STORE:
3512 return ssl_cert_set_cert_store(s->cert, parg, 0, larg);
3514 case SSL_CTRL_SET_CHAIN_CERT_STORE:
3515 return ssl_cert_set_cert_store(s->cert, parg, 1, larg);
3517 case SSL_CTRL_GET_PEER_SIGNATURE_NID:
3518 if (SSL_USE_SIGALGS(s))
3520 if (s->session && s->session->sess_cert)
3523 sig = s->session->sess_cert->peer_key->digest;
3526 *(int *)parg = EVP_MD_type(sig);
3532 /* Might want to do something here for other versions */
3536 case SSL_CTRL_GET_SERVER_TMP_KEY:
3537 if (s->server || !s->session || !s->session->sess_cert)
3544 sc = s->session->sess_cert;
3545 #if !defined(OPENSSL_NO_RSA) && !defined(OPENSSL_NO_DH) && !defined(OPENSSL_NO_EC)
3546 if (!sc->peer_rsa_tmp && !sc->peer_dh_tmp
3547 && !sc->peer_ecdh_tmp)
3550 ptmp = EVP_PKEY_new();
3554 #ifndef OPENSSL_NO_RSA
3555 else if (sc->peer_rsa_tmp)
3556 rv = EVP_PKEY_set1_RSA(ptmp, sc->peer_rsa_tmp);
3558 #ifndef OPENSSL_NO_DH
3559 else if (sc->peer_dh_tmp)
3560 rv = EVP_PKEY_set1_DH(ptmp, sc->peer_dh_tmp);
3562 #ifndef OPENSSL_NO_ECDH
3563 else if (sc->peer_ecdh_tmp)
3564 rv = EVP_PKEY_set1_EC_KEY(ptmp, sc->peer_ecdh_tmp);
3568 *(EVP_PKEY **)parg = ptmp;
3571 EVP_PKEY_free(ptmp);
3574 #ifndef OPENSSL_NO_EC
3575 case SSL_CTRL_GET_EC_POINT_FORMATS:
3577 SSL_SESSION *sess = s->session;
3578 const unsigned char **pformat = parg;
3579 if (!sess || !sess->tlsext_ecpointformatlist)
3581 *pformat = sess->tlsext_ecpointformatlist;
3582 return (int)sess->tlsext_ecpointformatlist_length;
3591 long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp)(void))
3595 #if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA)
3597 #ifndef OPENSSL_NO_RSA
3598 cmd == SSL_CTRL_SET_TMP_RSA_CB ||
3600 #ifndef OPENSSL_NO_DSA
3601 cmd == SSL_CTRL_SET_TMP_DH_CB ||
3605 if (!ssl_cert_inst(&s->cert))
3607 SSLerr(SSL_F_SSL3_CALLBACK_CTRL, ERR_R_MALLOC_FAILURE);
3615 #ifndef OPENSSL_NO_RSA
3616 case SSL_CTRL_SET_TMP_RSA_CB:
3618 s->cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
3622 #ifndef OPENSSL_NO_DH
3623 case SSL_CTRL_SET_TMP_DH_CB:
3625 s->cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
3629 #ifndef OPENSSL_NO_ECDH
3630 case SSL_CTRL_SET_TMP_ECDH_CB:
3632 s->cert->ecdh_tmp_cb = (EC_KEY *(*)(SSL *, int, int))fp;
3636 #ifndef OPENSSL_NO_TLSEXT
3637 case SSL_CTRL_SET_TLSEXT_DEBUG_CB:
3638 s->tlsext_debug_cb=(void (*)(SSL *,int ,int,
3639 unsigned char *, int, void *))fp;
3642 case SSL_CTRL_SET_NOT_RESUMABLE_SESS_CB:
3644 s->not_resumable_session_cb = (int (*)(SSL *, int))fp;
3653 long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg)
3661 #ifndef OPENSSL_NO_RSA
3662 case SSL_CTRL_NEED_TMP_RSA:
3663 if ( (cert->rsa_tmp == NULL) &&
3664 ((cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) ||
3665 (EVP_PKEY_size(cert->pkeys[SSL_PKEY_RSA_ENC].privatekey) > (512/8)))
3671 case SSL_CTRL_SET_TMP_RSA:
3682 if ((rsa=RSAPrivateKey_dup(rsa)) == NULL)
3687 SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_RSA_LIB);
3692 if (cert->rsa_tmp != NULL)
3693 RSA_free(cert->rsa_tmp);
3699 case SSL_CTRL_SET_TMP_RSA_CB:
3701 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3706 #ifndef OPENSSL_NO_DH
3707 case SSL_CTRL_SET_TMP_DH:
3712 if ((new=DHparams_dup(dh)) == NULL)
3714 SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_DH_LIB);
3717 if (!(ctx->options & SSL_OP_SINGLE_DH_USE))
3719 if (!DH_generate_key(new))
3721 SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_DH_LIB);
3726 if (cert->dh_tmp != NULL)
3727 DH_free(cert->dh_tmp);
3732 case SSL_CTRL_SET_TMP_DH_CB:
3734 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3739 #ifndef OPENSSL_NO_ECDH
3740 case SSL_CTRL_SET_TMP_ECDH:
3742 EC_KEY *ecdh = NULL;
3746 SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_ECDH_LIB);
3749 ecdh = EC_KEY_dup((EC_KEY *)parg);
3752 SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_EC_LIB);
3755 if (!(ctx->options & SSL_OP_SINGLE_ECDH_USE))
3757 if (!EC_KEY_generate_key(ecdh))
3760 SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_ECDH_LIB);
3765 if (cert->ecdh_tmp != NULL)
3767 EC_KEY_free(cert->ecdh_tmp);
3769 cert->ecdh_tmp = ecdh;
3773 case SSL_CTRL_SET_TMP_ECDH_CB:
3775 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
3779 #endif /* !OPENSSL_NO_ECDH */
3780 #ifndef OPENSSL_NO_TLSEXT
3781 case SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG:
3782 ctx->tlsext_servername_arg=parg;
3784 case SSL_CTRL_SET_TLSEXT_TICKET_KEYS:
3785 case SSL_CTRL_GET_TLSEXT_TICKET_KEYS:
3787 unsigned char *keys = parg;
3792 SSLerr(SSL_F_SSL3_CTX_CTRL, SSL_R_INVALID_TICKET_KEYS_LENGTH);
3795 if (cmd == SSL_CTRL_SET_TLSEXT_TICKET_KEYS)
3797 memcpy(ctx->tlsext_tick_key_name, keys, 16);
3798 memcpy(ctx->tlsext_tick_hmac_key, keys + 16, 16);
3799 memcpy(ctx->tlsext_tick_aes_key, keys + 32, 16);
3803 memcpy(keys, ctx->tlsext_tick_key_name, 16);
3804 memcpy(keys + 16, ctx->tlsext_tick_hmac_key, 16);
3805 memcpy(keys + 32, ctx->tlsext_tick_aes_key, 16);
3810 #ifdef TLSEXT_TYPE_opaque_prf_input
3811 case SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB_ARG:
3812 ctx->tlsext_opaque_prf_input_callback_arg = parg;
3816 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG:
3817 ctx->tlsext_status_arg=parg;
3821 #ifndef OPENSSL_NO_SRP
3822 case SSL_CTRL_SET_TLS_EXT_SRP_USERNAME:
3823 ctx->srp_ctx.srp_Mask|=SSL_kSRP;
3824 if (ctx->srp_ctx.login != NULL)
3825 OPENSSL_free(ctx->srp_ctx.login);
3826 ctx->srp_ctx.login = NULL;
3829 if (strlen((const char *)parg) > 255 || strlen((const char *)parg) < 1)
3831 SSLerr(SSL_F_SSL3_CTX_CTRL, SSL_R_INVALID_SRP_USERNAME);
3834 if ((ctx->srp_ctx.login = BUF_strdup((char *)parg)) == NULL)
3836 SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_INTERNAL_ERROR);
3840 case SSL_CTRL_SET_TLS_EXT_SRP_PASSWORD:
3841 ctx->srp_ctx.SRP_give_srp_client_pwd_callback=srp_password_from_info_cb;
3842 ctx->srp_ctx.info=parg;
3844 case SSL_CTRL_SET_SRP_ARG:
3845 ctx->srp_ctx.srp_Mask|=SSL_kSRP;
3846 ctx->srp_ctx.SRP_cb_arg=parg;
3849 case SSL_CTRL_SET_TLS_EXT_SRP_STRENGTH:
3850 ctx->srp_ctx.strength=larg;
3854 #ifndef OPENSSL_NO_EC
3855 case SSL_CTRL_SET_CURVES:
3856 return tls1_set_curves(&ctx->tlsext_ellipticcurvelist,
3857 &ctx->tlsext_ellipticcurvelist_length,
3860 case SSL_CTRL_SET_CURVES_LIST:
3861 return tls1_set_curves_list(&ctx->tlsext_ellipticcurvelist,
3862 &ctx->tlsext_ellipticcurvelist_length,
3864 case SSL_CTRL_SET_ECDH_AUTO:
3865 ctx->cert->ecdh_tmp_auto = larg;
3868 case SSL_CTRL_SET_SIGALGS:
3869 return tls1_set_sigalgs(ctx->cert, parg, larg, 0);
3871 case SSL_CTRL_SET_SIGALGS_LIST:
3872 return tls1_set_sigalgs_list(ctx->cert, parg, 0);
3874 case SSL_CTRL_SET_CLIENT_SIGALGS:
3875 return tls1_set_sigalgs(ctx->cert, parg, larg, 1);
3877 case SSL_CTRL_SET_CLIENT_SIGALGS_LIST:
3878 return tls1_set_sigalgs_list(ctx->cert, parg, 1);
3880 case SSL_CTRL_SET_CLIENT_CERT_TYPES:
3881 return ssl3_set_req_cert_type(ctx->cert, parg, larg);
3883 case SSL_CTRL_BUILD_CERT_CHAIN:
3884 return ssl_build_cert_chain(ctx->cert, ctx->cert_store, larg);
3886 case SSL_CTRL_SET_VERIFY_CERT_STORE:
3887 return ssl_cert_set_cert_store(ctx->cert, parg, 0, larg);
3889 case SSL_CTRL_SET_CHAIN_CERT_STORE:
3890 return ssl_cert_set_cert_store(ctx->cert, parg, 1, larg);
3892 case SSL_CTRL_SET_TLSEXT_AUTHZ_SERVER_AUDIT_PROOF_CB_ARG:
3893 ctx->tlsext_authz_server_audit_proof_cb_arg = parg;
3896 #endif /* !OPENSSL_NO_TLSEXT */
3898 /* A Thawte special :-) */
3899 case SSL_CTRL_EXTRA_CHAIN_CERT:
3900 if (ctx->extra_certs == NULL)
3902 if ((ctx->extra_certs=sk_X509_new_null()) == NULL)
3905 sk_X509_push(ctx->extra_certs,(X509 *)parg);
3908 case SSL_CTRL_GET_EXTRA_CHAIN_CERTS:
3909 *(STACK_OF(X509) **)parg = ctx->extra_certs;
3912 case SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS:
3913 if (ctx->extra_certs)
3915 sk_X509_pop_free(ctx->extra_certs, X509_free);
3916 ctx->extra_certs = NULL;
3920 case SSL_CTRL_CHAIN:
3922 return ssl_cert_set1_chain(ctx->cert,
3923 (STACK_OF (X509) *)parg);
3925 return ssl_cert_set0_chain(ctx->cert,
3926 (STACK_OF (X509) *)parg);
3928 case SSL_CTRL_CHAIN_CERT:
3930 return ssl_cert_add1_chain_cert(ctx->cert, (X509 *)parg);
3932 return ssl_cert_add0_chain_cert(ctx->cert, (X509 *)parg);
3940 long ssl3_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)(void))
3948 #ifndef OPENSSL_NO_RSA
3949 case SSL_CTRL_SET_TMP_RSA_CB:
3951 cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
3955 #ifndef OPENSSL_NO_DH
3956 case SSL_CTRL_SET_TMP_DH_CB:
3958 cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp;
3962 #ifndef OPENSSL_NO_ECDH
3963 case SSL_CTRL_SET_TMP_ECDH_CB:
3965 cert->ecdh_tmp_cb = (EC_KEY *(*)(SSL *, int, int))fp;
3969 #ifndef OPENSSL_NO_TLSEXT
3970 case SSL_CTRL_SET_TLSEXT_SERVERNAME_CB:
3971 ctx->tlsext_servername_callback=(int (*)(SSL *,int *,void *))fp;
3974 #ifdef TLSEXT_TYPE_opaque_prf_input
3975 case SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB:
3976 ctx->tlsext_opaque_prf_input_callback = (int (*)(SSL *,void *, size_t, void *))fp;
3980 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB:
3981 ctx->tlsext_status_cb=(int (*)(SSL *,void *))fp;
3984 case SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB:
3985 ctx->tlsext_ticket_key_cb=(int (*)(SSL *,unsigned char *,
3988 HMAC_CTX *, int))fp;
3991 #ifndef OPENSSL_NO_SRP
3992 case SSL_CTRL_SET_SRP_VERIFY_PARAM_CB:
3993 ctx->srp_ctx.srp_Mask|=SSL_kSRP;
3994 ctx->srp_ctx.SRP_verify_param_callback=(int (*)(SSL *,void *))fp;
3996 case SSL_CTRL_SET_TLS_EXT_SRP_USERNAME_CB:
3997 ctx->srp_ctx.srp_Mask|=SSL_kSRP;
3998 ctx->srp_ctx.TLS_ext_srp_username_callback=(int (*)(SSL *,int *,void *))fp;
4000 case SSL_CTRL_SET_SRP_GIVE_CLIENT_PWD_CB:
4001 ctx->srp_ctx.srp_Mask|=SSL_kSRP;
4002 ctx->srp_ctx.SRP_give_srp_client_pwd_callback=(char *(*)(SSL *,void *))fp;
4006 case SSL_CTRL_SET_TLSEXT_AUTHZ_SERVER_AUDIT_PROOF_CB:
4007 ctx->tlsext_authz_server_audit_proof_cb =
4008 (int (*)(SSL *, void *))fp;
4012 case SSL_CTRL_SET_NOT_RESUMABLE_SESS_CB:
4014 ctx->not_resumable_session_cb = (int (*)(SSL *, int))fp;
4023 /* This function needs to check if the ciphers required are actually
4025 const SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p)
4028 const SSL_CIPHER *cp;
4031 id=0x03000000L|((unsigned long)p[0]<<8L)|(unsigned long)p[1];
4033 cp = OBJ_bsearch_ssl_cipher_id(&c, ssl3_ciphers, SSL3_NUM_CIPHERS);
4034 #ifdef DEBUG_PRINT_UNKNOWN_CIPHERSUITES
4035 if (cp == NULL) fprintf(stderr, "Unknown cipher ID %x\n", (p[0] << 8) | p[1]);
4040 int ssl3_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p)
4047 if ((l & 0xff000000) != 0x03000000) return(0);
4048 p[0]=((unsigned char)(l>> 8L))&0xFF;
4049 p[1]=((unsigned char)(l ))&0xFF;
4054 SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt,
4055 STACK_OF(SSL_CIPHER) *srvr)
4057 SSL_CIPHER *c,*ret=NULL;
4058 STACK_OF(SSL_CIPHER) *prio, *allow;
4061 unsigned long alg_k,alg_a,mask_k,mask_a,emask_k,emask_a;
4063 /* Let's see which ciphers we can support */
4067 /* Do not set the compare functions, because this may lead to a
4068 * reordering by "id". We want to keep the original ordering.
4069 * We may pay a price in performance during sk_SSL_CIPHER_find(),
4070 * but would have to pay with the price of sk_SSL_CIPHER_dup().
4072 sk_SSL_CIPHER_set_cmp_func(srvr, ssl_cipher_ptr_id_cmp);
4073 sk_SSL_CIPHER_set_cmp_func(clnt, ssl_cipher_ptr_id_cmp);
4077 printf("Server has %d from %p:\n", sk_SSL_CIPHER_num(srvr), (void *)srvr);
4078 for(i=0 ; i < sk_SSL_CIPHER_num(srvr) ; ++i)
4080 c=sk_SSL_CIPHER_value(srvr,i);
4081 printf("%p:%s\n",(void *)c,c->name);
4083 printf("Client sent %d from %p:\n", sk_SSL_CIPHER_num(clnt), (void *)clnt);
4084 for(i=0 ; i < sk_SSL_CIPHER_num(clnt) ; ++i)
4086 c=sk_SSL_CIPHER_value(clnt,i);
4087 printf("%p:%s\n",(void *)c,c->name);
4091 if (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE || tls1_suiteb(s))
4102 tls1_set_cert_validity(s);
4104 for (i=0; i<sk_SSL_CIPHER_num(prio); i++)
4106 c=sk_SSL_CIPHER_value(prio,i);
4108 /* Skip TLS v1.2 only ciphersuites if not supported */
4109 if ((c->algorithm_ssl & SSL_TLSV1_2) &&
4110 !SSL_USE_TLS1_2_CIPHERS(s))
4113 ssl_set_cert_masks(cert,c);
4114 mask_k = cert->mask_k;
4115 mask_a = cert->mask_a;
4116 emask_k = cert->export_mask_k;
4117 emask_a = cert->export_mask_a;
4118 #ifndef OPENSSL_NO_SRP
4119 mask_k=cert->mask_k | s->srp_ctx.srp_Mask;
4120 emask_k=cert->export_mask_k | s->srp_ctx.srp_Mask;
4124 /* printf("ssl3_choose_cipher %d alg= %lx\n", i,c->algorithms);*/
4125 #endif /* KSSL_DEBUG */
4127 alg_k=c->algorithm_mkey;
4128 alg_a=c->algorithm_auth;
4130 #ifndef OPENSSL_NO_KRB5
4131 if (alg_k & SSL_kKRB5)
4133 if ( !kssl_keytab_is_available(s->kssl_ctx) )
4136 #endif /* OPENSSL_NO_KRB5 */
4137 #ifndef OPENSSL_NO_PSK
4138 /* with PSK there must be server callback set */
4139 if ((alg_k & SSL_kPSK) && s->psk_server_callback == NULL)
4141 #endif /* OPENSSL_NO_PSK */
4143 if (SSL_C_IS_EXPORT(c))
4145 ok = (alg_k & emask_k) && (alg_a & emask_a);
4147 printf("%d:[%08lX:%08lX:%08lX:%08lX]%p:%s (export)\n",ok,alg_k,alg_a,emask_k,emask_a,
4153 ok = (alg_k & mask_k) && (alg_a & mask_a);
4155 printf("%d:[%08lX:%08lX:%08lX:%08lX]%p:%s\n",ok,alg_k,alg_a,mask_k,mask_a,(void *)c,
4160 #ifndef OPENSSL_NO_TLSEXT
4161 #ifndef OPENSSL_NO_EC
4162 /* if we are considering an ECC cipher suite that uses
4163 * an ephemeral EC key check it */
4164 if (alg_k & SSL_kEECDH)
4165 ok = ok && tls1_check_ec_tmp_key(s, c->id);
4166 #endif /* OPENSSL_NO_EC */
4167 #endif /* OPENSSL_NO_TLSEXT */
4170 ii=sk_SSL_CIPHER_find(allow,c);
4173 ret=sk_SSL_CIPHER_value(allow,ii);
4180 int ssl3_get_req_cert_type(SSL *s, unsigned char *p)
4183 const unsigned char *sig;
4185 int have_rsa_sign = 0, have_dsa_sign = 0;
4186 #ifndef OPENSSL_NO_ECDSA
4187 int have_ecdsa_sign = 0;
4190 unsigned long alg_k;
4192 /* If we have custom certificate types set, use them */
4193 if (s->cert->ctypes)
4195 memcpy(p, s->cert->ctypes, s->cert->ctype_num);
4196 return (int)s->cert->ctype_num;
4198 /* get configured sigalgs */
4199 siglen = tls12_get_psigalgs(s, &sig);
4200 if (s->cert->cert_flags & SSL_CERT_FLAGS_CHECK_TLS_STRICT)
4202 for (i = 0; i < siglen; i+=2, sig+=2)
4206 case TLSEXT_signature_rsa:
4210 case TLSEXT_signature_dsa:
4213 #ifndef OPENSSL_NO_ECDSA
4214 case TLSEXT_signature_ecdsa:
4215 have_ecdsa_sign = 1;
4221 alg_k = s->s3->tmp.new_cipher->algorithm_mkey;
4223 #ifndef OPENSSL_NO_GOST
4224 if (s->version >= TLS1_VERSION)
4226 if (alg_k & SSL_kGOST)
4228 p[ret++]=TLS_CT_GOST94_SIGN;
4229 p[ret++]=TLS_CT_GOST01_SIGN;
4235 #ifndef OPENSSL_NO_DH
4236 if (alg_k & (SSL_kDHr|SSL_kEDH))
4238 # ifndef OPENSSL_NO_RSA
4239 /* Since this refers to a certificate signed with an RSA
4240 * algorithm, only check for rsa signing in strict mode.
4242 if (nostrict || have_rsa_sign)
4243 p[ret++]=SSL3_CT_RSA_FIXED_DH;
4245 # ifndef OPENSSL_NO_DSA
4246 if (nostrict || have_dsa_sign)
4247 p[ret++]=SSL3_CT_DSS_FIXED_DH;
4250 if ((s->version == SSL3_VERSION) &&
4251 (alg_k & (SSL_kEDH|SSL_kDHd|SSL_kDHr)))
4253 # ifndef OPENSSL_NO_RSA
4254 p[ret++]=SSL3_CT_RSA_EPHEMERAL_DH;
4256 # ifndef OPENSSL_NO_DSA
4257 p[ret++]=SSL3_CT_DSS_EPHEMERAL_DH;
4260 #endif /* !OPENSSL_NO_DH */
4261 #ifndef OPENSSL_NO_RSA
4263 p[ret++]=SSL3_CT_RSA_SIGN;
4265 #ifndef OPENSSL_NO_DSA
4267 p[ret++]=SSL3_CT_DSS_SIGN;
4269 #ifndef OPENSSL_NO_ECDH
4270 if ((alg_k & (SSL_kECDHr|SSL_kECDHe)) && (s->version >= TLS1_VERSION))
4272 if (nostrict || have_rsa_sign)
4273 p[ret++]=TLS_CT_RSA_FIXED_ECDH;
4274 if (nostrict || have_ecdsa_sign)
4275 p[ret++]=TLS_CT_ECDSA_FIXED_ECDH;
4279 #ifndef OPENSSL_NO_ECDSA
4280 /* ECDSA certs can be used with RSA cipher suites as well
4281 * so we don't need to check for SSL_kECDH or SSL_kEECDH
4283 if (s->version >= TLS1_VERSION)
4285 if (have_ecdsa_sign)
4286 p[ret++]=TLS_CT_ECDSA_SIGN;
4292 static int ssl3_set_req_cert_type(CERT *c, const unsigned char *p, size_t len)
4296 OPENSSL_free(c->ctypes);
4303 c->ctypes = OPENSSL_malloc(len);
4306 memcpy(c->ctypes, p, len);
4311 int ssl3_shutdown(SSL *s)
4315 /* Don't do anything much if we have not done the handshake or
4316 * we don't want to send messages :-) */
4317 if ((s->quiet_shutdown) || (s->state == SSL_ST_BEFORE))
4319 s->shutdown=(SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
4323 if (!(s->shutdown & SSL_SENT_SHUTDOWN))
4325 s->shutdown|=SSL_SENT_SHUTDOWN;
4327 ssl3_send_alert(s,SSL3_AL_WARNING,SSL_AD_CLOSE_NOTIFY);
4329 /* our shutdown alert has been sent now, and if it still needs
4330 * to be written, s->s3->alert_dispatch will be true */
4331 if (s->s3->alert_dispatch)
4332 return(-1); /* return WANT_WRITE */
4334 else if (s->s3->alert_dispatch)
4336 /* resend it if not sent */
4338 ret=s->method->ssl_dispatch_alert(s);
4341 /* we only get to return -1 here the 2nd/Nth
4342 * invocation, we must have already signalled
4343 * return 0 upon a previous invoation,
4344 * return WANT_WRITE */
4349 else if (!(s->shutdown & SSL_RECEIVED_SHUTDOWN))
4351 /* If we are waiting for a close from our peer, we are closed */
4352 s->method->ssl_read_bytes(s,0,NULL,0,0);
4353 if(!(s->shutdown & SSL_RECEIVED_SHUTDOWN))
4355 return(-1); /* return WANT_READ */
4359 if ((s->shutdown == (SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN)) &&
4360 !s->s3->alert_dispatch)
4366 int ssl3_write(SSL *s, const void *buf, int len)
4371 if (s->shutdown & SSL_SEND_SHUTDOWN)
4373 s->rwstate=SSL_NOTHING;
4378 if (s->s3->renegotiate) ssl3_renegotiate_check(s);
4380 /* This is an experimental flag that sends the
4381 * last handshake message in the same packet as the first
4382 * use data - used to see if it helps the TCP protocol during
4383 * session-id reuse */
4384 /* The second test is because the buffer may have been removed */
4385 if ((s->s3->flags & SSL3_FLAGS_POP_BUFFER) && (s->wbio == s->bbio))
4387 /* First time through, we write into the buffer */
4388 if (s->s3->delay_buf_pop_ret == 0)
4390 ret=ssl3_write_bytes(s,SSL3_RT_APPLICATION_DATA,
4392 if (ret <= 0) return(ret);
4394 s->s3->delay_buf_pop_ret=ret;
4397 s->rwstate=SSL_WRITING;
4398 n=BIO_flush(s->wbio);
4399 if (n <= 0) return(n);
4400 s->rwstate=SSL_NOTHING;
4402 /* We have flushed the buffer, so remove it */
4403 ssl_free_wbio_buffer(s);
4404 s->s3->flags&= ~SSL3_FLAGS_POP_BUFFER;
4406 ret=s->s3->delay_buf_pop_ret;
4407 s->s3->delay_buf_pop_ret=0;
4411 ret=s->method->ssl_write_bytes(s,SSL3_RT_APPLICATION_DATA,
4413 if (ret <= 0) return(ret);
4419 static int ssl3_read_internal(SSL *s, void *buf, int len, int peek)
4424 if (s->s3->renegotiate) ssl3_renegotiate_check(s);
4425 s->s3->in_read_app_data=1;
4426 ret=s->method->ssl_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len,peek);
4427 if ((ret == -1) && (s->s3->in_read_app_data == 2))
4429 /* ssl3_read_bytes decided to call s->handshake_func, which
4430 * called ssl3_read_bytes to read handshake data.
4431 * However, ssl3_read_bytes actually found application data
4432 * and thinks that application data makes sense here; so disable
4433 * handshake processing and try to read application data again. */
4435 ret=s->method->ssl_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len,peek);
4439 s->s3->in_read_app_data=0;
4444 int ssl3_read(SSL *s, void *buf, int len)
4446 return ssl3_read_internal(s, buf, len, 0);
4449 int ssl3_peek(SSL *s, void *buf, int len)
4451 return ssl3_read_internal(s, buf, len, 1);
4454 int ssl3_renegotiate(SSL *s)
4456 if (s->handshake_func == NULL)
4459 if (s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS)
4462 s->s3->renegotiate=1;
4466 int ssl3_renegotiate_check(SSL *s)
4470 if (s->s3->renegotiate)
4472 if ( (s->s3->rbuf.left == 0) &&
4473 (s->s3->wbuf.left == 0) &&
4477 if we are the server, and we have sent a 'RENEGOTIATE' message, we
4478 need to go to SSL_ST_ACCEPT.
4481 s->state=SSL_ST_RENEGOTIATE;
4482 s->s3->renegotiate=0;
4483 s->s3->num_renegotiations++;
4484 s->s3->total_renegotiations++;
4490 /* If we are using default SHA1+MD5 algorithms switch to new SHA256 PRF
4491 * and handshake macs if required.
4493 long ssl_get_algorithm2(SSL *s)
4495 long alg2 = s->s3->tmp.new_cipher->algorithm2;
4496 if (s->method->ssl3_enc->enc_flags & SSL_ENC_FLAG_SHA256_PRF
4497 && alg2 == (SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF))
4498 return SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256;