diff options
Diffstat (limited to 'src/lib/libssl')
-rw-r--r-- | src/lib/libssl/LICENSE | 2 | ||||
-rw-r--r-- | src/lib/libssl/bio_ssl.c | 6 | ||||
-rw-r--r-- | src/lib/libssl/doc/standards.txt | 173 | ||||
-rw-r--r-- | src/lib/libssl/s23_clnt.c | 24 | ||||
-rw-r--r-- | src/lib/libssl/s23_srvr.c | 19 | ||||
-rw-r--r-- | src/lib/libssl/s3_both.c | 25 | ||||
-rw-r--r-- | src/lib/libssl/s3_clnt.c | 73 | ||||
-rw-r--r-- | src/lib/libssl/s3_lib.c | 193 | ||||
-rw-r--r-- | src/lib/libssl/s3_pkt.c | 47 | ||||
-rw-r--r-- | src/lib/libssl/s3_srvr.c | 53 | ||||
-rw-r--r-- | src/lib/libssl/ssl.h | 30 | ||||
-rw-r--r-- | src/lib/libssl/ssl3.h | 48 | ||||
-rw-r--r-- | src/lib/libssl/ssl_asn1.c | 11 | ||||
-rw-r--r-- | src/lib/libssl/ssl_cert.c | 30 | ||||
-rw-r--r-- | src/lib/libssl/ssl_ciph.c | 14 | ||||
-rw-r--r-- | src/lib/libssl/ssl_err.c | 1 | ||||
-rw-r--r-- | src/lib/libssl/ssl_lib.c | 45 | ||||
-rw-r--r-- | src/lib/libssl/ssl_sess.c | 17 | ||||
-rw-r--r-- | src/lib/libssl/t1_clnt.c | 17 | ||||
-rw-r--r-- | src/lib/libssl/t1_enc.c | 20 | ||||
-rw-r--r-- | src/lib/libssl/t1_meth.c | 20 | ||||
-rw-r--r-- | src/lib/libssl/t1_srvr.c | 17 | ||||
-rw-r--r-- | src/lib/libssl/test/methtest.c | 4 | ||||
-rw-r--r-- | src/lib/libssl/test/testgen | 2 | ||||
-rw-r--r-- | src/lib/libssl/test/testssl | 16 |
25 files changed, 669 insertions, 238 deletions
diff --git a/src/lib/libssl/LICENSE b/src/lib/libssl/LICENSE index 7b93e0dbce..dddb07842b 100644 --- a/src/lib/libssl/LICENSE +++ b/src/lib/libssl/LICENSE | |||
@@ -12,7 +12,7 @@ | |||
12 | --------------- | 12 | --------------- |
13 | 13 | ||
14 | /* ==================================================================== | 14 | /* ==================================================================== |
15 | * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. | 15 | * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. |
16 | * | 16 | * |
17 | * Redistribution and use in source and binary forms, with or without | 17 | * Redistribution and use in source and binary forms, with or without |
18 | * modification, are permitted provided that the following conditions | 18 | * modification, are permitted provided that the following conditions |
diff --git a/src/lib/libssl/bio_ssl.c b/src/lib/libssl/bio_ssl.c index 467e149947..d683ee43e1 100644 --- a/src/lib/libssl/bio_ssl.c +++ b/src/lib/libssl/bio_ssl.c | |||
@@ -403,6 +403,10 @@ static long ssl_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
403 | { | 403 | { |
404 | BIO_free_all(ssl->wbio); | 404 | BIO_free_all(ssl->wbio); |
405 | } | 405 | } |
406 | if (b->next_bio != NULL) | ||
407 | { | ||
408 | CRYPTO_add(&b->next_bio->references,1,CRYPTO_LOCK_BIO); | ||
409 | } | ||
406 | ssl->wbio=NULL; | 410 | ssl->wbio=NULL; |
407 | ssl->rbio=NULL; | 411 | ssl->rbio=NULL; |
408 | break; | 412 | break; |
@@ -509,6 +513,7 @@ static int ssl_puts(BIO *bp, const char *str) | |||
509 | 513 | ||
510 | BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx) | 514 | BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx) |
511 | { | 515 | { |
516 | #ifndef OPENSSL_NO_SOCK | ||
512 | BIO *ret=NULL,*buf=NULL,*ssl=NULL; | 517 | BIO *ret=NULL,*buf=NULL,*ssl=NULL; |
513 | 518 | ||
514 | if ((buf=BIO_new(BIO_f_buffer())) == NULL) | 519 | if ((buf=BIO_new(BIO_f_buffer())) == NULL) |
@@ -521,6 +526,7 @@ BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx) | |||
521 | err: | 526 | err: |
522 | if (buf != NULL) BIO_free(buf); | 527 | if (buf != NULL) BIO_free(buf); |
523 | if (ssl != NULL) BIO_free(ssl); | 528 | if (ssl != NULL) BIO_free(ssl); |
529 | #endif | ||
524 | return(NULL); | 530 | return(NULL); |
525 | } | 531 | } |
526 | 532 | ||
diff --git a/src/lib/libssl/doc/standards.txt b/src/lib/libssl/doc/standards.txt index 596d9001e6..edbe2f3a57 100644 --- a/src/lib/libssl/doc/standards.txt +++ b/src/lib/libssl/doc/standards.txt | |||
@@ -42,20 +42,9 @@ whole or at least great parts) in OpenSSL. | |||
42 | 2268 A Description of the RC2(r) Encryption Algorithm. R. Rivest. | 42 | 2268 A Description of the RC2(r) Encryption Algorithm. R. Rivest. |
43 | January 1998. (Format: TXT=19048 bytes) (Status: INFORMATIONAL) | 43 | January 1998. (Format: TXT=19048 bytes) (Status: INFORMATIONAL) |
44 | 44 | ||
45 | 2314 PKCS 10: Certification Request Syntax Version 1.5. B. Kaliski. | ||
46 | March 1998. (Format: TXT=15814 bytes) (Status: INFORMATIONAL) | ||
47 | |||
48 | 2315 PKCS 7: Cryptographic Message Syntax Version 1.5. B. Kaliski. | 45 | 2315 PKCS 7: Cryptographic Message Syntax Version 1.5. B. Kaliski. |
49 | March 1998. (Format: TXT=69679 bytes) (Status: INFORMATIONAL) | 46 | March 1998. (Format: TXT=69679 bytes) (Status: INFORMATIONAL) |
50 | 47 | ||
51 | 2437 PKCS #1: RSA Cryptography Specifications Version 2.0. B. Kaliski, | ||
52 | J. Staddon. October 1998. (Format: TXT=73529 bytes) (Obsoletes | ||
53 | RFC2313) (Status: INFORMATIONAL) | ||
54 | |||
55 | 2459 Internet X.509 Public Key Infrastructure Certificate and CRL | ||
56 | Profile. R. Housley, W. Ford, W. Polk, D. Solo. January 1999. | ||
57 | (Format: TXT=278438 bytes) (Status: PROPOSED STANDARD) | ||
58 | |||
59 | PKCS#8: Private-Key Information Syntax Standard | 48 | PKCS#8: Private-Key Information Syntax Standard |
60 | 49 | ||
61 | PKCS#12: Personal Information Exchange Syntax Standard, version 1.0. | 50 | PKCS#12: Personal Information Exchange Syntax Standard, version 1.0. |
@@ -65,6 +54,40 @@ PKCS#12: Personal Information Exchange Syntax Standard, version 1.0. | |||
65 | C. Adams. June 1999. (Format: TXT=43243 bytes) (Status: PROPOSED | 54 | C. Adams. June 1999. (Format: TXT=43243 bytes) (Status: PROPOSED |
66 | STANDARD) | 55 | STANDARD) |
67 | 56 | ||
57 | 2712 Addition of Kerberos Cipher Suites to Transport Layer Security | ||
58 | (TLS). A. Medvinsky, M. Hur. October 1999. (Format: TXT=13763 bytes) | ||
59 | (Status: PROPOSED STANDARD) | ||
60 | |||
61 | 2898 PKCS #5: Password-Based Cryptography Specification Version 2.0. | ||
62 | B. Kaliski. September 2000. (Format: TXT=68692 bytes) (Status: | ||
63 | INFORMATIONAL) | ||
64 | |||
65 | 2986 PKCS #10: Certification Request Syntax Specification Version 1.7. | ||
66 | M. Nystrom, B. Kaliski. November 2000. (Format: TXT=27794 bytes) | ||
67 | (Obsoletes RFC2314) (Status: INFORMATIONAL) | ||
68 | |||
69 | 3174 US Secure Hash Algorithm 1 (SHA1). D. Eastlake 3rd, P. Jones. | ||
70 | September 2001. (Format: TXT=35525 bytes) (Status: INFORMATIONAL) | ||
71 | |||
72 | 3268 Advanced Encryption Standard (AES) Ciphersuites for Transport | ||
73 | Layer Security (TLS). P. Chown. June 2002. (Format: TXT=13530 bytes) | ||
74 | (Status: PROPOSED STANDARD) | ||
75 | |||
76 | 3279 Algorithms and Identifiers for the Internet X.509 Public Key | ||
77 | Infrastructure Certificate and Certificate Revocation List (CRL) | ||
78 | Profile. L. Bassham, W. Polk, R. Housley. April 2002. (Format: | ||
79 | TXT=53833 bytes) (Status: PROPOSED STANDARD) | ||
80 | |||
81 | 3280 Internet X.509 Public Key Infrastructure Certificate and | ||
82 | Certificate Revocation List (CRL) Profile. R. Housley, W. Polk, W. | ||
83 | Ford, D. Solo. April 2002. (Format: TXT=295556 bytes) (Obsoletes | ||
84 | RFC2459) (Status: PROPOSED STANDARD) | ||
85 | |||
86 | 3447 Public-Key Cryptography Standards (PKCS) #1: RSA Cryptography | ||
87 | Specifications Version 2.1. J. Jonsson, B. Kaliski. February 2003. | ||
88 | (Format: TXT=143173 bytes) (Obsoletes RFC2437) (Status: | ||
89 | INFORMATIONAL) | ||
90 | |||
68 | 91 | ||
69 | Related: | 92 | Related: |
70 | -------- | 93 | -------- |
@@ -90,23 +113,60 @@ STARTTLS documents. | |||
90 | Certification and Related Services. B. Kaliski. February 1993. | 113 | Certification and Related Services. B. Kaliski. February 1993. |
91 | (Format: TXT=17537 bytes) (Status: PROPOSED STANDARD) | 114 | (Format: TXT=17537 bytes) (Status: PROPOSED STANDARD) |
92 | 115 | ||
93 | 2256 A Summary of the X.500(96) User Schema for use with LDAPv3. M. | 116 | 2025 The Simple Public-Key GSS-API Mechanism (SPKM). C. Adams. October |
94 | Wahl. December 1997. (Format: TXT=32377 bytes) (Status: PROPOSED | 117 | 1996. (Format: TXT=101692 bytes) (Status: PROPOSED STANDARD) |
95 | STANDARD) | 118 | |
119 | 2510 Internet X.509 Public Key Infrastructure Certificate Management | ||
120 | Protocols. C. Adams, S. Farrell. March 1999. (Format: TXT=158178 | ||
121 | bytes) (Status: PROPOSED STANDARD) | ||
122 | |||
123 | 2511 Internet X.509 Certificate Request Message Format. M. Myers, C. | ||
124 | Adams, D. Solo, D. Kemp. March 1999. (Format: TXT=48278 bytes) | ||
125 | (Status: PROPOSED STANDARD) | ||
126 | |||
127 | 2527 Internet X.509 Public Key Infrastructure Certificate Policy and | ||
128 | Certification Practices Framework. S. Chokhani, W. Ford. March 1999. | ||
129 | (Format: TXT=91860 bytes) (Status: INFORMATIONAL) | ||
96 | 130 | ||
97 | 2487 SMTP Service Extension for Secure SMTP over TLS. P. Hoffman. | 131 | 2538 Storing Certificates in the Domain Name System (DNS). D. Eastlake |
98 | January 1999. (Format: TXT=15120 bytes) (Status: PROPOSED STANDARD) | 132 | 3rd, O. Gudmundsson. March 1999. (Format: TXT=19857 bytes) (Status: |
133 | PROPOSED STANDARD) | ||
134 | |||
135 | 2539 Storage of Diffie-Hellman Keys in the Domain Name System (DNS). | ||
136 | D. Eastlake 3rd. March 1999. (Format: TXT=21049 bytes) (Status: | ||
137 | PROPOSED STANDARD) | ||
138 | |||
139 | 2559 Internet X.509 Public Key Infrastructure Operational Protocols - | ||
140 | LDAPv2. S. Boeyen, T. Howes, P. Richard. April 1999. (Format: | ||
141 | TXT=22889 bytes) (Updates RFC1778) (Status: PROPOSED STANDARD) | ||
99 | 142 | ||
100 | 2585 Internet X.509 Public Key Infrastructure Operational Protocols: | 143 | 2585 Internet X.509 Public Key Infrastructure Operational Protocols: |
101 | FTP and HTTP. R. Housley, P. Hoffman. May 1999. (Format: TXT=14813 | 144 | FTP and HTTP. R. Housley, P. Hoffman. May 1999. (Format: TXT=14813 |
102 | bytes) (Status: PROPOSED STANDARD) | 145 | bytes) (Status: PROPOSED STANDARD) |
103 | 146 | ||
147 | 2587 Internet X.509 Public Key Infrastructure LDAPv2 Schema. S. | ||
148 | Boeyen, T. Howes, P. Richard. June 1999. (Format: TXT=15102 bytes) | ||
149 | (Status: PROPOSED STANDARD) | ||
150 | |||
104 | 2595 Using TLS with IMAP, POP3 and ACAP. C. Newman. June 1999. | 151 | 2595 Using TLS with IMAP, POP3 and ACAP. C. Newman. June 1999. |
105 | (Format: TXT=32440 bytes) (Status: PROPOSED STANDARD) | 152 | (Format: TXT=32440 bytes) (Status: PROPOSED STANDARD) |
106 | 153 | ||
107 | 2712 Addition of Kerberos Cipher Suites to Transport Layer Security | 154 | 2631 Diffie-Hellman Key Agreement Method. E. Rescorla. June 1999. |
108 | (TLS). A. Medvinsky, M. Hur. October 1999. (Format: TXT=13763 bytes) | 155 | (Format: TXT=25932 bytes) (Status: PROPOSED STANDARD) |
109 | (Status: PROPOSED STANDARD) | 156 | |
157 | 2632 S/MIME Version 3 Certificate Handling. B. Ramsdell, Ed.. June | ||
158 | 1999. (Format: TXT=27925 bytes) (Status: PROPOSED STANDARD) | ||
159 | |||
160 | 2716 PPP EAP TLS Authentication Protocol. B. Aboba, D. Simon. October | ||
161 | 1999. (Format: TXT=50108 bytes) (Status: EXPERIMENTAL) | ||
162 | |||
163 | 2773 Encryption using KEA and SKIPJACK. R. Housley, P. Yee, W. Nace. | ||
164 | February 2000. (Format: TXT=20008 bytes) (Updates RFC0959) (Status: | ||
165 | EXPERIMENTAL) | ||
166 | |||
167 | 2797 Certificate Management Messages over CMS. M. Myers, X. Liu, J. | ||
168 | Schaad, J. Weinstein. April 2000. (Format: TXT=103357 bytes) (Status: | ||
169 | PROPOSED STANDARD) | ||
110 | 170 | ||
111 | 2817 Upgrading to TLS Within HTTP/1.1. R. Khare, S. Lawrence. May | 171 | 2817 Upgrading to TLS Within HTTP/1.1. R. Khare, S. Lawrence. May |
112 | 2000. (Format: TXT=27598 bytes) (Updates RFC2616) (Status: PROPOSED | 172 | 2000. (Format: TXT=27598 bytes) (Updates RFC2616) (Status: PROPOSED |
@@ -115,6 +175,77 @@ STARTTLS documents. | |||
115 | 2818 HTTP Over TLS. E. Rescorla. May 2000. (Format: TXT=15170 bytes) | 175 | 2818 HTTP Over TLS. E. Rescorla. May 2000. (Format: TXT=15170 bytes) |
116 | (Status: INFORMATIONAL) | 176 | (Status: INFORMATIONAL) |
117 | 177 | ||
178 | 2876 Use of the KEA and SKIPJACK Algorithms in CMS. J. Pawling. July | ||
179 | 2000. (Format: TXT=29265 bytes) (Status: INFORMATIONAL) | ||
180 | |||
181 | 2984 Use of the CAST-128 Encryption Algorithm in CMS. C. Adams. | ||
182 | October 2000. (Format: TXT=11591 bytes) (Status: PROPOSED STANDARD) | ||
183 | |||
184 | 2985 PKCS #9: Selected Object Classes and Attribute Types Version 2.0. | ||
185 | M. Nystrom, B. Kaliski. November 2000. (Format: TXT=70703 bytes) | ||
186 | (Status: INFORMATIONAL) | ||
187 | |||
188 | 3029 Internet X.509 Public Key Infrastructure Data Validation and | ||
189 | Certification Server Protocols. C. Adams, P. Sylvester, M. Zolotarev, | ||
190 | R. Zuccherato. February 2001. (Format: TXT=107347 bytes) (Status: | ||
191 | EXPERIMENTAL) | ||
192 | |||
193 | 3039 Internet X.509 Public Key Infrastructure Qualified Certificates | ||
194 | Profile. S. Santesson, W. Polk, P. Barzin, M. Nystrom. January 2001. | ||
195 | (Format: TXT=67619 bytes) (Status: PROPOSED STANDARD) | ||
196 | |||
197 | 3058 Use of the IDEA Encryption Algorithm in CMS. S. Teiwes, P. | ||
198 | Hartmann, D. Kuenzi. February 2001. (Format: TXT=17257 bytes) | ||
199 | (Status: INFORMATIONAL) | ||
200 | |||
201 | 3161 Internet X.509 Public Key Infrastructure Time-Stamp Protocol | ||
202 | (TSP). C. Adams, P. Cain, D. Pinkas, R. Zuccherato. August 2001. | ||
203 | (Format: TXT=54585 bytes) (Status: PROPOSED STANDARD) | ||
204 | |||
205 | 3185 Reuse of CMS Content Encryption Keys. S. Farrell, S. Turner. | ||
206 | October 2001. (Format: TXT=20404 bytes) (Status: PROPOSED STANDARD) | ||
207 | |||
208 | 3207 SMTP Service Extension for Secure SMTP over Transport Layer | ||
209 | Security. P. Hoffman. February 2002. (Format: TXT=18679 bytes) | ||
210 | (Obsoletes RFC2487) (Status: PROPOSED STANDARD) | ||
211 | |||
212 | 3217 Triple-DES and RC2 Key Wrapping. R. Housley. December 2001. | ||
213 | (Format: TXT=19855 bytes) (Status: INFORMATIONAL) | ||
214 | |||
215 | 3274 Compressed Data Content Type for Cryptographic Message Syntax | ||
216 | (CMS). P. Gutmann. June 2002. (Format: TXT=11276 bytes) (Status: | ||
217 | PROPOSED STANDARD) | ||
218 | |||
219 | 3278 Use of Elliptic Curve Cryptography (ECC) Algorithms in | ||
220 | Cryptographic Message Syntax (CMS). S. Blake-Wilson, D. Brown, P. | ||
221 | Lambert. April 2002. (Format: TXT=33779 bytes) (Status: | ||
222 | INFORMATIONAL) | ||
223 | |||
224 | 3281 An Internet Attribute Certificate Profile for Authorization. S. | ||
225 | Farrell, R. Housley. April 2002. (Format: TXT=90580 bytes) (Status: | ||
226 | PROPOSED STANDARD) | ||
227 | |||
228 | 3369 Cryptographic Message Syntax (CMS). R. Housley. August 2002. | ||
229 | (Format: TXT=113975 bytes) (Obsoletes RFC2630, RFC3211) (Status: | ||
230 | PROPOSED STANDARD) | ||
231 | |||
232 | 3370 Cryptographic Message Syntax (CMS) Algorithms. R. Housley. August | ||
233 | 2002. (Format: TXT=51001 bytes) (Obsoletes RFC2630, RFC3211) (Status: | ||
234 | PROPOSED STANDARD) | ||
235 | |||
236 | 3377 Lightweight Directory Access Protocol (v3): Technical | ||
237 | Specification. J. Hodges, R. Morgan. September 2002. (Format: | ||
238 | TXT=9981 bytes) (Updates RFC2251, RFC2252, RFC2253, RFC2254, RFC2255, | ||
239 | RFC2256, RFC2829, RFC2830) (Status: PROPOSED STANDARD) | ||
240 | |||
241 | 3394 Advanced Encryption Standard (AES) Key Wrap Algorithm. J. Schaad, | ||
242 | R. Housley. September 2002. (Format: TXT=73072 bytes) (Status: | ||
243 | INFORMATIONAL) | ||
244 | |||
245 | 3436 Transport Layer Security over Stream Control Transmission | ||
246 | Protocol. A. Jungmaier, E. Rescorla, M. Tuexen. December 2002. | ||
247 | (Format: TXT=16333 bytes) (Status: PROPOSED STANDARD) | ||
248 | |||
118 | "Securing FTP with TLS", 01/27/2000, <draft-murray-auth-ftp-ssl-05.txt> | 249 | "Securing FTP with TLS", 01/27/2000, <draft-murray-auth-ftp-ssl-05.txt> |
119 | 250 | ||
120 | 251 | ||
@@ -124,7 +255,3 @@ To be implemented: | |||
124 | These are documents that describe things that are planed to be | 255 | These are documents that describe things that are planed to be |
125 | implemented in the hopefully short future. | 256 | implemented in the hopefully short future. |
126 | 257 | ||
127 | 2712 Addition of Kerberos Cipher Suites to Transport Layer Security | ||
128 | (TLS). A. Medvinsky, M. Hur. October 1999. (Format: TXT=13763 bytes) | ||
129 | (Status: PROPOSED STANDARD) | ||
130 | |||
diff --git a/src/lib/libssl/s23_clnt.c b/src/lib/libssl/s23_clnt.c index 019e9aecee..64ee4269ec 100644 --- a/src/lib/libssl/s23_clnt.c +++ b/src/lib/libssl/s23_clnt.c | |||
@@ -87,18 +87,25 @@ SSL_METHOD *SSLv23_client_method(void) | |||
87 | 87 | ||
88 | if (init) | 88 | if (init) |
89 | { | 89 | { |
90 | memcpy((char *)&SSLv23_client_data, | 90 | CRYPTO_w_lock(CRYPTO_LOCK_SSL_METHOD); |
91 | (char *)sslv23_base_method(),sizeof(SSL_METHOD)); | 91 | |
92 | SSLv23_client_data.ssl_connect=ssl23_connect; | 92 | if (init) |
93 | SSLv23_client_data.get_ssl_method=ssl23_get_client_method; | 93 | { |
94 | init=0; | 94 | memcpy((char *)&SSLv23_client_data, |
95 | (char *)sslv23_base_method(),sizeof(SSL_METHOD)); | ||
96 | SSLv23_client_data.ssl_connect=ssl23_connect; | ||
97 | SSLv23_client_data.get_ssl_method=ssl23_get_client_method; | ||
98 | init=0; | ||
99 | } | ||
100 | |||
101 | CRYPTO_w_unlock(CRYPTO_LOCK_SSL_METHOD); | ||
95 | } | 102 | } |
96 | return(&SSLv23_client_data); | 103 | return(&SSLv23_client_data); |
97 | } | 104 | } |
98 | 105 | ||
99 | int ssl23_connect(SSL *s) | 106 | int ssl23_connect(SSL *s) |
100 | { | 107 | { |
101 | BUF_MEM *buf; | 108 | BUF_MEM *buf=NULL; |
102 | unsigned long Time=time(NULL); | 109 | unsigned long Time=time(NULL); |
103 | void (*cb)(const SSL *ssl,int type,int val)=NULL; | 110 | void (*cb)(const SSL *ssl,int type,int val)=NULL; |
104 | int ret= -1; | 111 | int ret= -1; |
@@ -152,6 +159,7 @@ int ssl23_connect(SSL *s) | |||
152 | goto end; | 159 | goto end; |
153 | } | 160 | } |
154 | s->init_buf=buf; | 161 | s->init_buf=buf; |
162 | buf=NULL; | ||
155 | } | 163 | } |
156 | 164 | ||
157 | if (!ssl3_setup_buffers(s)) { ret= -1; goto end; } | 165 | if (!ssl3_setup_buffers(s)) { ret= -1; goto end; } |
@@ -200,6 +208,8 @@ int ssl23_connect(SSL *s) | |||
200 | } | 208 | } |
201 | end: | 209 | end: |
202 | s->in_handshake--; | 210 | s->in_handshake--; |
211 | if (buf != NULL) | ||
212 | BUF_MEM_free(buf); | ||
203 | if (cb != NULL) | 213 | if (cb != NULL) |
204 | cb(s,SSL_CB_CONNECT_EXIT,ret); | 214 | cb(s,SSL_CB_CONNECT_EXIT,ret); |
205 | return(ret); | 215 | return(ret); |
@@ -363,7 +373,7 @@ static int ssl23_get_server_hello(SSL *s) | |||
363 | 373 | ||
364 | if (s->s3 != NULL) ssl3_free(s); | 374 | if (s->s3 != NULL) ssl3_free(s); |
365 | 375 | ||
366 | if (!BUF_MEM_grow(s->init_buf, | 376 | if (!BUF_MEM_grow_clean(s->init_buf, |
367 | SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER)) | 377 | SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER)) |
368 | { | 378 | { |
369 | SSLerr(SSL_F_SSL23_GET_SERVER_HELLO,ERR_R_BUF_LIB); | 379 | SSLerr(SSL_F_SSL23_GET_SERVER_HELLO,ERR_R_BUF_LIB); |
diff --git a/src/lib/libssl/s23_srvr.c b/src/lib/libssl/s23_srvr.c index 8743b61cbb..c5404ca0bc 100644 --- a/src/lib/libssl/s23_srvr.c +++ b/src/lib/libssl/s23_srvr.c | |||
@@ -139,11 +139,18 @@ SSL_METHOD *SSLv23_server_method(void) | |||
139 | 139 | ||
140 | if (init) | 140 | if (init) |
141 | { | 141 | { |
142 | memcpy((char *)&SSLv23_server_data, | 142 | CRYPTO_w_lock(CRYPTO_LOCK_SSL_METHOD); |
143 | (char *)sslv23_base_method(),sizeof(SSL_METHOD)); | 143 | |
144 | SSLv23_server_data.ssl_accept=ssl23_accept; | 144 | if (init) |
145 | SSLv23_server_data.get_ssl_method=ssl23_get_server_method; | 145 | { |
146 | init=0; | 146 | memcpy((char *)&SSLv23_server_data, |
147 | (char *)sslv23_base_method(),sizeof(SSL_METHOD)); | ||
148 | SSLv23_server_data.ssl_accept=ssl23_accept; | ||
149 | SSLv23_server_data.get_ssl_method=ssl23_get_server_method; | ||
150 | init=0; | ||
151 | } | ||
152 | |||
153 | CRYPTO_w_unlock(CRYPTO_LOCK_SSL_METHOD); | ||
147 | } | 154 | } |
148 | return(&SSLv23_server_data); | 155 | return(&SSLv23_server_data); |
149 | } | 156 | } |
@@ -505,7 +512,7 @@ int ssl23_get_client_hello(SSL *s) | |||
505 | 512 | ||
506 | if (s->s3 != NULL) ssl3_free(s); | 513 | if (s->s3 != NULL) ssl3_free(s); |
507 | 514 | ||
508 | if (!BUF_MEM_grow(s->init_buf, | 515 | if (!BUF_MEM_grow_clean(s->init_buf, |
509 | SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER)) | 516 | SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER)) |
510 | { | 517 | { |
511 | goto err; | 518 | goto err; |
diff --git a/src/lib/libssl/s3_both.c b/src/lib/libssl/s3_both.c index 8864366f59..64d317b7ac 100644 --- a/src/lib/libssl/s3_both.c +++ b/src/lib/libssl/s3_both.c | |||
@@ -268,16 +268,23 @@ unsigned long ssl3_output_cert_chain(SSL *s, X509 *x) | |||
268 | X509_STORE_CTX xs_ctx; | 268 | X509_STORE_CTX xs_ctx; |
269 | X509_OBJECT obj; | 269 | X509_OBJECT obj; |
270 | 270 | ||
271 | int no_chain; | ||
272 | |||
273 | if ((s->mode & SSL_MODE_NO_AUTO_CHAIN) || s->ctx->extra_certs) | ||
274 | no_chain = 1; | ||
275 | else | ||
276 | no_chain = 0; | ||
277 | |||
271 | /* TLSv1 sends a chain with nothing in it, instead of an alert */ | 278 | /* TLSv1 sends a chain with nothing in it, instead of an alert */ |
272 | buf=s->init_buf; | 279 | buf=s->init_buf; |
273 | if (!BUF_MEM_grow(buf,(int)(10))) | 280 | if (!BUF_MEM_grow_clean(buf,10)) |
274 | { | 281 | { |
275 | SSLerr(SSL_F_SSL3_OUTPUT_CERT_CHAIN,ERR_R_BUF_LIB); | 282 | SSLerr(SSL_F_SSL3_OUTPUT_CERT_CHAIN,ERR_R_BUF_LIB); |
276 | return(0); | 283 | return(0); |
277 | } | 284 | } |
278 | if (x != NULL) | 285 | if (x != NULL) |
279 | { | 286 | { |
280 | if(!X509_STORE_CTX_init(&xs_ctx,s->ctx->cert_store,NULL,NULL)) | 287 | if(!no_chain && !X509_STORE_CTX_init(&xs_ctx,s->ctx->cert_store,NULL,NULL)) |
281 | { | 288 | { |
282 | SSLerr(SSL_F_SSL3_OUTPUT_CERT_CHAIN,ERR_R_X509_LIB); | 289 | SSLerr(SSL_F_SSL3_OUTPUT_CERT_CHAIN,ERR_R_X509_LIB); |
283 | return(0); | 290 | return(0); |
@@ -286,7 +293,7 @@ unsigned long ssl3_output_cert_chain(SSL *s, X509 *x) | |||
286 | for (;;) | 293 | for (;;) |
287 | { | 294 | { |
288 | n=i2d_X509(x,NULL); | 295 | n=i2d_X509(x,NULL); |
289 | if (!BUF_MEM_grow(buf,(int)(n+l+3))) | 296 | if (!BUF_MEM_grow_clean(buf,(int)(n+l+3))) |
290 | { | 297 | { |
291 | SSLerr(SSL_F_SSL3_OUTPUT_CERT_CHAIN,ERR_R_BUF_LIB); | 298 | SSLerr(SSL_F_SSL3_OUTPUT_CERT_CHAIN,ERR_R_BUF_LIB); |
292 | return(0); | 299 | return(0); |
@@ -295,6 +302,10 @@ unsigned long ssl3_output_cert_chain(SSL *s, X509 *x) | |||
295 | l2n3(n,p); | 302 | l2n3(n,p); |
296 | i2d_X509(x,&p); | 303 | i2d_X509(x,&p); |
297 | l+=n+3; | 304 | l+=n+3; |
305 | |||
306 | if (no_chain) | ||
307 | break; | ||
308 | |||
298 | if (X509_NAME_cmp(X509_get_subject_name(x), | 309 | if (X509_NAME_cmp(X509_get_subject_name(x), |
299 | X509_get_issuer_name(x)) == 0) break; | 310 | X509_get_issuer_name(x)) == 0) break; |
300 | 311 | ||
@@ -306,8 +317,8 @@ unsigned long ssl3_output_cert_chain(SSL *s, X509 *x) | |||
306 | * ref count */ | 317 | * ref count */ |
307 | X509_free(x); | 318 | X509_free(x); |
308 | } | 319 | } |
309 | 320 | if (!no_chain) | |
310 | X509_STORE_CTX_cleanup(&xs_ctx); | 321 | X509_STORE_CTX_cleanup(&xs_ctx); |
311 | } | 322 | } |
312 | 323 | ||
313 | /* Thawte special :-) */ | 324 | /* Thawte special :-) */ |
@@ -316,7 +327,7 @@ unsigned long ssl3_output_cert_chain(SSL *s, X509 *x) | |||
316 | { | 327 | { |
317 | x=sk_X509_value(s->ctx->extra_certs,i); | 328 | x=sk_X509_value(s->ctx->extra_certs,i); |
318 | n=i2d_X509(x,NULL); | 329 | n=i2d_X509(x,NULL); |
319 | if (!BUF_MEM_grow(buf,(int)(n+l+3))) | 330 | if (!BUF_MEM_grow_clean(buf,(int)(n+l+3))) |
320 | { | 331 | { |
321 | SSLerr(SSL_F_SSL3_OUTPUT_CERT_CHAIN,ERR_R_BUF_LIB); | 332 | SSLerr(SSL_F_SSL3_OUTPUT_CERT_CHAIN,ERR_R_BUF_LIB); |
322 | return(0); | 333 | return(0); |
@@ -439,7 +450,7 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok) | |||
439 | SSLerr(SSL_F_SSL3_GET_MESSAGE,SSL_R_EXCESSIVE_MESSAGE_SIZE); | 450 | SSLerr(SSL_F_SSL3_GET_MESSAGE,SSL_R_EXCESSIVE_MESSAGE_SIZE); |
440 | goto f_err; | 451 | goto f_err; |
441 | } | 452 | } |
442 | if (l && !BUF_MEM_grow(s->init_buf,(int)l+4)) | 453 | if (l && !BUF_MEM_grow_clean(s->init_buf,(int)l+4)) |
443 | { | 454 | { |
444 | SSLerr(SSL_F_SSL3_GET_MESSAGE,ERR_R_BUF_LIB); | 455 | SSLerr(SSL_F_SSL3_GET_MESSAGE,ERR_R_BUF_LIB); |
445 | goto err; | 456 | goto err; |
diff --git a/src/lib/libssl/s3_clnt.c b/src/lib/libssl/s3_clnt.c index 2b58482484..fae8eadada 100644 --- a/src/lib/libssl/s3_clnt.c +++ b/src/lib/libssl/s3_clnt.c | |||
@@ -146,18 +146,25 @@ SSL_METHOD *SSLv3_client_method(void) | |||
146 | 146 | ||
147 | if (init) | 147 | if (init) |
148 | { | 148 | { |
149 | init=0; | 149 | CRYPTO_w_lock(CRYPTO_LOCK_SSL_METHOD); |
150 | memcpy((char *)&SSLv3_client_data,(char *)sslv3_base_method(), | 150 | |
151 | sizeof(SSL_METHOD)); | 151 | if (init) |
152 | SSLv3_client_data.ssl_connect=ssl3_connect; | 152 | { |
153 | SSLv3_client_data.get_ssl_method=ssl3_get_client_method; | 153 | memcpy((char *)&SSLv3_client_data,(char *)sslv3_base_method(), |
154 | sizeof(SSL_METHOD)); | ||
155 | SSLv3_client_data.ssl_connect=ssl3_connect; | ||
156 | SSLv3_client_data.get_ssl_method=ssl3_get_client_method; | ||
157 | init=0; | ||
158 | } | ||
159 | |||
160 | CRYPTO_w_unlock(CRYPTO_LOCK_SSL_METHOD); | ||
154 | } | 161 | } |
155 | return(&SSLv3_client_data); | 162 | return(&SSLv3_client_data); |
156 | } | 163 | } |
157 | 164 | ||
158 | int ssl3_connect(SSL *s) | 165 | int ssl3_connect(SSL *s) |
159 | { | 166 | { |
160 | BUF_MEM *buf; | 167 | BUF_MEM *buf=NULL; |
161 | unsigned long Time=time(NULL),l; | 168 | unsigned long Time=time(NULL),l; |
162 | long num1; | 169 | long num1; |
163 | void (*cb)(const SSL *ssl,int type,int val)=NULL; | 170 | void (*cb)(const SSL *ssl,int type,int val)=NULL; |
@@ -218,6 +225,7 @@ int ssl3_connect(SSL *s) | |||
218 | goto end; | 225 | goto end; |
219 | } | 226 | } |
220 | s->init_buf=buf; | 227 | s->init_buf=buf; |
228 | buf=NULL; | ||
221 | } | 229 | } |
222 | 230 | ||
223 | if (!ssl3_setup_buffers(s)) { ret= -1; goto end; } | 231 | if (!ssl3_setup_buffers(s)) { ret= -1; goto end; } |
@@ -496,6 +504,8 @@ int ssl3_connect(SSL *s) | |||
496 | } | 504 | } |
497 | end: | 505 | end: |
498 | s->in_handshake--; | 506 | s->in_handshake--; |
507 | if (buf != NULL) | ||
508 | BUF_MEM_free(buf); | ||
499 | if (cb != NULL) | 509 | if (cb != NULL) |
500 | cb(s,SSL_CB_CONNECT_EXIT,ret); | 510 | cb(s,SSL_CB_CONNECT_EXIT,ret); |
501 | return(ret); | 511 | return(ret); |
@@ -632,30 +642,20 @@ static int ssl3_get_server_hello(SSL *s) | |||
632 | /* get the session-id */ | 642 | /* get the session-id */ |
633 | j= *(p++); | 643 | j= *(p++); |
634 | 644 | ||
635 | if(j > sizeof s->session->session_id) | 645 | if ((j > sizeof s->session->session_id) || (j > SSL3_SESSION_ID_SIZE)) |
636 | { | ||
637 | al=SSL_AD_ILLEGAL_PARAMETER; | ||
638 | SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, | ||
639 | SSL_R_SSL3_SESSION_ID_TOO_LONG); | ||
640 | goto f_err; | ||
641 | } | ||
642 | |||
643 | if ((j != 0) && (j != SSL3_SESSION_ID_SIZE)) | ||
644 | { | 646 | { |
645 | /* SSLref returns 16 :-( */ | 647 | al=SSL_AD_ILLEGAL_PARAMETER; |
646 | if (j < SSL2_SSL_SESSION_ID_LENGTH) | 648 | SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_SSL3_SESSION_ID_TOO_LONG); |
647 | { | 649 | goto f_err; |
648 | al=SSL_AD_ILLEGAL_PARAMETER; | ||
649 | SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_SSL3_SESSION_ID_TOO_SHORT); | ||
650 | goto f_err; | ||
651 | } | ||
652 | } | 650 | } |
651 | |||
653 | if (j != 0 && j == s->session->session_id_length | 652 | if (j != 0 && j == s->session->session_id_length |
654 | && memcmp(p,s->session->session_id,j) == 0) | 653 | && memcmp(p,s->session->session_id,j) == 0) |
655 | { | 654 | { |
656 | if(s->sid_ctx_length != s->session->sid_ctx_length | 655 | if(s->sid_ctx_length != s->session->sid_ctx_length |
657 | || memcmp(s->session->sid_ctx,s->sid_ctx,s->sid_ctx_length)) | 656 | || memcmp(s->session->sid_ctx,s->sid_ctx,s->sid_ctx_length)) |
658 | { | 657 | { |
658 | /* actually a client application bug */ | ||
659 | al=SSL_AD_ILLEGAL_PARAMETER; | 659 | al=SSL_AD_ILLEGAL_PARAMETER; |
660 | SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT); | 660 | SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT); |
661 | goto f_err; | 661 | goto f_err; |
@@ -699,7 +699,12 @@ static int ssl3_get_server_hello(SSL *s) | |||
699 | goto f_err; | 699 | goto f_err; |
700 | } | 700 | } |
701 | 701 | ||
702 | if (s->hit && (s->session->cipher != c)) | 702 | /* Depending on the session caching (internal/external), the cipher |
703 | and/or cipher_id values may not be set. Make sure that | ||
704 | cipher_id is set and use it for comparison. */ | ||
705 | if (s->session->cipher) | ||
706 | s->session->cipher_id = s->session->cipher->id; | ||
707 | if (s->hit && (s->session->cipher_id != c->id)) | ||
703 | { | 708 | { |
704 | if (!(s->options & | 709 | if (!(s->options & |
705 | SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG)) | 710 | SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG)) |
@@ -1457,16 +1462,16 @@ static int ssl3_send_client_key_exchange(SSL *s) | |||
1457 | 1462 | ||
1458 | tmp_buf[0]=s->client_version>>8; | 1463 | tmp_buf[0]=s->client_version>>8; |
1459 | tmp_buf[1]=s->client_version&0xff; | 1464 | tmp_buf[1]=s->client_version&0xff; |
1460 | if (RAND_bytes(&(tmp_buf[2]),SSL_MAX_MASTER_KEY_LENGTH-2) <= 0) | 1465 | if (RAND_bytes(&(tmp_buf[2]),sizeof tmp_buf-2) <= 0) |
1461 | goto err; | 1466 | goto err; |
1462 | 1467 | ||
1463 | s->session->master_key_length=SSL_MAX_MASTER_KEY_LENGTH; | 1468 | s->session->master_key_length=sizeof tmp_buf; |
1464 | 1469 | ||
1465 | q=p; | 1470 | q=p; |
1466 | /* Fix buf for TLS and beyond */ | 1471 | /* Fix buf for TLS and beyond */ |
1467 | if (s->version > SSL3_VERSION) | 1472 | if (s->version > SSL3_VERSION) |
1468 | p+=2; | 1473 | p+=2; |
1469 | n=RSA_public_encrypt(SSL_MAX_MASTER_KEY_LENGTH, | 1474 | n=RSA_public_encrypt(sizeof tmp_buf, |
1470 | tmp_buf,p,rsa,RSA_PKCS1_PADDING); | 1475 | tmp_buf,p,rsa,RSA_PKCS1_PADDING); |
1471 | #ifdef PKCS1_CHECK | 1476 | #ifdef PKCS1_CHECK |
1472 | if (s->options & SSL_OP_PKCS1_CHECK_1) p[1]++; | 1477 | if (s->options & SSL_OP_PKCS1_CHECK_1) p[1]++; |
@@ -1488,8 +1493,8 @@ static int ssl3_send_client_key_exchange(SSL *s) | |||
1488 | s->session->master_key_length= | 1493 | s->session->master_key_length= |
1489 | s->method->ssl3_enc->generate_master_secret(s, | 1494 | s->method->ssl3_enc->generate_master_secret(s, |
1490 | s->session->master_key, | 1495 | s->session->master_key, |
1491 | tmp_buf,SSL_MAX_MASTER_KEY_LENGTH); | 1496 | tmp_buf,sizeof tmp_buf); |
1492 | memset(tmp_buf,0,SSL_MAX_MASTER_KEY_LENGTH); | 1497 | OPENSSL_cleanse(tmp_buf,sizeof tmp_buf); |
1493 | } | 1498 | } |
1494 | #endif | 1499 | #endif |
1495 | #ifndef OPENSSL_NO_KRB5 | 1500 | #ifndef OPENSSL_NO_KRB5 |
@@ -1585,7 +1590,7 @@ static int ssl3_send_client_key_exchange(SSL *s) | |||
1585 | n+=2; | 1590 | n+=2; |
1586 | } | 1591 | } |
1587 | 1592 | ||
1588 | if (RAND_bytes(tmp_buf,SSL_MAX_MASTER_KEY_LENGTH) <= 0) | 1593 | if (RAND_bytes(tmp_buf,sizeof tmp_buf) <= 0) |
1589 | goto err; | 1594 | goto err; |
1590 | 1595 | ||
1591 | /* 20010420 VRS. Tried it this way; failed. | 1596 | /* 20010420 VRS. Tried it this way; failed. |
@@ -1595,11 +1600,11 @@ static int ssl3_send_client_key_exchange(SSL *s) | |||
1595 | ** EVP_EncryptInit_ex(&ciph_ctx,NULL, key,iv); | 1600 | ** EVP_EncryptInit_ex(&ciph_ctx,NULL, key,iv); |
1596 | */ | 1601 | */ |
1597 | 1602 | ||
1598 | memset(iv, 0, EVP_MAX_IV_LENGTH); /* per RFC 1510 */ | 1603 | memset(iv, 0, sizeof iv); /* per RFC 1510 */ |
1599 | EVP_EncryptInit_ex(&ciph_ctx,enc, NULL, | 1604 | EVP_EncryptInit_ex(&ciph_ctx,enc, NULL, |
1600 | kssl_ctx->key,iv); | 1605 | kssl_ctx->key,iv); |
1601 | EVP_EncryptUpdate(&ciph_ctx,epms,&outl,tmp_buf, | 1606 | EVP_EncryptUpdate(&ciph_ctx,epms,&outl,tmp_buf, |
1602 | SSL_MAX_MASTER_KEY_LENGTH); | 1607 | sizeof tmp_buf); |
1603 | EVP_EncryptFinal_ex(&ciph_ctx,&(epms[outl]),&padl); | 1608 | EVP_EncryptFinal_ex(&ciph_ctx,&(epms[outl]),&padl); |
1604 | outl += padl; | 1609 | outl += padl; |
1605 | if (outl > sizeof epms) | 1610 | if (outl > sizeof epms) |
@@ -1618,10 +1623,10 @@ static int ssl3_send_client_key_exchange(SSL *s) | |||
1618 | s->session->master_key_length= | 1623 | s->session->master_key_length= |
1619 | s->method->ssl3_enc->generate_master_secret(s, | 1624 | s->method->ssl3_enc->generate_master_secret(s, |
1620 | s->session->master_key, | 1625 | s->session->master_key, |
1621 | tmp_buf, SSL_MAX_MASTER_KEY_LENGTH); | 1626 | tmp_buf, sizeof tmp_buf); |
1622 | 1627 | ||
1623 | memset(tmp_buf, 0, SSL_MAX_MASTER_KEY_LENGTH); | 1628 | OPENSSL_cleanse(tmp_buf, sizeof tmp_buf); |
1624 | memset(epms, 0, outl); | 1629 | OPENSSL_cleanse(epms, outl); |
1625 | } | 1630 | } |
1626 | #endif | 1631 | #endif |
1627 | #ifndef OPENSSL_NO_DH | 1632 | #ifndef OPENSSL_NO_DH |
diff --git a/src/lib/libssl/s3_lib.c b/src/lib/libssl/s3_lib.c index 14b2f13ae2..896b12fc4f 100644 --- a/src/lib/libssl/s3_lib.c +++ b/src/lib/libssl/s3_lib.c | |||
@@ -512,6 +512,7 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={ | |||
512 | SSL_ALL_STRENGTHS, | 512 | SSL_ALL_STRENGTHS, |
513 | }, | 513 | }, |
514 | 514 | ||
515 | #if 0 | ||
515 | /* Cipher 1E */ | 516 | /* Cipher 1E */ |
516 | { | 517 | { |
517 | 0, | 518 | 0, |
@@ -525,55 +526,70 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={ | |||
525 | SSL_ALL_CIPHERS, | 526 | SSL_ALL_CIPHERS, |
526 | SSL_ALL_STRENGTHS, | 527 | SSL_ALL_STRENGTHS, |
527 | }, | 528 | }, |
529 | #endif | ||
528 | 530 | ||
529 | #ifndef OPENSSL_NO_KRB5 | 531 | #ifndef OPENSSL_NO_KRB5 |
530 | /* The Kerberos ciphers | 532 | /* The Kerberos ciphers |
531 | ** 20000107 VRS: And the first shall be last, | 533 | ** 20000107 VRS: And the first shall be last, |
532 | ** in hopes of avoiding the lynx ssl renegotiation problem. | 534 | ** in hopes of avoiding the lynx ssl renegotiation problem. |
533 | */ | 535 | */ |
534 | /* Cipher 21 VRS */ | 536 | /* Cipher 1E VRS */ |
535 | { | 537 | { |
536 | 1, | 538 | 1, |
537 | SSL3_TXT_KRB5_DES_40_CBC_SHA, | 539 | SSL3_TXT_KRB5_DES_64_CBC_SHA, |
538 | SSL3_CK_KRB5_DES_40_CBC_SHA, | 540 | SSL3_CK_KRB5_DES_64_CBC_SHA, |
539 | SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_SHA1 |SSL_SSLV3, | 541 | SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_SHA1 |SSL_SSLV3, |
540 | SSL_EXPORT|SSL_EXP40, | 542 | SSL_NOT_EXP|SSL_LOW, |
541 | 0, | 543 | 0, |
542 | 40, | 544 | 56, |
543 | 56, | 545 | 56, |
544 | SSL_ALL_CIPHERS, | 546 | SSL_ALL_CIPHERS, |
545 | SSL_ALL_STRENGTHS, | 547 | SSL_ALL_STRENGTHS, |
546 | }, | 548 | }, |
547 | 549 | ||
548 | /* Cipher 22 VRS */ | 550 | /* Cipher 1F VRS */ |
549 | { | 551 | { |
550 | 1, | 552 | 1, |
551 | SSL3_TXT_KRB5_DES_40_CBC_MD5, | 553 | SSL3_TXT_KRB5_DES_192_CBC3_SHA, |
552 | SSL3_CK_KRB5_DES_40_CBC_MD5, | 554 | SSL3_CK_KRB5_DES_192_CBC3_SHA, |
553 | SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_MD5 |SSL_SSLV3, | 555 | SSL_kKRB5|SSL_aKRB5| SSL_3DES|SSL_SHA1 |SSL_SSLV3, |
554 | SSL_EXPORT|SSL_EXP40, | 556 | SSL_NOT_EXP|SSL_HIGH, |
555 | 0, | 557 | 0, |
556 | 40, | 558 | 112, |
557 | 56, | 559 | 168, |
558 | SSL_ALL_CIPHERS, | 560 | SSL_ALL_CIPHERS, |
559 | SSL_ALL_STRENGTHS, | 561 | SSL_ALL_STRENGTHS, |
560 | }, | 562 | }, |
561 | 563 | ||
562 | /* Cipher 23 VRS */ | 564 | /* Cipher 20 VRS */ |
563 | { | 565 | { |
564 | 1, | 566 | 1, |
565 | SSL3_TXT_KRB5_DES_64_CBC_SHA, | 567 | SSL3_TXT_KRB5_RC4_128_SHA, |
566 | SSL3_CK_KRB5_DES_64_CBC_SHA, | 568 | SSL3_CK_KRB5_RC4_128_SHA, |
567 | SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_SHA1 |SSL_SSLV3, | 569 | SSL_kKRB5|SSL_aKRB5| SSL_RC4|SSL_SHA1 |SSL_SSLV3, |
568 | SSL_NOT_EXP|SSL_LOW, | 570 | SSL_NOT_EXP|SSL_MEDIUM, |
569 | 0, | 571 | 0, |
570 | 56, | 572 | 128, |
571 | 56, | 573 | 128, |
572 | SSL_ALL_CIPHERS, | 574 | SSL_ALL_CIPHERS, |
573 | SSL_ALL_STRENGTHS, | 575 | SSL_ALL_STRENGTHS, |
574 | }, | 576 | }, |
575 | 577 | ||
576 | /* Cipher 24 VRS */ | 578 | /* Cipher 21 VRS */ |
579 | { | ||
580 | 1, | ||
581 | SSL3_TXT_KRB5_IDEA_128_CBC_SHA, | ||
582 | SSL3_CK_KRB5_IDEA_128_CBC_SHA, | ||
583 | SSL_kKRB5|SSL_aKRB5| SSL_IDEA|SSL_SHA1 |SSL_SSLV3, | ||
584 | SSL_NOT_EXP|SSL_MEDIUM, | ||
585 | 0, | ||
586 | 128, | ||
587 | 128, | ||
588 | SSL_ALL_CIPHERS, | ||
589 | SSL_ALL_STRENGTHS, | ||
590 | }, | ||
591 | |||
592 | /* Cipher 22 VRS */ | ||
577 | { | 593 | { |
578 | 1, | 594 | 1, |
579 | SSL3_TXT_KRB5_DES_64_CBC_MD5, | 595 | SSL3_TXT_KRB5_DES_64_CBC_MD5, |
@@ -587,12 +603,12 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={ | |||
587 | SSL_ALL_STRENGTHS, | 603 | SSL_ALL_STRENGTHS, |
588 | }, | 604 | }, |
589 | 605 | ||
590 | /* Cipher 25 VRS */ | 606 | /* Cipher 23 VRS */ |
591 | { | 607 | { |
592 | 1, | 608 | 1, |
593 | SSL3_TXT_KRB5_DES_192_CBC3_SHA, | 609 | SSL3_TXT_KRB5_DES_192_CBC3_MD5, |
594 | SSL3_CK_KRB5_DES_192_CBC3_SHA, | 610 | SSL3_CK_KRB5_DES_192_CBC3_MD5, |
595 | SSL_kKRB5|SSL_aKRB5| SSL_3DES|SSL_SHA1 |SSL_SSLV3, | 611 | SSL_kKRB5|SSL_aKRB5| SSL_3DES|SSL_MD5 |SSL_SSLV3, |
596 | SSL_NOT_EXP|SSL_HIGH, | 612 | SSL_NOT_EXP|SSL_HIGH, |
597 | 0, | 613 | 0, |
598 | 112, | 614 | 112, |
@@ -601,16 +617,114 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={ | |||
601 | SSL_ALL_STRENGTHS, | 617 | SSL_ALL_STRENGTHS, |
602 | }, | 618 | }, |
603 | 619 | ||
620 | /* Cipher 24 VRS */ | ||
621 | { | ||
622 | 1, | ||
623 | SSL3_TXT_KRB5_RC4_128_MD5, | ||
624 | SSL3_CK_KRB5_RC4_128_MD5, | ||
625 | SSL_kKRB5|SSL_aKRB5| SSL_RC4|SSL_MD5 |SSL_SSLV3, | ||
626 | SSL_NOT_EXP|SSL_MEDIUM, | ||
627 | 0, | ||
628 | 128, | ||
629 | 128, | ||
630 | SSL_ALL_CIPHERS, | ||
631 | SSL_ALL_STRENGTHS, | ||
632 | }, | ||
633 | |||
634 | /* Cipher 25 VRS */ | ||
635 | { | ||
636 | 1, | ||
637 | SSL3_TXT_KRB5_IDEA_128_CBC_MD5, | ||
638 | SSL3_CK_KRB5_IDEA_128_CBC_MD5, | ||
639 | SSL_kKRB5|SSL_aKRB5| SSL_IDEA|SSL_MD5 |SSL_SSLV3, | ||
640 | SSL_NOT_EXP|SSL_MEDIUM, | ||
641 | 0, | ||
642 | 128, | ||
643 | 128, | ||
644 | SSL_ALL_CIPHERS, | ||
645 | SSL_ALL_STRENGTHS, | ||
646 | }, | ||
647 | |||
604 | /* Cipher 26 VRS */ | 648 | /* Cipher 26 VRS */ |
605 | { | 649 | { |
606 | 1, | 650 | 1, |
607 | SSL3_TXT_KRB5_DES_192_CBC3_MD5, | 651 | SSL3_TXT_KRB5_DES_40_CBC_SHA, |
608 | SSL3_CK_KRB5_DES_192_CBC3_MD5, | 652 | SSL3_CK_KRB5_DES_40_CBC_SHA, |
609 | SSL_kKRB5|SSL_aKRB5| SSL_3DES|SSL_MD5 |SSL_SSLV3, | 653 | SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_SHA1 |SSL_SSLV3, |
610 | SSL_NOT_EXP|SSL_HIGH, | 654 | SSL_EXPORT|SSL_EXP40, |
611 | 0, | 655 | 0, |
612 | 112, | 656 | 40, |
613 | 168, | 657 | 56, |
658 | SSL_ALL_CIPHERS, | ||
659 | SSL_ALL_STRENGTHS, | ||
660 | }, | ||
661 | |||
662 | /* Cipher 27 VRS */ | ||
663 | { | ||
664 | 1, | ||
665 | SSL3_TXT_KRB5_RC2_40_CBC_SHA, | ||
666 | SSL3_CK_KRB5_RC2_40_CBC_SHA, | ||
667 | SSL_kKRB5|SSL_aKRB5| SSL_RC2|SSL_SHA1 |SSL_SSLV3, | ||
668 | SSL_EXPORT|SSL_EXP40, | ||
669 | 0, | ||
670 | 40, | ||
671 | 128, | ||
672 | SSL_ALL_CIPHERS, | ||
673 | SSL_ALL_STRENGTHS, | ||
674 | }, | ||
675 | |||
676 | /* Cipher 28 VRS */ | ||
677 | { | ||
678 | 1, | ||
679 | SSL3_TXT_KRB5_RC4_40_SHA, | ||
680 | SSL3_CK_KRB5_RC4_40_SHA, | ||
681 | SSL_kKRB5|SSL_aKRB5| SSL_RC4|SSL_SHA1 |SSL_SSLV3, | ||
682 | SSL_EXPORT|SSL_EXP40, | ||
683 | 0, | ||
684 | 128, | ||
685 | 128, | ||
686 | SSL_ALL_CIPHERS, | ||
687 | SSL_ALL_STRENGTHS, | ||
688 | }, | ||
689 | |||
690 | /* Cipher 29 VRS */ | ||
691 | { | ||
692 | 1, | ||
693 | SSL3_TXT_KRB5_DES_40_CBC_MD5, | ||
694 | SSL3_CK_KRB5_DES_40_CBC_MD5, | ||
695 | SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_MD5 |SSL_SSLV3, | ||
696 | SSL_EXPORT|SSL_EXP40, | ||
697 | 0, | ||
698 | 40, | ||
699 | 56, | ||
700 | SSL_ALL_CIPHERS, | ||
701 | SSL_ALL_STRENGTHS, | ||
702 | }, | ||
703 | |||
704 | /* Cipher 2A VRS */ | ||
705 | { | ||
706 | 1, | ||
707 | SSL3_TXT_KRB5_RC2_40_CBC_MD5, | ||
708 | SSL3_CK_KRB5_RC2_40_CBC_MD5, | ||
709 | SSL_kKRB5|SSL_aKRB5| SSL_RC2|SSL_MD5 |SSL_SSLV3, | ||
710 | SSL_EXPORT|SSL_EXP40, | ||
711 | 0, | ||
712 | 40, | ||
713 | 128, | ||
714 | SSL_ALL_CIPHERS, | ||
715 | SSL_ALL_STRENGTHS, | ||
716 | }, | ||
717 | |||
718 | /* Cipher 2B VRS */ | ||
719 | { | ||
720 | 1, | ||
721 | SSL3_TXT_KRB5_RC4_40_MD5, | ||
722 | SSL3_CK_KRB5_RC4_40_MD5, | ||
723 | SSL_kKRB5|SSL_aKRB5| SSL_RC4|SSL_MD5 |SSL_SSLV3, | ||
724 | SSL_EXPORT|SSL_EXP40, | ||
725 | 0, | ||
726 | 128, | ||
727 | 128, | ||
614 | SSL_ALL_CIPHERS, | 728 | SSL_ALL_CIPHERS, |
615 | SSL_ALL_STRENGTHS, | 729 | SSL_ALL_STRENGTHS, |
616 | }, | 730 | }, |
@@ -986,7 +1100,7 @@ void ssl3_free(SSL *s) | |||
986 | sk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free); | 1100 | sk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free); |
987 | EVP_MD_CTX_cleanup(&s->s3->finish_dgst1); | 1101 | EVP_MD_CTX_cleanup(&s->s3->finish_dgst1); |
988 | EVP_MD_CTX_cleanup(&s->s3->finish_dgst2); | 1102 | EVP_MD_CTX_cleanup(&s->s3->finish_dgst2); |
989 | memset(s->s3,0,sizeof *s->s3); | 1103 | OPENSSL_cleanse(s->s3,sizeof *s->s3); |
990 | OPENSSL_free(s->s3); | 1104 | OPENSSL_free(s->s3); |
991 | s->s3=NULL; | 1105 | s->s3=NULL; |
992 | } | 1106 | } |
@@ -1341,16 +1455,19 @@ SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p) | |||
1341 | { | 1455 | { |
1342 | CRYPTO_w_lock(CRYPTO_LOCK_SSL); | 1456 | CRYPTO_w_lock(CRYPTO_LOCK_SSL); |
1343 | 1457 | ||
1344 | for (i=0; i<SSL3_NUM_CIPHERS; i++) | 1458 | if (init) |
1345 | sorted[i]= &(ssl3_ciphers[i]); | 1459 | { |
1460 | for (i=0; i<SSL3_NUM_CIPHERS; i++) | ||
1461 | sorted[i]= &(ssl3_ciphers[i]); | ||
1346 | 1462 | ||
1347 | qsort( (char *)sorted, | 1463 | qsort(sorted, |
1348 | SSL3_NUM_CIPHERS,sizeof(SSL_CIPHER *), | 1464 | SSL3_NUM_CIPHERS,sizeof(SSL_CIPHER *), |
1349 | FP_ICC ssl_cipher_ptr_id_cmp); | 1465 | FP_ICC ssl_cipher_ptr_id_cmp); |
1350 | 1466 | ||
1467 | init=0; | ||
1468 | } | ||
1469 | |||
1351 | CRYPTO_w_unlock(CRYPTO_LOCK_SSL); | 1470 | CRYPTO_w_unlock(CRYPTO_LOCK_SSL); |
1352 | |||
1353 | init=0; | ||
1354 | } | 1471 | } |
1355 | 1472 | ||
1356 | id=0x03000000L|((unsigned long)p[0]<<8L)|(unsigned long)p[1]; | 1473 | id=0x03000000L|((unsigned long)p[0]<<8L)|(unsigned long)p[1]; |
diff --git a/src/lib/libssl/s3_pkt.c b/src/lib/libssl/s3_pkt.c index 6ccea9aee5..3f88429e79 100644 --- a/src/lib/libssl/s3_pkt.c +++ b/src/lib/libssl/s3_pkt.c | |||
@@ -238,6 +238,8 @@ static int ssl3_get_record(SSL *s) | |||
238 | unsigned int mac_size; | 238 | unsigned int mac_size; |
239 | int clear=0; | 239 | int clear=0; |
240 | size_t extra; | 240 | size_t extra; |
241 | int decryption_failed_or_bad_record_mac = 0; | ||
242 | unsigned char *mac = NULL; | ||
241 | 243 | ||
242 | rr= &(s->s3->rrec); | 244 | rr= &(s->s3->rrec); |
243 | sess=s->session; | 245 | sess=s->session; |
@@ -353,8 +355,11 @@ again: | |||
353 | /* SSLerr() and ssl3_send_alert() have been called */ | 355 | /* SSLerr() and ssl3_send_alert() have been called */ |
354 | goto err; | 356 | goto err; |
355 | 357 | ||
356 | /* otherwise enc_err == -1 */ | 358 | /* Otherwise enc_err == -1, which indicates bad padding |
357 | goto decryption_failed_or_bad_record_mac; | 359 | * (rec->length has not been changed in this case). |
360 | * To minimize information leaked via timing, we will perform | ||
361 | * the MAC computation anyway. */ | ||
362 | decryption_failed_or_bad_record_mac = 1; | ||
358 | } | 363 | } |
359 | 364 | ||
360 | #ifdef TLS_DEBUG | 365 | #ifdef TLS_DEBUG |
@@ -380,28 +385,46 @@ printf("\n"); | |||
380 | SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_PRE_MAC_LENGTH_TOO_LONG); | 385 | SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_PRE_MAC_LENGTH_TOO_LONG); |
381 | goto f_err; | 386 | goto f_err; |
382 | #else | 387 | #else |
383 | goto decryption_failed_or_bad_record_mac; | 388 | decryption_failed_or_bad_record_mac = 1; |
384 | #endif | 389 | #endif |
385 | } | 390 | } |
386 | /* check the MAC for rr->input (it's in mac_size bytes at the tail) */ | 391 | /* check the MAC for rr->input (it's in mac_size bytes at the tail) */ |
387 | if (rr->length < mac_size) | 392 | if (rr->length >= mac_size) |
388 | { | 393 | { |
394 | rr->length -= mac_size; | ||
395 | mac = &rr->data[rr->length]; | ||
396 | } | ||
397 | else | ||
398 | { | ||
399 | /* record (minus padding) is too short to contain a MAC */ | ||
389 | #if 0 /* OK only for stream ciphers */ | 400 | #if 0 /* OK only for stream ciphers */ |
390 | al=SSL_AD_DECODE_ERROR; | 401 | al=SSL_AD_DECODE_ERROR; |
391 | SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_LENGTH_TOO_SHORT); | 402 | SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_LENGTH_TOO_SHORT); |
392 | goto f_err; | 403 | goto f_err; |
393 | #else | 404 | #else |
394 | goto decryption_failed_or_bad_record_mac; | 405 | decryption_failed_or_bad_record_mac = 1; |
406 | rr->length = 0; | ||
395 | #endif | 407 | #endif |
396 | } | 408 | } |
397 | rr->length-=mac_size; | ||
398 | i=s->method->ssl3_enc->mac(s,md,0); | 409 | i=s->method->ssl3_enc->mac(s,md,0); |
399 | if (memcmp(md,&(rr->data[rr->length]),mac_size) != 0) | 410 | if (mac == NULL || memcmp(md, mac, mac_size) != 0) |
400 | { | 411 | { |
401 | goto decryption_failed_or_bad_record_mac; | 412 | decryption_failed_or_bad_record_mac = 1; |
402 | } | 413 | } |
403 | } | 414 | } |
404 | 415 | ||
416 | if (decryption_failed_or_bad_record_mac) | ||
417 | { | ||
418 | /* A separate 'decryption_failed' alert was introduced with TLS 1.0, | ||
419 | * SSL 3.0 only has 'bad_record_mac'. But unless a decryption | ||
420 | * failure is directly visible from the ciphertext anyway, | ||
421 | * we should not reveal which kind of error occured -- this | ||
422 | * might become visible to an attacker (e.g. via a logfile) */ | ||
423 | al=SSL_AD_BAD_RECORD_MAC; | ||
424 | SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC); | ||
425 | goto f_err; | ||
426 | } | ||
427 | |||
405 | /* r->length is now just compressed */ | 428 | /* r->length is now just compressed */ |
406 | if (s->expand != NULL) | 429 | if (s->expand != NULL) |
407 | { | 430 | { |
@@ -443,14 +466,6 @@ printf("\n"); | |||
443 | 466 | ||
444 | return(1); | 467 | return(1); |
445 | 468 | ||
446 | decryption_failed_or_bad_record_mac: | ||
447 | /* Separate 'decryption_failed' alert was introduced with TLS 1.0, | ||
448 | * SSL 3.0 only has 'bad_record_mac'. But unless a decryption | ||
449 | * failure is directly visible from the ciphertext anyway, | ||
450 | * we should not reveal which kind of error occured -- this | ||
451 | * might become visible to an attacker (e.g. via logfile) */ | ||
452 | al=SSL_AD_BAD_RECORD_MAC; | ||
453 | SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC); | ||
454 | f_err: | 469 | f_err: |
455 | ssl3_send_alert(s,SSL3_AL_FATAL,al); | 470 | ssl3_send_alert(s,SSL3_AL_FATAL,al); |
456 | err: | 471 | err: |
diff --git a/src/lib/libssl/s3_srvr.c b/src/lib/libssl/s3_srvr.c index 20d716fb1b..58cf774967 100644 --- a/src/lib/libssl/s3_srvr.c +++ b/src/lib/libssl/s3_srvr.c | |||
@@ -152,11 +152,18 @@ SSL_METHOD *SSLv3_server_method(void) | |||
152 | 152 | ||
153 | if (init) | 153 | if (init) |
154 | { | 154 | { |
155 | memcpy((char *)&SSLv3_server_data,(char *)sslv3_base_method(), | 155 | CRYPTO_w_lock(CRYPTO_LOCK_SSL_METHOD); |
156 | sizeof(SSL_METHOD)); | 156 | |
157 | SSLv3_server_data.ssl_accept=ssl3_accept; | 157 | if (init) |
158 | SSLv3_server_data.get_ssl_method=ssl3_get_server_method; | 158 | { |
159 | init=0; | 159 | memcpy((char *)&SSLv3_server_data,(char *)sslv3_base_method(), |
160 | sizeof(SSL_METHOD)); | ||
161 | SSLv3_server_data.ssl_accept=ssl3_accept; | ||
162 | SSLv3_server_data.get_ssl_method=ssl3_get_server_method; | ||
163 | init=0; | ||
164 | } | ||
165 | |||
166 | CRYPTO_w_unlock(CRYPTO_LOCK_SSL_METHOD); | ||
160 | } | 167 | } |
161 | return(&SSLv3_server_data); | 168 | return(&SSLv3_server_data); |
162 | } | 169 | } |
@@ -1171,7 +1178,7 @@ static int ssl3_send_server_key_exchange(SSL *s) | |||
1171 | kn=0; | 1178 | kn=0; |
1172 | } | 1179 | } |
1173 | 1180 | ||
1174 | if (!BUF_MEM_grow(buf,n+4+kn)) | 1181 | if (!BUF_MEM_grow_clean(buf,n+4+kn)) |
1175 | { | 1182 | { |
1176 | SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,ERR_LIB_BUF); | 1183 | SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,ERR_LIB_BUF); |
1177 | goto err; | 1184 | goto err; |
@@ -1298,7 +1305,7 @@ static int ssl3_send_certificate_request(SSL *s) | |||
1298 | { | 1305 | { |
1299 | name=sk_X509_NAME_value(sk,i); | 1306 | name=sk_X509_NAME_value(sk,i); |
1300 | j=i2d_X509_NAME(name,NULL); | 1307 | j=i2d_X509_NAME(name,NULL); |
1301 | if (!BUF_MEM_grow(buf,4+n+j+2)) | 1308 | if (!BUF_MEM_grow_clean(buf,4+n+j+2)) |
1302 | { | 1309 | { |
1303 | SSLerr(SSL_F_SSL3_SEND_CERTIFICATE_REQUEST,ERR_R_BUF_LIB); | 1310 | SSLerr(SSL_F_SSL3_SEND_CERTIFICATE_REQUEST,ERR_R_BUF_LIB); |
1304 | goto err; | 1311 | goto err; |
@@ -1440,7 +1447,7 @@ static int ssl3_get_client_key_exchange(SSL *s) | |||
1440 | if (i != SSL_MAX_MASTER_KEY_LENGTH) | 1447 | if (i != SSL_MAX_MASTER_KEY_LENGTH) |
1441 | { | 1448 | { |
1442 | al=SSL_AD_DECODE_ERROR; | 1449 | al=SSL_AD_DECODE_ERROR; |
1443 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_BAD_RSA_DECRYPT); | 1450 | /* SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_BAD_RSA_DECRYPT); */ |
1444 | } | 1451 | } |
1445 | 1452 | ||
1446 | if ((al == -1) && !((p[0] == (s->client_version>>8)) && (p[1] == (s->client_version & 0xff)))) | 1453 | if ((al == -1) && !((p[0] == (s->client_version>>8)) && (p[1] == (s->client_version & 0xff)))) |
@@ -1456,37 +1463,35 @@ static int ssl3_get_client_key_exchange(SSL *s) | |||
1456 | (p[0] == (s->version>>8)) && (p[1] == (s->version & 0xff)))) | 1463 | (p[0] == (s->version>>8)) && (p[1] == (s->version & 0xff)))) |
1457 | { | 1464 | { |
1458 | al=SSL_AD_DECODE_ERROR; | 1465 | al=SSL_AD_DECODE_ERROR; |
1459 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_BAD_PROTOCOL_VERSION_NUMBER); | 1466 | /* SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_BAD_PROTOCOL_VERSION_NUMBER); */ |
1460 | goto f_err; | 1467 | |
1468 | /* The Klima-Pokorny-Rosa extension of Bleichenbacher's attack | ||
1469 | * (http://eprint.iacr.org/2003/052/) exploits the version | ||
1470 | * number check as a "bad version oracle" -- an alert would | ||
1471 | * reveal that the plaintext corresponding to some ciphertext | ||
1472 | * made up by the adversary is properly formatted except | ||
1473 | * that the version number is wrong. To avoid such attacks, | ||
1474 | * we should treat this just like any other decryption error. */ | ||
1461 | } | 1475 | } |
1462 | } | 1476 | } |
1463 | 1477 | ||
1464 | if (al != -1) | 1478 | if (al != -1) |
1465 | { | 1479 | { |
1466 | #if 0 | ||
1467 | goto f_err; | ||
1468 | #else | ||
1469 | /* Some decryption failure -- use random value instead as countermeasure | 1480 | /* Some decryption failure -- use random value instead as countermeasure |
1470 | * against Bleichenbacher's attack on PKCS #1 v1.5 RSA padding | 1481 | * against Bleichenbacher's attack on PKCS #1 v1.5 RSA padding |
1471 | * (see RFC 2246, section 7.4.7.1). | 1482 | * (see RFC 2246, section 7.4.7.1). */ |
1472 | * But note that due to length and protocol version checking, the | ||
1473 | * attack is impractical anyway (see section 5 in D. Bleichenbacher: | ||
1474 | * "Chosen Ciphertext Attacks Against Protocols Based on the RSA | ||
1475 | * Encryption Standard PKCS #1", CRYPTO '98, LNCS 1462, pp. 1-12). | ||
1476 | */ | ||
1477 | ERR_clear_error(); | 1483 | ERR_clear_error(); |
1478 | i = SSL_MAX_MASTER_KEY_LENGTH; | 1484 | i = SSL_MAX_MASTER_KEY_LENGTH; |
1479 | p[0] = s->client_version >> 8; | 1485 | p[0] = s->client_version >> 8; |
1480 | p[1] = s->client_version & 0xff; | 1486 | p[1] = s->client_version & 0xff; |
1481 | RAND_pseudo_bytes(p+2, i-2); /* should be RAND_bytes, but we cannot work around a failure */ | 1487 | RAND_pseudo_bytes(p+2, i-2); /* should be RAND_bytes, but we cannot work around a failure */ |
1482 | #endif | ||
1483 | } | 1488 | } |
1484 | 1489 | ||
1485 | s->session->master_key_length= | 1490 | s->session->master_key_length= |
1486 | s->method->ssl3_enc->generate_master_secret(s, | 1491 | s->method->ssl3_enc->generate_master_secret(s, |
1487 | s->session->master_key, | 1492 | s->session->master_key, |
1488 | p,i); | 1493 | p,i); |
1489 | memset(p,0,i); | 1494 | OPENSSL_cleanse(p,i); |
1490 | } | 1495 | } |
1491 | else | 1496 | else |
1492 | #endif | 1497 | #endif |
@@ -1549,7 +1554,7 @@ static int ssl3_get_client_key_exchange(SSL *s) | |||
1549 | s->session->master_key_length= | 1554 | s->session->master_key_length= |
1550 | s->method->ssl3_enc->generate_master_secret(s, | 1555 | s->method->ssl3_enc->generate_master_secret(s, |
1551 | s->session->master_key,p,i); | 1556 | s->session->master_key,p,i); |
1552 | memset(p,0,i); | 1557 | OPENSSL_cleanse(p,i); |
1553 | } | 1558 | } |
1554 | else | 1559 | else |
1555 | #endif | 1560 | #endif |
@@ -1652,7 +1657,7 @@ static int ssl3_get_client_key_exchange(SSL *s) | |||
1652 | if (enc == NULL) | 1657 | if (enc == NULL) |
1653 | goto err; | 1658 | goto err; |
1654 | 1659 | ||
1655 | memset(iv, 0, EVP_MAX_IV_LENGTH); /* per RFC 1510 */ | 1660 | memset(iv, 0, sizeof iv); /* per RFC 1510 */ |
1656 | 1661 | ||
1657 | if (!EVP_DecryptInit_ex(&ciph_ctx,enc,NULL,kssl_ctx->key,iv)) | 1662 | if (!EVP_DecryptInit_ex(&ciph_ctx,enc,NULL,kssl_ctx->key,iv)) |
1658 | { | 1663 | { |
@@ -1740,7 +1745,7 @@ static int ssl3_get_cert_verify(SSL *s) | |||
1740 | SSL3_ST_SR_CERT_VRFY_A, | 1745 | SSL3_ST_SR_CERT_VRFY_A, |
1741 | SSL3_ST_SR_CERT_VRFY_B, | 1746 | SSL3_ST_SR_CERT_VRFY_B, |
1742 | -1, | 1747 | -1, |
1743 | 512, /* 512? */ | 1748 | 514, /* 514? */ |
1744 | &ok); | 1749 | &ok); |
1745 | 1750 | ||
1746 | if (!ok) return((int)n); | 1751 | if (!ok) return((int)n); |
diff --git a/src/lib/libssl/ssl.h b/src/lib/libssl/ssl.h index e9d1e896d7..4ae8458259 100644 --- a/src/lib/libssl/ssl.h +++ b/src/lib/libssl/ssl.h | |||
@@ -204,6 +204,22 @@ extern "C" { | |||
204 | 204 | ||
205 | /* VRS Additional Kerberos5 entries | 205 | /* VRS Additional Kerberos5 entries |
206 | */ | 206 | */ |
207 | #define SSL_TXT_KRB5_DES_64_CBC_SHA SSL3_TXT_KRB5_DES_64_CBC_SHA | ||
208 | #define SSL_TXT_KRB5_DES_192_CBC3_SHA SSL3_TXT_KRB5_DES_192_CBC3_SHA | ||
209 | #define SSL_TXT_KRB5_RC4_128_SHA SSL3_TXT_KRB5_RC4_128_SHA | ||
210 | #define SSL_TXT_KRB5_IDEA_128_CBC_SHA SSL3_TXT_KRB5_IDEA_128_CBC_SHA | ||
211 | #define SSL_TXT_KRB5_DES_64_CBC_MD5 SSL3_TXT_KRB5_DES_64_CBC_MD5 | ||
212 | #define SSL_TXT_KRB5_DES_192_CBC3_MD5 SSL3_TXT_KRB5_DES_192_CBC3_MD5 | ||
213 | #define SSL_TXT_KRB5_RC4_128_MD5 SSL3_TXT_KRB5_RC4_128_MD5 | ||
214 | #define SSL_TXT_KRB5_IDEA_128_CBC_MD5 SSL3_TXT_KRB5_IDEA_128_CBC_MD5 | ||
215 | |||
216 | #define SSL_TXT_KRB5_DES_40_CBC_SHA SSL3_TXT_KRB5_DES_40_CBC_SHA | ||
217 | #define SSL_TXT_KRB5_RC2_40_CBC_SHA SSL3_TXT_KRB5_RC2_40_CBC_SHA | ||
218 | #define SSL_TXT_KRB5_RC4_40_SHA SSL3_TXT_KRB5_RC4_40_SHA | ||
219 | #define SSL_TXT_KRB5_DES_40_CBC_MD5 SSL3_TXT_KRB5_DES_40_CBC_MD5 | ||
220 | #define SSL_TXT_KRB5_RC2_40_CBC_MD5 SSL3_TXT_KRB5_RC2_40_CBC_MD5 | ||
221 | #define SSL_TXT_KRB5_RC4_40_MD5 SSL3_TXT_KRB5_RC4_40_MD5 | ||
222 | |||
207 | #define SSL_TXT_KRB5_DES_40_CBC_SHA SSL3_TXT_KRB5_DES_40_CBC_SHA | 223 | #define SSL_TXT_KRB5_DES_40_CBC_SHA SSL3_TXT_KRB5_DES_40_CBC_SHA |
208 | #define SSL_TXT_KRB5_DES_40_CBC_MD5 SSL3_TXT_KRB5_DES_40_CBC_MD5 | 224 | #define SSL_TXT_KRB5_DES_40_CBC_MD5 SSL3_TXT_KRB5_DES_40_CBC_MD5 |
209 | #define SSL_TXT_KRB5_DES_64_CBC_SHA SSL3_TXT_KRB5_DES_64_CBC_SHA | 225 | #define SSL_TXT_KRB5_DES_64_CBC_SHA SSL3_TXT_KRB5_DES_64_CBC_SHA |
@@ -299,9 +315,7 @@ extern "C" { | |||
299 | #include <openssl/crypto.h> | 315 | #include <openssl/crypto.h> |
300 | #include <openssl/lhash.h> | 316 | #include <openssl/lhash.h> |
301 | #include <openssl/buffer.h> | 317 | #include <openssl/buffer.h> |
302 | #include <openssl/bio.h> | ||
303 | #include <openssl/pem.h> | 318 | #include <openssl/pem.h> |
304 | #include <openssl/x509.h> | ||
305 | 319 | ||
306 | #ifdef __cplusplus | 320 | #ifdef __cplusplus |
307 | extern "C" { | 321 | extern "C" { |
@@ -507,6 +521,8 @@ typedef struct ssl_session_st | |||
507 | /* Never bother the application with retries if the transport | 521 | /* Never bother the application with retries if the transport |
508 | * is blocking: */ | 522 | * is blocking: */ |
509 | #define SSL_MODE_AUTO_RETRY 0x00000004L | 523 | #define SSL_MODE_AUTO_RETRY 0x00000004L |
524 | /* Don't attempt to automatically build certificate chain */ | ||
525 | #define SSL_MODE_NO_AUTO_CHAIN 0x00000008L | ||
510 | 526 | ||
511 | 527 | ||
512 | /* Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value, | 528 | /* Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value, |
@@ -704,10 +720,11 @@ struct ssl_ctx_st | |||
704 | #define SSL_SESS_CACHE_SERVER 0x0002 | 720 | #define SSL_SESS_CACHE_SERVER 0x0002 |
705 | #define SSL_SESS_CACHE_BOTH (SSL_SESS_CACHE_CLIENT|SSL_SESS_CACHE_SERVER) | 721 | #define SSL_SESS_CACHE_BOTH (SSL_SESS_CACHE_CLIENT|SSL_SESS_CACHE_SERVER) |
706 | #define SSL_SESS_CACHE_NO_AUTO_CLEAR 0x0080 | 722 | #define SSL_SESS_CACHE_NO_AUTO_CLEAR 0x0080 |
707 | /* This one, when set, makes the server session-id lookup not look | 723 | /* enough comments already ... see SSL_CTX_set_session_cache_mode(3) */ |
708 | * in the cache. If there is an application get_session callback | ||
709 | * defined, this will still get called. */ | ||
710 | #define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP 0x0100 | 724 | #define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP 0x0100 |
725 | #define SSL_SESS_CACHE_NO_INTERNAL_STORE 0x0200 | ||
726 | #define SSL_SESS_CACHE_NO_INTERNAL \ | ||
727 | (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP|SSL_SESS_CACHE_NO_INTERNAL_STORE) | ||
711 | 728 | ||
712 | struct lhash_st *SSL_CTX_sessions(SSL_CTX *ctx); | 729 | struct lhash_st *SSL_CTX_sessions(SSL_CTX *ctx); |
713 | #define SSL_CTX_sess_number(ctx) \ | 730 | #define SSL_CTX_sess_number(ctx) \ |
@@ -1212,14 +1229,12 @@ int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file); /* PEM t | |||
1212 | STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file); | 1229 | STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file); |
1213 | int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, | 1230 | int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, |
1214 | const char *file); | 1231 | const char *file); |
1215 | #ifndef OPENSSL_SYS_WIN32 | ||
1216 | #ifndef OPENSSL_SYS_VMS | 1232 | #ifndef OPENSSL_SYS_VMS |
1217 | #ifndef OPENSSL_SYS_MACINTOSH_CLASSIC /* XXXXX: Better scheme needed! [was: #ifndef MAC_OS_pre_X] */ | 1233 | #ifndef OPENSSL_SYS_MACINTOSH_CLASSIC /* XXXXX: Better scheme needed! [was: #ifndef MAC_OS_pre_X] */ |
1218 | int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, | 1234 | int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, |
1219 | const char *dir); | 1235 | const char *dir); |
1220 | #endif | 1236 | #endif |
1221 | #endif | 1237 | #endif |
1222 | #endif | ||
1223 | 1238 | ||
1224 | #endif | 1239 | #endif |
1225 | 1240 | ||
@@ -1688,6 +1703,7 @@ void ERR_load_SSL_strings(void); | |||
1688 | #define SSL_R_LENGTH_TOO_SHORT 160 | 1703 | #define SSL_R_LENGTH_TOO_SHORT 160 |
1689 | #define SSL_R_LIBRARY_BUG 274 | 1704 | #define SSL_R_LIBRARY_BUG 274 |
1690 | #define SSL_R_LIBRARY_HAS_NO_CIPHERS 161 | 1705 | #define SSL_R_LIBRARY_HAS_NO_CIPHERS 161 |
1706 | #define SSL_R_MASTER_KEY_TOO_LONG 1112 | ||
1691 | #define SSL_R_MESSAGE_TOO_LONG 1111 | 1707 | #define SSL_R_MESSAGE_TOO_LONG 1111 |
1692 | #define SSL_R_MISSING_DH_DSA_CERT 162 | 1708 | #define SSL_R_MISSING_DH_DSA_CERT 162 |
1693 | #define SSL_R_MISSING_DH_KEY 163 | 1709 | #define SSL_R_MISSING_DH_KEY 163 |
diff --git a/src/lib/libssl/ssl3.h b/src/lib/libssl/ssl3.h index 8fd6951d77..1153aeda74 100644 --- a/src/lib/libssl/ssl3.h +++ b/src/lib/libssl/ssl3.h | |||
@@ -156,23 +156,29 @@ extern "C" { | |||
156 | 156 | ||
157 | #define SSL3_CK_FZA_DMS_NULL_SHA 0x0300001C | 157 | #define SSL3_CK_FZA_DMS_NULL_SHA 0x0300001C |
158 | #define SSL3_CK_FZA_DMS_FZA_SHA 0x0300001D | 158 | #define SSL3_CK_FZA_DMS_FZA_SHA 0x0300001D |
159 | #if 0 /* Because it clashes with KRB5, is never used any more, and is safe | ||
160 | to remove according to David Hopwood <david.hopwood@zetnet.co.uk> | ||
161 | of the ietf-tls list */ | ||
159 | #define SSL3_CK_FZA_DMS_RC4_SHA 0x0300001E | 162 | #define SSL3_CK_FZA_DMS_RC4_SHA 0x0300001E |
163 | #endif | ||
160 | 164 | ||
161 | /* VRS Additional Kerberos5 entries | 165 | /* VRS Additional Kerberos5 entries |
162 | */ | 166 | */ |
163 | #define SSL3_CK_KRB5_DES_40_CBC_SHA 0x03000021 | 167 | #define SSL3_CK_KRB5_DES_64_CBC_SHA 0x0300001E |
164 | #define SSL3_CK_KRB5_DES_40_CBC_MD5 0x03000022 | 168 | #define SSL3_CK_KRB5_DES_192_CBC3_SHA 0x0300001F |
165 | #define SSL3_CK_KRB5_DES_64_CBC_SHA 0x03000023 | 169 | #define SSL3_CK_KRB5_RC4_128_SHA 0x03000020 |
166 | #define SSL3_CK_KRB5_DES_64_CBC_MD5 0x03000024 | 170 | #define SSL3_CK_KRB5_IDEA_128_CBC_SHA 0x03000021 |
167 | #define SSL3_CK_KRB5_DES_192_CBC3_SHA 0x03000025 | 171 | #define SSL3_CK_KRB5_DES_64_CBC_MD5 0x03000022 |
168 | #define SSL3_CK_KRB5_DES_192_CBC3_MD5 0x03000026 | 172 | #define SSL3_CK_KRB5_DES_192_CBC3_MD5 0x03000023 |
169 | 173 | #define SSL3_CK_KRB5_RC4_128_MD5 0x03000024 | |
170 | #define SSL3_TXT_KRB5_DES_40_CBC_SHA "EXP-KRB5-DES-CBC-SHA" | 174 | #define SSL3_CK_KRB5_IDEA_128_CBC_MD5 0x03000025 |
171 | #define SSL3_TXT_KRB5_DES_40_CBC_MD5 "EXP-KRB5-DES-CBC-MD5" | 175 | |
172 | #define SSL3_TXT_KRB5_DES_64_CBC_SHA "KRB5-DES-CBC-SHA" | 176 | #define SSL3_CK_KRB5_DES_40_CBC_SHA 0x03000026 |
173 | #define SSL3_TXT_KRB5_DES_64_CBC_MD5 "KRB5-DES-CBC-MD5" | 177 | #define SSL3_CK_KRB5_RC2_40_CBC_SHA 0x03000027 |
174 | #define SSL3_TXT_KRB5_DES_192_CBC3_SHA "KRB5-DES-CBC3-SHA" | 178 | #define SSL3_CK_KRB5_RC4_40_SHA 0x03000028 |
175 | #define SSL3_TXT_KRB5_DES_192_CBC3_MD5 "KRB5-DES-CBC3-MD5" | 179 | #define SSL3_CK_KRB5_DES_40_CBC_MD5 0x03000029 |
180 | #define SSL3_CK_KRB5_RC2_40_CBC_MD5 0x0300002A | ||
181 | #define SSL3_CK_KRB5_RC4_40_MD5 0x0300002B | ||
176 | 182 | ||
177 | #define SSL3_TXT_RSA_NULL_MD5 "NULL-MD5" | 183 | #define SSL3_TXT_RSA_NULL_MD5 "NULL-MD5" |
178 | #define SSL3_TXT_RSA_NULL_SHA "NULL-SHA" | 184 | #define SSL3_TXT_RSA_NULL_SHA "NULL-SHA" |
@@ -209,6 +215,22 @@ extern "C" { | |||
209 | #define SSL3_TXT_FZA_DMS_FZA_SHA "FZA-FZA-CBC-SHA" | 215 | #define SSL3_TXT_FZA_DMS_FZA_SHA "FZA-FZA-CBC-SHA" |
210 | #define SSL3_TXT_FZA_DMS_RC4_SHA "FZA-RC4-SHA" | 216 | #define SSL3_TXT_FZA_DMS_RC4_SHA "FZA-RC4-SHA" |
211 | 217 | ||
218 | #define SSL3_TXT_KRB5_DES_64_CBC_SHA "KRB5-DES-CBC-SHA" | ||
219 | #define SSL3_TXT_KRB5_DES_192_CBC3_SHA "KRB5-DES-CBC3-SHA" | ||
220 | #define SSL3_TXT_KRB5_RC4_128_SHA "KRB5-RC4-SHA" | ||
221 | #define SSL3_TXT_KRB5_IDEA_128_CBC_SHA "KRB5-IDEA-CBC-SHA" | ||
222 | #define SSL3_TXT_KRB5_DES_64_CBC_MD5 "KRB5-DES-CBC-MD5" | ||
223 | #define SSL3_TXT_KRB5_DES_192_CBC3_MD5 "KRB5-DES-CBC3-MD5" | ||
224 | #define SSL3_TXT_KRB5_RC4_128_MD5 "KRB5-RC4-MD5" | ||
225 | #define SSL3_TXT_KRB5_IDEA_128_CBC_MD5 "KRB5-IDEA-CBC-MD5" | ||
226 | |||
227 | #define SSL3_TXT_KRB5_DES_40_CBC_SHA "EXP-KRB5-DES-CBC-SHA" | ||
228 | #define SSL3_TXT_KRB5_RC2_40_CBC_SHA "EXP-KRB5-RC2-CBC-SHA" | ||
229 | #define SSL3_TXT_KRB5_RC4_40_SHA "EXP-KRB5-RC4-SHA" | ||
230 | #define SSL3_TXT_KRB5_DES_40_CBC_MD5 "EXP-KRB5-DES-CBC-MD5" | ||
231 | #define SSL3_TXT_KRB5_RC2_40_CBC_MD5 "EXP-KRB5-RC2-CBC-MD5" | ||
232 | #define SSL3_TXT_KRB5_RC4_40_MD5 "EXP-KRB5-RC4-MD5" | ||
233 | |||
212 | #define SSL3_SSL_SESSION_ID_LENGTH 32 | 234 | #define SSL3_SSL_SESSION_ID_LENGTH 32 |
213 | #define SSL3_MAX_SSL_SESSION_ID_LENGTH 32 | 235 | #define SSL3_MAX_SSL_SESSION_ID_LENGTH 32 |
214 | 236 | ||
diff --git a/src/lib/libssl/ssl_asn1.c b/src/lib/libssl/ssl_asn1.c index 3723fc2e37..16bc11b559 100644 --- a/src/lib/libssl/ssl_asn1.c +++ b/src/lib/libssl/ssl_asn1.c | |||
@@ -299,6 +299,7 @@ SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, unsigned char **pp, | |||
299 | os.length = sizeof ret->session_id; | 299 | os.length = sizeof ret->session_id; |
300 | 300 | ||
301 | ret->session_id_length=os.length; | 301 | ret->session_id_length=os.length; |
302 | OPENSSL_assert(os.length <= sizeof ret->session_id); | ||
302 | memcpy(ret->session_id,os.data,os.length); | 303 | memcpy(ret->session_id,os.data,os.length); |
303 | 304 | ||
304 | M_ASN1_D2I_get(osp,d2i_ASN1_OCTET_STRING); | 305 | M_ASN1_D2I_get(osp,d2i_ASN1_OCTET_STRING); |
@@ -370,9 +371,15 @@ SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, unsigned char **pp, | |||
370 | if(os.data != NULL) | 371 | if(os.data != NULL) |
371 | { | 372 | { |
372 | if (os.length > SSL_MAX_SID_CTX_LENGTH) | 373 | if (os.length > SSL_MAX_SID_CTX_LENGTH) |
374 | { | ||
375 | ret->sid_ctx_length=os.length; | ||
373 | SSLerr(SSL_F_D2I_SSL_SESSION,SSL_R_BAD_LENGTH); | 376 | SSLerr(SSL_F_D2I_SSL_SESSION,SSL_R_BAD_LENGTH); |
374 | ret->sid_ctx_length=os.length; | 377 | } |
375 | memcpy(ret->sid_ctx,os.data,os.length); | 378 | else |
379 | { | ||
380 | ret->sid_ctx_length=os.length; | ||
381 | memcpy(ret->sid_ctx,os.data,os.length); | ||
382 | } | ||
376 | OPENSSL_free(os.data); os.data=NULL; os.length=0; | 383 | OPENSSL_free(os.data); os.data=NULL; os.length=0; |
377 | } | 384 | } |
378 | else | 385 | else |
diff --git a/src/lib/libssl/ssl_cert.c b/src/lib/libssl/ssl_cert.c index 3d31bbf05f..da90078a37 100644 --- a/src/lib/libssl/ssl_cert.c +++ b/src/lib/libssl/ssl_cert.c | |||
@@ -781,7 +781,7 @@ err: | |||
781 | #endif | 781 | #endif |
782 | #endif | 782 | #endif |
783 | 783 | ||
784 | #else | 784 | #else /* OPENSSL_SYS_WIN32 */ |
785 | 785 | ||
786 | int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, | 786 | int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, |
787 | const char *dir) | 787 | const char *dir) |
@@ -789,10 +789,30 @@ int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, | |||
789 | WIN32_FIND_DATA FindFileData; | 789 | WIN32_FIND_DATA FindFileData; |
790 | HANDLE hFind; | 790 | HANDLE hFind; |
791 | int ret = 0; | 791 | int ret = 0; |
792 | #ifdef OPENSSL_SYS_WINCE | ||
793 | WCHAR* wdir = NULL; | ||
794 | #endif | ||
792 | 795 | ||
793 | CRYPTO_w_lock(CRYPTO_LOCK_READDIR); | 796 | CRYPTO_w_lock(CRYPTO_LOCK_READDIR); |
794 | 797 | ||
798 | #ifdef OPENSSL_SYS_WINCE | ||
799 | /* convert strings to UNICODE */ | ||
800 | { | ||
801 | BOOL result = FALSE; | ||
802 | int i; | ||
803 | wdir = malloc((strlen(dir)+1)*2); | ||
804 | if (wdir == NULL) | ||
805 | goto err_noclose; | ||
806 | for (i=0; i<(int)strlen(dir)+1; i++) | ||
807 | wdir[i] = (short)dir[i]; | ||
808 | } | ||
809 | #endif | ||
810 | |||
811 | #ifdef OPENSSL_SYS_WINCE | ||
812 | hFind = FindFirstFile(wdir, &FindFileData); | ||
813 | #else | ||
795 | hFind = FindFirstFile(dir, &FindFileData); | 814 | hFind = FindFirstFile(dir, &FindFileData); |
815 | #endif | ||
796 | /* Note that a side effect is that the CAs will be sorted by name */ | 816 | /* Note that a side effect is that the CAs will be sorted by name */ |
797 | if(hFind == INVALID_HANDLE_VALUE) | 817 | if(hFind == INVALID_HANDLE_VALUE) |
798 | { | 818 | { |
@@ -807,7 +827,11 @@ int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, | |||
807 | char buf[1024]; | 827 | char buf[1024]; |
808 | int r; | 828 | int r; |
809 | 829 | ||
830 | #ifdef OPENSSL_SYS_WINCE | ||
831 | if(strlen(dir)+_tcslen(FindFileData.cFileName)+2 > sizeof buf) | ||
832 | #else | ||
810 | if(strlen(dir)+strlen(FindFileData.cFileName)+2 > sizeof buf) | 833 | if(strlen(dir)+strlen(FindFileData.cFileName)+2 > sizeof buf) |
834 | #endif | ||
811 | { | 835 | { |
812 | SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK,SSL_R_PATH_TOO_LONG); | 836 | SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK,SSL_R_PATH_TOO_LONG); |
813 | goto err; | 837 | goto err; |
@@ -825,6 +849,10 @@ int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, | |||
825 | err: | 849 | err: |
826 | FindClose(hFind); | 850 | FindClose(hFind); |
827 | err_noclose: | 851 | err_noclose: |
852 | #ifdef OPENSSL_SYS_WINCE | ||
853 | if (wdir != NULL) | ||
854 | free(wdir); | ||
855 | #endif | ||
828 | CRYPTO_w_unlock(CRYPTO_LOCK_READDIR); | 856 | CRYPTO_w_unlock(CRYPTO_LOCK_READDIR); |
829 | return ret; | 857 | return ret; |
830 | } | 858 | } |
diff --git a/src/lib/libssl/ssl_ciph.c b/src/lib/libssl/ssl_ciph.c index 37f58886a6..888b667fa1 100644 --- a/src/lib/libssl/ssl_ciph.c +++ b/src/lib/libssl/ssl_ciph.c | |||
@@ -668,13 +668,14 @@ static int ssl_cipher_process_rulestr(const char *rule_str, | |||
668 | * So additionally check whether the cipher name found | 668 | * So additionally check whether the cipher name found |
669 | * has the correct length. We can save a strlen() call: | 669 | * has the correct length. We can save a strlen() call: |
670 | * just checking for the '\0' at the right place is | 670 | * just checking for the '\0' at the right place is |
671 | * sufficient, we have to strncmp() anyway. | 671 | * sufficient, we have to strncmp() anyway. (We cannot |
672 | * use strcmp(), because buf is not '\0' terminated.) | ||
672 | */ | 673 | */ |
673 | j = found = 0; | 674 | j = found = 0; |
674 | while (ca_list[j]) | 675 | while (ca_list[j]) |
675 | { | 676 | { |
676 | if ((ca_list[j]->name[buflen] == '\0') && | 677 | if (!strncmp(buf, ca_list[j]->name, buflen) && |
677 | !strncmp(buf, ca_list[j]->name, buflen)) | 678 | (ca_list[j]->name[buflen] == '\0')) |
678 | { | 679 | { |
679 | found = 1; | 680 | found = 1; |
680 | break; | 681 | break; |
@@ -751,7 +752,12 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method, | |||
751 | */ | 752 | */ |
752 | if (rule_str == NULL) return(NULL); | 753 | if (rule_str == NULL) return(NULL); |
753 | 754 | ||
754 | if (init_ciphers) load_ciphers(); | 755 | if (init_ciphers) |
756 | { | ||
757 | CRYPTO_w_lock(CRYPTO_LOCK_SSL); | ||
758 | if (init_ciphers) load_ciphers(); | ||
759 | CRYPTO_w_unlock(CRYPTO_LOCK_SSL); | ||
760 | } | ||
755 | 761 | ||
756 | /* | 762 | /* |
757 | * To reduce the work to do we only want to process the compiled | 763 | * To reduce the work to do we only want to process the compiled |
diff --git a/src/lib/libssl/ssl_err.c b/src/lib/libssl/ssl_err.c index 7067a745f3..d2cb181503 100644 --- a/src/lib/libssl/ssl_err.c +++ b/src/lib/libssl/ssl_err.c | |||
@@ -296,6 +296,7 @@ static ERR_STRING_DATA SSL_str_reasons[]= | |||
296 | {SSL_R_LENGTH_TOO_SHORT ,"length too short"}, | 296 | {SSL_R_LENGTH_TOO_SHORT ,"length too short"}, |
297 | {SSL_R_LIBRARY_BUG ,"library bug"}, | 297 | {SSL_R_LIBRARY_BUG ,"library bug"}, |
298 | {SSL_R_LIBRARY_HAS_NO_CIPHERS ,"library has no ciphers"}, | 298 | {SSL_R_LIBRARY_HAS_NO_CIPHERS ,"library has no ciphers"}, |
299 | {SSL_R_MASTER_KEY_TOO_LONG ,"master key too long"}, | ||
299 | {SSL_R_MESSAGE_TOO_LONG ,"message too long"}, | 300 | {SSL_R_MESSAGE_TOO_LONG ,"message too long"}, |
300 | {SSL_R_MISSING_DH_DSA_CERT ,"missing dh dsa cert"}, | 301 | {SSL_R_MISSING_DH_DSA_CERT ,"missing dh dsa cert"}, |
301 | {SSL_R_MISSING_DH_KEY ,"missing dh key"}, | 302 | {SSL_R_MISSING_DH_KEY ,"missing dh key"}, |
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c index 4bc4ce5b3a..ddd8114587 100644 --- a/src/lib/libssl/ssl_lib.c +++ b/src/lib/libssl/ssl_lib.c | |||
@@ -121,6 +121,7 @@ | |||
121 | #include <openssl/objects.h> | 121 | #include <openssl/objects.h> |
122 | #include <openssl/lhash.h> | 122 | #include <openssl/lhash.h> |
123 | #include <openssl/x509v3.h> | 123 | #include <openssl/x509v3.h> |
124 | #include "cryptlib.h" | ||
124 | 125 | ||
125 | const char *SSL_version_str=OPENSSL_VERSION_TEXT; | 126 | const char *SSL_version_str=OPENSSL_VERSION_TEXT; |
126 | 127 | ||
@@ -273,6 +274,7 @@ SSL *SSL_new(SSL_CTX *ctx) | |||
273 | s->verify_mode=ctx->verify_mode; | 274 | s->verify_mode=ctx->verify_mode; |
274 | s->verify_depth=ctx->verify_depth; | 275 | s->verify_depth=ctx->verify_depth; |
275 | s->sid_ctx_length=ctx->sid_ctx_length; | 276 | s->sid_ctx_length=ctx->sid_ctx_length; |
277 | OPENSSL_assert(s->sid_ctx_length <= sizeof s->sid_ctx); | ||
276 | memcpy(&s->sid_ctx,&ctx->sid_ctx,sizeof(s->sid_ctx)); | 278 | memcpy(&s->sid_ctx,&ctx->sid_ctx,sizeof(s->sid_ctx)); |
277 | s->verify_callback=ctx->default_verify_callback; | 279 | s->verify_callback=ctx->default_verify_callback; |
278 | s->generate_session_id=ctx->generate_session_id; | 280 | s->generate_session_id=ctx->generate_session_id; |
@@ -314,7 +316,7 @@ err: | |||
314 | int SSL_CTX_set_session_id_context(SSL_CTX *ctx,const unsigned char *sid_ctx, | 316 | int SSL_CTX_set_session_id_context(SSL_CTX *ctx,const unsigned char *sid_ctx, |
315 | unsigned int sid_ctx_len) | 317 | unsigned int sid_ctx_len) |
316 | { | 318 | { |
317 | if(sid_ctx_len > SSL_MAX_SID_CTX_LENGTH) | 319 | if(sid_ctx_len > sizeof ctx->sid_ctx) |
318 | { | 320 | { |
319 | SSLerr(SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT,SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG); | 321 | SSLerr(SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT,SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG); |
320 | return 0; | 322 | return 0; |
@@ -364,6 +366,10 @@ int SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id, | |||
364 | * any new session built out of this id/id_len and the ssl_version in | 366 | * any new session built out of this id/id_len and the ssl_version in |
365 | * use by this SSL. */ | 367 | * use by this SSL. */ |
366 | SSL_SESSION r, *p; | 368 | SSL_SESSION r, *p; |
369 | |||
370 | if(id_len > sizeof r.session_id) | ||
371 | return 0; | ||
372 | |||
367 | r.ssl_version = ssl->version; | 373 | r.ssl_version = ssl->version; |
368 | r.session_id_length = id_len; | 374 | r.session_id_length = id_len; |
369 | memcpy(r.session_id, id, id_len); | 375 | memcpy(r.session_id, id, id_len); |
@@ -1063,14 +1069,17 @@ int ssl_cipher_ptr_id_cmp(const SSL_CIPHER * const *ap, | |||
1063 | * preference */ | 1069 | * preference */ |
1064 | STACK_OF(SSL_CIPHER) *SSL_get_ciphers(SSL *s) | 1070 | STACK_OF(SSL_CIPHER) *SSL_get_ciphers(SSL *s) |
1065 | { | 1071 | { |
1066 | if ((s != NULL) && (s->cipher_list != NULL)) | 1072 | if (s != NULL) |
1067 | { | ||
1068 | return(s->cipher_list); | ||
1069 | } | ||
1070 | else if ((s->ctx != NULL) && | ||
1071 | (s->ctx->cipher_list != NULL)) | ||
1072 | { | 1073 | { |
1073 | return(s->ctx->cipher_list); | 1074 | if (s->cipher_list != NULL) |
1075 | { | ||
1076 | return(s->cipher_list); | ||
1077 | } | ||
1078 | else if ((s->ctx != NULL) && | ||
1079 | (s->ctx->cipher_list != NULL)) | ||
1080 | { | ||
1081 | return(s->ctx->cipher_list); | ||
1082 | } | ||
1074 | } | 1083 | } |
1075 | return(NULL); | 1084 | return(NULL); |
1076 | } | 1085 | } |
@@ -1079,14 +1088,17 @@ STACK_OF(SSL_CIPHER) *SSL_get_ciphers(SSL *s) | |||
1079 | * algorithm id */ | 1088 | * algorithm id */ |
1080 | STACK_OF(SSL_CIPHER) *ssl_get_ciphers_by_id(SSL *s) | 1089 | STACK_OF(SSL_CIPHER) *ssl_get_ciphers_by_id(SSL *s) |
1081 | { | 1090 | { |
1082 | if ((s != NULL) && (s->cipher_list_by_id != NULL)) | 1091 | if (s != NULL) |
1083 | { | ||
1084 | return(s->cipher_list_by_id); | ||
1085 | } | ||
1086 | else if ((s != NULL) && (s->ctx != NULL) && | ||
1087 | (s->ctx->cipher_list_by_id != NULL)) | ||
1088 | { | 1092 | { |
1089 | return(s->ctx->cipher_list_by_id); | 1093 | if (s->cipher_list_by_id != NULL) |
1094 | { | ||
1095 | return(s->cipher_list_by_id); | ||
1096 | } | ||
1097 | else if ((s->ctx != NULL) && | ||
1098 | (s->ctx->cipher_list_by_id != NULL)) | ||
1099 | { | ||
1100 | return(s->ctx->cipher_list_by_id); | ||
1101 | } | ||
1090 | } | 1102 | } |
1091 | return(NULL); | 1103 | return(NULL); |
1092 | } | 1104 | } |
@@ -1652,7 +1664,7 @@ void ssl_update_cache(SSL *s,int mode) | |||
1652 | 1664 | ||
1653 | i=s->ctx->session_cache_mode; | 1665 | i=s->ctx->session_cache_mode; |
1654 | if ((i & mode) && (!s->hit) | 1666 | if ((i & mode) && (!s->hit) |
1655 | && ((i & SSL_SESS_CACHE_NO_INTERNAL_LOOKUP) | 1667 | && ((i & SSL_SESS_CACHE_NO_INTERNAL_STORE) |
1656 | || SSL_CTX_add_session(s->ctx,s->session)) | 1668 | || SSL_CTX_add_session(s->ctx,s->session)) |
1657 | && (s->ctx->new_session_cb != NULL)) | 1669 | && (s->ctx->new_session_cb != NULL)) |
1658 | { | 1670 | { |
@@ -1884,6 +1896,7 @@ SSL *SSL_dup(SSL *s) | |||
1884 | * they should not both point to the same object, | 1896 | * they should not both point to the same object, |
1885 | * and thus we can't use SSL_copy_session_id. */ | 1897 | * and thus we can't use SSL_copy_session_id. */ |
1886 | 1898 | ||
1899 | ret->method->ssl_free(ret); | ||
1887 | ret->method = s->method; | 1900 | ret->method = s->method; |
1888 | ret->method->ssl_new(ret); | 1901 | ret->method->ssl_new(ret); |
1889 | 1902 | ||
diff --git a/src/lib/libssl/ssl_sess.c b/src/lib/libssl/ssl_sess.c index ca1a7427be..fbc30b94e6 100644 --- a/src/lib/libssl/ssl_sess.c +++ b/src/lib/libssl/ssl_sess.c | |||
@@ -309,9 +309,12 @@ int ssl_get_prev_session(SSL *s, unsigned char *session_id, int len) | |||
309 | if (copy) | 309 | if (copy) |
310 | CRYPTO_add(&ret->references,1,CRYPTO_LOCK_SSL_SESSION); | 310 | CRYPTO_add(&ret->references,1,CRYPTO_LOCK_SSL_SESSION); |
311 | 311 | ||
312 | /* The following should not return 1, otherwise, | 312 | /* Add the externally cached session to the internal |
313 | * things are very strange */ | 313 | * cache as well if and only if we are supposed to. */ |
314 | SSL_CTX_add_session(s->ctx,ret); | 314 | if(!(s->ctx->session_cache_mode & SSL_SESS_CACHE_NO_INTERNAL_STORE)) |
315 | /* The following should not return 1, otherwise, | ||
316 | * things are very strange */ | ||
317 | SSL_CTX_add_session(s->ctx,ret); | ||
315 | } | 318 | } |
316 | if (ret == NULL) | 319 | if (ret == NULL) |
317 | goto err; | 320 | goto err; |
@@ -525,13 +528,13 @@ void SSL_SESSION_free(SSL_SESSION *ss) | |||
525 | 528 | ||
526 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data); | 529 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data); |
527 | 530 | ||
528 | memset(ss->key_arg,0,SSL_MAX_KEY_ARG_LENGTH); | 531 | OPENSSL_cleanse(ss->key_arg,sizeof ss->key_arg); |
529 | memset(ss->master_key,0,SSL_MAX_MASTER_KEY_LENGTH); | 532 | OPENSSL_cleanse(ss->master_key,sizeof ss->master_key); |
530 | memset(ss->session_id,0,SSL_MAX_SSL_SESSION_ID_LENGTH); | 533 | OPENSSL_cleanse(ss->session_id,sizeof ss->session_id); |
531 | if (ss->sess_cert != NULL) ssl_sess_cert_free(ss->sess_cert); | 534 | if (ss->sess_cert != NULL) ssl_sess_cert_free(ss->sess_cert); |
532 | if (ss->peer != NULL) X509_free(ss->peer); | 535 | if (ss->peer != NULL) X509_free(ss->peer); |
533 | if (ss->ciphers != NULL) sk_SSL_CIPHER_free(ss->ciphers); | 536 | if (ss->ciphers != NULL) sk_SSL_CIPHER_free(ss->ciphers); |
534 | memset(ss,0,sizeof(*ss)); | 537 | OPENSSL_cleanse(ss,sizeof(*ss)); |
535 | OPENSSL_free(ss); | 538 | OPENSSL_free(ss); |
536 | } | 539 | } |
537 | 540 | ||
diff --git a/src/lib/libssl/t1_clnt.c b/src/lib/libssl/t1_clnt.c index 9ad518f9f4..57205fb429 100644 --- a/src/lib/libssl/t1_clnt.c +++ b/src/lib/libssl/t1_clnt.c | |||
@@ -79,11 +79,18 @@ SSL_METHOD *TLSv1_client_method(void) | |||
79 | 79 | ||
80 | if (init) | 80 | if (init) |
81 | { | 81 | { |
82 | memcpy((char *)&TLSv1_client_data,(char *)tlsv1_base_method(), | 82 | CRYPTO_w_lock(CRYPTO_LOCK_SSL_METHOD); |
83 | sizeof(SSL_METHOD)); | 83 | |
84 | TLSv1_client_data.ssl_connect=ssl3_connect; | 84 | if (init) |
85 | TLSv1_client_data.get_ssl_method=tls1_get_client_method; | 85 | { |
86 | init=0; | 86 | memcpy((char *)&TLSv1_client_data,(char *)tlsv1_base_method(), |
87 | sizeof(SSL_METHOD)); | ||
88 | TLSv1_client_data.ssl_connect=ssl3_connect; | ||
89 | TLSv1_client_data.get_ssl_method=tls1_get_client_method; | ||
90 | init=0; | ||
91 | } | ||
92 | |||
93 | CRYPTO_w_unlock(CRYPTO_LOCK_SSL_METHOD); | ||
87 | } | 94 | } |
88 | return(&TLSv1_client_data); | 95 | return(&TLSv1_client_data); |
89 | } | 96 | } |
diff --git a/src/lib/libssl/t1_enc.c b/src/lib/libssl/t1_enc.c index 5290bf6665..271e247eea 100644 --- a/src/lib/libssl/t1_enc.c +++ b/src/lib/libssl/t1_enc.c | |||
@@ -124,7 +124,7 @@ static void tls1_P_hash(const EVP_MD *md, const unsigned char *sec, | |||
124 | unsigned int j; | 124 | unsigned int j; |
125 | HMAC_CTX ctx; | 125 | HMAC_CTX ctx; |
126 | HMAC_CTX ctx_tmp; | 126 | HMAC_CTX ctx_tmp; |
127 | unsigned char A1[HMAC_MAX_MD_CBLOCK]; | 127 | unsigned char A1[EVP_MAX_MD_SIZE]; |
128 | unsigned int A1_len; | 128 | unsigned int A1_len; |
129 | 129 | ||
130 | chunk=EVP_MD_size(md); | 130 | chunk=EVP_MD_size(md); |
@@ -161,7 +161,7 @@ static void tls1_P_hash(const EVP_MD *md, const unsigned char *sec, | |||
161 | } | 161 | } |
162 | HMAC_CTX_cleanup(&ctx); | 162 | HMAC_CTX_cleanup(&ctx); |
163 | HMAC_CTX_cleanup(&ctx_tmp); | 163 | HMAC_CTX_cleanup(&ctx_tmp); |
164 | memset(A1,0,sizeof(A1)); | 164 | OPENSSL_cleanse(A1,sizeof(A1)); |
165 | } | 165 | } |
166 | 166 | ||
167 | static void tls1_PRF(const EVP_MD *md5, const EVP_MD *sha1, | 167 | static void tls1_PRF(const EVP_MD *md5, const EVP_MD *sha1, |
@@ -418,10 +418,10 @@ printf("\niv="); | |||
418 | printf("\n"); | 418 | printf("\n"); |
419 | #endif | 419 | #endif |
420 | 420 | ||
421 | memset(tmp1,0,sizeof(tmp1)); | 421 | OPENSSL_cleanse(tmp1,sizeof(tmp1)); |
422 | memset(tmp2,0,sizeof(tmp1)); | 422 | OPENSSL_cleanse(tmp2,sizeof(tmp1)); |
423 | memset(iv1,0,sizeof(iv1)); | 423 | OPENSSL_cleanse(iv1,sizeof(iv1)); |
424 | memset(iv2,0,sizeof(iv2)); | 424 | OPENSSL_cleanse(iv2,sizeof(iv2)); |
425 | return(1); | 425 | return(1); |
426 | err: | 426 | err: |
427 | SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE,ERR_R_MALLOC_FAILURE); | 427 | SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE,ERR_R_MALLOC_FAILURE); |
@@ -476,7 +476,7 @@ printf("pre-master\n"); | |||
476 | { int z; for (z=0; z<s->session->master_key_length; z++) printf("%02X%c",s->session->master_key[z],((z+1)%16)?' ':'\n'); } | 476 | { int z; for (z=0; z<s->session->master_key_length; z++) printf("%02X%c",s->session->master_key[z],((z+1)%16)?' ':'\n'); } |
477 | #endif | 477 | #endif |
478 | tls1_generate_key_block(s,p1,p2,num); | 478 | tls1_generate_key_block(s,p1,p2,num); |
479 | memset(p2,0,num); | 479 | OPENSSL_cleanse(p2,num); |
480 | OPENSSL_free(p2); | 480 | OPENSSL_free(p2); |
481 | #ifdef TLS_DEBUG | 481 | #ifdef TLS_DEBUG |
482 | printf("\nkey block\n"); | 482 | printf("\nkey block\n"); |
@@ -683,10 +683,10 @@ int tls1_final_finish_mac(SSL *s, EVP_MD_CTX *in1_ctx, EVP_MD_CTX *in2_ctx, | |||
683 | 683 | ||
684 | tls1_PRF(s->ctx->md5,s->ctx->sha1,buf,(int)(q-buf), | 684 | tls1_PRF(s->ctx->md5,s->ctx->sha1,buf,(int)(q-buf), |
685 | s->session->master_key,s->session->master_key_length, | 685 | s->session->master_key,s->session->master_key_length, |
686 | out,buf2,12); | 686 | out,buf2,sizeof buf2); |
687 | EVP_MD_CTX_cleanup(&ctx); | 687 | EVP_MD_CTX_cleanup(&ctx); |
688 | 688 | ||
689 | return((int)12); | 689 | return sizeof buf2; |
690 | } | 690 | } |
691 | 691 | ||
692 | int tls1_mac(SSL *ssl, unsigned char *md, int send) | 692 | int tls1_mac(SSL *ssl, unsigned char *md, int send) |
@@ -773,7 +773,7 @@ int tls1_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p, | |||
773 | s->s3->server_random,SSL3_RANDOM_SIZE); | 773 | s->s3->server_random,SSL3_RANDOM_SIZE); |
774 | tls1_PRF(s->ctx->md5,s->ctx->sha1, | 774 | tls1_PRF(s->ctx->md5,s->ctx->sha1, |
775 | buf,TLS_MD_MASTER_SECRET_CONST_SIZE+SSL3_RANDOM_SIZE*2,p,len, | 775 | buf,TLS_MD_MASTER_SECRET_CONST_SIZE+SSL3_RANDOM_SIZE*2,p,len, |
776 | s->session->master_key,buff,SSL3_MASTER_SECRET_SIZE); | 776 | s->session->master_key,buff,sizeof buff); |
777 | #ifdef KSSL_DEBUG | 777 | #ifdef KSSL_DEBUG |
778 | printf ("tls1_generate_master_secret() complete\n"); | 778 | printf ("tls1_generate_master_secret() complete\n"); |
779 | #endif /* KSSL_DEBUG */ | 779 | #endif /* KSSL_DEBUG */ |
diff --git a/src/lib/libssl/t1_meth.c b/src/lib/libssl/t1_meth.c index 9bb36a7d1c..fcc243f782 100644 --- a/src/lib/libssl/t1_meth.c +++ b/src/lib/libssl/t1_meth.c | |||
@@ -76,13 +76,21 @@ SSL_METHOD *TLSv1_method(void) | |||
76 | 76 | ||
77 | if (init) | 77 | if (init) |
78 | { | 78 | { |
79 | memcpy((char *)&TLSv1_data,(char *)tlsv1_base_method(), | 79 | CRYPTO_w_lock(CRYPTO_LOCK_SSL_METHOD); |
80 | sizeof(SSL_METHOD)); | 80 | |
81 | TLSv1_data.ssl_connect=ssl3_connect; | 81 | if (init) |
82 | TLSv1_data.ssl_accept=ssl3_accept; | 82 | { |
83 | TLSv1_data.get_ssl_method=tls1_get_method; | 83 | memcpy((char *)&TLSv1_data,(char *)tlsv1_base_method(), |
84 | init=0; | 84 | sizeof(SSL_METHOD)); |
85 | TLSv1_data.ssl_connect=ssl3_connect; | ||
86 | TLSv1_data.ssl_accept=ssl3_accept; | ||
87 | TLSv1_data.get_ssl_method=tls1_get_method; | ||
88 | init=0; | ||
89 | } | ||
90 | |||
91 | CRYPTO_w_unlock(CRYPTO_LOCK_SSL_METHOD); | ||
85 | } | 92 | } |
93 | |||
86 | return(&TLSv1_data); | 94 | return(&TLSv1_data); |
87 | } | 95 | } |
88 | 96 | ||
diff --git a/src/lib/libssl/t1_srvr.c b/src/lib/libssl/t1_srvr.c index 6e765e587f..1c1149e49f 100644 --- a/src/lib/libssl/t1_srvr.c +++ b/src/lib/libssl/t1_srvr.c | |||
@@ -80,11 +80,18 @@ SSL_METHOD *TLSv1_server_method(void) | |||
80 | 80 | ||
81 | if (init) | 81 | if (init) |
82 | { | 82 | { |
83 | memcpy((char *)&TLSv1_server_data,(char *)tlsv1_base_method(), | 83 | CRYPTO_w_lock(CRYPTO_LOCK_SSL_METHOD); |
84 | sizeof(SSL_METHOD)); | 84 | |
85 | TLSv1_server_data.ssl_accept=ssl3_accept; | 85 | if (init) |
86 | TLSv1_server_data.get_ssl_method=tls1_get_server_method; | 86 | { |
87 | init=0; | 87 | memcpy((char *)&TLSv1_server_data,(char *)tlsv1_base_method(), |
88 | sizeof(SSL_METHOD)); | ||
89 | TLSv1_server_data.ssl_accept=ssl3_accept; | ||
90 | TLSv1_server_data.get_ssl_method=tls1_get_server_method; | ||
91 | init=0; | ||
92 | } | ||
93 | |||
94 | CRYPTO_w_unlock(CRYPTO_LOCK_SSL_METHOD); | ||
88 | } | 95 | } |
89 | return(&TLSv1_server_data); | 96 | return(&TLSv1_server_data); |
90 | } | 97 | } |
diff --git a/src/lib/libssl/test/methtest.c b/src/lib/libssl/test/methtest.c index 06ccb3b310..005c2f4822 100644 --- a/src/lib/libssl/test/methtest.c +++ b/src/lib/libssl/test/methtest.c | |||
@@ -96,10 +96,10 @@ char *argv[]; | |||
96 | METH_init(top); | 96 | METH_init(top); |
97 | METH_control(tmp1,METH_CONTROL_DUMP,stdout); | 97 | METH_control(tmp1,METH_CONTROL_DUMP,stdout); |
98 | METH_control(tmp2,METH_CONTROL_DUMP,stdout); | 98 | METH_control(tmp2,METH_CONTROL_DUMP,stdout); |
99 | exit(0); | 99 | EXIT(0); |
100 | err: | 100 | err: |
101 | ERR_load_crypto_strings(); | 101 | ERR_load_crypto_strings(); |
102 | ERR_print_errors_fp(stderr); | 102 | ERR_print_errors_fp(stderr); |
103 | exit(1); | 103 | EXIT(1); |
104 | return(0); | 104 | return(0); |
105 | } | 105 | } |
diff --git a/src/lib/libssl/test/testgen b/src/lib/libssl/test/testgen index 55c496f4bc..3798543e04 100644 --- a/src/lib/libssl/test/testgen +++ b/src/lib/libssl/test/testgen | |||
@@ -27,6 +27,8 @@ fi | |||
27 | 27 | ||
28 | echo "This could take some time." | 28 | echo "This could take some time." |
29 | 29 | ||
30 | rm -f testkey.pem testreq.pem | ||
31 | |||
30 | ../apps/openssl req -config test.cnf $req_new -out testreq.pem | 32 | ../apps/openssl req -config test.cnf $req_new -out testreq.pem |
31 | if [ $? != 0 ]; then | 33 | if [ $? != 0 ]; then |
32 | echo problems creating request | 34 | echo problems creating request |
diff --git a/src/lib/libssl/test/testssl b/src/lib/libssl/test/testssl index ba5e41c861..ca8e718022 100644 --- a/src/lib/libssl/test/testssl +++ b/src/lib/libssl/test/testssl | |||
@@ -121,8 +121,12 @@ $ssltest -bio_pair -server_auth -client_auth -app_verify $CA $extra || exit 1 | |||
121 | 121 | ||
122 | ############################################################################# | 122 | ############################################################################# |
123 | 123 | ||
124 | echo test tls1 with 1024bit anonymous DH, multiple handshakes | 124 | if ../apps/openssl no-dh; then |
125 | $ssltest -v -bio_pair -tls1 -cipher ADH -dhe1024dsa -num 10 -f -time $extra || exit 1 | 125 | echo skipping anonymous DH tests |
126 | else | ||
127 | echo test tls1 with 1024bit anonymous DH, multiple handshakes | ||
128 | $ssltest -v -bio_pair -tls1 -cipher ADH -dhe1024dsa -num 10 -f -time $extra || exit 1 | ||
129 | fi | ||
126 | 130 | ||
127 | if ../apps/openssl no-rsa; then | 131 | if ../apps/openssl no-rsa; then |
128 | echo skipping RSA tests | 132 | echo skipping RSA tests |
@@ -130,8 +134,12 @@ else | |||
130 | echo test tls1 with 1024bit RSA, no DHE, multiple handshakes | 134 | echo test tls1 with 1024bit RSA, no DHE, multiple handshakes |
131 | ./ssltest -v -bio_pair -tls1 -cert ../apps/server2.pem -no_dhe -num 10 -f -time $extra || exit 1 | 135 | ./ssltest -v -bio_pair -tls1 -cert ../apps/server2.pem -no_dhe -num 10 -f -time $extra || exit 1 |
132 | 136 | ||
133 | echo test tls1 with 1024bit RSA, 1024bit DHE, multiple handshakes | 137 | if ../apps/openssl no-dh; then |
134 | ./ssltest -v -bio_pair -tls1 -cert ../apps/server2.pem -dhe1024dsa -num 10 -f -time $extra || exit 1 | 138 | echo skipping RSA+DHE tests |
139 | else | ||
140 | echo test tls1 with 1024bit RSA, 1024bit DHE, multiple handshakes | ||
141 | ./ssltest -v -bio_pair -tls1 -cert ../apps/server2.pem -dhe1024dsa -num 10 -f -time $extra || exit 1 | ||
142 | fi | ||
135 | fi | 143 | fi |
136 | 144 | ||
137 | exit 0 | 145 | exit 0 |