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-2006 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.
126 #include <openssl/objects.h>
127 #include "ssl_locl.h"
128 #include "kssl_lcl.h"
129 #include <openssl/md5.h>
130 #ifndef OPENSSL_NO_DH
131 #include <openssl/dh.h>
133 #include <openssl/pq_compat.h>
135 const char ssl3_version_str
[]="SSLv3" OPENSSL_VERSION_PTEXT
;
137 #define SSL3_NUM_CIPHERS (sizeof(ssl3_ciphers)/sizeof(SSL_CIPHER))
139 /* list of available SSLv3 ciphers (sorted by id) */
140 OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers
[]={
141 /* The RSA ciphers */
145 SSL3_TXT_RSA_NULL_MD5
,
146 SSL3_CK_RSA_NULL_MD5
,
147 SSL_kRSA
|SSL_aRSA
|SSL_eNULL
|SSL_MD5
|SSL_SSLV3
,
148 SSL_NOT_EXP
|SSL_STRONG_NONE
,
158 SSL3_TXT_RSA_NULL_SHA
,
159 SSL3_CK_RSA_NULL_SHA
,
160 SSL_kRSA
|SSL_aRSA
|SSL_eNULL
|SSL_SHA1
|SSL_SSLV3
,
161 SSL_NOT_EXP
|SSL_STRONG_NONE
|SSL_FIPS
,
171 SSL3_TXT_RSA_RC4_40_MD5
,
172 SSL3_CK_RSA_RC4_40_MD5
,
173 SSL_kRSA
|SSL_aRSA
|SSL_RC4
|SSL_MD5
|SSL_SSLV3
,
174 SSL_EXPORT
|SSL_EXP40
,
184 SSL3_TXT_RSA_RC4_128_MD5
,
185 SSL3_CK_RSA_RC4_128_MD5
,
186 SSL_kRSA
|SSL_aRSA
|SSL_RC4
|SSL_MD5
|SSL_SSLV3
,
187 SSL_NOT_EXP
|SSL_MEDIUM
,
197 SSL3_TXT_RSA_RC4_128_SHA
,
198 SSL3_CK_RSA_RC4_128_SHA
,
199 SSL_kRSA
|SSL_aRSA
|SSL_RC4
|SSL_SHA1
|SSL_SSLV3
,
200 SSL_NOT_EXP
|SSL_MEDIUM
,
210 SSL3_TXT_RSA_RC2_40_MD5
,
211 SSL3_CK_RSA_RC2_40_MD5
,
212 SSL_kRSA
|SSL_aRSA
|SSL_RC2
|SSL_MD5
|SSL_SSLV3
,
213 SSL_EXPORT
|SSL_EXP40
,
221 #ifndef OPENSSL_NO_IDEA
224 SSL3_TXT_RSA_IDEA_128_SHA
,
225 SSL3_CK_RSA_IDEA_128_SHA
,
226 SSL_kRSA
|SSL_aRSA
|SSL_IDEA
|SSL_SHA1
|SSL_SSLV3
,
227 SSL_NOT_EXP
|SSL_MEDIUM
,
238 SSL3_TXT_RSA_DES_40_CBC_SHA
,
239 SSL3_CK_RSA_DES_40_CBC_SHA
,
240 SSL_kRSA
|SSL_aRSA
|SSL_DES
|SSL_SHA1
|SSL_SSLV3
,
241 SSL_EXPORT
|SSL_EXP40
,
251 SSL3_TXT_RSA_DES_64_CBC_SHA
,
252 SSL3_CK_RSA_DES_64_CBC_SHA
,
253 SSL_kRSA
|SSL_aRSA
|SSL_DES
|SSL_SHA1
|SSL_SSLV3
,
264 SSL3_TXT_RSA_DES_192_CBC3_SHA
,
265 SSL3_CK_RSA_DES_192_CBC3_SHA
,
266 SSL_kRSA
|SSL_aRSA
|SSL_3DES
|SSL_SHA1
|SSL_SSLV3
,
267 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
278 SSL3_TXT_DH_DSS_DES_40_CBC_SHA
,
279 SSL3_CK_DH_DSS_DES_40_CBC_SHA
,
280 SSL_kDHd
|SSL_aDH
|SSL_DES
|SSL_SHA1
|SSL_SSLV3
,
281 SSL_EXPORT
|SSL_EXP40
,
291 SSL3_TXT_DH_DSS_DES_64_CBC_SHA
,
292 SSL3_CK_DH_DSS_DES_64_CBC_SHA
,
293 SSL_kDHd
|SSL_aDH
|SSL_DES
|SSL_SHA1
|SSL_SSLV3
,
304 SSL3_TXT_DH_DSS_DES_192_CBC3_SHA
,
305 SSL3_CK_DH_DSS_DES_192_CBC3_SHA
,
306 SSL_kDHd
|SSL_aDH
|SSL_3DES
|SSL_SHA1
|SSL_SSLV3
,
307 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
317 SSL3_TXT_DH_RSA_DES_40_CBC_SHA
,
318 SSL3_CK_DH_RSA_DES_40_CBC_SHA
,
319 SSL_kDHr
|SSL_aDH
|SSL_DES
|SSL_SHA1
|SSL_SSLV3
,
320 SSL_EXPORT
|SSL_EXP40
,
330 SSL3_TXT_DH_RSA_DES_64_CBC_SHA
,
331 SSL3_CK_DH_RSA_DES_64_CBC_SHA
,
332 SSL_kDHr
|SSL_aDH
|SSL_DES
|SSL_SHA1
|SSL_SSLV3
,
343 SSL3_TXT_DH_RSA_DES_192_CBC3_SHA
,
344 SSL3_CK_DH_RSA_DES_192_CBC3_SHA
,
345 SSL_kDHr
|SSL_aDH
|SSL_3DES
|SSL_SHA1
|SSL_SSLV3
,
346 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
354 /* The Ephemeral DH ciphers */
358 SSL3_TXT_EDH_DSS_DES_40_CBC_SHA
,
359 SSL3_CK_EDH_DSS_DES_40_CBC_SHA
,
360 SSL_kEDH
|SSL_aDSS
|SSL_DES
|SSL_SHA1
|SSL_SSLV3
,
361 SSL_EXPORT
|SSL_EXP40
,
371 SSL3_TXT_EDH_DSS_DES_64_CBC_SHA
,
372 SSL3_CK_EDH_DSS_DES_64_CBC_SHA
,
373 SSL_kEDH
|SSL_aDSS
|SSL_DES
|SSL_SHA1
|SSL_SSLV3
,
384 SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA
,
385 SSL3_CK_EDH_DSS_DES_192_CBC3_SHA
,
386 SSL_kEDH
|SSL_aDSS
|SSL_3DES
|SSL_SHA1
|SSL_SSLV3
,
387 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
397 SSL3_TXT_EDH_RSA_DES_40_CBC_SHA
,
398 SSL3_CK_EDH_RSA_DES_40_CBC_SHA
,
399 SSL_kEDH
|SSL_aRSA
|SSL_DES
|SSL_SHA1
|SSL_SSLV3
,
400 SSL_EXPORT
|SSL_EXP40
,
410 SSL3_TXT_EDH_RSA_DES_64_CBC_SHA
,
411 SSL3_CK_EDH_RSA_DES_64_CBC_SHA
,
412 SSL_kEDH
|SSL_aRSA
|SSL_DES
|SSL_SHA1
|SSL_SSLV3
,
423 SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA
,
424 SSL3_CK_EDH_RSA_DES_192_CBC3_SHA
,
425 SSL_kEDH
|SSL_aRSA
|SSL_3DES
|SSL_SHA1
|SSL_SSLV3
,
426 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
436 SSL3_TXT_ADH_RC4_40_MD5
,
437 SSL3_CK_ADH_RC4_40_MD5
,
438 SSL_kEDH
|SSL_aNULL
|SSL_RC4
|SSL_MD5
|SSL_SSLV3
,
439 SSL_EXPORT
|SSL_EXP40
,
449 SSL3_TXT_ADH_RC4_128_MD5
,
450 SSL3_CK_ADH_RC4_128_MD5
,
451 SSL_kEDH
|SSL_aNULL
|SSL_RC4
|SSL_MD5
|SSL_SSLV3
,
452 SSL_NOT_EXP
|SSL_MEDIUM
,
462 SSL3_TXT_ADH_DES_40_CBC_SHA
,
463 SSL3_CK_ADH_DES_40_CBC_SHA
,
464 SSL_kEDH
|SSL_aNULL
|SSL_DES
|SSL_SHA1
|SSL_SSLV3
,
465 SSL_EXPORT
|SSL_EXP40
,
475 SSL3_TXT_ADH_DES_64_CBC_SHA
,
476 SSL3_CK_ADH_DES_64_CBC_SHA
,
477 SSL_kEDH
|SSL_aNULL
|SSL_DES
|SSL_SHA1
|SSL_SSLV3
,
488 SSL3_TXT_ADH_DES_192_CBC_SHA
,
489 SSL3_CK_ADH_DES_192_CBC_SHA
,
490 SSL_kEDH
|SSL_aNULL
|SSL_3DES
|SSL_SHA1
|SSL_SSLV3
,
491 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
503 SSL3_TXT_FZA_DMS_NULL_SHA
,
504 SSL3_CK_FZA_DMS_NULL_SHA
,
505 SSL_kFZA
|SSL_aFZA
|SSL_eNULL
|SSL_SHA1
|SSL_SSLV3
,
506 SSL_NOT_EXP
|SSL_STRONG_NONE
,
517 SSL3_TXT_FZA_DMS_FZA_SHA
,
518 SSL3_CK_FZA_DMS_FZA_SHA
,
519 SSL_kFZA
|SSL_aFZA
|SSL_eFZA
|SSL_SHA1
|SSL_SSLV3
,
520 SSL_NOT_EXP
|SSL_STRONG_NONE
,
532 SSL3_TXT_FZA_DMS_RC4_SHA
,
533 SSL3_CK_FZA_DMS_RC4_SHA
,
534 SSL_kFZA
|SSL_aFZA
|SSL_RC4
|SSL_SHA1
|SSL_SSLV3
,
535 SSL_NOT_EXP
|SSL_MEDIUM
,
544 #ifndef OPENSSL_NO_KRB5
545 /* The Kerberos ciphers */
549 SSL3_TXT_KRB5_DES_64_CBC_SHA
,
550 SSL3_CK_KRB5_DES_64_CBC_SHA
,
551 SSL_kKRB5
|SSL_aKRB5
| SSL_DES
|SSL_SHA1
|SSL_SSLV3
,
563 SSL3_TXT_KRB5_DES_192_CBC3_SHA
,
564 SSL3_CK_KRB5_DES_192_CBC3_SHA
,
565 SSL_kKRB5
|SSL_aKRB5
| SSL_3DES
|SSL_SHA1
|SSL_SSLV3
,
566 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
577 SSL3_TXT_KRB5_RC4_128_SHA
,
578 SSL3_CK_KRB5_RC4_128_SHA
,
579 SSL_kKRB5
|SSL_aKRB5
| SSL_RC4
|SSL_SHA1
|SSL_SSLV3
,
580 SSL_NOT_EXP
|SSL_MEDIUM
,
591 SSL3_TXT_KRB5_IDEA_128_CBC_SHA
,
592 SSL3_CK_KRB5_IDEA_128_CBC_SHA
,
593 SSL_kKRB5
|SSL_aKRB5
| SSL_IDEA
|SSL_SHA1
|SSL_SSLV3
,
594 SSL_NOT_EXP
|SSL_MEDIUM
,
605 SSL3_TXT_KRB5_DES_64_CBC_MD5
,
606 SSL3_CK_KRB5_DES_64_CBC_MD5
,
607 SSL_kKRB5
|SSL_aKRB5
| SSL_DES
|SSL_MD5
|SSL_SSLV3
,
619 SSL3_TXT_KRB5_DES_192_CBC3_MD5
,
620 SSL3_CK_KRB5_DES_192_CBC3_MD5
,
621 SSL_kKRB5
|SSL_aKRB5
| SSL_3DES
|SSL_MD5
|SSL_SSLV3
,
622 SSL_NOT_EXP
|SSL_HIGH
,
633 SSL3_TXT_KRB5_RC4_128_MD5
,
634 SSL3_CK_KRB5_RC4_128_MD5
,
635 SSL_kKRB5
|SSL_aKRB5
| SSL_RC4
|SSL_MD5
|SSL_SSLV3
,
636 SSL_NOT_EXP
|SSL_MEDIUM
,
647 SSL3_TXT_KRB5_IDEA_128_CBC_MD5
,
648 SSL3_CK_KRB5_IDEA_128_CBC_MD5
,
649 SSL_kKRB5
|SSL_aKRB5
| SSL_IDEA
|SSL_MD5
|SSL_SSLV3
,
650 SSL_NOT_EXP
|SSL_MEDIUM
,
661 SSL3_TXT_KRB5_DES_40_CBC_SHA
,
662 SSL3_CK_KRB5_DES_40_CBC_SHA
,
663 SSL_kKRB5
|SSL_aKRB5
| SSL_DES
|SSL_SHA1
|SSL_SSLV3
,
664 SSL_EXPORT
|SSL_EXP40
,
675 SSL3_TXT_KRB5_RC2_40_CBC_SHA
,
676 SSL3_CK_KRB5_RC2_40_CBC_SHA
,
677 SSL_kKRB5
|SSL_aKRB5
| SSL_RC2
|SSL_SHA1
|SSL_SSLV3
,
678 SSL_EXPORT
|SSL_EXP40
,
689 SSL3_TXT_KRB5_RC4_40_SHA
,
690 SSL3_CK_KRB5_RC4_40_SHA
,
691 SSL_kKRB5
|SSL_aKRB5
| SSL_RC4
|SSL_SHA1
|SSL_SSLV3
,
692 SSL_EXPORT
|SSL_EXP40
,
703 SSL3_TXT_KRB5_DES_40_CBC_MD5
,
704 SSL3_CK_KRB5_DES_40_CBC_MD5
,
705 SSL_kKRB5
|SSL_aKRB5
| SSL_DES
|SSL_MD5
|SSL_SSLV3
,
706 SSL_EXPORT
|SSL_EXP40
,
717 SSL3_TXT_KRB5_RC2_40_CBC_MD5
,
718 SSL3_CK_KRB5_RC2_40_CBC_MD5
,
719 SSL_kKRB5
|SSL_aKRB5
| SSL_RC2
|SSL_MD5
|SSL_SSLV3
,
720 SSL_EXPORT
|SSL_EXP40
,
731 SSL3_TXT_KRB5_RC4_40_MD5
,
732 SSL3_CK_KRB5_RC4_40_MD5
,
733 SSL_kKRB5
|SSL_aKRB5
| SSL_RC4
|SSL_MD5
|SSL_SSLV3
,
734 SSL_EXPORT
|SSL_EXP40
,
741 #endif /* OPENSSL_NO_KRB5 */
743 /* New AES ciphersuites */
747 TLS1_TXT_RSA_WITH_AES_128_SHA
,
748 TLS1_CK_RSA_WITH_AES_128_SHA
,
749 SSL_kRSA
|SSL_aRSA
|SSL_AES
|SSL_SHA
|SSL_TLSV1
,
750 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
760 TLS1_TXT_DH_DSS_WITH_AES_128_SHA
,
761 TLS1_CK_DH_DSS_WITH_AES_128_SHA
,
762 SSL_kDHd
|SSL_aDH
|SSL_AES
|SSL_SHA
|SSL_TLSV1
,
763 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
773 TLS1_TXT_DH_RSA_WITH_AES_128_SHA
,
774 TLS1_CK_DH_RSA_WITH_AES_128_SHA
,
775 SSL_kDHr
|SSL_aDH
|SSL_AES
|SSL_SHA
|SSL_TLSV1
,
776 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
786 TLS1_TXT_DHE_DSS_WITH_AES_128_SHA
,
787 TLS1_CK_DHE_DSS_WITH_AES_128_SHA
,
788 SSL_kEDH
|SSL_aDSS
|SSL_AES
|SSL_SHA
|SSL_TLSV1
,
789 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
799 TLS1_TXT_DHE_RSA_WITH_AES_128_SHA
,
800 TLS1_CK_DHE_RSA_WITH_AES_128_SHA
,
801 SSL_kEDH
|SSL_aRSA
|SSL_AES
|SSL_SHA
|SSL_TLSV1
,
802 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
812 TLS1_TXT_ADH_WITH_AES_128_SHA
,
813 TLS1_CK_ADH_WITH_AES_128_SHA
,
814 SSL_kEDH
|SSL_aNULL
|SSL_AES
|SSL_SHA
|SSL_TLSV1
,
815 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
826 TLS1_TXT_RSA_WITH_AES_256_SHA
,
827 TLS1_CK_RSA_WITH_AES_256_SHA
,
828 SSL_kRSA
|SSL_aRSA
|SSL_AES
|SSL_SHA
|SSL_TLSV1
,
829 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
839 TLS1_TXT_DH_DSS_WITH_AES_256_SHA
,
840 TLS1_CK_DH_DSS_WITH_AES_256_SHA
,
841 SSL_kDHd
|SSL_aDH
|SSL_AES
|SSL_SHA
|SSL_TLSV1
,
842 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
852 TLS1_TXT_DH_RSA_WITH_AES_256_SHA
,
853 TLS1_CK_DH_RSA_WITH_AES_256_SHA
,
854 SSL_kDHr
|SSL_aDH
|SSL_AES
|SSL_SHA
|SSL_TLSV1
,
855 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
865 TLS1_TXT_DHE_DSS_WITH_AES_256_SHA
,
866 TLS1_CK_DHE_DSS_WITH_AES_256_SHA
,
867 SSL_kEDH
|SSL_aDSS
|SSL_AES
|SSL_SHA
|SSL_TLSV1
,
868 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
878 TLS1_TXT_DHE_RSA_WITH_AES_256_SHA
,
879 TLS1_CK_DHE_RSA_WITH_AES_256_SHA
,
880 SSL_kEDH
|SSL_aRSA
|SSL_AES
|SSL_SHA
|SSL_TLSV1
,
881 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
891 TLS1_TXT_ADH_WITH_AES_256_SHA
,
892 TLS1_CK_ADH_WITH_AES_256_SHA
,
893 SSL_kEDH
|SSL_aNULL
|SSL_AES
|SSL_SHA
|SSL_TLSV1
,
894 SSL_NOT_EXP
|SSL_HIGH
|SSL_FIPS
,
902 #ifndef OPENSSL_NO_CAMELLIA
903 /* Camellia ciphersuites from RFC4132 (128-bit portion) */
908 TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA
,
909 TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA
,
910 SSL_kRSA
|SSL_aRSA
|SSL_CAMELLIA
|SSL_SHA
|SSL_TLSV1
,
911 SSL_NOT_EXP
|SSL_HIGH
,
920 0, /* not implemented (non-ephemeral DH) */
921 TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA
,
922 TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA
,
923 SSL_kDHd
|SSL_aDH
|SSL_CAMELLIA
|SSL_SHA
|SSL_TLSV1
,
924 SSL_NOT_EXP
|SSL_HIGH
,
933 0, /* not implemented (non-ephemeral DH) */
934 TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA
,
935 TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA
,
936 SSL_kDHr
|SSL_aDH
|SSL_CAMELLIA
|SSL_SHA
|SSL_TLSV1
,
937 SSL_NOT_EXP
|SSL_HIGH
,
947 TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA
,
948 TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA
,
949 SSL_kEDH
|SSL_aDSS
|SSL_CAMELLIA
|SSL_SHA
|SSL_TLSV1
,
950 SSL_NOT_EXP
|SSL_HIGH
,
960 TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA
,
961 TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA
,
962 SSL_kEDH
|SSL_aRSA
|SSL_CAMELLIA
|SSL_SHA
|SSL_TLSV1
,
963 SSL_NOT_EXP
|SSL_HIGH
,
973 TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA
,
974 TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA
,
975 SSL_kEDH
|SSL_aNULL
|SSL_CAMELLIA
|SSL_SHA
|SSL_TLSV1
,
976 SSL_NOT_EXP
|SSL_HIGH
,
983 #endif /* OPENSSL_NO_CAMELLIA */
985 #if TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES
986 /* New TLS Export CipherSuites from expired ID */
991 TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5
,
992 TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5
,
993 SSL_kRSA
|SSL_aRSA
|SSL_RC4
|SSL_MD5
|SSL_TLSV1
,
994 SSL_EXPORT
|SSL_EXP56
,
1004 TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5
,
1005 TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5
,
1006 SSL_kRSA
|SSL_aRSA
|SSL_RC2
|SSL_MD5
|SSL_TLSV1
,
1007 SSL_EXPORT
|SSL_EXP56
,
1018 TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA
,
1019 TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA
,
1020 SSL_kRSA
|SSL_aRSA
|SSL_DES
|SSL_SHA
|SSL_TLSV1
,
1021 SSL_EXPORT
|SSL_EXP56
,
1031 TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA
,
1032 TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA
,
1033 SSL_kEDH
|SSL_aDSS
|SSL_DES
|SSL_SHA
|SSL_TLSV1
,
1034 SSL_EXPORT
|SSL_EXP56
,
1044 TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA
,
1045 TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA
,
1046 SSL_kRSA
|SSL_aRSA
|SSL_RC4
|SSL_SHA
|SSL_TLSV1
,
1047 SSL_EXPORT
|SSL_EXP56
,
1057 TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA
,
1058 TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA
,
1059 SSL_kEDH
|SSL_aDSS
|SSL_RC4
|SSL_SHA
|SSL_TLSV1
,
1060 SSL_EXPORT
|SSL_EXP56
,
1070 TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA
,
1071 TLS1_CK_DHE_DSS_WITH_RC4_128_SHA
,
1072 SSL_kEDH
|SSL_aDSS
|SSL_RC4
|SSL_SHA
|SSL_TLSV1
,
1073 SSL_NOT_EXP
|SSL_MEDIUM
,
1082 #ifndef OPENSSL_NO_CAMELLIA
1083 /* Camellia ciphersuites from RFC4132 (256-bit portion) */
1088 TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA
,
1089 TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA
,
1090 SSL_kRSA
|SSL_aRSA
|SSL_CAMELLIA
|SSL_SHA
|SSL_TLSV1
,
1091 SSL_NOT_EXP
|SSL_HIGH
,
1100 0, /* not implemented (non-ephemeral DH) */
1101 TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA
,
1102 TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA
,
1103 SSL_kDHd
|SSL_aDH
|SSL_CAMELLIA
|SSL_SHA
|SSL_TLSV1
,
1104 SSL_NOT_EXP
|SSL_HIGH
,
1113 0, /* not implemented (non-ephemeral DH) */
1114 TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA
,
1115 TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA
,
1116 SSL_kDHr
|SSL_aDH
|SSL_CAMELLIA
|SSL_SHA
|SSL_TLSV1
,
1117 SSL_NOT_EXP
|SSL_HIGH
,
1127 TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA
,
1128 TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA
,
1129 SSL_kEDH
|SSL_aDSS
|SSL_CAMELLIA
|SSL_SHA
|SSL_TLSV1
,
1130 SSL_NOT_EXP
|SSL_HIGH
,
1140 TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA
,
1141 TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA
,
1142 SSL_kEDH
|SSL_aRSA
|SSL_CAMELLIA
|SSL_SHA
|SSL_TLSV1
,
1143 SSL_NOT_EXP
|SSL_HIGH
,
1153 TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA
,
1154 TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA
,
1155 SSL_kEDH
|SSL_aNULL
|SSL_CAMELLIA
|SSL_SHA
|SSL_TLSV1
,
1156 SSL_NOT_EXP
|SSL_HIGH
,
1163 #endif /* OPENSSL_NO_CAMELLIA */
1165 #ifndef OPENSSL_NO_SEED
1166 /* SEED ciphersuites from RFC4162 */
1171 TLS1_TXT_RSA_WITH_SEED_SHA
,
1172 TLS1_CK_RSA_WITH_SEED_SHA
,
1173 SSL_kRSA
|SSL_aRSA
|SSL_SEED
|SSL_SHA1
|SSL_TLSV1
,
1174 SSL_NOT_EXP
|SSL_MEDIUM
,
1184 0, /* not implemented (non-ephemeral DH) */
1185 TLS1_TXT_DH_DSS_WITH_SEED_SHA
,
1186 TLS1_CK_DH_DSS_WITH_SEED_SHA
,
1187 SSL_kDHd
|SSL_aDH
|SSL_SEED
|SSL_SHA1
|SSL_TLSV1
,
1188 SSL_NOT_EXP
|SSL_MEDIUM
,
1198 0, /* not implemented (non-ephemeral DH) */
1199 TLS1_TXT_DH_RSA_WITH_SEED_SHA
,
1200 TLS1_CK_DH_RSA_WITH_SEED_SHA
,
1201 SSL_kDHr
|SSL_aDH
|SSL_SEED
|SSL_SHA1
|SSL_TLSV1
,
1202 SSL_NOT_EXP
|SSL_MEDIUM
,
1213 TLS1_TXT_DHE_DSS_WITH_SEED_SHA
,
1214 TLS1_CK_DHE_DSS_WITH_SEED_SHA
,
1215 SSL_kEDH
|SSL_aDSS
|SSL_SEED
|SSL_SHA1
|SSL_TLSV1
,
1216 SSL_NOT_EXP
|SSL_MEDIUM
,
1227 TLS1_TXT_DHE_RSA_WITH_SEED_SHA
,
1228 TLS1_CK_DHE_RSA_WITH_SEED_SHA
,
1229 SSL_kEDH
|SSL_aRSA
|SSL_SEED
|SSL_SHA1
|SSL_TLSV1
,
1230 SSL_NOT_EXP
|SSL_MEDIUM
,
1241 TLS1_TXT_ADH_WITH_SEED_SHA
,
1242 TLS1_CK_ADH_WITH_SEED_SHA
,
1243 SSL_kEDH
|SSL_aNULL
|SSL_SEED
|SSL_SHA1
|SSL_TLSV1
,
1244 SSL_NOT_EXP
|SSL_MEDIUM
,
1252 #endif /* OPENSSL_NO_SEED */
1254 #ifndef OPENSSL_NO_ECDH
1258 TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA
,
1259 TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA
,
1260 SSL_kECDH
|SSL_aECDSA
|SSL_eNULL
|SSL_SHA
|SSL_TLSV1
,
1272 TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA
,
1273 TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA
,
1274 SSL_kECDH
|SSL_aECDSA
|SSL_RC4
|SSL_SHA
|SSL_TLSV1
,
1286 TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA
,
1287 TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA
,
1288 SSL_kECDH
|SSL_aECDSA
|SSL_3DES
|SSL_SHA
|SSL_TLSV1
,
1289 SSL_NOT_EXP
|SSL_HIGH
,
1300 TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA
,
1301 TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA
,
1302 SSL_kECDH
|SSL_aECDSA
|SSL_AES
|SSL_SHA
|SSL_TLSV1
,
1303 SSL_NOT_EXP
|SSL_HIGH
,
1314 TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA
,
1315 TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA
,
1316 SSL_kECDH
|SSL_aECDSA
|SSL_AES
|SSL_SHA
|SSL_TLSV1
,
1317 SSL_NOT_EXP
|SSL_HIGH
,
1328 TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA
,
1329 TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA
,
1330 SSL_kECDHE
|SSL_aECDSA
|SSL_eNULL
|SSL_SHA
|SSL_TLSV1
,
1342 TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA
,
1343 TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA
,
1344 SSL_kECDHE
|SSL_aECDSA
|SSL_RC4
|SSL_SHA
|SSL_TLSV1
,
1356 TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA
,
1357 TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA
,
1358 SSL_kECDHE
|SSL_aECDSA
|SSL_3DES
|SSL_SHA
|SSL_TLSV1
,
1359 SSL_NOT_EXP
|SSL_HIGH
,
1370 TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
,
1371 TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
,
1372 SSL_kECDHE
|SSL_aECDSA
|SSL_AES
|SSL_SHA
|SSL_TLSV1
,
1373 SSL_NOT_EXP
|SSL_HIGH
,
1384 TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
,
1385 TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
,
1386 SSL_kECDHE
|SSL_aECDSA
|SSL_AES
|SSL_SHA
|SSL_TLSV1
,
1387 SSL_NOT_EXP
|SSL_HIGH
,
1398 TLS1_TXT_ECDH_RSA_WITH_NULL_SHA
,
1399 TLS1_CK_ECDH_RSA_WITH_NULL_SHA
,
1400 SSL_kECDH
|SSL_aRSA
|SSL_eNULL
|SSL_SHA
|SSL_TLSV1
,
1412 TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA
,
1413 TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA
,
1414 SSL_kECDH
|SSL_aRSA
|SSL_RC4
|SSL_SHA
|SSL_TLSV1
,
1426 TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA
,
1427 TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA
,
1428 SSL_kECDH
|SSL_aRSA
|SSL_3DES
|SSL_SHA
|SSL_TLSV1
,
1429 SSL_NOT_EXP
|SSL_HIGH
,
1440 TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA
,
1441 TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA
,
1442 SSL_kECDH
|SSL_aRSA
|SSL_AES
|SSL_SHA
|SSL_TLSV1
,
1443 SSL_NOT_EXP
|SSL_HIGH
,
1454 TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA
,
1455 TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA
,
1456 SSL_kECDH
|SSL_aRSA
|SSL_AES
|SSL_SHA
|SSL_TLSV1
,
1457 SSL_NOT_EXP
|SSL_HIGH
,
1468 TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA
,
1469 TLS1_CK_ECDHE_RSA_WITH_NULL_SHA
,
1470 SSL_kECDHE
|SSL_aRSA
|SSL_eNULL
|SSL_SHA
|SSL_TLSV1
,
1482 TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA
,
1483 TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA
,
1484 SSL_kECDHE
|SSL_aRSA
|SSL_RC4
|SSL_SHA
|SSL_TLSV1
,
1496 TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA
,
1497 TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA
,
1498 SSL_kECDHE
|SSL_aRSA
|SSL_3DES
|SSL_SHA
|SSL_TLSV1
,
1499 SSL_NOT_EXP
|SSL_HIGH
,
1510 TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA
,
1511 TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA
,
1512 SSL_kECDHE
|SSL_aRSA
|SSL_AES
|SSL_SHA
|SSL_TLSV1
,
1513 SSL_NOT_EXP
|SSL_HIGH
,
1524 TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA
,
1525 TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA
,
1526 SSL_kECDHE
|SSL_aRSA
|SSL_AES
|SSL_SHA
|SSL_TLSV1
,
1527 SSL_NOT_EXP
|SSL_HIGH
,
1538 TLS1_TXT_ECDH_anon_WITH_NULL_SHA
,
1539 TLS1_CK_ECDH_anon_WITH_NULL_SHA
,
1540 SSL_kECDHE
|SSL_aNULL
|SSL_eNULL
|SSL_SHA
|SSL_TLSV1
,
1552 TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA
,
1553 TLS1_CK_ECDH_anon_WITH_RC4_128_SHA
,
1554 SSL_kECDHE
|SSL_aNULL
|SSL_RC4
|SSL_SHA
|SSL_TLSV1
,
1566 TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA
,
1567 TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA
,
1568 SSL_kECDHE
|SSL_aNULL
|SSL_3DES
|SSL_SHA
|SSL_TLSV1
,
1569 SSL_NOT_EXP
|SSL_HIGH
,
1580 TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA
,
1581 TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA
,
1582 SSL_kECDHE
|SSL_aNULL
|SSL_AES
|SSL_SHA
|SSL_TLSV1
,
1583 SSL_NOT_EXP
|SSL_HIGH
,
1594 TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA
,
1595 TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA
,
1596 SSL_kECDHE
|SSL_aNULL
|SSL_AES
|SSL_SHA
|SSL_TLSV1
,
1597 SSL_NOT_EXP
|SSL_HIGH
,
1604 #endif /* OPENSSL_NO_ECDH */
1610 SSL3_ENC_METHOD SSLv3_enc_data
={
1613 ssl3_setup_key_block
,
1614 ssl3_generate_master_secret
,
1615 ssl3_change_cipher_state
,
1616 ssl3_final_finish_mac
,
1617 MD5_DIGEST_LENGTH
+SHA_DIGEST_LENGTH
,
1618 ssl3_cert_verify_mac
,
1619 SSL3_MD_CLIENT_FINISHED_CONST
,4,
1620 SSL3_MD_SERVER_FINISHED_CONST
,4,
1624 long ssl3_default_timeout(void)
1626 /* 2 hours, the 24 hours mentioned in the SSLv3 spec
1627 * is way too long for http, the cache would over fill */
1631 IMPLEMENT_ssl3_meth_func(sslv3_base_method
,
1632 ssl_undefined_function
,
1633 ssl_undefined_function
,
1636 int ssl3_num_ciphers(void)
1638 return(SSL3_NUM_CIPHERS
);
1641 SSL_CIPHER
*ssl3_get_cipher(unsigned int u
)
1643 if (u
< SSL3_NUM_CIPHERS
)
1644 return(&(ssl3_ciphers
[SSL3_NUM_CIPHERS
-1-u
]));
1649 int ssl3_pending(const SSL
*s
)
1651 if (s
->rstate
== SSL_ST_READ_BODY
)
1654 return (s
->s3
->rrec
.type
== SSL3_RT_APPLICATION_DATA
) ? s
->s3
->rrec
.length
: 0;
1657 int ssl3_new(SSL
*s
)
1661 if ((s3
=OPENSSL_malloc(sizeof *s3
)) == NULL
) goto err
;
1662 memset(s3
,0,sizeof *s3
);
1663 EVP_MD_CTX_init(&s3
->finish_dgst1
);
1664 EVP_MD_CTX_init(&s3
->finish_dgst2
);
1665 pq_64bit_init(&(s3
->rrec
.seq_num
));
1666 pq_64bit_init(&(s3
->wrec
.seq_num
));
1670 s
->method
->ssl_clear(s
);
1676 void ssl3_free(SSL
*s
)
1681 ssl3_cleanup_key_block(s
);
1682 if (s
->s3
->rbuf
.buf
!= NULL
)
1683 OPENSSL_free(s
->s3
->rbuf
.buf
);
1684 if (s
->s3
->wbuf
.buf
!= NULL
)
1685 OPENSSL_free(s
->s3
->wbuf
.buf
);
1686 if (s
->s3
->rrec
.comp
!= NULL
)
1687 OPENSSL_free(s
->s3
->rrec
.comp
);
1688 #ifndef OPENSSL_NO_DH
1689 if (s
->s3
->tmp
.dh
!= NULL
)
1690 DH_free(s
->s3
->tmp
.dh
);
1692 #ifndef OPENSSL_NO_ECDH
1693 if (s
->s3
->tmp
.ecdh
!= NULL
)
1694 EC_KEY_free(s
->s3
->tmp
.ecdh
);
1697 if (s
->s3
->tmp
.ca_names
!= NULL
)
1698 sk_X509_NAME_pop_free(s
->s3
->tmp
.ca_names
,X509_NAME_free
);
1699 EVP_MD_CTX_cleanup(&s
->s3
->finish_dgst1
);
1700 EVP_MD_CTX_cleanup(&s
->s3
->finish_dgst2
);
1701 pq_64bit_free(&(s
->s3
->rrec
.seq_num
));
1702 pq_64bit_free(&(s
->s3
->wrec
.seq_num
));
1704 OPENSSL_cleanse(s
->s3
,sizeof *s
->s3
);
1705 OPENSSL_free(s
->s3
);
1709 void ssl3_clear(SSL
*s
)
1711 unsigned char *rp
,*wp
;
1714 ssl3_cleanup_key_block(s
);
1715 if (s
->s3
->tmp
.ca_names
!= NULL
)
1716 sk_X509_NAME_pop_free(s
->s3
->tmp
.ca_names
,X509_NAME_free
);
1718 if (s
->s3
->rrec
.comp
!= NULL
)
1720 OPENSSL_free(s
->s3
->rrec
.comp
);
1721 s
->s3
->rrec
.comp
=NULL
;
1723 #ifndef OPENSSL_NO_DH
1724 if (s
->s3
->tmp
.dh
!= NULL
)
1725 DH_free(s
->s3
->tmp
.dh
);
1727 #ifndef OPENSSL_NO_ECDH
1728 if (s
->s3
->tmp
.ecdh
!= NULL
)
1729 EC_KEY_free(s
->s3
->tmp
.ecdh
);
1732 rp
= s
->s3
->rbuf
.buf
;
1733 wp
= s
->s3
->wbuf
.buf
;
1734 rlen
= s
->s3
->rbuf
.len
;
1735 wlen
= s
->s3
->wbuf
.len
;
1737 EVP_MD_CTX_cleanup(&s
->s3
->finish_dgst1
);
1738 EVP_MD_CTX_cleanup(&s
->s3
->finish_dgst2
);
1740 memset(s
->s3
,0,sizeof *s
->s3
);
1741 s
->s3
->rbuf
.buf
= rp
;
1742 s
->s3
->wbuf
.buf
= wp
;
1743 s
->s3
->rbuf
.len
= rlen
;
1744 s
->s3
->wbuf
.len
= wlen
;
1746 ssl_free_wbio_buffer(s
);
1749 s
->s3
->renegotiate
=0;
1750 s
->s3
->total_renegotiations
=0;
1751 s
->s3
->num_renegotiations
=0;
1752 s
->s3
->in_read_app_data
=0;
1753 s
->version
=SSL3_VERSION
;
1756 long ssl3_ctrl(SSL
*s
, int cmd
, long larg
, void *parg
)
1760 #if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA)
1762 #ifndef OPENSSL_NO_RSA
1763 cmd
== SSL_CTRL_SET_TMP_RSA
||
1764 cmd
== SSL_CTRL_SET_TMP_RSA_CB
||
1766 #ifndef OPENSSL_NO_DSA
1767 cmd
== SSL_CTRL_SET_TMP_DH
||
1768 cmd
== SSL_CTRL_SET_TMP_DH_CB
||
1772 if (!ssl_cert_inst(&s
->cert
))
1774 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_MALLOC_FAILURE
);
1782 case SSL_CTRL_GET_SESSION_REUSED
:
1785 case SSL_CTRL_GET_CLIENT_CERT_REQUEST
:
1787 case SSL_CTRL_GET_NUM_RENEGOTIATIONS
:
1788 ret
=s
->s3
->num_renegotiations
;
1790 case SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS
:
1791 ret
=s
->s3
->num_renegotiations
;
1792 s
->s3
->num_renegotiations
=0;
1794 case SSL_CTRL_GET_TOTAL_RENEGOTIATIONS
:
1795 ret
=s
->s3
->total_renegotiations
;
1797 case SSL_CTRL_GET_FLAGS
:
1798 ret
=(int)(s
->s3
->flags
);
1800 #ifndef OPENSSL_NO_RSA
1801 case SSL_CTRL_NEED_TMP_RSA
:
1802 if ((s
->cert
!= NULL
) && (s
->cert
->rsa_tmp
== NULL
) &&
1803 ((s
->cert
->pkeys
[SSL_PKEY_RSA_ENC
].privatekey
== NULL
) ||
1804 (EVP_PKEY_size(s
->cert
->pkeys
[SSL_PKEY_RSA_ENC
].privatekey
) > (512/8))))
1807 case SSL_CTRL_SET_TMP_RSA
:
1809 RSA
*rsa
= (RSA
*)parg
;
1812 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_PASSED_NULL_PARAMETER
);
1815 if ((rsa
= RSAPrivateKey_dup(rsa
)) == NULL
)
1817 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_RSA_LIB
);
1820 if (s
->cert
->rsa_tmp
!= NULL
)
1821 RSA_free(s
->cert
->rsa_tmp
);
1822 s
->cert
->rsa_tmp
= rsa
;
1826 case SSL_CTRL_SET_TMP_RSA_CB
:
1828 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED
);
1833 #ifndef OPENSSL_NO_DH
1834 case SSL_CTRL_SET_TMP_DH
:
1836 DH
*dh
= (DH
*)parg
;
1839 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_PASSED_NULL_PARAMETER
);
1842 if ((dh
= DHparams_dup(dh
)) == NULL
)
1844 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_DH_LIB
);
1847 if (!(s
->options
& SSL_OP_SINGLE_DH_USE
))
1849 if (!DH_generate_key(dh
))
1852 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_DH_LIB
);
1856 if (s
->cert
->dh_tmp
!= NULL
)
1857 DH_free(s
->cert
->dh_tmp
);
1858 s
->cert
->dh_tmp
= dh
;
1862 case SSL_CTRL_SET_TMP_DH_CB
:
1864 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED
);
1869 #ifndef OPENSSL_NO_ECDH
1870 case SSL_CTRL_SET_TMP_ECDH
:
1872 EC_KEY
*ecdh
= NULL
;
1876 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_PASSED_NULL_PARAMETER
);
1879 if (!EC_KEY_up_ref((EC_KEY
*)parg
))
1881 SSLerr(SSL_F_SSL3_CTRL
,ERR_R_ECDH_LIB
);
1884 ecdh
= (EC_KEY
*)parg
;
1885 if (!(s
->options
& SSL_OP_SINGLE_ECDH_USE
))
1887 if (!EC_KEY_generate_key(ecdh
))
1890 SSLerr(SSL_F_SSL3_CTRL
,ERR_R_ECDH_LIB
);
1894 if (s
->cert
->ecdh_tmp
!= NULL
)
1895 EC_KEY_free(s
->cert
->ecdh_tmp
);
1896 s
->cert
->ecdh_tmp
= ecdh
;
1900 case SSL_CTRL_SET_TMP_ECDH_CB
:
1902 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED
);
1906 #endif /* !OPENSSL_NO_ECDH */
1907 #ifndef OPENSSL_NO_TLSEXT
1908 case SSL_CTRL_SET_TLSEXT_HOSTNAME
:
1909 if (larg
== TLSEXT_NAMETYPE_host_name
)
1911 if (s
->tlsext_hostname
!= NULL
)
1912 OPENSSL_free(s
->tlsext_hostname
);
1913 s
->tlsext_hostname
= NULL
;
1918 if (strlen((char *)parg
) > TLSEXT_MAXLEN_host_name
)
1920 SSLerr(SSL_F_SSL3_CTRL
, SSL_R_SSL3_EXT_INVALID_SERVERNAME
);
1923 if ((s
->tlsext_hostname
= BUF_strdup((char *)parg
)) == NULL
)
1925 SSLerr(SSL_F_SSL3_CTRL
, ERR_R_INTERNAL_ERROR
);
1931 SSLerr(SSL_F_SSL3_CTRL
, SSL_R_SSL3_EXT_INVALID_SERVERNAME_TYPE
);
1935 case SSL_CTRL_SET_TLSEXT_DEBUG_ARG
:
1936 s
->tlsext_debug_arg
=parg
;
1940 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE
:
1941 s
->tlsext_status_type
=larg
;
1945 case SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS
:
1946 *(STACK_OF(X509_EXTENSION
) **)parg
= s
->tlsext_ocsp_exts
;
1950 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS
:
1951 s
->tlsext_ocsp_exts
= parg
;
1955 case SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS
:
1956 *(STACK_OF(OCSP_RESPID
) **)parg
= s
->tlsext_ocsp_ids
;
1960 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS
:
1961 s
->tlsext_ocsp_ids
= parg
;
1965 case SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP
:
1966 *(unsigned char **)parg
= s
->tlsext_ocsp_resp
;
1967 return s
->tlsext_ocsp_resplen
;
1969 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP
:
1970 if (s
->tlsext_ocsp_resp
)
1971 OPENSSL_free(s
->tlsext_ocsp_resp
);
1972 s
->tlsext_ocsp_resp
= parg
;
1973 s
->tlsext_ocsp_resplen
= larg
;
1977 #endif /* !OPENSSL_NO_TLSEXT */
1984 long ssl3_callback_ctrl(SSL
*s
, int cmd
, void (*fp
)(void))
1988 #if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA)
1990 #ifndef OPENSSL_NO_RSA
1991 cmd
== SSL_CTRL_SET_TMP_RSA_CB
||
1993 #ifndef OPENSSL_NO_DSA
1994 cmd
== SSL_CTRL_SET_TMP_DH_CB
||
1998 if (!ssl_cert_inst(&s
->cert
))
2000 SSLerr(SSL_F_SSL3_CALLBACK_CTRL
, ERR_R_MALLOC_FAILURE
);
2008 #ifndef OPENSSL_NO_RSA
2009 case SSL_CTRL_SET_TMP_RSA_CB
:
2011 s
->cert
->rsa_tmp_cb
= (RSA
*(*)(SSL
*, int, int))fp
;
2015 #ifndef OPENSSL_NO_DH
2016 case SSL_CTRL_SET_TMP_DH_CB
:
2018 s
->cert
->dh_tmp_cb
= (DH
*(*)(SSL
*, int, int))fp
;
2022 #ifndef OPENSSL_NO_ECDH
2023 case SSL_CTRL_SET_TMP_ECDH_CB
:
2025 s
->cert
->ecdh_tmp_cb
= (EC_KEY
*(*)(SSL
*, int, int))fp
;
2029 #ifndef OPENSSL_NO_TLSEXT
2030 case SSL_CTRL_SET_TLSEXT_DEBUG_CB
:
2031 s
->tlsext_debug_cb
=(void (*)(SSL
*,int ,int,
2032 unsigned char *, int, void *))fp
;
2041 long ssl3_ctx_ctrl(SSL_CTX
*ctx
, int cmd
, long larg
, void *parg
)
2049 #ifndef OPENSSL_NO_RSA
2050 case SSL_CTRL_NEED_TMP_RSA
:
2051 if ( (cert
->rsa_tmp
== NULL
) &&
2052 ((cert
->pkeys
[SSL_PKEY_RSA_ENC
].privatekey
== NULL
) ||
2053 (EVP_PKEY_size(cert
->pkeys
[SSL_PKEY_RSA_ENC
].privatekey
) > (512/8)))
2059 case SSL_CTRL_SET_TMP_RSA
:
2070 if ((rsa
=RSAPrivateKey_dup(rsa
)) == NULL
)
2075 SSLerr(SSL_F_SSL3_CTX_CTRL
,ERR_R_RSA_LIB
);
2080 if (cert
->rsa_tmp
!= NULL
)
2081 RSA_free(cert
->rsa_tmp
);
2087 case SSL_CTRL_SET_TMP_RSA_CB
:
2089 SSLerr(SSL_F_SSL3_CTX_CTRL
, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED
);
2094 #ifndef OPENSSL_NO_DH
2095 case SSL_CTRL_SET_TMP_DH
:
2100 if ((new=DHparams_dup(dh
)) == NULL
)
2102 SSLerr(SSL_F_SSL3_CTX_CTRL
,ERR_R_DH_LIB
);
2105 if (!(ctx
->options
& SSL_OP_SINGLE_DH_USE
))
2107 if (!DH_generate_key(new))
2109 SSLerr(SSL_F_SSL3_CTX_CTRL
,ERR_R_DH_LIB
);
2114 if (cert
->dh_tmp
!= NULL
)
2115 DH_free(cert
->dh_tmp
);
2120 case SSL_CTRL_SET_TMP_DH_CB
:
2122 SSLerr(SSL_F_SSL3_CTX_CTRL
, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED
);
2127 #ifndef OPENSSL_NO_ECDH
2128 case SSL_CTRL_SET_TMP_ECDH
:
2130 EC_KEY
*ecdh
= NULL
;
2134 SSLerr(SSL_F_SSL3_CTX_CTRL
,ERR_R_ECDH_LIB
);
2137 ecdh
= EC_KEY_dup((EC_KEY
*)parg
);
2140 SSLerr(SSL_F_SSL3_CTX_CTRL
,ERR_R_EC_LIB
);
2143 if (!(ctx
->options
& SSL_OP_SINGLE_ECDH_USE
))
2145 if (!EC_KEY_generate_key(ecdh
))
2148 SSLerr(SSL_F_SSL3_CTX_CTRL
,ERR_R_ECDH_LIB
);
2153 if (cert
->ecdh_tmp
!= NULL
)
2155 EC_KEY_free(cert
->ecdh_tmp
);
2157 cert
->ecdh_tmp
= ecdh
;
2161 case SSL_CTRL_SET_TMP_ECDH_CB
:
2163 SSLerr(SSL_F_SSL3_CTX_CTRL
, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED
);
2167 #endif /* !OPENSSL_NO_ECDH */
2168 #ifndef OPENSSL_NO_TLSEXT
2169 case SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG
:
2170 ctx
->tlsext_servername_arg
=parg
;
2172 case SSL_CTRL_SET_TLSEXT_TICKET_KEYS
:
2173 case SSL_CTRL_GET_TLSEXT_TICKET_KEYS
:
2175 unsigned char *keys
= parg
;
2180 SSLerr(SSL_F_SSL3_CTX_CTRL
, SSL_R_INVALID_TICKET_KEYS_LENGTH
);
2183 if (cmd
== SSL_CTRL_SET_TLSEXT_TICKET_KEYS
)
2185 memcpy(ctx
->tlsext_tick_key_name
, keys
, 16);
2186 memcpy(ctx
->tlsext_tick_hmac_key
, keys
+ 16, 16);
2187 memcpy(ctx
->tlsext_tick_aes_key
, keys
+ 32, 16);
2191 memcpy(keys
, ctx
->tlsext_tick_key_name
, 16);
2192 memcpy(keys
+ 16, ctx
->tlsext_tick_hmac_key
, 16);
2193 memcpy(keys
+ 32, ctx
->tlsext_tick_aes_key
, 16);
2198 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG
:
2199 ctx
->tlsext_status_arg
=parg
;
2203 #endif /* !OPENSSL_NO_TLSEXT */
2204 /* A Thawte special :-) */
2205 case SSL_CTRL_EXTRA_CHAIN_CERT
:
2206 if (ctx
->extra_certs
== NULL
)
2208 if ((ctx
->extra_certs
=sk_X509_new_null()) == NULL
)
2211 sk_X509_push(ctx
->extra_certs
,(X509
*)parg
);
2220 long ssl3_ctx_callback_ctrl(SSL_CTX
*ctx
, int cmd
, void (*fp
)(void))
2228 #ifndef OPENSSL_NO_RSA
2229 case SSL_CTRL_SET_TMP_RSA_CB
:
2231 cert
->rsa_tmp_cb
= (RSA
*(*)(SSL
*, int, int))fp
;
2235 #ifndef OPENSSL_NO_DH
2236 case SSL_CTRL_SET_TMP_DH_CB
:
2238 cert
->dh_tmp_cb
= (DH
*(*)(SSL
*, int, int))fp
;
2242 #ifndef OPENSSL_NO_ECDH
2243 case SSL_CTRL_SET_TMP_ECDH_CB
:
2245 cert
->ecdh_tmp_cb
= (EC_KEY
*(*)(SSL
*, int, int))fp
;
2249 #ifndef OPENSSL_NO_TLSEXT
2250 case SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
:
2251 ctx
->tlsext_servername_callback
=(int (*)(SSL
*,int *,void *))fp
;
2254 case SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB
:
2255 ctx
->tlsext_status_cb
=(int (*)(SSL
*,void *))fp
;
2258 case SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB
:
2259 ctx
->tlsext_ticket_key_cb
=(int (*)(SSL
*,unsigned char *,
2262 HMAC_CTX
*, int))fp
;
2272 /* This function needs to check if the ciphers required are actually
2274 SSL_CIPHER
*ssl3_get_cipher_by_char(const unsigned char *p
)
2279 id
=0x03000000L
|((unsigned long)p
[0]<<8L)|(unsigned long)p
[1];
2281 cp
= (SSL_CIPHER
*)OBJ_bsearch((char *)&c
,
2282 (char *)ssl3_ciphers
,
2283 SSL3_NUM_CIPHERS
,sizeof(SSL_CIPHER
),
2284 FP_ICC ssl_cipher_id_cmp
);
2285 if (cp
== NULL
|| cp
->valid
== 0)
2291 int ssl3_put_cipher_by_char(const SSL_CIPHER
*c
, unsigned char *p
)
2298 if ((l
& 0xff000000) != 0x03000000) return(0);
2299 p
[0]=((unsigned char)(l
>> 8L))&0xFF;
2300 p
[1]=((unsigned char)(l
))&0xFF;
2305 SSL_CIPHER
*ssl3_choose_cipher(SSL
*s
, STACK_OF(SSL_CIPHER
) *clnt
,
2306 STACK_OF(SSL_CIPHER
) *srvr
)
2308 SSL_CIPHER
*c
,*ret
=NULL
;
2309 STACK_OF(SSL_CIPHER
) *prio
, *allow
;
2313 unsigned long alg
,mask
,emask
;
2315 /* Let's see which ciphers we can support */
2319 /* Do not set the compare functions, because this may lead to a
2320 * reordering by "id". We want to keep the original ordering.
2321 * We may pay a price in performance during sk_SSL_CIPHER_find(),
2322 * but would have to pay with the price of sk_SSL_CIPHER_dup().
2324 sk_SSL_CIPHER_set_cmp_func(srvr
, ssl_cipher_ptr_id_cmp
);
2325 sk_SSL_CIPHER_set_cmp_func(clnt
, ssl_cipher_ptr_id_cmp
);
2329 printf("Server has %d from %p:\n", sk_SSL_CIPHER_num(srvr
), srvr
);
2330 for(i
=0 ; i
< sk_SSL_CIPHER_num(srvr
) ; ++i
)
2332 c
=sk_SSL_CIPHER_value(srvr
,i
);
2333 printf("%p:%s\n",c
,c
->name
);
2335 printf("Client sent %d from %p:\n", sk_SSL_CIPHER_num(clnt
), clnt
);
2336 for(i
=0 ; i
< sk_SSL_CIPHER_num(clnt
) ; ++i
)
2338 c
=sk_SSL_CIPHER_value(clnt
,i
);
2339 printf("%p:%s\n",c
,c
->name
);
2343 if (s
->options
& SSL_OP_CIPHER_SERVER_PREFERENCE
)
2354 for (i
=0; i
<sk_SSL_CIPHER_num(prio
); i
++)
2356 c
=sk_SSL_CIPHER_value(prio
,i
);
2358 ssl_set_cert_masks(cert
,c
);
2360 emask
=cert
->export_mask
;
2363 printf("ssl3_choose_cipher %d alg= %lx\n", i
,c
->algorithms
);
2364 #endif /* KSSL_DEBUG */
2366 alg
=c
->algorithms
&(SSL_MKEY_MASK
|SSL_AUTH_MASK
);
2367 #ifndef OPENSSL_NO_KRB5
2370 if ( !kssl_keytab_is_available(s
->kssl_ctx
) )
2373 #endif /* OPENSSL_NO_KRB5 */
2374 if (SSL_C_IS_EXPORT(c
))
2376 ok
=((alg
& emask
) == alg
)?1:0;
2378 printf("%d:[%08lX:%08lX]%p:%s (export)\n",ok
,alg
,emask
,
2384 ok
=((alg
& mask
) == alg
)?1:0;
2386 printf("%d:[%08lX:%08lX]%p:%s\n",ok
,alg
,mask
,c
,
2392 j
=sk_SSL_CIPHER_find(allow
,c
);
2395 ret
=sk_SSL_CIPHER_value(allow
,j
);
2402 int ssl3_get_req_cert_type(SSL
*s
, unsigned char *p
)
2407 alg
=s
->s3
->tmp
.new_cipher
->algorithms
;
2409 #ifndef OPENSSL_NO_DH
2410 if (alg
& (SSL_kDHr
|SSL_kEDH
))
2412 # ifndef OPENSSL_NO_RSA
2413 p
[ret
++]=SSL3_CT_RSA_FIXED_DH
;
2415 # ifndef OPENSSL_NO_DSA
2416 p
[ret
++]=SSL3_CT_DSS_FIXED_DH
;
2419 if ((s
->version
== SSL3_VERSION
) &&
2420 (alg
& (SSL_kEDH
|SSL_kDHd
|SSL_kDHr
)))
2422 # ifndef OPENSSL_NO_RSA
2423 p
[ret
++]=SSL3_CT_RSA_EPHEMERAL_DH
;
2425 # ifndef OPENSSL_NO_DSA
2426 p
[ret
++]=SSL3_CT_DSS_EPHEMERAL_DH
;
2429 #endif /* !OPENSSL_NO_DH */
2430 #ifndef OPENSSL_NO_RSA
2431 p
[ret
++]=SSL3_CT_RSA_SIGN
;
2433 #ifndef OPENSSL_NO_DSA
2434 p
[ret
++]=SSL3_CT_DSS_SIGN
;
2436 #ifndef OPENSSL_NO_ECDH
2437 /* We should ask for fixed ECDH certificates only
2438 * for SSL_kECDH (and not SSL_kECDHE)
2440 if ((alg
& SSL_kECDH
) && (s
->version
>= TLS1_VERSION
))
2442 p
[ret
++]=TLS_CT_RSA_FIXED_ECDH
;
2443 p
[ret
++]=TLS_CT_ECDSA_FIXED_ECDH
;
2447 #ifndef OPENSSL_NO_ECDSA
2448 /* ECDSA certs can be used with RSA cipher suites as well
2449 * so we don't need to check for SSL_kECDH or SSL_kECDHE
2451 if (s
->version
>= TLS1_VERSION
)
2453 p
[ret
++]=TLS_CT_ECDSA_SIGN
;
2459 int ssl3_shutdown(SSL
*s
)
2462 /* Don't do anything much if we have not done the handshake or
2463 * we don't want to send messages :-) */
2464 if ((s
->quiet_shutdown
) || (s
->state
== SSL_ST_BEFORE
))
2466 s
->shutdown
=(SSL_SENT_SHUTDOWN
|SSL_RECEIVED_SHUTDOWN
);
2470 if (!(s
->shutdown
& SSL_SENT_SHUTDOWN
))
2472 s
->shutdown
|=SSL_SENT_SHUTDOWN
;
2474 ssl3_send_alert(s
,SSL3_AL_WARNING
,SSL_AD_CLOSE_NOTIFY
);
2476 /* our shutdown alert has been sent now, and if it still needs
2477 * to be written, s->s3->alert_dispatch will be true */
2479 else if (s
->s3
->alert_dispatch
)
2481 /* resend it if not sent */
2483 s
->method
->ssl_dispatch_alert(s
);
2486 else if (!(s
->shutdown
& SSL_RECEIVED_SHUTDOWN
))
2488 /* If we are waiting for a close from our peer, we are closed */
2489 s
->method
->ssl_read_bytes(s
,0,NULL
,0,0);
2492 if ((s
->shutdown
== (SSL_SENT_SHUTDOWN
|SSL_RECEIVED_SHUTDOWN
)) &&
2493 !s
->s3
->alert_dispatch
)
2499 int ssl3_write(SSL
*s
, const void *buf
, int len
)
2504 if (s
->shutdown
& SSL_SEND_SHUTDOWN
)
2506 s
->rwstate
=SSL_NOTHING
;
2511 if (s
->s3
->renegotiate
) ssl3_renegotiate_check(s
);
2513 /* This is an experimental flag that sends the
2514 * last handshake message in the same packet as the first
2515 * use data - used to see if it helps the TCP protocol during
2516 * session-id reuse */
2517 /* The second test is because the buffer may have been removed */
2518 if ((s
->s3
->flags
& SSL3_FLAGS_POP_BUFFER
) && (s
->wbio
== s
->bbio
))
2520 /* First time through, we write into the buffer */
2521 if (s
->s3
->delay_buf_pop_ret
== 0)
2523 ret
=ssl3_write_bytes(s
,SSL3_RT_APPLICATION_DATA
,
2525 if (ret
<= 0) return(ret
);
2527 s
->s3
->delay_buf_pop_ret
=ret
;
2530 s
->rwstate
=SSL_WRITING
;
2531 n
=BIO_flush(s
->wbio
);
2532 if (n
<= 0) return(n
);
2533 s
->rwstate
=SSL_NOTHING
;
2535 /* We have flushed the buffer, so remove it */
2536 ssl_free_wbio_buffer(s
);
2537 s
->s3
->flags
&= ~SSL3_FLAGS_POP_BUFFER
;
2539 ret
=s
->s3
->delay_buf_pop_ret
;
2540 s
->s3
->delay_buf_pop_ret
=0;
2544 ret
=s
->method
->ssl_write_bytes(s
,SSL3_RT_APPLICATION_DATA
,
2546 if (ret
<= 0) return(ret
);
2552 static int ssl3_read_internal(SSL
*s
, void *buf
, int len
, int peek
)
2557 if (s
->s3
->renegotiate
) ssl3_renegotiate_check(s
);
2558 s
->s3
->in_read_app_data
=1;
2559 ret
=s
->method
->ssl_read_bytes(s
,SSL3_RT_APPLICATION_DATA
,buf
,len
,peek
);
2560 if ((ret
== -1) && (s
->s3
->in_read_app_data
== 2))
2562 /* ssl3_read_bytes decided to call s->handshake_func, which
2563 * called ssl3_read_bytes to read handshake data.
2564 * However, ssl3_read_bytes actually found application data
2565 * and thinks that application data makes sense here; so disable
2566 * handshake processing and try to read application data again. */
2568 ret
=s
->method
->ssl_read_bytes(s
,SSL3_RT_APPLICATION_DATA
,buf
,len
,peek
);
2572 s
->s3
->in_read_app_data
=0;
2577 int ssl3_read(SSL
*s
, void *buf
, int len
)
2579 return ssl3_read_internal(s
, buf
, len
, 0);
2582 int ssl3_peek(SSL
*s
, void *buf
, int len
)
2584 return ssl3_read_internal(s
, buf
, len
, 1);
2587 int ssl3_renegotiate(SSL
*s
)
2589 if (s
->handshake_func
== NULL
)
2592 if (s
->s3
->flags
& SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS
)
2595 s
->s3
->renegotiate
=1;
2599 int ssl3_renegotiate_check(SSL
*s
)
2603 if (s
->s3
->renegotiate
)
2605 if ( (s
->s3
->rbuf
.left
== 0) &&
2606 (s
->s3
->wbuf
.left
== 0) &&
2610 if we are the server, and we have sent a 'RENEGOTIATE' message, we
2611 need to go to SSL_ST_ACCEPT.
2614 s
->state
=SSL_ST_RENEGOTIATE
;
2615 s
->s3
->renegotiate
=0;
2616 s
->s3
->num_renegotiations
++;
2617 s
->s3
->total_renegotiations
++;