diff options
Diffstat (limited to 'src/lib/libssl/s3_both.c')
| -rw-r--r-- | src/lib/libssl/s3_both.c | 295 |
1 files changed, 225 insertions, 70 deletions
diff --git a/src/lib/libssl/s3_both.c b/src/lib/libssl/s3_both.c index 6de62e1591..58a24cd883 100644 --- a/src/lib/libssl/s3_both.c +++ b/src/lib/libssl/s3_both.c | |||
| @@ -55,26 +55,95 @@ | |||
| 55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
| 56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
| 57 | */ | 57 | */ |
| 58 | /* ==================================================================== | ||
| 59 | * Copyright (c) 1998-2002 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 | */ | ||
| 58 | 111 | ||
| 112 | #include <limits.h> | ||
| 113 | #include <string.h> | ||
| 59 | #include <stdio.h> | 114 | #include <stdio.h> |
| 60 | #include "buffer.h" | 115 | #include <openssl/buffer.h> |
| 61 | #include "rand.h" | 116 | #include <openssl/rand.h> |
| 62 | #include "objects.h" | 117 | #include <openssl/objects.h> |
| 63 | #include "evp.h" | 118 | #include <openssl/evp.h> |
| 64 | #include "x509.h" | 119 | #include <openssl/x509.h> |
| 65 | #include "ssl_locl.h" | 120 | #include "ssl_locl.h" |
| 66 | 121 | ||
| 67 | #define BREAK break | 122 | /* send s->init_buf in records of type 'type' (SSL3_RT_HANDSHAKE or SSL3_RT_CHANGE_CIPHER_SPEC) */ |
| 68 | 123 | int ssl3_do_write(SSL *s, int type) | |
| 69 | /* SSL3err(SSL_F_SSL3_GET_FINISHED,SSL_R_EXCESSIVE_MESSAGE_SIZE); | 124 | { |
| 70 | */ | 125 | int ret; |
| 126 | |||
| 127 | ret=ssl3_write_bytes(s,type,&s->init_buf->data[s->init_off], | ||
| 128 | s->init_num); | ||
| 129 | if (ret < 0) return(-1); | ||
| 130 | if (type == SSL3_RT_HANDSHAKE) | ||
| 131 | /* should not be done for 'Hello Request's, but in that case | ||
| 132 | * we'll ignore the result anyway */ | ||
| 133 | ssl3_finish_mac(s,(unsigned char *)&s->init_buf->data[s->init_off],ret); | ||
| 134 | |||
| 135 | if (ret == s->init_num) | ||
| 136 | { | ||
| 137 | if (s->msg_callback) | ||
| 138 | s->msg_callback(1, s->version, type, s->init_buf->data, (size_t)(s->init_off + s->init_num), s, s->msg_callback_arg); | ||
| 139 | return(1); | ||
| 140 | } | ||
| 141 | s->init_off+=ret; | ||
| 142 | s->init_num-=ret; | ||
| 143 | return(0); | ||
| 144 | } | ||
| 71 | 145 | ||
| 72 | int ssl3_send_finished(s,a,b,sender,slen) | 146 | int ssl3_send_finished(SSL *s, int a, int b, const char *sender, int slen) |
| 73 | SSL *s; | ||
| 74 | int a; | ||
| 75 | int b; | ||
| 76 | unsigned char *sender; | ||
| 77 | int slen; | ||
| 78 | { | 147 | { |
| 79 | unsigned char *p,*d; | 148 | unsigned char *p,*d; |
| 80 | int i; | 149 | int i; |
| @@ -88,10 +157,19 @@ int slen; | |||
| 88 | i=s->method->ssl3_enc->final_finish_mac(s, | 157 | i=s->method->ssl3_enc->final_finish_mac(s, |
| 89 | &(s->s3->finish_dgst1), | 158 | &(s->s3->finish_dgst1), |
| 90 | &(s->s3->finish_dgst2), | 159 | &(s->s3->finish_dgst2), |
| 91 | sender,slen,p); | 160 | sender,slen,s->s3->tmp.finish_md); |
| 161 | s->s3->tmp.finish_md_len = i; | ||
| 162 | memcpy(p, s->s3->tmp.finish_md, i); | ||
| 92 | p+=i; | 163 | p+=i; |
| 93 | l=i; | 164 | l=i; |
| 94 | 165 | ||
| 166 | #ifdef OPENSSL_SYS_WIN16 | ||
| 167 | /* MSVC 1.5 does not clear the top bytes of the word unless | ||
| 168 | * I do this. | ||
| 169 | */ | ||
| 170 | l&=0xffff; | ||
| 171 | #endif | ||
| 172 | |||
| 95 | *(d++)=SSL3_MT_FINISHED; | 173 | *(d++)=SSL3_MT_FINISHED; |
| 96 | l2n3(l,d); | 174 | l2n3(l,d); |
| 97 | s->init_num=(int)l+4; | 175 | s->init_num=(int)l+4; |
| @@ -104,17 +182,14 @@ int slen; | |||
| 104 | return(ssl3_do_write(s,SSL3_RT_HANDSHAKE)); | 182 | return(ssl3_do_write(s,SSL3_RT_HANDSHAKE)); |
| 105 | } | 183 | } |
| 106 | 184 | ||
| 107 | int ssl3_get_finished(s,a,b) | 185 | int ssl3_get_finished(SSL *s, int a, int b) |
| 108 | SSL *s; | ||
| 109 | int a; | ||
| 110 | int b; | ||
| 111 | { | 186 | { |
| 112 | int al,i,ok; | 187 | int al,i,ok; |
| 113 | long n; | 188 | long n; |
| 114 | unsigned char *p; | 189 | unsigned char *p; |
| 115 | 190 | ||
| 116 | /* the mac has already been generated when we received the | 191 | /* the mac has already been generated when we received the |
| 117 | * change cipher spec message and is in s->s3->tmp.in_dgst[12] | 192 | * change cipher spec message and is in s->s3->tmp.peer_finish_md |
| 118 | */ | 193 | */ |
| 119 | 194 | ||
| 120 | n=ssl3_get_message(s, | 195 | n=ssl3_get_message(s, |
| @@ -126,7 +201,7 @@ int b; | |||
| 126 | 201 | ||
| 127 | if (!ok) return((int)n); | 202 | if (!ok) return((int)n); |
| 128 | 203 | ||
| 129 | /* If this occurs if we has missed a message */ | 204 | /* If this occurs, we have missed a message */ |
| 130 | if (!s->s3->change_cipher_spec) | 205 | if (!s->s3->change_cipher_spec) |
| 131 | { | 206 | { |
| 132 | al=SSL_AD_UNEXPECTED_MESSAGE; | 207 | al=SSL_AD_UNEXPECTED_MESSAGE; |
| @@ -135,9 +210,8 @@ int b; | |||
| 135 | } | 210 | } |
| 136 | s->s3->change_cipher_spec=0; | 211 | s->s3->change_cipher_spec=0; |
| 137 | 212 | ||
| 138 | p=(unsigned char *)s->init_buf->data; | 213 | p = (unsigned char *)s->init_msg; |
| 139 | 214 | i = s->s3->tmp.peer_finish_md_len; | |
| 140 | i=s->method->ssl3_enc->finish_mac_length; | ||
| 141 | 215 | ||
| 142 | if (i != n) | 216 | if (i != n) |
| 143 | { | 217 | { |
| @@ -146,7 +220,7 @@ int b; | |||
| 146 | goto f_err; | 220 | goto f_err; |
| 147 | } | 221 | } |
| 148 | 222 | ||
| 149 | if (memcmp( p, (char *)&(s->s3->tmp.finish_md[0]),i) != 0) | 223 | if (memcmp(p, s->s3->tmp.peer_finish_md, i) != 0) |
| 150 | { | 224 | { |
| 151 | al=SSL_AD_DECRYPT_ERROR; | 225 | al=SSL_AD_DECRYPT_ERROR; |
| 152 | SSLerr(SSL_F_SSL3_GET_FINISHED,SSL_R_DIGEST_CHECK_FAILED); | 226 | SSLerr(SSL_F_SSL3_GET_FINISHED,SSL_R_DIGEST_CHECK_FAILED); |
| @@ -167,9 +241,7 @@ f_err: | |||
| 167 | * ssl->session->read_compression assign | 241 | * ssl->session->read_compression assign |
| 168 | * ssl->session->read_hash assign | 242 | * ssl->session->read_hash assign |
| 169 | */ | 243 | */ |
| 170 | int ssl3_send_change_cipher_spec(s,a,b) | 244 | int ssl3_send_change_cipher_spec(SSL *s, int a, int b) |
| 171 | SSL *s; | ||
| 172 | int a,b; | ||
| 173 | { | 245 | { |
| 174 | unsigned char *p; | 246 | unsigned char *p; |
| 175 | 247 | ||
| @@ -187,9 +259,7 @@ int a,b; | |||
| 187 | return(ssl3_do_write(s,SSL3_RT_CHANGE_CIPHER_SPEC)); | 259 | return(ssl3_do_write(s,SSL3_RT_CHANGE_CIPHER_SPEC)); |
| 188 | } | 260 | } |
| 189 | 261 | ||
| 190 | unsigned long ssl3_output_cert_chain(s,x) | 262 | unsigned long ssl3_output_cert_chain(SSL *s, X509 *x) |
| 191 | SSL *s; | ||
| 192 | X509 *x; | ||
| 193 | { | 263 | { |
| 194 | unsigned char *p; | 264 | unsigned char *p; |
| 195 | int n,i; | 265 | int n,i; |
| @@ -207,7 +277,11 @@ X509 *x; | |||
| 207 | } | 277 | } |
| 208 | if (x != NULL) | 278 | if (x != NULL) |
| 209 | { | 279 | { |
| 210 | X509_STORE_CTX_init(&xs_ctx,s->ctx->cert_store,NULL,NULL); | 280 | if(!X509_STORE_CTX_init(&xs_ctx,s->ctx->cert_store,NULL,NULL)) |
| 281 | { | ||
| 282 | SSLerr(SSL_F_SSL3_OUTPUT_CERT_CHAIN,ERR_R_X509_LIB); | ||
| 283 | return(0); | ||
| 284 | } | ||
| 211 | 285 | ||
| 212 | for (;;) | 286 | for (;;) |
| 213 | { | 287 | { |
| @@ -236,6 +310,23 @@ X509 *x; | |||
| 236 | X509_STORE_CTX_cleanup(&xs_ctx); | 310 | X509_STORE_CTX_cleanup(&xs_ctx); |
| 237 | } | 311 | } |
| 238 | 312 | ||
| 313 | /* Thawte special :-) */ | ||
| 314 | if (s->ctx->extra_certs != NULL) | ||
| 315 | for (i=0; i<sk_X509_num(s->ctx->extra_certs); i++) | ||
| 316 | { | ||
| 317 | x=sk_X509_value(s->ctx->extra_certs,i); | ||
| 318 | n=i2d_X509(x,NULL); | ||
| 319 | if (!BUF_MEM_grow(buf,(int)(n+l+3))) | ||
| 320 | { | ||
| 321 | SSLerr(SSL_F_SSL3_OUTPUT_CERT_CHAIN,ERR_R_BUF_LIB); | ||
| 322 | return(0); | ||
| 323 | } | ||
| 324 | p=(unsigned char *)&(buf->data[l]); | ||
| 325 | l2n3(n,p); | ||
| 326 | i2d_X509(x,&p); | ||
| 327 | l+=n+3; | ||
| 328 | } | ||
| 329 | |||
| 239 | l-=7; | 330 | l-=7; |
| 240 | p=(unsigned char *)&(buf->data[4]); | 331 | p=(unsigned char *)&(buf->data[4]); |
| 241 | l2n3(l,p); | 332 | l2n3(l,p); |
| @@ -247,11 +338,12 @@ X509 *x; | |||
| 247 | return(l); | 338 | return(l); |
| 248 | } | 339 | } |
| 249 | 340 | ||
| 250 | long ssl3_get_message(s,st1,stn,mt,max,ok) | 341 | /* Obtain handshake message of message type 'mt' (any if mt == -1), |
| 251 | SSL *s; | 342 | * maximum acceptable body length 'max'. |
| 252 | int st1,stn,mt; | 343 | * The first four bytes (msg_type and length) are read in state 'st1', |
| 253 | long max; | 344 | * the body is read in state 'stn'. |
| 254 | int *ok; | 345 | */ |
| 346 | long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok) | ||
| 255 | { | 347 | { |
| 256 | unsigned char *p; | 348 | unsigned char *p; |
| 257 | unsigned long l; | 349 | unsigned long l; |
| @@ -268,21 +360,51 @@ int *ok; | |||
| 268 | goto f_err; | 360 | goto f_err; |
| 269 | } | 361 | } |
| 270 | *ok=1; | 362 | *ok=1; |
| 271 | return((int)s->s3->tmp.message_size); | 363 | s->init_msg = s->init_buf->data + 4; |
| 364 | s->init_num = (int)s->s3->tmp.message_size; | ||
| 365 | return s->init_num; | ||
| 272 | } | 366 | } |
| 273 | 367 | ||
| 274 | p=(unsigned char *)s->init_buf->data; | 368 | p=(unsigned char *)s->init_buf->data; |
| 275 | 369 | ||
| 276 | if (s->state == st1) | 370 | if (s->state == st1) /* s->init_num < 4 */ |
| 277 | { | 371 | { |
| 278 | i=ssl3_read_bytes(s,SSL3_RT_HANDSHAKE, | 372 | int skip_message; |
| 279 | (char *)&(p[s->init_num]), | 373 | |
| 280 | 4-s->init_num); | 374 | do |
| 281 | if (i < (4-s->init_num)) | ||
| 282 | { | 375 | { |
| 283 | *ok=0; | 376 | while (s->init_num < 4) |
| 284 | return(ssl3_part_read(s,i)); | 377 | { |
| 378 | i=ssl3_read_bytes(s,SSL3_RT_HANDSHAKE,&p[s->init_num], | ||
| 379 | 4 - s->init_num, 0); | ||
| 380 | if (i <= 0) | ||
| 381 | { | ||
| 382 | s->rwstate=SSL_READING; | ||
| 383 | *ok = 0; | ||
| 384 | return i; | ||
| 385 | } | ||
| 386 | s->init_num+=i; | ||
| 387 | } | ||
| 388 | |||
| 389 | skip_message = 0; | ||
| 390 | if (!s->server) | ||
| 391 | if (p[0] == SSL3_MT_HELLO_REQUEST) | ||
| 392 | /* The server may always send 'Hello Request' messages -- | ||
| 393 | * we are doing a handshake anyway now, so ignore them | ||
| 394 | * if their format is correct. Does not count for | ||
| 395 | * 'Finished' MAC. */ | ||
| 396 | if (p[1] == 0 && p[2] == 0 &&p[3] == 0) | ||
| 397 | { | ||
| 398 | s->init_num = 0; | ||
| 399 | skip_message = 1; | ||
| 400 | |||
| 401 | if (s->msg_callback) | ||
| 402 | s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, p, 4, s, s->msg_callback_arg); | ||
| 403 | } | ||
| 285 | } | 404 | } |
| 405 | while (skip_message); | ||
| 406 | |||
| 407 | /* s->init_num == 4 */ | ||
| 286 | 408 | ||
| 287 | if ((mt >= 0) && (*p != mt)) | 409 | if ((mt >= 0) && (*p != mt)) |
| 288 | { | 410 | { |
| @@ -290,6 +412,18 @@ int *ok; | |||
| 290 | SSLerr(SSL_F_SSL3_GET_MESSAGE,SSL_R_UNEXPECTED_MESSAGE); | 412 | SSLerr(SSL_F_SSL3_GET_MESSAGE,SSL_R_UNEXPECTED_MESSAGE); |
| 291 | goto f_err; | 413 | goto f_err; |
| 292 | } | 414 | } |
| 415 | if ((mt < 0) && (*p == SSL3_MT_CLIENT_HELLO) && | ||
| 416 | (st1 == SSL3_ST_SR_CERT_A) && | ||
| 417 | (stn == SSL3_ST_SR_CERT_B)) | ||
| 418 | { | ||
| 419 | /* At this point we have got an MS SGC second client | ||
| 420 | * hello (maybe we should always allow the client to | ||
| 421 | * start a new handshake?). We need to restart the mac. | ||
| 422 | * Don't increment {num,total}_renegotiations because | ||
| 423 | * we have not completed the handshake. */ | ||
| 424 | ssl3_init_finished_mac(s); | ||
| 425 | } | ||
| 426 | |||
| 293 | s->s3->tmp.message_type= *(p++); | 427 | s->s3->tmp.message_type= *(p++); |
| 294 | 428 | ||
| 295 | n2l3(p,l); | 429 | n2l3(p,l); |
| @@ -299,7 +433,13 @@ int *ok; | |||
| 299 | SSLerr(SSL_F_SSL3_GET_MESSAGE,SSL_R_EXCESSIVE_MESSAGE_SIZE); | 433 | SSLerr(SSL_F_SSL3_GET_MESSAGE,SSL_R_EXCESSIVE_MESSAGE_SIZE); |
| 300 | goto f_err; | 434 | goto f_err; |
| 301 | } | 435 | } |
| 302 | if (l && !BUF_MEM_grow(s->init_buf,(int)l)) | 436 | if (l > (INT_MAX-4)) /* BUF_MEM_grow takes an 'int' parameter */ |
| 437 | { | ||
| 438 | al=SSL_AD_ILLEGAL_PARAMETER; | ||
| 439 | SSLerr(SSL_F_SSL3_GET_MESSAGE,SSL_R_EXCESSIVE_MESSAGE_SIZE); | ||
| 440 | goto f_err; | ||
| 441 | } | ||
| 442 | if (l && !BUF_MEM_grow(s->init_buf,(int)l+4)) | ||
| 303 | { | 443 | { |
| 304 | SSLerr(SSL_F_SSL3_GET_MESSAGE,ERR_R_BUF_LIB); | 444 | SSLerr(SSL_F_SSL3_GET_MESSAGE,ERR_R_BUF_LIB); |
| 305 | goto err; | 445 | goto err; |
| @@ -307,24 +447,30 @@ int *ok; | |||
| 307 | s->s3->tmp.message_size=l; | 447 | s->s3->tmp.message_size=l; |
| 308 | s->state=stn; | 448 | s->state=stn; |
| 309 | 449 | ||
| 310 | s->init_num=0; | 450 | s->init_msg = s->init_buf->data + 4; |
| 451 | s->init_num = 0; | ||
| 311 | } | 452 | } |
| 312 | 453 | ||
| 313 | /* next state (stn) */ | 454 | /* next state (stn) */ |
| 314 | p=(unsigned char *)s->init_buf->data; | 455 | p = s->init_msg; |
| 315 | n=s->s3->tmp.message_size; | 456 | n = s->s3->tmp.message_size - s->init_num; |
| 316 | if (n > 0) | 457 | while (n > 0) |
| 317 | { | 458 | { |
| 318 | i=ssl3_read_bytes(s,SSL3_RT_HANDSHAKE, | 459 | i=ssl3_read_bytes(s,SSL3_RT_HANDSHAKE,&p[s->init_num],n,0); |
| 319 | (char *)&(p[s->init_num]),(int)n); | 460 | if (i <= 0) |
| 320 | if (i != (int)n) | ||
| 321 | { | 461 | { |
| 322 | *ok=0; | 462 | s->rwstate=SSL_READING; |
| 323 | return(ssl3_part_read(s,i)); | 463 | *ok = 0; |
| 464 | return i; | ||
| 324 | } | 465 | } |
| 466 | s->init_num += i; | ||
| 467 | n -= i; | ||
| 325 | } | 468 | } |
| 469 | ssl3_finish_mac(s, (unsigned char *)s->init_buf->data, s->init_num + 4); | ||
| 470 | if (s->msg_callback) | ||
| 471 | s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, s->init_buf->data, (size_t)s->init_num + 4, s, s->msg_callback_arg); | ||
| 326 | *ok=1; | 472 | *ok=1; |
| 327 | return(n); | 473 | return s->init_num; |
| 328 | f_err: | 474 | f_err: |
| 329 | ssl3_send_alert(s,SSL3_AL_FATAL,al); | 475 | ssl3_send_alert(s,SSL3_AL_FATAL,al); |
| 330 | err: | 476 | err: |
| @@ -332,9 +478,7 @@ err: | |||
| 332 | return(-1); | 478 | return(-1); |
| 333 | } | 479 | } |
| 334 | 480 | ||
| 335 | int ssl_cert_type(x,pkey) | 481 | int ssl_cert_type(X509 *x, EVP_PKEY *pkey) |
| 336 | X509 *x; | ||
| 337 | EVP_PKEY *pkey; | ||
| 338 | { | 482 | { |
| 339 | EVP_PKEY *pk; | 483 | EVP_PKEY *pk; |
| 340 | int ret= -1,i,j; | 484 | int ret= -1,i,j; |
| @@ -380,11 +524,11 @@ EVP_PKEY *pkey; | |||
| 380 | ret= -1; | 524 | ret= -1; |
| 381 | 525 | ||
| 382 | err: | 526 | err: |
| 527 | if(!pkey) EVP_PKEY_free(pk); | ||
| 383 | return(ret); | 528 | return(ret); |
| 384 | } | 529 | } |
| 385 | 530 | ||
| 386 | int ssl_verify_alarm_type(type) | 531 | int ssl_verify_alarm_type(long type) |
| 387 | long type; | ||
| 388 | { | 532 | { |
| 389 | int al; | 533 | int al; |
| 390 | 534 | ||
| @@ -392,6 +536,7 @@ long type; | |||
| 392 | { | 536 | { |
| 393 | case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: | 537 | case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: |
| 394 | case X509_V_ERR_UNABLE_TO_GET_CRL: | 538 | case X509_V_ERR_UNABLE_TO_GET_CRL: |
| 539 | case X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER: | ||
| 395 | al=SSL_AD_UNKNOWN_CA; | 540 | al=SSL_AD_UNKNOWN_CA; |
| 396 | break; | 541 | break; |
| 397 | case X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: | 542 | case X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: |
| @@ -403,6 +548,8 @@ long type; | |||
| 403 | case X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: | 548 | case X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: |
| 404 | case X509_V_ERR_CERT_NOT_YET_VALID: | 549 | case X509_V_ERR_CERT_NOT_YET_VALID: |
| 405 | case X509_V_ERR_CRL_NOT_YET_VALID: | 550 | case X509_V_ERR_CRL_NOT_YET_VALID: |
| 551 | case X509_V_ERR_CERT_UNTRUSTED: | ||
| 552 | case X509_V_ERR_CERT_REJECTED: | ||
| 406 | al=SSL_AD_BAD_CERTIFICATE; | 553 | al=SSL_AD_BAD_CERTIFICATE; |
| 407 | break; | 554 | break; |
| 408 | case X509_V_ERR_CERT_SIGNATURE_FAILURE: | 555 | case X509_V_ERR_CERT_SIGNATURE_FAILURE: |
| @@ -424,11 +571,16 @@ long type; | |||
| 424 | case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: | 571 | case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: |
| 425 | case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: | 572 | case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: |
| 426 | case X509_V_ERR_CERT_CHAIN_TOO_LONG: | 573 | case X509_V_ERR_CERT_CHAIN_TOO_LONG: |
| 574 | case X509_V_ERR_PATH_LENGTH_EXCEEDED: | ||
| 575 | case X509_V_ERR_INVALID_CA: | ||
| 427 | al=SSL_AD_UNKNOWN_CA; | 576 | al=SSL_AD_UNKNOWN_CA; |
| 428 | break; | 577 | break; |
| 429 | case X509_V_ERR_APPLICATION_VERIFICATION: | 578 | case X509_V_ERR_APPLICATION_VERIFICATION: |
| 430 | al=SSL_AD_HANDSHAKE_FAILURE; | 579 | al=SSL_AD_HANDSHAKE_FAILURE; |
| 431 | break; | 580 | break; |
| 581 | case X509_V_ERR_INVALID_PURPOSE: | ||
| 582 | al=SSL_AD_UNSUPPORTED_CERTIFICATE; | ||
| 583 | break; | ||
| 432 | default: | 584 | default: |
| 433 | al=SSL_AD_CERTIFICATE_UNKNOWN; | 585 | al=SSL_AD_CERTIFICATE_UNKNOWN; |
| 434 | break; | 586 | break; |
| @@ -436,11 +588,11 @@ long type; | |||
| 436 | return(al); | 588 | return(al); |
| 437 | } | 589 | } |
| 438 | 590 | ||
| 439 | int ssl3_setup_buffers(s) | 591 | int ssl3_setup_buffers(SSL *s) |
| 440 | SSL *s; | ||
| 441 | { | 592 | { |
| 442 | unsigned char *p; | 593 | unsigned char *p; |
| 443 | unsigned int extra; | 594 | unsigned int extra; |
| 595 | size_t len; | ||
| 444 | 596 | ||
| 445 | if (s->s3->rbuf.buf == NULL) | 597 | if (s->s3->rbuf.buf == NULL) |
| 446 | { | 598 | { |
| @@ -448,18 +600,21 @@ SSL *s; | |||
| 448 | extra=SSL3_RT_MAX_EXTRA; | 600 | extra=SSL3_RT_MAX_EXTRA; |
| 449 | else | 601 | else |
| 450 | extra=0; | 602 | extra=0; |
| 451 | if ((p=(unsigned char *)Malloc(SSL3_RT_MAX_PACKET_SIZE+extra)) | 603 | len = SSL3_RT_MAX_PACKET_SIZE + extra; |
| 452 | == NULL) | 604 | if ((p=OPENSSL_malloc(len)) == NULL) |
| 453 | goto err; | 605 | goto err; |
| 454 | s->s3->rbuf.buf=p; | 606 | s->s3->rbuf.buf = p; |
| 607 | s->s3->rbuf.len = len; | ||
| 455 | } | 608 | } |
| 456 | 609 | ||
| 457 | if (s->s3->wbuf.buf == NULL) | 610 | if (s->s3->wbuf.buf == NULL) |
| 458 | { | 611 | { |
| 459 | if ((p=(unsigned char *)Malloc(SSL3_RT_MAX_PACKET_SIZE)) | 612 | len = SSL3_RT_MAX_PACKET_SIZE; |
| 460 | == NULL) | 613 | len += SSL3_RT_HEADER_LENGTH + 256; /* extra space for empty fragment */ |
| 614 | if ((p=OPENSSL_malloc(len)) == NULL) | ||
| 461 | goto err; | 615 | goto err; |
| 462 | s->s3->wbuf.buf=p; | 616 | s->s3->wbuf.buf = p; |
| 617 | s->s3->wbuf.len = len; | ||
| 463 | } | 618 | } |
| 464 | s->packet= &(s->s3->rbuf.buf[0]); | 619 | s->packet= &(s->s3->rbuf.buf[0]); |
| 465 | return(1); | 620 | return(1); |
