diff options
author | cvs2svn <admin@example.com> | 2016-07-23 19:31:36 +0000 |
---|---|---|
committer | cvs2svn <admin@example.com> | 2016-07-23 19:31:36 +0000 |
commit | 86c49b31af735796dfde37aa29473a30d36367db (patch) | |
tree | e9a354a92a348338fe2b361e2eda703cae23cfab /src/lib/libssl/s23_clnt.c | |
parent | 19d5fe348e8926bac4521c5807aa64c45b8f7a41 (diff) | |
download | openbsd-OPENBSD_6_0_BASE.tar.gz openbsd-OPENBSD_6_0_BASE.tar.bz2 openbsd-OPENBSD_6_0_BASE.zip |
This commit was manufactured by cvs2git to create tag 'OPENBSD_6_0_BASE'.OPENBSD_6_0_BASE
Diffstat (limited to 'src/lib/libssl/s23_clnt.c')
-rw-r--r-- | src/lib/libssl/s23_clnt.c | 480 |
1 files changed, 0 insertions, 480 deletions
diff --git a/src/lib/libssl/s23_clnt.c b/src/lib/libssl/s23_clnt.c deleted file mode 100644 index c6920e2b34..0000000000 --- a/src/lib/libssl/s23_clnt.c +++ /dev/null | |||
@@ -1,480 +0,0 @@ | |||
1 | /* $OpenBSD: s23_clnt.c,v 1.46 2015/09/11 18:08:21 jsing Exp $ */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
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. | ||
8 | * | ||
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). | ||
15 | * | ||
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. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
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)" | ||
40 | * | ||
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 | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
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.] | ||
57 | */ | ||
58 | /* ==================================================================== | ||
59 | * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. | ||
60 | * | ||
61 | * Redistribution and use in source and binary forms, with or without | ||
62 | * modification, are permitted provided that the following conditions | ||
63 | * are met: | ||
64 | * | ||
65 | * 1. Redistributions of source code must retain the above copyright | ||
66 | * notice, this list of conditions and the following disclaimer. | ||
67 | * | ||
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 | ||
71 | * distribution. | ||
72 | * | ||
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/)" | ||
77 | * | ||
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. | ||
82 | * | ||
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. | ||
86 | * | ||
87 | * 6. Redistributions of any form whatsoever must retain the following | ||
88 | * acknowledgment: | ||
89 | * "This product includes software developed by the OpenSSL Project | ||
90 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
91 | * | ||
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 | * ==================================================================== | ||
105 | * | ||
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). | ||
109 | * | ||
110 | */ | ||
111 | |||
112 | #include <stdio.h> | ||
113 | |||
114 | #include "ssl_locl.h" | ||
115 | |||
116 | #include <openssl/buffer.h> | ||
117 | #include <openssl/evp.h> | ||
118 | #include <openssl/objects.h> | ||
119 | |||
120 | static int ssl23_client_hello(SSL *s); | ||
121 | static int ssl23_get_server_hello(SSL *s); | ||
122 | |||
123 | int | ||
124 | ssl23_connect(SSL *s) | ||
125 | { | ||
126 | void (*cb)(const SSL *ssl, int type, int val) = NULL; | ||
127 | int ret = -1; | ||
128 | int new_state, state; | ||
129 | |||
130 | ERR_clear_error(); | ||
131 | errno = 0; | ||
132 | |||
133 | if (s->info_callback != NULL) | ||
134 | cb = s->info_callback; | ||
135 | else if (s->ctx->info_callback != NULL) | ||
136 | cb = s->ctx->info_callback; | ||
137 | |||
138 | s->in_handshake++; | ||
139 | if (!SSL_in_init(s) || SSL_in_before(s)) | ||
140 | SSL_clear(s); | ||
141 | |||
142 | for (;;) { | ||
143 | state = s->state; | ||
144 | |||
145 | switch (s->state) { | ||
146 | case SSL_ST_BEFORE: | ||
147 | case SSL_ST_CONNECT: | ||
148 | case SSL_ST_BEFORE|SSL_ST_CONNECT: | ||
149 | case SSL_ST_OK|SSL_ST_CONNECT: | ||
150 | |||
151 | if (s->session != NULL) { | ||
152 | SSLerr(SSL_F_SSL23_CONNECT, SSL_R_SSL23_DOING_SESSION_ID_REUSE); | ||
153 | ret = -1; | ||
154 | goto end; | ||
155 | } | ||
156 | s->server = 0; | ||
157 | if (cb != NULL) | ||
158 | cb(s, SSL_CB_HANDSHAKE_START, 1); | ||
159 | |||
160 | /* s->version=TLS1_VERSION; */ | ||
161 | s->type = SSL_ST_CONNECT; | ||
162 | |||
163 | if (!ssl3_setup_init_buffer(s)) { | ||
164 | ret = -1; | ||
165 | goto end; | ||
166 | } | ||
167 | if (!ssl3_setup_buffers(s)) { | ||
168 | ret = -1; | ||
169 | goto end; | ||
170 | } | ||
171 | if (!tls1_init_finished_mac(s)) { | ||
172 | ret = -1; | ||
173 | goto end; | ||
174 | } | ||
175 | |||
176 | s->state = SSL23_ST_CW_CLNT_HELLO_A; | ||
177 | s->ctx->stats.sess_connect++; | ||
178 | s->init_num = 0; | ||
179 | break; | ||
180 | |||
181 | case SSL23_ST_CW_CLNT_HELLO_A: | ||
182 | case SSL23_ST_CW_CLNT_HELLO_B: | ||
183 | |||
184 | s->shutdown = 0; | ||
185 | ret = ssl23_client_hello(s); | ||
186 | if (ret <= 0) | ||
187 | goto end; | ||
188 | s->state = SSL23_ST_CR_SRVR_HELLO_A; | ||
189 | s->init_num = 0; | ||
190 | |||
191 | break; | ||
192 | |||
193 | case SSL23_ST_CR_SRVR_HELLO_A: | ||
194 | case SSL23_ST_CR_SRVR_HELLO_B: | ||
195 | ret = ssl23_get_server_hello(s); | ||
196 | if (ret >= 0) | ||
197 | cb = NULL; | ||
198 | goto end; | ||
199 | /* break; */ | ||
200 | |||
201 | default: | ||
202 | SSLerr(SSL_F_SSL23_CONNECT, SSL_R_UNKNOWN_STATE); | ||
203 | ret = -1; | ||
204 | goto end; | ||
205 | /* break; */ | ||
206 | } | ||
207 | |||
208 | if (s->debug) { | ||
209 | (void)BIO_flush(s->wbio); | ||
210 | } | ||
211 | |||
212 | if ((cb != NULL) && (s->state != state)) { | ||
213 | new_state = s->state; | ||
214 | s->state = state; | ||
215 | cb(s, SSL_CB_CONNECT_LOOP, 1); | ||
216 | s->state = new_state; | ||
217 | } | ||
218 | } | ||
219 | |||
220 | end: | ||
221 | s->in_handshake--; | ||
222 | if (cb != NULL) | ||
223 | cb(s, SSL_CB_CONNECT_EXIT, ret); | ||
224 | |||
225 | return (ret); | ||
226 | } | ||
227 | |||
228 | static int | ||
229 | ssl23_client_hello(SSL *s) | ||
230 | { | ||
231 | unsigned char *buf; | ||
232 | unsigned char *p, *d; | ||
233 | int i; | ||
234 | unsigned long l; | ||
235 | int version = 0, version_major, version_minor; | ||
236 | int ret; | ||
237 | unsigned long mask, options = s->options; | ||
238 | |||
239 | /* | ||
240 | * SSL_OP_NO_X disables all protocols above X *if* there are | ||
241 | * some protocols below X enabled. This is required in order | ||
242 | * to maintain "version capability" vector contiguous. So | ||
243 | * that if application wants to disable TLS1.0 in favour of | ||
244 | * TLS1>=1, it would be insufficient to pass SSL_NO_TLSv1, the | ||
245 | * answer is SSL_OP_NO_TLSv1|SSL_OP_NO_SSLv3|SSL_OP_NO_SSLv2. | ||
246 | */ | ||
247 | mask = SSL_OP_NO_TLSv1_1|SSL_OP_NO_TLSv1; | ||
248 | version = TLS1_2_VERSION; | ||
249 | |||
250 | if ((options & SSL_OP_NO_TLSv1_2) && (options & mask) != mask) | ||
251 | version = TLS1_1_VERSION; | ||
252 | mask &= ~SSL_OP_NO_TLSv1_1; | ||
253 | if ((options & SSL_OP_NO_TLSv1_1) && (options & mask) != mask) | ||
254 | version = TLS1_VERSION; | ||
255 | mask &= ~SSL_OP_NO_TLSv1; | ||
256 | |||
257 | buf = (unsigned char *)s->init_buf->data; | ||
258 | if (s->state == SSL23_ST_CW_CLNT_HELLO_A) { | ||
259 | arc4random_buf(s->s3->client_random, SSL3_RANDOM_SIZE); | ||
260 | |||
261 | if (version == TLS1_2_VERSION) { | ||
262 | version_major = TLS1_2_VERSION_MAJOR; | ||
263 | version_minor = TLS1_2_VERSION_MINOR; | ||
264 | } else if (version == TLS1_1_VERSION) { | ||
265 | version_major = TLS1_1_VERSION_MAJOR; | ||
266 | version_minor = TLS1_1_VERSION_MINOR; | ||
267 | } else if (version == TLS1_VERSION) { | ||
268 | version_major = TLS1_VERSION_MAJOR; | ||
269 | version_minor = TLS1_VERSION_MINOR; | ||
270 | } else { | ||
271 | SSLerr(SSL_F_SSL23_CLIENT_HELLO, | ||
272 | SSL_R_NO_PROTOCOLS_AVAILABLE); | ||
273 | return (-1); | ||
274 | } | ||
275 | |||
276 | s->client_version = version; | ||
277 | |||
278 | /* create Client Hello in SSL 3.0/TLS 1.0 format */ | ||
279 | |||
280 | /* | ||
281 | * Do the record header (5 bytes) and handshake | ||
282 | * message header (4 bytes) last | ||
283 | */ | ||
284 | d = p = &(buf[SSL3_RT_HEADER_LENGTH + SSL3_HM_HEADER_LENGTH]); | ||
285 | |||
286 | *(p++) = version_major; | ||
287 | *(p++) = version_minor; | ||
288 | |||
289 | /* Random stuff */ | ||
290 | memcpy(p, s->s3->client_random, SSL3_RANDOM_SIZE); | ||
291 | p += SSL3_RANDOM_SIZE; | ||
292 | |||
293 | /* Session ID (zero since there is no reuse) */ | ||
294 | *(p++) = 0; | ||
295 | |||
296 | /* Ciphers supported (using SSL 3.0/TLS 1.0 format) */ | ||
297 | i = ssl_cipher_list_to_bytes(s, SSL_get_ciphers(s), &p[2]); | ||
298 | if (i == 0) { | ||
299 | SSLerr(SSL_F_SSL23_CLIENT_HELLO, | ||
300 | SSL_R_NO_CIPHERS_AVAILABLE); | ||
301 | return -1; | ||
302 | } | ||
303 | s2n(i, p); | ||
304 | p += i; | ||
305 | |||
306 | /* add in (no) COMPRESSION */ | ||
307 | *(p++) = 1; | ||
308 | /* Add the NULL method */ | ||
309 | *(p++) = 0; | ||
310 | |||
311 | /* TLS extensions*/ | ||
312 | if ((p = ssl_add_clienthello_tlsext(s, p, | ||
313 | buf + SSL3_RT_MAX_PLAIN_LENGTH)) == NULL) { | ||
314 | SSLerr(SSL_F_SSL23_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); | ||
315 | return -1; | ||
316 | } | ||
317 | |||
318 | l = p - d; | ||
319 | |||
320 | /* fill in 4-byte handshake header */ | ||
321 | d = &(buf[SSL3_RT_HEADER_LENGTH]); | ||
322 | *(d++) = SSL3_MT_CLIENT_HELLO; | ||
323 | l2n3(l, d); | ||
324 | |||
325 | l += 4; | ||
326 | |||
327 | if (l > SSL3_RT_MAX_PLAIN_LENGTH) { | ||
328 | SSLerr(SSL_F_SSL23_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); | ||
329 | return -1; | ||
330 | } | ||
331 | |||
332 | /* fill in 5-byte record header */ | ||
333 | d = buf; | ||
334 | *(d++) = SSL3_RT_HANDSHAKE; | ||
335 | *(d++) = version_major; | ||
336 | |||
337 | /* | ||
338 | * Some servers hang if we use long client hellos | ||
339 | * and a record number > TLS 1.0. | ||
340 | */ | ||
341 | if (TLS1_get_client_version(s) > TLS1_VERSION) | ||
342 | *(d++) = 1; | ||
343 | else | ||
344 | *(d++) = version_minor; | ||
345 | s2n((int)l, d); | ||
346 | |||
347 | /* number of bytes to write */ | ||
348 | s->init_num = p - buf; | ||
349 | s->init_off = 0; | ||
350 | |||
351 | tls1_finish_mac(s, &(buf[SSL3_RT_HEADER_LENGTH]), | ||
352 | s->init_num - SSL3_RT_HEADER_LENGTH); | ||
353 | |||
354 | s->state = SSL23_ST_CW_CLNT_HELLO_B; | ||
355 | s->init_off = 0; | ||
356 | } | ||
357 | |||
358 | /* SSL3_ST_CW_CLNT_HELLO_B */ | ||
359 | ret = ssl23_write_bytes(s); | ||
360 | |||
361 | if ((ret >= 2) && s->msg_callback) { | ||
362 | /* Client Hello has been sent; tell msg_callback */ | ||
363 | |||
364 | s->msg_callback(1, version, SSL3_RT_HANDSHAKE, | ||
365 | s->init_buf->data + 5, ret - 5, s, s->msg_callback_arg); | ||
366 | } | ||
367 | |||
368 | return ret; | ||
369 | } | ||
370 | |||
371 | static int | ||
372 | ssl23_get_server_hello(SSL *s) | ||
373 | { | ||
374 | char buf[8]; | ||
375 | unsigned char *p; | ||
376 | int i; | ||
377 | int n; | ||
378 | |||
379 | n = ssl23_read_bytes(s, 7); | ||
380 | |||
381 | if (n != 7) | ||
382 | return (n); | ||
383 | p = s->packet; | ||
384 | |||
385 | memcpy(buf, p, n); | ||
386 | |||
387 | /* Old unsupported sslv2 handshake */ | ||
388 | if ((p[0] & 0x80) && (p[2] == SSL2_MT_SERVER_HELLO) && | ||
389 | (p[5] == 0x00) && (p[6] == 0x02)) { | ||
390 | SSLerr(SSL_F_SSL23_GET_SERVER_HELLO, | ||
391 | SSL_R_UNSUPPORTED_PROTOCOL); | ||
392 | goto err; | ||
393 | } | ||
394 | |||
395 | if (p[1] == SSL3_VERSION_MAJOR && | ||
396 | p[2] <= TLS1_2_VERSION_MINOR && | ||
397 | ((p[0] == SSL3_RT_HANDSHAKE && p[5] == SSL3_MT_SERVER_HELLO) || | ||
398 | (p[0] == SSL3_RT_ALERT && p[3] == 0 && p[4] == 2))) { | ||
399 | /* we have sslv3 or tls1 (server hello or alert) */ | ||
400 | |||
401 | if ((p[2] == TLS1_VERSION_MINOR) && | ||
402 | !(s->options & SSL_OP_NO_TLSv1)) { | ||
403 | s->version = TLS1_VERSION; | ||
404 | s->method = TLSv1_client_method(); | ||
405 | } else if ((p[2] == TLS1_1_VERSION_MINOR) && | ||
406 | !(s->options & SSL_OP_NO_TLSv1_1)) { | ||
407 | s->version = TLS1_1_VERSION; | ||
408 | s->method = TLSv1_1_client_method(); | ||
409 | } else if ((p[2] == TLS1_2_VERSION_MINOR) && | ||
410 | !(s->options & SSL_OP_NO_TLSv1_2)) { | ||
411 | s->version = TLS1_2_VERSION; | ||
412 | s->method = TLSv1_2_client_method(); | ||
413 | } else { | ||
414 | SSLerr(SSL_F_SSL23_GET_SERVER_HELLO, | ||
415 | SSL_R_UNSUPPORTED_PROTOCOL); | ||
416 | goto err; | ||
417 | } | ||
418 | |||
419 | if (p[0] == SSL3_RT_ALERT && p[5] != SSL3_AL_WARNING) { | ||
420 | /* fatal alert */ | ||
421 | void (*cb)(const SSL *ssl, int type, int val) = NULL; | ||
422 | int j; | ||
423 | |||
424 | if (s->info_callback != NULL) | ||
425 | cb = s->info_callback; | ||
426 | else if (s->ctx->info_callback != NULL) | ||
427 | cb = s->ctx->info_callback; | ||
428 | |||
429 | i = p[5]; | ||
430 | if (cb != NULL) { | ||
431 | j = (i << 8) | p[6]; | ||
432 | cb(s, SSL_CB_READ_ALERT, j); | ||
433 | } | ||
434 | |||
435 | if (s->msg_callback) | ||
436 | s->msg_callback(0, s->version, SSL3_RT_ALERT, | ||
437 | p + 5, 2, s, s->msg_callback_arg); | ||
438 | |||
439 | s->rwstate = SSL_NOTHING; | ||
440 | SSLerr(SSL_F_SSL23_GET_SERVER_HELLO, | ||
441 | SSL_AD_REASON_OFFSET + p[6]); | ||
442 | goto err; | ||
443 | } | ||
444 | |||
445 | if (!ssl_init_wbio_buffer(s, 1)) | ||
446 | goto err; | ||
447 | |||
448 | /* we are in this state */ | ||
449 | s->state = SSL3_ST_CR_SRVR_HELLO_A; | ||
450 | |||
451 | /* put the 7 bytes we have read into the input buffer | ||
452 | * for SSLv3 */ | ||
453 | s->rstate = SSL_ST_READ_HEADER; | ||
454 | s->packet_length = n; | ||
455 | if (s->s3->rbuf.buf == NULL) | ||
456 | if (!ssl3_setup_read_buffer(s)) | ||
457 | goto err; | ||
458 | s->packet = &(s->s3->rbuf.buf[0]); | ||
459 | memcpy(s->packet, buf, n); | ||
460 | s->s3->rbuf.left = n; | ||
461 | s->s3->rbuf.offset = 0; | ||
462 | |||
463 | s->handshake_func = s->method->ssl_connect; | ||
464 | } else { | ||
465 | SSLerr(SSL_F_SSL23_GET_SERVER_HELLO, SSL_R_UNKNOWN_PROTOCOL); | ||
466 | goto err; | ||
467 | } | ||
468 | s->init_num = 0; | ||
469 | |||
470 | /* | ||
471 | * Since, if we are sending a ssl23 client hello, we are not | ||
472 | * reusing a session-id | ||
473 | */ | ||
474 | if (!ssl_get_new_session(s, 0)) | ||
475 | goto err; | ||
476 | |||
477 | return (SSL_connect(s)); | ||
478 | err: | ||
479 | return (-1); | ||
480 | } | ||