diff options
Diffstat (limited to 'src/lib/libssl/s23_clnt.c')
-rw-r--r-- | src/lib/libssl/s23_clnt.c | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/src/lib/libssl/s23_clnt.c b/src/lib/libssl/s23_clnt.c index a4661ebb68..299d2ae5d2 100644 --- a/src/lib/libssl/s23_clnt.c +++ b/src/lib/libssl/s23_clnt.c | |||
@@ -57,28 +57,20 @@ | |||
57 | */ | 57 | */ |
58 | 58 | ||
59 | #include <stdio.h> | 59 | #include <stdio.h> |
60 | #include "buffer.h" | 60 | #include <openssl/buffer.h> |
61 | #include "rand.h" | 61 | #include <openssl/rand.h> |
62 | #include "objects.h" | 62 | #include <openssl/objects.h> |
63 | #include "evp.h" | 63 | #include <openssl/evp.h> |
64 | #include "ssl_locl.h" | 64 | #include "ssl_locl.h" |
65 | 65 | ||
66 | #define BREAK break | 66 | static SSL_METHOD *ssl23_get_client_method(int ver); |
67 | |||
68 | #ifndef NOPROTO | ||
69 | static int ssl23_client_hello(SSL *s); | 67 | static int ssl23_client_hello(SSL *s); |
70 | static int ssl23_get_server_hello(SSL *s); | 68 | static int ssl23_get_server_hello(SSL *s); |
71 | #else | 69 | static SSL_METHOD *ssl23_get_client_method(int ver) |
72 | static int ssl23_client_hello(); | ||
73 | static int ssl23_get_server_hello(); | ||
74 | #endif | ||
75 | |||
76 | static SSL_METHOD *ssl23_get_client_method(ver) | ||
77 | int ver; | ||
78 | { | 70 | { |
79 | if (ver == SSL2_VERSION) | 71 | if (ver == SSL2_VERSION) |
80 | return(SSLv2_client_method()); | 72 | return(SSLv2_client_method()); |
81 | else if (ver == SSL3_VERSION) | 73 | if (ver == SSL3_VERSION) |
82 | return(SSLv3_client_method()); | 74 | return(SSLv3_client_method()); |
83 | else if (ver == TLS1_VERSION) | 75 | else if (ver == TLS1_VERSION) |
84 | return(TLSv1_client_method()); | 76 | return(TLSv1_client_method()); |
@@ -86,24 +78,23 @@ int ver; | |||
86 | return(NULL); | 78 | return(NULL); |
87 | } | 79 | } |
88 | 80 | ||
89 | SSL_METHOD *SSLv23_client_method() | 81 | SSL_METHOD *SSLv23_client_method(void) |
90 | { | 82 | { |
91 | static int init=1; | 83 | static int init=1; |
92 | static SSL_METHOD SSLv23_client_data; | 84 | static SSL_METHOD SSLv23_client_data; |
93 | 85 | ||
94 | if (init) | 86 | if (init) |
95 | { | 87 | { |
96 | init=0; | ||
97 | memcpy((char *)&SSLv23_client_data, | 88 | memcpy((char *)&SSLv23_client_data, |
98 | (char *)sslv23_base_method(),sizeof(SSL_METHOD)); | 89 | (char *)sslv23_base_method(),sizeof(SSL_METHOD)); |
99 | SSLv23_client_data.ssl_connect=ssl23_connect; | 90 | SSLv23_client_data.ssl_connect=ssl23_connect; |
100 | SSLv23_client_data.get_ssl_method=ssl23_get_client_method; | 91 | SSLv23_client_data.get_ssl_method=ssl23_get_client_method; |
92 | init=0; | ||
101 | } | 93 | } |
102 | return(&SSLv23_client_data); | 94 | return(&SSLv23_client_data); |
103 | } | 95 | } |
104 | 96 | ||
105 | int ssl23_connect(s) | 97 | int ssl23_connect(SSL *s) |
106 | SSL *s; | ||
107 | { | 98 | { |
108 | BUF_MEM *buf; | 99 | BUF_MEM *buf; |
109 | unsigned long Time=time(NULL); | 100 | unsigned long Time=time(NULL); |
@@ -111,7 +102,7 @@ SSL *s; | |||
111 | int ret= -1; | 102 | int ret= -1; |
112 | int new_state,state; | 103 | int new_state,state; |
113 | 104 | ||
114 | RAND_seed((unsigned char *)&Time,sizeof(Time)); | 105 | RAND_seed(&Time,sizeof(Time)); |
115 | ERR_clear_error(); | 106 | ERR_clear_error(); |
116 | clear_sys_error(); | 107 | clear_sys_error(); |
117 | 108 | ||
@@ -134,6 +125,13 @@ SSL *s; | |||
134 | case SSL_ST_BEFORE|SSL_ST_CONNECT: | 125 | case SSL_ST_BEFORE|SSL_ST_CONNECT: |
135 | case SSL_ST_OK|SSL_ST_CONNECT: | 126 | case SSL_ST_OK|SSL_ST_CONNECT: |
136 | 127 | ||
128 | if (s->session != NULL) | ||
129 | { | ||
130 | SSLerr(SSL_F_SSL23_CONNECT,SSL_R_SSL23_DOING_SESSION_ID_REUSE); | ||
131 | ret= -1; | ||
132 | goto end; | ||
133 | } | ||
134 | s->server=0; | ||
137 | if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_START,1); | 135 | if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_START,1); |
138 | 136 | ||
139 | /* s->version=TLS1_VERSION; */ | 137 | /* s->version=TLS1_VERSION; */ |
@@ -159,7 +157,7 @@ SSL *s; | |||
159 | ssl3_init_finished_mac(s); | 157 | ssl3_init_finished_mac(s); |
160 | 158 | ||
161 | s->state=SSL23_ST_CW_CLNT_HELLO_A; | 159 | s->state=SSL23_ST_CW_CLNT_HELLO_A; |
162 | s->ctx->sess_connect++; | 160 | s->ctx->stats.sess_connect++; |
163 | s->init_num=0; | 161 | s->init_num=0; |
164 | break; | 162 | break; |
165 | 163 | ||
@@ -179,7 +177,7 @@ SSL *s; | |||
179 | ret=ssl23_get_server_hello(s); | 177 | ret=ssl23_get_server_hello(s); |
180 | if (ret >= 0) cb=NULL; | 178 | if (ret >= 0) cb=NULL; |
181 | goto end; | 179 | goto end; |
182 | break; | 180 | /* break; */ |
183 | 181 | ||
184 | default: | 182 | default: |
185 | SSLerr(SSL_F_SSL23_CONNECT,SSL_R_UNKNOWN_STATE); | 183 | SSLerr(SSL_F_SSL23_CONNECT,SSL_R_UNKNOWN_STATE); |
@@ -188,7 +186,7 @@ SSL *s; | |||
188 | /* break; */ | 186 | /* break; */ |
189 | } | 187 | } |
190 | 188 | ||
191 | if (s->debug) BIO_flush(s->wbio); | 189 | if (s->debug) { (void)BIO_flush(s->wbio); } |
192 | 190 | ||
193 | if ((cb != NULL) && (s->state != state)) | 191 | if ((cb != NULL) && (s->state != state)) |
194 | { | 192 | { |
@@ -206,8 +204,7 @@ end: | |||
206 | } | 204 | } |
207 | 205 | ||
208 | 206 | ||
209 | static int ssl23_client_hello(s) | 207 | static int ssl23_client_hello(SSL *s) |
210 | SSL *s; | ||
211 | { | 208 | { |
212 | unsigned char *buf; | 209 | unsigned char *buf; |
213 | unsigned char *p,*d; | 210 | unsigned char *p,*d; |
@@ -236,16 +233,19 @@ SSL *s; | |||
236 | { | 233 | { |
237 | *(d++)=TLS1_VERSION_MAJOR; | 234 | *(d++)=TLS1_VERSION_MAJOR; |
238 | *(d++)=TLS1_VERSION_MINOR; | 235 | *(d++)=TLS1_VERSION_MINOR; |
236 | s->client_version=TLS1_VERSION; | ||
239 | } | 237 | } |
240 | else if (!(s->options & SSL_OP_NO_SSLv3)) | 238 | else if (!(s->options & SSL_OP_NO_SSLv3)) |
241 | { | 239 | { |
242 | *(d++)=SSL3_VERSION_MAJOR; | 240 | *(d++)=SSL3_VERSION_MAJOR; |
243 | *(d++)=SSL3_VERSION_MINOR; | 241 | *(d++)=SSL3_VERSION_MINOR; |
242 | s->client_version=SSL3_VERSION; | ||
244 | } | 243 | } |
245 | else if (!(s->options & SSL_OP_NO_SSLv2)) | 244 | else if (!(s->options & SSL_OP_NO_SSLv2)) |
246 | { | 245 | { |
247 | *(d++)=SSL2_VERSION_MAJOR; | 246 | *(d++)=SSL2_VERSION_MAJOR; |
248 | *(d++)=SSL2_VERSION_MINOR; | 247 | *(d++)=SSL2_VERSION_MINOR; |
248 | s->client_version=SSL2_VERSION; | ||
249 | } | 249 | } |
250 | else | 250 | else |
251 | { | 251 | { |
@@ -303,8 +303,7 @@ SSL *s; | |||
303 | return(ssl23_write_bytes(s)); | 303 | return(ssl23_write_bytes(s)); |
304 | } | 304 | } |
305 | 305 | ||
306 | static int ssl23_get_server_hello(s) | 306 | static int ssl23_get_server_hello(SSL *s) |
307 | SSL *s; | ||
308 | { | 307 | { |
309 | char buf[8]; | 308 | char buf[8]; |
310 | unsigned char *p; | 309 | unsigned char *p; |
@@ -443,7 +442,7 @@ SSL *s; | |||
443 | } | 442 | } |
444 | 443 | ||
445 | s->rwstate=SSL_NOTHING; | 444 | s->rwstate=SSL_NOTHING; |
446 | SSLerr(SSL_F_SSL23_GET_SERVER_HELLO,1000+p[6]); | 445 | SSLerr(SSL_F_SSL23_GET_SERVER_HELLO,SSL_AD_REASON_OFFSET+p[6]); |
447 | goto err; | 446 | goto err; |
448 | } | 447 | } |
449 | else | 448 | else |