2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
58 /* ====================================================================
59 * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved.
61 * Redistribution and use in source and binary forms, with or without
62 * modification, are permitted provided that the following conditions
65 * 1. Redistributions of source code must retain the above copyright
66 * notice, this list of conditions and the following disclaimer.
68 * 2. Redistributions in binary form must reproduce the above copyright
69 * notice, this list of conditions and the following disclaimer in
70 * the documentation and/or other materials provided with the
73 * 3. All advertising materials mentioning features or use of this
74 * software must display the following acknowledgment:
75 * "This product includes software developed by the OpenSSL Project
76 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
78 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
79 * endorse or promote products derived from this software without
80 * prior written permission. For written permission, please contact
81 * openssl-core@openssl.org.
83 * 5. Products derived from this software may not be called "OpenSSL"
84 * nor may "OpenSSL" appear in their names without prior written
85 * permission of the OpenSSL Project.
87 * 6. Redistributions of any form whatsoever must retain the following
89 * "This product includes software developed by the OpenSSL Project
90 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
92 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
93 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
94 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
95 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
96 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
97 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
98 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
99 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
100 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
101 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
102 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
103 * OF THE POSSIBILITY OF SUCH DAMAGE.
104 * ====================================================================
106 * This product includes cryptographic software written by Eric Young
107 * (eay@cryptsoft.com). This product includes software written by Tim
108 * Hudson (tjh@cryptsoft.com).
111 /* ====================================================================
112 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
114 * Portions of the attached software ("Contribution") are developed by
115 * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
117 * The Contribution is licensed pursuant to the OpenSSL open source
118 * license provided above.
120 * ECC cipher suite support in OpenSSL originally written by
121 * Vipul Gupta and Sumit Gupta of Sun Microsystems Laboratories.
124 /* ====================================================================
125 * Copyright 2005 Nokia. All rights reserved.
127 * The portions of the attached software ("Contribution") is developed by
128 * Nokia Corporation and is licensed pursuant to the OpenSSL open source
131 * The Contribution, originally written by Mika Kousa and Pasi Eronen of
132 * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites
133 * support (see RFC 4279) to OpenSSL.
135 * No patent licenses or other rights except those expressly stated in
136 * the OpenSSL open source license shall be deemed granted or received
137 * expressly, by implication, estoppel, or otherwise.
139 * No assurances are provided by Nokia that the Contribution does not
140 * infringe the patent or other intellectual property rights of any third
141 * party or that the license provides you with all the necessary rights
142 * to make use of the Contribution.
144 * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN
145 * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA
146 * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY
147 * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR
152 #include <openssl/objects.h>
153 #include "ssl_locl.h"
154 #include "kssl_lcl.h"
155 #ifndef OPENSSL_NO_TLSEXT
156 #ifndef OPENSSL_NO_EC
157 #include "../crypto/ec/ec_lcl.h"
158 #endif /* OPENSSL_NO_EC */
159 #endif /* OPENSSL_NO_TLSEXT */
160 #include <openssl/md5.h>
161 #ifndef OPENSSL_NO_DH
162 #include <openssl/dh.h>
165 const char ssl3_version_str
[]="SSLv3" OPENSSL_VERSION_PTEXT
;
167 #define SSL3_NUM_CIPHERS (sizeof(ssl3_ciphers)/sizeof(SSL_CIPHER))
169 /* list of available SSLv3 ciphers (sorted by id) */
170 OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers
[]={
172 /* The RSA ciphers */
176 SSL3_TXT_RSA_NULL_MD5
,
177 SSL3_CK_RSA_NULL_MD5
,
183 SSL_NOT_EXP
|SSL_STRONG_NONE
,
184 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
192 SSL3_TXT_RSA_NULL_SHA
,
193 SSL3_CK_RSA_NULL_SHA
,
199 SSL_NOT_EXP
|SSL_STRONG_NONE
|SSL_FIPS
,
200 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
208 SSL3_TXT_RSA_RC4_40_MD5
,
209 SSL3_CK_RSA_RC4_40_MD5
,
215 SSL_EXPORT
|SSL_EXP40
,
216 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
224 SSL3_TXT_RSA_RC4_128_MD5
,
225 SSL3_CK_RSA_RC4_128_MD5
,
231 SSL_NOT_EXP
|SSL_MEDIUM
,
232 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
240 SSL3_TXT_RSA_RC4_128_SHA
,
241 SSL3_CK_RSA_RC4_128_SHA
,
247 SSL_NOT_EXP
|SSL_MEDIUM
,
248 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
256 SSL3_TXT_RSA_RC2_40_MD5
,
257 SSL3_CK_RSA_RC2_40_MD5
,
263 SSL_EXPORT
|SSL_EXP40
,
264 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
270 #ifndef OPENSSL_NO_IDEA
273 SSL3_TXT_RSA_IDEA_128_SHA
,
274 SSL3_CK_RSA_IDEA_128_SHA
,
280 SSL_NOT_EXP
|SSL_MEDIUM
,
281 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
290 SSL3_TXT_RSA_DES_40_CBC_SHA
,
291 SSL3_CK_RSA_DES_40_CBC_SHA
,
297 SSL_EXPORT
|SSL_EXP40
,
298 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
306 SSL3_TXT_RSA_DES_64_CBC_SHA
,
307 SSL3_CK_RSA_DES_64_CBC_SHA
,
314 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
322 SSL3_TXT_RSA_DES_192_CBC3_SHA
,
323 SSL3_CK_RSA_DES_192_CBC3_SHA
,
329 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
330 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
339 SSL3_TXT_DH_DSS_DES_40_CBC_SHA
,
340 SSL3_CK_DH_DSS_DES_40_CBC_SHA
,
346 SSL_EXPORT
|SSL_EXP40
,
347 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
354 0, /* not implemented (non-ephemeral DH) */
355 SSL3_TXT_DH_DSS_DES_64_CBC_SHA
,
356 SSL3_CK_DH_DSS_DES_64_CBC_SHA
,
363 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
370 0, /* not implemented (non-ephemeral DH) */
371 SSL3_TXT_DH_DSS_DES_192_CBC3_SHA
,
372 SSL3_CK_DH_DSS_DES_192_CBC3_SHA
,
378 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
379 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
386 0, /* not implemented (non-ephemeral DH) */
387 SSL3_TXT_DH_RSA_DES_40_CBC_SHA
,
388 SSL3_CK_DH_RSA_DES_40_CBC_SHA
,
394 SSL_EXPORT
|SSL_EXP40
,
395 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
402 0, /* not implemented (non-ephemeral DH) */
403 SSL3_TXT_DH_RSA_DES_64_CBC_SHA
,
404 SSL3_CK_DH_RSA_DES_64_CBC_SHA
,
411 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
418 0, /* not implemented (non-ephemeral DH) */
419 SSL3_TXT_DH_RSA_DES_192_CBC3_SHA
,
420 SSL3_CK_DH_RSA_DES_192_CBC3_SHA
,
426 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
427 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
432 /* The Ephemeral DH ciphers */
436 SSL3_TXT_EDH_DSS_DES_40_CBC_SHA
,
437 SSL3_CK_EDH_DSS_DES_40_CBC_SHA
,
443 SSL_EXPORT
|SSL_EXP40
,
444 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
452 SSL3_TXT_EDH_DSS_DES_64_CBC_SHA
,
453 SSL3_CK_EDH_DSS_DES_64_CBC_SHA
,
460 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
468 SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA
,
469 SSL3_CK_EDH_DSS_DES_192_CBC3_SHA
,
475 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
476 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
484 SSL3_TXT_EDH_RSA_DES_40_CBC_SHA
,
485 SSL3_CK_EDH_RSA_DES_40_CBC_SHA
,
491 SSL_EXPORT
|SSL_EXP40
,
492 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
500 SSL3_TXT_EDH_RSA_DES_64_CBC_SHA
,
501 SSL3_CK_EDH_RSA_DES_64_CBC_SHA
,
508 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
516 SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA
,
517 SSL3_CK_EDH_RSA_DES_192_CBC3_SHA
,
523 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
524 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
532 SSL3_TXT_ADH_RC4_40_MD5
,
533 SSL3_CK_ADH_RC4_40_MD5
,
539 SSL_EXPORT
|SSL_EXP40
,
540 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
548 SSL3_TXT_ADH_RC4_128_MD5
,
549 SSL3_CK_ADH_RC4_128_MD5
,
555 SSL_NOT_EXP
|SSL_MEDIUM
,
556 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
564 SSL3_TXT_ADH_DES_40_CBC_SHA
,
565 SSL3_CK_ADH_DES_40_CBC_SHA
,
571 SSL_EXPORT
|SSL_EXP40
,
572 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
580 SSL3_TXT_ADH_DES_64_CBC_SHA
,
581 SSL3_CK_ADH_DES_64_CBC_SHA
,
588 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
596 SSL3_TXT_ADH_DES_192_CBC_SHA
,
597 SSL3_CK_ADH_DES_192_CBC_SHA
,
603 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
604 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
609 /* Fortezza ciphersuite from SSL 3.0 spec */
614 SSL3_TXT_FZA_DMS_NULL_SHA
,
615 SSL3_CK_FZA_DMS_NULL_SHA
,
621 SSL_NOT_EXP
|SSL_STRONG_NONE
,
622 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
630 SSL3_TXT_FZA_DMS_FZA_SHA
,
631 SSL3_CK_FZA_DMS_FZA_SHA
,
637 SSL_NOT_EXP
|SSL_STRONG_NONE
,
638 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
646 SSL3_TXT_FZA_DMS_RC4_SHA
,
647 SSL3_CK_FZA_DMS_RC4_SHA
,
653 SSL_NOT_EXP
|SSL_MEDIUM
,
654 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
660 #ifndef OPENSSL_NO_KRB5
661 /* The Kerberos ciphers*/
665 SSL3_TXT_KRB5_DES_64_CBC_SHA
,
666 SSL3_CK_KRB5_DES_64_CBC_SHA
,
673 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
681 SSL3_TXT_KRB5_DES_192_CBC3_SHA
,
682 SSL3_CK_KRB5_DES_192_CBC3_SHA
,
688 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
689 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
697 SSL3_TXT_KRB5_RC4_128_SHA
,
698 SSL3_CK_KRB5_RC4_128_SHA
,
704 SSL_NOT_EXP
|SSL_MEDIUM
,
705 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
713 SSL3_TXT_KRB5_IDEA_128_CBC_SHA
,
714 SSL3_CK_KRB5_IDEA_128_CBC_SHA
,
720 SSL_NOT_EXP
|SSL_MEDIUM
,
721 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
729 SSL3_TXT_KRB5_DES_64_CBC_MD5
,
730 SSL3_CK_KRB5_DES_64_CBC_MD5
,
737 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
745 SSL3_TXT_KRB5_DES_192_CBC3_MD5
,
746 SSL3_CK_KRB5_DES_192_CBC3_MD5
,
752 SSL_NOT_EXP
|SSL_HIGH
,
753 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
761 SSL3_TXT_KRB5_RC4_128_MD5
,
762 SSL3_CK_KRB5_RC4_128_MD5
,
768 SSL_NOT_EXP
|SSL_MEDIUM
,
769 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
777 SSL3_TXT_KRB5_IDEA_128_CBC_MD5
,
778 SSL3_CK_KRB5_IDEA_128_CBC_MD5
,
784 SSL_NOT_EXP
|SSL_MEDIUM
,
785 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
793 SSL3_TXT_KRB5_DES_40_CBC_SHA
,
794 SSL3_CK_KRB5_DES_40_CBC_SHA
,
800 SSL_EXPORT
|SSL_EXP40
,
801 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
809 SSL3_TXT_KRB5_RC2_40_CBC_SHA
,
810 SSL3_CK_KRB5_RC2_40_CBC_SHA
,
816 SSL_EXPORT
|SSL_EXP40
,
817 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
825 SSL3_TXT_KRB5_RC4_40_SHA
,
826 SSL3_CK_KRB5_RC4_40_SHA
,
832 SSL_EXPORT
|SSL_EXP40
,
833 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
841 SSL3_TXT_KRB5_DES_40_CBC_MD5
,
842 SSL3_CK_KRB5_DES_40_CBC_MD5
,
848 SSL_EXPORT
|SSL_EXP40
,
849 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
857 SSL3_TXT_KRB5_RC2_40_CBC_MD5
,
858 SSL3_CK_KRB5_RC2_40_CBC_MD5
,
864 SSL_EXPORT
|SSL_EXP40
,
865 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
873 SSL3_TXT_KRB5_RC4_40_MD5
,
874 SSL3_CK_KRB5_RC4_40_MD5
,
880 SSL_EXPORT
|SSL_EXP40
,
881 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
885 #endif /* OPENSSL_NO_KRB5 */
887 /* New AES ciphersuites */
891 TLS1_TXT_RSA_WITH_AES_128_SHA
,
892 TLS1_CK_RSA_WITH_AES_128_SHA
,
898 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
899 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
906 TLS1_TXT_DH_DSS_WITH_AES_128_SHA
,
907 TLS1_CK_DH_DSS_WITH_AES_128_SHA
,
913 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
914 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
921 TLS1_TXT_DH_RSA_WITH_AES_128_SHA
,
922 TLS1_CK_DH_RSA_WITH_AES_128_SHA
,
928 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
929 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
936 TLS1_TXT_DHE_DSS_WITH_AES_128_SHA
,
937 TLS1_CK_DHE_DSS_WITH_AES_128_SHA
,
943 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
944 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
951 TLS1_TXT_DHE_RSA_WITH_AES_128_SHA
,
952 TLS1_CK_DHE_RSA_WITH_AES_128_SHA
,
958 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
959 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
966 TLS1_TXT_ADH_WITH_AES_128_SHA
,
967 TLS1_CK_ADH_WITH_AES_128_SHA
,
973 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
974 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
982 TLS1_TXT_RSA_WITH_AES_256_SHA
,
983 TLS1_CK_RSA_WITH_AES_256_SHA
,
989 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
990 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
997 TLS1_TXT_DH_DSS_WITH_AES_256_SHA
,
998 TLS1_CK_DH_DSS_WITH_AES_256_SHA
,
1004 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
1005 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1012 0, /* not implemented (non-ephemeral DH) */
1013 TLS1_TXT_DH_RSA_WITH_AES_256_SHA
,
1014 TLS1_CK_DH_RSA_WITH_AES_256_SHA
,
1020 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
1021 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1029 TLS1_TXT_DHE_DSS_WITH_AES_256_SHA
,
1030 TLS1_CK_DHE_DSS_WITH_AES_256_SHA
,
1036 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
1037 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1045 TLS1_TXT_DHE_RSA_WITH_AES_256_SHA
,
1046 TLS1_CK_DHE_RSA_WITH_AES_256_SHA
,
1052 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
1053 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1061 TLS1_TXT_ADH_WITH_AES_256_SHA
,
1062 TLS1_CK_ADH_WITH_AES_256_SHA
,
1068 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
1069 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1074 #ifndef OPENSSL_NO_CAMELLIA
1075 /* Camellia ciphersuites from RFC4132 (128-bit portion) */
1080 TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA
,
1081 TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA
,
1087 SSL_NOT_EXP
|SSL_HIGH
,
1088 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1095 0, /* not implemented (non-ephemeral DH) */
1096 TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA
,
1097 TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA
,
1103 SSL_NOT_EXP
|SSL_HIGH
,
1104 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1111 0, /* not implemented (non-ephemeral DH) */
1112 TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA
,
1113 TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA
,
1119 SSL_NOT_EXP
|SSL_HIGH
,
1120 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1128 TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA
,
1129 TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA
,
1135 SSL_NOT_EXP
|SSL_HIGH
,
1136 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1144 TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA
,
1145 TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA
,
1151 SSL_NOT_EXP
|SSL_HIGH
,
1152 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1160 TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA
,
1161 TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA
,
1167 SSL_NOT_EXP
|SSL_HIGH
,
1168 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1172 #endif /* OPENSSL_NO_CAMELLIA */
1174 #if TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES
1175 /* New TLS Export CipherSuites from expired ID */
1180 TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5
,
1181 TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5
,
1187 SSL_EXPORT
|SSL_EXP56
,
1188 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1196 TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5
,
1197 TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5
,
1203 SSL_EXPORT
|SSL_EXP56
,
1204 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1213 TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA
,
1214 TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA
,
1220 SSL_EXPORT
|SSL_EXP56
,
1221 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1229 TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA
,
1230 TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA
,
1236 SSL_EXPORT
|SSL_EXP56
,
1237 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1245 TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA
,
1246 TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA
,
1252 SSL_EXPORT
|SSL_EXP56
,
1253 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1261 TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA
,
1262 TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA
,
1268 SSL_EXPORT
|SSL_EXP56
,
1269 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1277 TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA
,
1278 TLS1_CK_DHE_DSS_WITH_RC4_128_SHA
,
1284 SSL_NOT_EXP
|SSL_MEDIUM
,
1285 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1292 "GOST94-GOST89-GOST89",
1296 SSL_eGOST2814789CNT
,
1299 SSL_NOT_EXP
|SSL_HIGH
,
1300 SSL_HANDSHAKE_MAC_GOST94
|TLS1_PRF_GOST94
|TLS1_STREAM_MAC
,
1306 "GOST2001-GOST89-GOST89",
1310 SSL_eGOST2814789CNT
,
1313 SSL_NOT_EXP
|SSL_HIGH
,
1314 SSL_HANDSHAKE_MAC_GOST94
|TLS1_PRF_GOST94
|TLS1_STREAM_MAC
,
1320 "GOST94-NULL-GOST94",
1327 SSL_NOT_EXP
|SSL_STRONG_NONE
,
1328 SSL_HANDSHAKE_MAC_GOST94
|TLS1_PRF_GOST94
,
1334 "GOST2001-NULL-GOST94",
1341 SSL_NOT_EXP
|SSL_STRONG_NONE
,
1342 SSL_HANDSHAKE_MAC_GOST94
|TLS1_PRF_GOST94
,
1347 #ifndef OPENSSL_NO_CAMELLIA
1348 /* Camellia ciphersuites from RFC4132 (256-bit portion) */
1353 TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA
,
1354 TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA
,
1360 SSL_NOT_EXP
|SSL_HIGH
,
1361 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1367 0, /* not implemented (non-ephemeral DH) */
1368 TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA
,
1369 TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA
,
1375 SSL_NOT_EXP
|SSL_HIGH
,
1376 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1383 0, /* not implemented (non-ephemeral DH) */
1384 TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA
,
1385 TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA
,
1391 SSL_NOT_EXP
|SSL_HIGH
,
1392 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1400 TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA
,
1401 TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA
,
1407 SSL_NOT_EXP
|SSL_HIGH
,
1408 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1416 TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA
,
1417 TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA
,
1423 SSL_NOT_EXP
|SSL_HIGH
,
1424 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1432 TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA
,
1433 TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA
,
1439 SSL_NOT_EXP
|SSL_HIGH
,
1440 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1444 #endif /* OPENSSL_NO_CAMELLIA */
1446 #ifndef OPENSSL_NO_PSK
1450 TLS1_TXT_PSK_WITH_RC4_128_SHA
,
1451 TLS1_CK_PSK_WITH_RC4_128_SHA
,
1457 SSL_NOT_EXP
|SSL_MEDIUM
,
1458 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1466 TLS1_TXT_PSK_WITH_3DES_EDE_CBC_SHA
,
1467 TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA
,
1473 SSL_NOT_EXP
|SSL_HIGH
,
1474 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1482 TLS1_TXT_PSK_WITH_AES_128_CBC_SHA
,
1483 TLS1_CK_PSK_WITH_AES_128_CBC_SHA
,
1489 SSL_NOT_EXP
|SSL_HIGH
,
1490 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1498 TLS1_TXT_PSK_WITH_AES_256_CBC_SHA
,
1499 TLS1_CK_PSK_WITH_AES_256_CBC_SHA
,
1505 SSL_NOT_EXP
|SSL_HIGH
,
1506 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1510 #endif /* OPENSSL_NO_PSK */
1512 #ifndef OPENSSL_NO_SEED
1513 /* SEED ciphersuites from RFC4162 */
1518 TLS1_TXT_RSA_WITH_SEED_SHA
,
1519 TLS1_CK_RSA_WITH_SEED_SHA
,
1525 SSL_NOT_EXP
|SSL_MEDIUM
,
1526 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1533 0, /* not implemented (non-ephemeral DH) */
1534 TLS1_TXT_DH_DSS_WITH_SEED_SHA
,
1535 TLS1_CK_DH_DSS_WITH_SEED_SHA
,
1541 SSL_NOT_EXP
|SSL_MEDIUM
,
1542 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1549 0, /* not implemented (non-ephemeral DH) */
1550 TLS1_TXT_DH_RSA_WITH_SEED_SHA
,
1551 TLS1_CK_DH_RSA_WITH_SEED_SHA
,
1557 SSL_NOT_EXP
|SSL_MEDIUM
,
1558 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1566 TLS1_TXT_DHE_DSS_WITH_SEED_SHA
,
1567 TLS1_CK_DHE_DSS_WITH_SEED_SHA
,
1573 SSL_NOT_EXP
|SSL_MEDIUM
,
1574 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1582 TLS1_TXT_DHE_RSA_WITH_SEED_SHA
,
1583 TLS1_CK_DHE_RSA_WITH_SEED_SHA
,
1589 SSL_NOT_EXP
|SSL_MEDIUM
,
1590 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1598 TLS1_TXT_ADH_WITH_SEED_SHA
,
1599 TLS1_CK_ADH_WITH_SEED_SHA
,
1605 SSL_NOT_EXP
|SSL_MEDIUM
,
1606 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1611 #endif /* OPENSSL_NO_SEED */
1613 #ifndef OPENSSL_NO_ECDH
1617 TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA
,
1618 TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA
,
1624 SSL_NOT_EXP
|SSL_STRONG_NONE
,
1625 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1633 TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA
,
1634 TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA
,
1640 SSL_NOT_EXP
|SSL_MEDIUM
,
1641 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1649 TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA
,
1650 TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA
,
1656 SSL_NOT_EXP
|SSL_HIGH
,
1657 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1665 TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA
,
1666 TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA
,
1672 SSL_NOT_EXP
|SSL_HIGH
,
1673 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1681 TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA
,
1682 TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA
,
1688 SSL_NOT_EXP
|SSL_HIGH
,
1689 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1697 TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA
,
1698 TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA
,
1704 SSL_NOT_EXP
|SSL_STRONG_NONE
,
1705 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1713 TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA
,
1714 TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA
,
1720 SSL_NOT_EXP
|SSL_MEDIUM
,
1721 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1729 TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA
,
1730 TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA
,
1736 SSL_NOT_EXP
|SSL_HIGH
,
1737 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1745 TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
,
1746 TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
,
1752 SSL_NOT_EXP
|SSL_HIGH
,
1753 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1761 TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
,
1762 TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
,
1768 SSL_NOT_EXP
|SSL_HIGH
,
1769 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1777 TLS1_TXT_ECDH_RSA_WITH_NULL_SHA
,
1778 TLS1_CK_ECDH_RSA_WITH_NULL_SHA
,
1784 SSL_NOT_EXP
|SSL_STRONG_NONE
,
1785 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1793 TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA
,
1794 TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA
,
1800 SSL_NOT_EXP
|SSL_MEDIUM
,
1801 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1809 TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA
,
1810 TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA
,
1816 SSL_NOT_EXP
|SSL_HIGH
,
1817 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1825 TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA
,
1826 TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA
,
1832 SSL_NOT_EXP
|SSL_HIGH
,
1833 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1841 TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA
,
1842 TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA
,
1848 SSL_NOT_EXP
|SSL_HIGH
,
1849 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1857 TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA
,
1858 TLS1_CK_ECDHE_RSA_WITH_NULL_SHA
,
1864 SSL_NOT_EXP
|SSL_STRONG_NONE
,
1865 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1873 TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA
,
1874 TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA
,
1880 SSL_NOT_EXP
|SSL_MEDIUM
,
1881 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1889 TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA
,
1890 TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA
,
1896 SSL_NOT_EXP
|SSL_HIGH
,
1897 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1905 TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA
,
1906 TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA
,
1912 SSL_NOT_EXP
|SSL_HIGH
,
1913 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1921 TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA
,
1922 TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA
,
1928 SSL_NOT_EXP
|SSL_HIGH
,
1929 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1937 TLS1_TXT_ECDH_anon_WITH_NULL_SHA
,
1938 TLS1_CK_ECDH_anon_WITH_NULL_SHA
,
1944 SSL_NOT_EXP
|SSL_STRONG_NONE
,
1945 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1953 TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA
,
1954 TLS1_CK_ECDH_anon_WITH_RC4_128_SHA
,
1960 SSL_NOT_EXP
|SSL_MEDIUM
,
1961 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1969 TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA
,
1970 TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA
,
1976 SSL_NOT_EXP
|SSL_HIGH
,
1977 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
1985 TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA
,
1986 TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA
,
1992 SSL_NOT_EXP
|SSL_HIGH
,
1993 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
2001 TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA
,
2002 TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA
,
2008 SSL_NOT_EXP
|SSL_HIGH
,
2009 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
2013 #endif /* OPENSSL_NO_ECDH */
2015 #ifdef TEMP_GOST_TLS
2023 SSL_eGOST2814789CNT
,
2026 SSL_NOT_EXP
|SSL_HIGH
,
2027 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
2037 SSL_eGOST2814789CNT
,
2040 SSL_NOT_EXP
|SSL_HIGH
,
2041 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
2051 SSL_eGOST2814789CNT
,
2054 SSL_NOT_EXP
|SSL_HIGH
,
2055 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
,
2061 "GOST-GOST89STREAM",
2065 SSL_eGOST2814789CNT
,
2068 SSL_NOT_EXP
|SSL_HIGH
,
2069 SSL_HANDSHAKE_MAC_DEFAULT
|TLS1_PRF
|TLS1_STREAM_MAC
,
2078 SSL3_ENC_METHOD SSLv3_enc_data
={
2081 ssl3_setup_key_block
,
2082 ssl3_generate_master_secret
,
2083 ssl3_change_cipher_state
,
2084 ssl3_final_finish_mac
,
2085 MD5_DIGEST_LENGTH
+SHA_DIGEST_LENGTH
,
2086 ssl3_cert_verify_mac
,
2087 SSL3_MD_CLIENT_FINISHED_CONST
,4,
2088 SSL3_MD_SERVER_FINISHED_CONST
,4,
2092 long ssl3_default_timeout(void)
2094 /* 2 hours, the 24 hours mentioned in the SSLv3 spec
2095 * is way too long for http, the cache would over fill */
2099 int ssl3_num_ciphers(void)
2101 return(SSL3_NUM_CIPHERS
);
2104 const SSL_CIPHER
*ssl3_get_cipher(unsigned int u
)
2106 if (u
< SSL3_NUM_CIPHERS
)
2107 return(&(ssl3_ciphers
[SSL3_NUM_CIPHERS
-1-u
]));
2112 int ssl3_pending(const SSL
*s
)
2114 if (s
->rstate
== SSL_ST_READ_BODY
)
2117 return (s
->s3
->rrec
.type
== SSL3_RT_APPLICATION_DATA
) ? s
->s3
->rrec
.length
: 0;
2120 int ssl3_new(SSL
*s
)
2124 if ((s3
=OPENSSL_malloc(sizeof *s3
)) == NULL
) goto err
;
2125 memset(s3
,0,sizeof *s3
);
2126 memset(s3
->rrec
.seq_num
,0,sizeof(s3
->rrec
.seq_num
));
2127 memset(s3
->wrec
.seq_num
,0,sizeof(s3
->wrec
.seq_num
));
2131 s
->method
->ssl_clear(s
);
2137 void ssl3_free(SSL
*s
)
2142 #ifdef TLSEXT_TYPE_opaque_prf_input
2143 if (s
->s3
->client_opaque_prf_input
!= NULL
)
2144 OPENSSL_free(s
->s3
->client_opaque_prf_input
);
2145 if (s
->s3
->server_opaque_prf_input
!= NULL
)
2146 OPENSSL_free(s
->s3
->server_opaque_prf_input
);
2149 ssl3_cleanup_key_block(s
);
2150 if (s
->s3
->rbuf
.buf
!= NULL
)
2151 ssl3_release_read_buffer(s
);
2152 if (s
->s3
->wbuf
.buf
!= NULL
)
2153 ssl3_release_write_buffer(s
);
2154 if (s
->s3
->rrec
.comp
!= NULL
)
2155 OPENSSL_free(s
->s3
->rrec
.comp
);
2156 #ifndef OPENSSL_NO_DH
2157 if (s
->s3
->tmp
.dh
!= NULL
)
2158 DH_free(s
->s3
->tmp
.dh
);
2160 #ifndef OPENSSL_NO_ECDH
2161 if (s
->s3
->tmp
.ecdh
!= NULL
)
2162 EC_KEY_free(s
->s3
->tmp
.ecdh
);
2165 if (s
->s3
->tmp
.ca_names
!= NULL
)
2166 sk_X509_NAME_pop_free(s
->s3
->tmp
.ca_names
,X509_NAME_free
);
2167 if (s
->s3
->handshake_buffer
) {
2168 BIO_free(s
->s3
->handshake_buffer
);
2170 if (s
->s3
->handshake_dgst
) ssl3_free_digest_list(s
);
2171 OPENSSL_cleanse(s
->s3
,sizeof *s
->s3
);
2172 OPENSSL_free(s
->s3
);
2176 void ssl3_clear(SSL
*s
)
2178 unsigned char *rp
,*wp
;
2181 #ifdef TLSEXT_TYPE_opaque_prf_input
2182 if (s
->s3
->client_opaque_prf_input
!= NULL
)
2183 OPENSSL_free(s
->s3
->client_opaque_prf_input
);
2184 s
->s3
->client_opaque_prf_input
= NULL
;
2185 if (s
->s3
->server_opaque_prf_input
!= NULL
)
2186 OPENSSL_free(s
->s3
->server_opaque_prf_input
);
2187 s
->s3
->server_opaque_prf_input
= NULL
;
2190 ssl3_cleanup_key_block(s
);
2191 if (s
->s3
->tmp
.ca_names
!= NULL
)
2192 sk_X509_NAME_pop_free(s
->s3
->tmp
.ca_names
,X509_NAME_free
);
2194 if (s
->s3
->rrec
.comp
!= NULL
)
2196 OPENSSL_free(s
->s3
->rrec
.comp
);
2197 s
->s3
->rrec
.comp
=NULL
;
2199 #ifndef OPENSSL_NO_DH
2200 if (s
->s3
->tmp
.dh
!= NULL
)
2201 DH_free(s
->s3
->tmp
.dh
);
2203 #ifndef OPENSSL_NO_ECDH
2204 if (s
->s3
->tmp
.ecdh
!= NULL
)
2205 EC_KEY_free(s
->s3
->tmp
.ecdh
);
2208 rp
= s
->s3
->rbuf
.buf
;
2209 wp
= s
->s3
->wbuf
.buf
;
2210 rlen
= s
->s3
->rbuf
.len
;
2211 wlen
= s
->s3
->wbuf
.len
;
2212 if (s
->s3
->handshake_buffer
) {
2213 BIO_free(s
->s3
->handshake_buffer
);
2214 s
->s3
->handshake_buffer
= NULL
;
2216 if (s
->s3
->handshake_dgst
) {
2217 ssl3_free_digest_list(s
);
2219 memset(s
->s3
,0,sizeof *s
->s3
);
2220 s
->s3
->rbuf
.buf
= rp
;
2221 s
->s3
->wbuf
.buf
= wp
;
2222 s
->s3
->rbuf
.len
= rlen
;
2223 s
->s3
->wbuf
.len
= wlen
;
2225 ssl_free_wbio_buffer(s
);
2228 s
->s3
->renegotiate
=0;
2229 s
->s3
->total_renegotiations
=0;
2230 s
->s3
->num_renegotiations
=0;
2231 s
->s3
->in_read_app_data
=0;
2232 s
->version
=SSL3_VERSION
;
2235 long ssl3_ctrl(SSL
*s
, int cmd
, long larg
, void *parg
)
2239 #if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA)
2241 #ifndef OPENSSL_NO_RSA
2242 cmd
== SSL_CTRL_SET_TMP_RSA
||
2243 cmd
== SSL_CTRL_SET_TMP_RSA_CB
||
2245 #ifndef OPENSSL_NO_DSA
2246 cmd
== SSL_CTRL_SET_TMP_DH
||
2247 cmd
== SSL_CTRL_SET_TMP_DH_CB
||
2251 if (!ssl_cert_inst(&s
->cert
))
2253 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_MALLOC_FAILURE
);
2261 case SSL_CTRL_GET_SESSION_REUSED
:
2264 case SSL_CTRL_GET_CLIENT_CERT_REQUEST
:
2266 case SSL_CTRL_GET_NUM_RENEGOTIATIONS
:
2267 ret
=s
->s3
->num_renegotiations
;
2269 case SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS
:
2270 ret
=s
->s3
->num_renegotiations
;
2271 s
->s3
->num_renegotiations
=0;
2273 case SSL_CTRL_GET_TOTAL_RENEGOTIATIONS
:
2274 ret
=s
->s3
->total_renegotiations
;
2276 case SSL_CTRL_GET_FLAGS
:
2277 ret
=(int)(s
->s3
->flags
);
2279 #ifndef OPENSSL_NO_RSA
2280 case SSL_CTRL_NEED_TMP_RSA
:
2281 if ((s
->cert
!= NULL
) && (s
->cert
->rsa_tmp
== NULL
) &&
2282 ((s
->cert
->pkeys
[SSL_PKEY_RSA_ENC
].privatekey
== NULL
) ||
2283 (EVP_PKEY_size(s
->cert
->pkeys
[SSL_PKEY_RSA_ENC
].privatekey
) > (512/8))))
2286 case SSL_CTRL_SET_TMP_RSA
:
2288 RSA
*rsa
= (RSA
*)parg
;
2291 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_PASSED_NULL_PARAMETER
);
2294 if ((rsa
= RSAPrivateKey_dup(rsa
)) == NULL
)
2296 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_RSA_LIB
);
2299 if (s
->cert
->rsa_tmp
!= NULL
)
2300 RSA_free(s
->cert
->rsa_tmp
);
2301 s
->cert
->rsa_tmp
= rsa
;
2305 case SSL_CTRL_SET_TMP_RSA_CB
:
2307 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED
);
2312 #ifndef OPENSSL_NO_DH
2313 case SSL_CTRL_SET_TMP_DH
:
2315 DH
*dh
= (DH
*)parg
;
2318 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_PASSED_NULL_PARAMETER
);
2321 if ((dh
= DHparams_dup(dh
)) == NULL
)
2323 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_DH_LIB
);
2326 if (!(s
->options
& SSL_OP_SINGLE_DH_USE
))
2328 if (!DH_generate_key(dh
))
2331 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_DH_LIB
);
2335 if (s
->cert
->dh_tmp
!= NULL
)
2336 DH_free(s
->cert
->dh_tmp
);
2337 s
->cert
->dh_tmp
= dh
;
2341 case SSL_CTRL_SET_TMP_DH_CB
:
2343 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED
);
2348 #ifndef OPENSSL_NO_ECDH
2349 case SSL_CTRL_SET_TMP_ECDH
:
2351 EC_KEY
*ecdh
= NULL
;
2355 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_PASSED_NULL_PARAMETER
);
2358 if (!EC_KEY_up_ref((EC_KEY
*)parg
))
2360 SSLerr(SSL_F_SSL3_CTRL
,ERR_R_ECDH_LIB
);
2363 ecdh
= (EC_KEY
*)parg
;
2364 if (!(s
->options
& SSL_OP_SINGLE_ECDH_USE
))
2366 if (!EC_KEY_generate_key(ecdh
))
2369 SSLerr(SSL_F_SSL3_CTRL
,ERR_R_ECDH_LIB
);
2373 if (s
->cert
->ecdh_tmp
!= NULL
)
2374 EC_KEY_free(s
->cert
->ecdh_tmp
);
2375 s
->cert
->ecdh_tmp
= ecdh
;
2379 case SSL_CTRL_SET_TMP_ECDH_CB
:
2381 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED
);
2385 #endif /* !OPENSSL_NO_ECDH */
2386 #ifndef OPENSSL_NO_TLSEXT
2387 case SSL_CTRL_SET_TLSEXT_HOSTNAME
:
2388 if (larg
== TLSEXT_NAMETYPE_host_name
)
2390 if (s
->tlsext_hostname
!= NULL
)
2391 OPENSSL_free(s
->tlsext_hostname
);
2392 s
->tlsext_hostname
= NULL
;
2397 if (strlen((char *)parg
) > TLSEXT_MAXLEN_host_name
)
2399 SSLerr(SSL_F_SSL3_CTRL
, SSL_R_SSL3_EXT_INVALID_SERVERNAME
);
2402 if ((s
->tlsext_hostname
= BUF_strdup((char *)parg
)) == NULL
)
2404 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_INTERNAL_ERROR
);
2410 SSLerr(SSL_F_SSL3_CTRL
, SSL_R_SSL3_EXT_INVALID_SERVERNAME_TYPE
);
2414 case SSL_CTRL_SET_TLSEXT_DEBUG_ARG
:
2415 s
->tlsext_debug_arg
=parg
;
2419 #ifdef TLSEXT_TYPE_opaque_prf_input
2420 case SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT
:
2421 if (larg
> 12288) /* actual internal limit is 2^16 for the complete hello message
2422 * (including the cert chain and everything) */
2424 SSLerr(SSL_F_SSL3_CTRL
, SSL_R_OPAQUE_PRF_INPUT_TOO_LONG
);
2427 if (s
->tlsext_opaque_prf_input
!= NULL
)
2428 OPENSSL_free(s
->tlsext_opaque_prf_input
);
2429 if ((size_t)larg
== 0)
2430 s
->tlsext_opaque_prf_input
= OPENSSL_malloc(1); /* dummy byte just to get non-NULL */
2432 s
->tlsext_opaque_prf_input
= BUF_memdup(parg
, (size_t)larg
);
2433 if (s
->tlsext_opaque_prf_input
!= NULL
)
2435 s
->tlsext_opaque_prf_input_len
= (size_t)larg
;
2439 s
->tlsext_opaque_prf_input_len
= 0;
2443 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE
:
2444 s
->tlsext_status_type
=larg
;
2448 case SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS
:
2449 *(STACK_OF(X509_EXTENSION
) **)parg
= s
->tlsext_ocsp_exts
;
2453 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS
:
2454 s
->tlsext_ocsp_exts
= parg
;
2458 case SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS
:
2459 *(STACK_OF(OCSP_RESPID
) **)parg
= s
->tlsext_ocsp_ids
;
2463 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS
:
2464 s
->tlsext_ocsp_ids
= parg
;
2468 case SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP
:
2469 *(unsigned char **)parg
= s
->tlsext_ocsp_resp
;
2470 return s
->tlsext_ocsp_resplen
;
2472 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP
:
2473 if (s
->tlsext_ocsp_resp
)
2474 OPENSSL_free(s
->tlsext_ocsp_resp
);
2475 s
->tlsext_ocsp_resp
= parg
;
2476 s
->tlsext_ocsp_resplen
= larg
;
2480 #endif /* !OPENSSL_NO_TLSEXT */
2487 long ssl3_callback_ctrl(SSL
*s
, int cmd
, void (*fp
)(void))
2491 #if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA)
2493 #ifndef OPENSSL_NO_RSA
2494 cmd
== SSL_CTRL_SET_TMP_RSA_CB
||
2496 #ifndef OPENSSL_NO_DSA
2497 cmd
== SSL_CTRL_SET_TMP_DH_CB
||
2501 if (!ssl_cert_inst(&s
->cert
))
2503 SSLerr(SSL_F_SSL3_CALLBACK_CTRL
, ERR_R_MALLOC_FAILURE
);
2511 #ifndef OPENSSL_NO_RSA
2512 case SSL_CTRL_SET_TMP_RSA_CB
:
2514 s
->cert
->rsa_tmp_cb
= (RSA
*(*)(SSL
*, int, int))fp
;
2518 #ifndef OPENSSL_NO_DH
2519 case SSL_CTRL_SET_TMP_DH_CB
:
2521 s
->cert
->dh_tmp_cb
= (DH
*(*)(SSL
*, int, int))fp
;
2525 #ifndef OPENSSL_NO_ECDH
2526 case SSL_CTRL_SET_TMP_ECDH_CB
:
2528 s
->cert
->ecdh_tmp_cb
= (EC_KEY
*(*)(SSL
*, int, int))fp
;
2532 #ifndef OPENSSL_NO_TLSEXT
2533 case SSL_CTRL_SET_TLSEXT_DEBUG_CB
:
2534 s
->tlsext_debug_cb
=(void (*)(SSL
*,int ,int,
2535 unsigned char *, int, void *))fp
;
2544 long ssl3_ctx_ctrl(SSL_CTX
*ctx
, int cmd
, long larg
, void *parg
)
2552 #ifndef OPENSSL_NO_RSA
2553 case SSL_CTRL_NEED_TMP_RSA
:
2554 if ( (cert
->rsa_tmp
== NULL
) &&
2555 ((cert
->pkeys
[SSL_PKEY_RSA_ENC
].privatekey
== NULL
) ||
2556 (EVP_PKEY_size(cert
->pkeys
[SSL_PKEY_RSA_ENC
].privatekey
) > (512/8)))
2562 case SSL_CTRL_SET_TMP_RSA
:
2573 if ((rsa
=RSAPrivateKey_dup(rsa
)) == NULL
)
2578 SSLerr(SSL_F_SSL3_CTX_CTRL
,ERR_R_RSA_LIB
);
2583 if (cert
->rsa_tmp
!= NULL
)
2584 RSA_free(cert
->rsa_tmp
);
2590 case SSL_CTRL_SET_TMP_RSA_CB
:
2592 SSLerr(SSL_F_SSL3_CTX_CTRL
, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED
);
2597 #ifndef OPENSSL_NO_DH
2598 case SSL_CTRL_SET_TMP_DH
:
2603 if ((new=DHparams_dup(dh
)) == NULL
)
2605 SSLerr(SSL_F_SSL3_CTX_CTRL
,ERR_R_DH_LIB
);
2608 if (!(ctx
->options
& SSL_OP_SINGLE_DH_USE
))
2610 if (!DH_generate_key(new))
2612 SSLerr(SSL_F_SSL3_CTX_CTRL
,ERR_R_DH_LIB
);
2617 if (cert
->dh_tmp
!= NULL
)
2618 DH_free(cert
->dh_tmp
);
2623 case SSL_CTRL_SET_TMP_DH_CB
:
2625 SSLerr(SSL_F_SSL3_CTX_CTRL
, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED
);
2630 #ifndef OPENSSL_NO_ECDH
2631 case SSL_CTRL_SET_TMP_ECDH
:
2633 EC_KEY
*ecdh
= NULL
;
2637 SSLerr(SSL_F_SSL3_CTX_CTRL
,ERR_R_ECDH_LIB
);
2640 ecdh
= EC_KEY_dup((EC_KEY
*)parg
);
2643 SSLerr(SSL_F_SSL3_CTX_CTRL
,ERR_R_EC_LIB
);
2646 if (!(ctx
->options
& SSL_OP_SINGLE_ECDH_USE
))
2648 if (!EC_KEY_generate_key(ecdh
))
2651 SSLerr(SSL_F_SSL3_CTX_CTRL
,ERR_R_ECDH_LIB
);
2656 if (cert
->ecdh_tmp
!= NULL
)
2658 EC_KEY_free(cert
->ecdh_tmp
);
2660 cert
->ecdh_tmp
= ecdh
;
2664 case SSL_CTRL_SET_TMP_ECDH_CB
:
2666 SSLerr(SSL_F_SSL3_CTX_CTRL
, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED
);
2670 #endif /* !OPENSSL_NO_ECDH */
2671 #ifndef OPENSSL_NO_TLSEXT
2672 case SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG
:
2673 ctx
->tlsext_servername_arg
=parg
;
2675 case SSL_CTRL_SET_TLSEXT_TICKET_KEYS
:
2676 case SSL_CTRL_GET_TLSEXT_TICKET_KEYS
:
2678 unsigned char *keys
= parg
;
2683 SSLerr(SSL_F_SSL3_CTX_CTRL
, SSL_R_INVALID_TICKET_KEYS_LENGTH
);
2686 if (cmd
== SSL_CTRL_SET_TLSEXT_TICKET_KEYS
)
2688 memcpy(ctx
->tlsext_tick_key_name
, keys
, 16);
2689 memcpy(ctx
->tlsext_tick_hmac_key
, keys
+ 16, 16);
2690 memcpy(ctx
->tlsext_tick_aes_key
, keys
+ 32, 16);
2694 memcpy(keys
, ctx
->tlsext_tick_key_name
, 16);
2695 memcpy(keys
+ 16, ctx
->tlsext_tick_hmac_key
, 16);
2696 memcpy(keys
+ 32, ctx
->tlsext_tick_aes_key
, 16);
2701 #ifdef TLSEXT_TYPE_opaque_prf_input
2702 case SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB_ARG
:
2703 ctx
->tlsext_opaque_prf_input_callback_arg
= parg
;
2707 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG
:
2708 ctx
->tlsext_status_arg
=parg
;
2712 #endif /* !OPENSSL_NO_TLSEXT */
2714 /* A Thawte special :-) */
2715 case SSL_CTRL_EXTRA_CHAIN_CERT
:
2716 if (ctx
->extra_certs
== NULL
)
2718 if ((ctx
->extra_certs
=sk_X509_new_null()) == NULL
)
2721 sk_X509_push(ctx
->extra_certs
,(X509
*)parg
);
2730 long ssl3_ctx_callback_ctrl(SSL_CTX
*ctx
, int cmd
, void (*fp
)(void))
2738 #ifndef OPENSSL_NO_RSA
2739 case SSL_CTRL_SET_TMP_RSA_CB
:
2741 cert
->rsa_tmp_cb
= (RSA
*(*)(SSL
*, int, int))fp
;
2745 #ifndef OPENSSL_NO_DH
2746 case SSL_CTRL_SET_TMP_DH_CB
:
2748 cert
->dh_tmp_cb
= (DH
*(*)(SSL
*, int, int))fp
;
2752 #ifndef OPENSSL_NO_ECDH
2753 case SSL_CTRL_SET_TMP_ECDH_CB
:
2755 cert
->ecdh_tmp_cb
= (EC_KEY
*(*)(SSL
*, int, int))fp
;
2759 #ifndef OPENSSL_NO_TLSEXT
2760 case SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
:
2761 ctx
->tlsext_servername_callback
=(int (*)(SSL
*,int *,void *))fp
;
2764 #ifdef TLSEXT_TYPE_opaque_prf_input
2765 case SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB
:
2766 ctx
->tlsext_opaque_prf_input_callback
= (int (*)(SSL
*,void *, size_t, void *))fp
;
2770 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB
:
2771 ctx
->tlsext_status_cb
=(int (*)(SSL
*,void *))fp
;
2774 case SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB
:
2775 ctx
->tlsext_ticket_key_cb
=(int (*)(SSL
*,unsigned char *,
2778 HMAC_CTX
*, int))fp
;
2788 /* This function needs to check if the ciphers required are actually
2790 const SSL_CIPHER
*ssl3_get_cipher_by_char(const unsigned char *p
)
2793 const SSL_CIPHER
*cp
;
2796 id
=0x03000000L
|((unsigned long)p
[0]<<8L)|(unsigned long)p
[1];
2798 cp
= OBJ_bsearch_ssl_cipher_id(&c
, ssl3_ciphers
, SSL3_NUM_CIPHERS
);
2799 if (cp
== NULL
|| cp
->valid
== 0)
2805 int ssl3_put_cipher_by_char(const SSL_CIPHER
*c
, unsigned char *p
)
2812 if ((l
& 0xff000000) != 0x03000000) return(0);
2813 p
[0]=((unsigned char)(l
>> 8L))&0xFF;
2814 p
[1]=((unsigned char)(l
))&0xFF;
2819 SSL_CIPHER
*ssl3_choose_cipher(SSL
*s
, STACK_OF(SSL_CIPHER
) *clnt
,
2820 STACK_OF(SSL_CIPHER
) *srvr
)
2822 SSL_CIPHER
*c
,*ret
=NULL
;
2823 STACK_OF(SSL_CIPHER
) *prio
, *allow
;
2825 #if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_EC)
2828 unsigned char ec_search1
= 0, ec_search2
= 0;
2831 unsigned long alg_k
,alg_a
,mask_k
,mask_a
,emask_k
,emask_a
;
2833 /* Let's see which ciphers we can support */
2837 /* Do not set the compare functions, because this may lead to a
2838 * reordering by "id". We want to keep the original ordering.
2839 * We may pay a price in performance during sk_SSL_CIPHER_find(),
2840 * but would have to pay with the price of sk_SSL_CIPHER_dup().
2842 sk_SSL_CIPHER_set_cmp_func(srvr
, ssl_cipher_ptr_id_cmp
);
2843 sk_SSL_CIPHER_set_cmp_func(clnt
, ssl_cipher_ptr_id_cmp
);
2847 printf("Server has %d from %p:\n", sk_SSL_CIPHER_num(srvr
), (void *)srvr
);
2848 for(i
=0 ; i
< sk_SSL_CIPHER_num(srvr
) ; ++i
)
2850 c
=sk_SSL_CIPHER_value(srvr
,i
);
2851 printf("%p:%s\n",(void *)c
,c
->name
);
2853 printf("Client sent %d from %p:\n", sk_SSL_CIPHER_num(clnt
), (void *)clnt
);
2854 for(i
=0 ; i
< sk_SSL_CIPHER_num(clnt
) ; ++i
)
2856 c
=sk_SSL_CIPHER_value(clnt
,i
);
2857 printf("%p:%s\n",(void *)c
,c
->name
);
2861 if (s
->options
& SSL_OP_CIPHER_SERVER_PREFERENCE
)
2872 for (i
=0; i
<sk_SSL_CIPHER_num(prio
); i
++)
2874 c
=sk_SSL_CIPHER_value(prio
,i
);
2876 ssl_set_cert_masks(cert
,c
);
2877 mask_k
= cert
->mask_k
;
2878 mask_a
= cert
->mask_a
;
2879 emask_k
= cert
->export_mask_k
;
2880 emask_a
= cert
->export_mask_a
;
2883 /* printf("ssl3_choose_cipher %d alg= %lx\n", i,c->algorithms);*/
2884 #endif /* KSSL_DEBUG */
2886 alg_k
=c
->algorithm_mkey
;
2887 alg_a
=c
->algorithm_auth
;
2889 #ifndef OPENSSL_NO_KRB5
2890 if (alg_k
& SSL_kKRB5
)
2892 if ( !kssl_keytab_is_available(s
->kssl_ctx
) )
2895 #endif /* OPENSSL_NO_KRB5 */
2896 #ifndef OPENSSL_NO_PSK
2897 /* with PSK there must be server callback set */
2898 if ((alg_k
& SSL_kPSK
) && s
->psk_server_callback
== NULL
)
2900 #endif /* OPENSSL_NO_PSK */
2902 if (SSL_C_IS_EXPORT(c
))
2904 ok
= (alg_k
& emask_k
) && (alg_a
& emask_a
);
2906 printf("%d:[%08lX:%08lX:%08lX:%08lX]%p:%s (export)\n",ok
,alg_k
,alg_a
,emask_k
,emask_a
,
2912 ok
= (alg_k
& mask_k
) && (alg_a
& mask_a
);
2914 printf("%d:[%08lX:%08lX:%08lX:%08lX]%p:%s\n",ok
,alg_k
,alg_a
,mask_k
,mask_a
,(void *)c
,
2919 #ifndef OPENSSL_NO_TLSEXT
2920 #ifndef OPENSSL_NO_EC
2922 /* if we are considering an ECC cipher suite that uses our certificate */
2923 (alg_a
& SSL_aECDSA
|| alg_a
& SSL_aECDH
)
2924 /* and we have an ECC certificate */
2925 && (s
->cert
->pkeys
[SSL_PKEY_ECC
].x509
!= NULL
)
2926 /* and the client specified a Supported Point Formats extension */
2927 && ((s
->session
->tlsext_ecpointformatlist_length
> 0) && (s
->session
->tlsext_ecpointformatlist
!= NULL
))
2928 /* and our certificate's point is compressed */
2930 (s
->cert
->pkeys
[SSL_PKEY_ECC
].x509
->cert_info
!= NULL
)
2931 && (s
->cert
->pkeys
[SSL_PKEY_ECC
].x509
->cert_info
->key
!= NULL
)
2932 && (s
->cert
->pkeys
[SSL_PKEY_ECC
].x509
->cert_info
->key
->public_key
!= NULL
)
2933 && (s
->cert
->pkeys
[SSL_PKEY_ECC
].x509
->cert_info
->key
->public_key
->data
!= NULL
)
2935 (*(s
->cert
->pkeys
[SSL_PKEY_ECC
].x509
->cert_info
->key
->public_key
->data
) == POINT_CONVERSION_COMPRESSED
)
2936 || (*(s
->cert
->pkeys
[SSL_PKEY_ECC
].x509
->cert_info
->key
->public_key
->data
) == POINT_CONVERSION_COMPRESSED
+ 1)
2942 /* if our certificate's curve is over a field type that the client does not support
2943 * then do not allow this cipher suite to be negotiated */
2945 (s
->cert
->pkeys
[SSL_PKEY_ECC
].privatekey
->pkey
.ec
!= NULL
)
2946 && (s
->cert
->pkeys
[SSL_PKEY_ECC
].privatekey
->pkey
.ec
->group
!= NULL
)
2947 && (s
->cert
->pkeys
[SSL_PKEY_ECC
].privatekey
->pkey
.ec
->group
->meth
!= NULL
)
2948 && (EC_METHOD_get_field_type(s
->cert
->pkeys
[SSL_PKEY_ECC
].privatekey
->pkey
.ec
->group
->meth
) == NID_X9_62_prime_field
)
2951 for (j
= 0; j
< s
->session
->tlsext_ecpointformatlist_length
; j
++)
2953 if (s
->session
->tlsext_ecpointformatlist
[j
] == TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime
)
2960 else if (EC_METHOD_get_field_type(s
->cert
->pkeys
[SSL_PKEY_ECC
].privatekey
->pkey
.ec
->group
->meth
) == NID_X9_62_characteristic_two_field
)
2962 for (j
= 0; j
< s
->session
->tlsext_ecpointformatlist_length
; j
++)
2964 if (s
->session
->tlsext_ecpointformatlist
[j
] == TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2
)
2974 /* if we are considering an ECC cipher suite that uses our certificate */
2975 (alg_a
& SSL_aECDSA
|| alg_a
& SSL_aECDH
)
2976 /* and we have an ECC certificate */
2977 && (s
->cert
->pkeys
[SSL_PKEY_ECC
].x509
!= NULL
)
2978 /* and the client specified an EllipticCurves extension */
2979 && ((s
->session
->tlsext_ellipticcurvelist_length
> 0) && (s
->session
->tlsext_ellipticcurvelist
!= NULL
))
2984 (s
->cert
->pkeys
[SSL_PKEY_ECC
].privatekey
->pkey
.ec
!= NULL
)
2985 && (s
->cert
->pkeys
[SSL_PKEY_ECC
].privatekey
->pkey
.ec
->group
!= NULL
)
2988 ec_nid
= EC_GROUP_get_curve_name(s
->cert
->pkeys
[SSL_PKEY_ECC
].privatekey
->pkey
.ec
->group
);
2990 && (s
->cert
->pkeys
[SSL_PKEY_ECC
].privatekey
->pkey
.ec
->group
->meth
!= NULL
)
2993 if (EC_METHOD_get_field_type(s
->cert
->pkeys
[SSL_PKEY_ECC
].privatekey
->pkey
.ec
->group
->meth
) == NID_X9_62_prime_field
)
2998 else if (EC_METHOD_get_field_type(s
->cert
->pkeys
[SSL_PKEY_ECC
].privatekey
->pkey
.ec
->group
->meth
) == NID_X9_62_characteristic_two_field
)
3007 ec_search2
= tls1_ec_nid2curve_id(ec_nid
);
3009 if ((ec_search1
!= 0) || (ec_search2
!= 0))
3011 for (j
= 0; j
< s
->session
->tlsext_ellipticcurvelist_length
/ 2; j
++)
3013 if ((s
->session
->tlsext_ellipticcurvelist
[2*j
] == ec_search1
) && (s
->session
->tlsext_ellipticcurvelist
[2*j
+1] == ec_search2
))
3024 /* if we are considering an ECC cipher suite that uses an ephemeral EC key */
3025 (alg_k
& SSL_kEECDH
)
3026 /* and we have an ephemeral EC key */
3027 && (s
->cert
->ecdh_tmp
!= NULL
)
3028 /* and the client specified an EllipticCurves extension */
3029 && ((s
->session
->tlsext_ellipticcurvelist_length
> 0) && (s
->session
->tlsext_ellipticcurvelist
!= NULL
))
3033 if (s
->cert
->ecdh_tmp
->group
!= NULL
)
3035 ec_nid
= EC_GROUP_get_curve_name(s
->cert
->ecdh_tmp
->group
);
3037 && (s
->cert
->ecdh_tmp
->group
->meth
!= NULL
)
3040 if (EC_METHOD_get_field_type(s
->cert
->ecdh_tmp
->group
->meth
) == NID_X9_62_prime_field
)
3045 else if (EC_METHOD_get_field_type(s
->cert
->ecdh_tmp
->group
->meth
) == NID_X9_62_characteristic_two_field
)
3054 ec_search2
= tls1_ec_nid2curve_id(ec_nid
);
3056 if ((ec_search1
!= 0) || (ec_search2
!= 0))
3058 for (j
= 0; j
< s
->session
->tlsext_ellipticcurvelist_length
/ 2; j
++)
3060 if ((s
->session
->tlsext_ellipticcurvelist
[2*j
] == ec_search1
) && (s
->session
->tlsext_ellipticcurvelist
[2*j
+1] == ec_search2
))
3070 #endif /* OPENSSL_NO_EC */
3071 #endif /* OPENSSL_NO_TLSEXT */
3074 ii
=sk_SSL_CIPHER_find(allow
,c
);
3077 ret
=sk_SSL_CIPHER_value(allow
,ii
);
3084 int ssl3_get_req_cert_type(SSL
*s
, unsigned char *p
)
3087 unsigned long alg_k
;
3089 alg_k
= s
->s3
->tmp
.new_cipher
->algorithm_mkey
;
3091 #ifndef OPENSSL_NO_GOST
3092 if (s
->version
>= TLS1_VERSION
)
3094 if (alg_k
& SSL_kGOST
)
3096 p
[ret
++]=TLS_CT_GOST94_SIGN
;
3097 p
[ret
++]=TLS_CT_GOST01_SIGN
;
3103 #ifndef OPENSSL_NO_DH
3104 if (alg_k
& (SSL_kDHr
|SSL_kEDH
))
3106 # ifndef OPENSSL_NO_RSA
3107 p
[ret
++]=SSL3_CT_RSA_FIXED_DH
;
3109 # ifndef OPENSSL_NO_DSA
3110 p
[ret
++]=SSL3_CT_DSS_FIXED_DH
;
3113 if ((s
->version
== SSL3_VERSION
) &&
3114 (alg_k
& (SSL_kEDH
|SSL_kDHd
|SSL_kDHr
)))
3116 # ifndef OPENSSL_NO_RSA
3117 p
[ret
++]=SSL3_CT_RSA_EPHEMERAL_DH
;
3119 # ifndef OPENSSL_NO_DSA
3120 p
[ret
++]=SSL3_CT_DSS_EPHEMERAL_DH
;
3123 #endif /* !OPENSSL_NO_DH */
3124 #ifndef OPENSSL_NO_RSA
3125 p
[ret
++]=SSL3_CT_RSA_SIGN
;
3127 #ifndef OPENSSL_NO_DSA
3128 p
[ret
++]=SSL3_CT_DSS_SIGN
;
3130 #ifndef OPENSSL_NO_ECDH
3131 if ((alg_k
& (SSL_kECDHr
|SSL_kECDHe
)) && (s
->version
>= TLS1_VERSION
))
3133 p
[ret
++]=TLS_CT_RSA_FIXED_ECDH
;
3134 p
[ret
++]=TLS_CT_ECDSA_FIXED_ECDH
;
3138 #ifndef OPENSSL_NO_ECDSA
3139 /* ECDSA certs can be used with RSA cipher suites as well
3140 * so we don't need to check for SSL_kECDH or SSL_kEECDH
3142 if (s
->version
>= TLS1_VERSION
)
3144 p
[ret
++]=TLS_CT_ECDSA_SIGN
;
3150 int ssl3_shutdown(SSL
*s
)
3154 /* Don't do anything much if we have not done the handshake or
3155 * we don't want to send messages :-) */
3156 if ((s
->quiet_shutdown
) || (s
->state
== SSL_ST_BEFORE
))
3158 s
->shutdown
=(SSL_SENT_SHUTDOWN
|SSL_RECEIVED_SHUTDOWN
);
3162 if (!(s
->shutdown
& SSL_SENT_SHUTDOWN
))
3164 s
->shutdown
|=SSL_SENT_SHUTDOWN
;
3166 ssl3_send_alert(s
,SSL3_AL_WARNING
,SSL_AD_CLOSE_NOTIFY
);
3168 /* our shutdown alert has been sent now, and if it still needs
3169 * to be written, s->s3->alert_dispatch will be true */
3170 if (s
->s3
->alert_dispatch
)
3171 return(-1); /* return WANT_WRITE */
3173 else if (s
->s3
->alert_dispatch
)
3175 /* resend it if not sent */
3177 ret
=s
->method
->ssl_dispatch_alert(s
);
3180 /* we only get to return -1 here the 2nd/Nth
3181 * invocation, we must have already signalled
3182 * return 0 upon a previous invoation,
3183 * return WANT_WRITE */
3188 else if (!(s
->shutdown
& SSL_RECEIVED_SHUTDOWN
))
3190 /* If we are waiting for a close from our peer, we are closed */
3191 s
->method
->ssl_read_bytes(s
,0,NULL
,0,0);
3192 if(!(s
->shutdown
& SSL_RECEIVED_SHUTDOWN
))
3194 return(-1); /* return WANT_READ */
3198 if ((s
->shutdown
== (SSL_SENT_SHUTDOWN
|SSL_RECEIVED_SHUTDOWN
)) &&
3199 !s
->s3
->alert_dispatch
)
3205 int ssl3_write(SSL
*s
, const void *buf
, int len
)
3210 if (s
->shutdown
& SSL_SEND_SHUTDOWN
)
3212 s
->rwstate
=SSL_NOTHING
;
3217 if (s
->s3
->renegotiate
) ssl3_renegotiate_check(s
);
3219 /* This is an experimental flag that sends the
3220 * last handshake message in the same packet as the first
3221 * use data - used to see if it helps the TCP protocol during
3222 * session-id reuse */
3223 /* The second test is because the buffer may have been removed */
3224 if ((s
->s3
->flags
& SSL3_FLAGS_POP_BUFFER
) && (s
->wbio
== s
->bbio
))
3226 /* First time through, we write into the buffer */
3227 if (s
->s3
->delay_buf_pop_ret
== 0)
3229 ret
=ssl3_write_bytes(s
,SSL3_RT_APPLICATION_DATA
,
3231 if (ret
<= 0) return(ret
);
3233 s
->s3
->delay_buf_pop_ret
=ret
;
3236 s
->rwstate
=SSL_WRITING
;
3237 n
=BIO_flush(s
->wbio
);
3238 if (n
<= 0) return(n
);
3239 s
->rwstate
=SSL_NOTHING
;
3241 /* We have flushed the buffer, so remove it */
3242 ssl_free_wbio_buffer(s
);
3243 s
->s3
->flags
&= ~SSL3_FLAGS_POP_BUFFER
;
3245 ret
=s
->s3
->delay_buf_pop_ret
;
3246 s
->s3
->delay_buf_pop_ret
=0;
3250 ret
=s
->method
->ssl_write_bytes(s
,SSL3_RT_APPLICATION_DATA
,
3252 if (ret
<= 0) return(ret
);
3258 static int ssl3_read_internal(SSL
*s
, void *buf
, int len
, int peek
)
3263 if (s
->s3
->renegotiate
) ssl3_renegotiate_check(s
);
3264 s
->s3
->in_read_app_data
=1;
3265 ret
=s
->method
->ssl_read_bytes(s
,SSL3_RT_APPLICATION_DATA
,buf
,len
,peek
);
3266 if ((ret
== -1) && (s
->s3
->in_read_app_data
== 2))
3268 /* ssl3_read_bytes decided to call s->handshake_func, which
3269 * called ssl3_read_bytes to read handshake data.
3270 * However, ssl3_read_bytes actually found application data
3271 * and thinks that application data makes sense here; so disable
3272 * handshake processing and try to read application data again. */
3274 ret
=s
->method
->ssl_read_bytes(s
,SSL3_RT_APPLICATION_DATA
,buf
,len
,peek
);
3278 s
->s3
->in_read_app_data
=0;
3283 int ssl3_read(SSL
*s
, void *buf
, int len
)
3285 return ssl3_read_internal(s
, buf
, len
, 0);
3288 int ssl3_peek(SSL
*s
, void *buf
, int len
)
3290 return ssl3_read_internal(s
, buf
, len
, 1);
3293 int ssl3_renegotiate(SSL
*s
)
3295 if (s
->handshake_func
== NULL
)
3298 if (s
->s3
->flags
& SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS
)
3301 s
->s3
->renegotiate
=1;
3305 int ssl3_renegotiate_check(SSL
*s
)
3309 if (s
->s3
->renegotiate
)
3311 if ( (s
->s3
->rbuf
.left
== 0) &&
3312 (s
->s3
->wbuf
.left
== 0) &&
3316 if we are the server, and we have sent a 'RENEGOTIATE' message, we
3317 need to go to SSL_ST_ACCEPT.
3320 s
->state
=SSL_ST_RENEGOTIATE
;
3321 s
->s3
->renegotiate
=0;
3322 s
->s3
->num_renegotiations
++;
3323 s
->s3
->total_renegotiations
++;