diff options
Diffstat (limited to 'src/lib/libssl')
50 files changed, 8774 insertions, 4159 deletions
diff --git a/src/lib/libssl/LICENSE b/src/lib/libssl/LICENSE index b9e18d5e7b..7b93e0dbce 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-1999 The OpenSSL Project. All rights reserved. | 15 | * Copyright (c) 1998-2002 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 58a6d69b9b..467e149947 100644 --- a/src/lib/libssl/bio_ssl.c +++ b/src/lib/libssl/bio_ssl.c | |||
| @@ -60,27 +60,18 @@ | |||
| 60 | #include <stdlib.h> | 60 | #include <stdlib.h> |
| 61 | #include <string.h> | 61 | #include <string.h> |
| 62 | #include <errno.h> | 62 | #include <errno.h> |
| 63 | #include "crypto.h" | 63 | #include <openssl/crypto.h> |
| 64 | #include "bio.h" | 64 | #include <openssl/bio.h> |
| 65 | #include "err.h" | 65 | #include <openssl/err.h> |
| 66 | #include "ssl.h" | 66 | #include <openssl/ssl.h> |
| 67 | 67 | ||
| 68 | #ifndef NOPROTO | 68 | static int ssl_write(BIO *h, const char *buf, int num); |
| 69 | static int ssl_write(BIO *h,char *buf,int num); | 69 | static int ssl_read(BIO *h, char *buf, int size); |
| 70 | static int ssl_read(BIO *h,char *buf,int size); | 70 | static int ssl_puts(BIO *h, const char *str); |
| 71 | static int ssl_puts(BIO *h,char *str); | 71 | static long ssl_ctrl(BIO *h, int cmd, long arg1, void *arg2); |
| 72 | static long ssl_ctrl(BIO *h,int cmd,long arg1,char *arg2); | ||
| 73 | static int ssl_new(BIO *h); | 72 | static int ssl_new(BIO *h); |
| 74 | static int ssl_free(BIO *data); | 73 | static int ssl_free(BIO *data); |
| 75 | #else | 74 | static long ssl_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp); |
| 76 | static int ssl_write(); | ||
| 77 | static int ssl_read(); | ||
| 78 | static int ssl_puts(); | ||
| 79 | static long ssl_ctrl(); | ||
| 80 | static int ssl_new(); | ||
| 81 | static int ssl_free(); | ||
| 82 | #endif | ||
| 83 | |||
| 84 | typedef struct bio_ssl_st | 75 | typedef struct bio_ssl_st |
| 85 | { | 76 | { |
| 86 | SSL *ssl; /* The ssl handle :-) */ | 77 | SSL *ssl; /* The ssl handle :-) */ |
| @@ -102,19 +93,19 @@ static BIO_METHOD methods_sslp= | |||
| 102 | ssl_ctrl, | 93 | ssl_ctrl, |
| 103 | ssl_new, | 94 | ssl_new, |
| 104 | ssl_free, | 95 | ssl_free, |
| 96 | ssl_callback_ctrl, | ||
| 105 | }; | 97 | }; |
| 106 | 98 | ||
| 107 | BIO_METHOD *BIO_f_ssl() | 99 | BIO_METHOD *BIO_f_ssl(void) |
| 108 | { | 100 | { |
| 109 | return(&methods_sslp); | 101 | return(&methods_sslp); |
| 110 | } | 102 | } |
| 111 | 103 | ||
| 112 | static int ssl_new(bi) | 104 | static int ssl_new(BIO *bi) |
| 113 | BIO *bi; | ||
| 114 | { | 105 | { |
| 115 | BIO_SSL *bs; | 106 | BIO_SSL *bs; |
| 116 | 107 | ||
| 117 | bs=(BIO_SSL *)Malloc(sizeof(BIO_SSL)); | 108 | bs=(BIO_SSL *)OPENSSL_malloc(sizeof(BIO_SSL)); |
| 118 | if (bs == NULL) | 109 | if (bs == NULL) |
| 119 | { | 110 | { |
| 120 | BIOerr(BIO_F_SSL_NEW,ERR_R_MALLOC_FAILURE); | 111 | BIOerr(BIO_F_SSL_NEW,ERR_R_MALLOC_FAILURE); |
| @@ -127,8 +118,7 @@ BIO *bi; | |||
| 127 | return(1); | 118 | return(1); |
| 128 | } | 119 | } |
| 129 | 120 | ||
| 130 | static int ssl_free(a) | 121 | static int ssl_free(BIO *a) |
| 131 | BIO *a; | ||
| 132 | { | 122 | { |
| 133 | BIO_SSL *bs; | 123 | BIO_SSL *bs; |
| 134 | 124 | ||
| @@ -143,14 +133,11 @@ BIO *a; | |||
| 143 | a->flags=0; | 133 | a->flags=0; |
| 144 | } | 134 | } |
| 145 | if (a->ptr != NULL) | 135 | if (a->ptr != NULL) |
| 146 | Free(a->ptr); | 136 | OPENSSL_free(a->ptr); |
| 147 | return(1); | 137 | return(1); |
| 148 | } | 138 | } |
| 149 | 139 | ||
| 150 | static int ssl_read(b,out,outl) | 140 | static int ssl_read(BIO *b, char *out, int outl) |
| 151 | BIO *b; | ||
| 152 | char *out; | ||
| 153 | int outl; | ||
| 154 | { | 141 | { |
| 155 | int ret=1; | 142 | int ret=1; |
| 156 | BIO_SSL *sb; | 143 | BIO_SSL *sb; |
| @@ -219,6 +206,10 @@ int outl; | |||
| 219 | BIO_set_retry_special(b); | 206 | BIO_set_retry_special(b); |
| 220 | retry_reason=BIO_RR_SSL_X509_LOOKUP; | 207 | retry_reason=BIO_RR_SSL_X509_LOOKUP; |
| 221 | break; | 208 | break; |
| 209 | case SSL_ERROR_WANT_ACCEPT: | ||
| 210 | BIO_set_retry_special(b); | ||
| 211 | retry_reason=BIO_RR_ACCEPT; | ||
| 212 | break; | ||
| 222 | case SSL_ERROR_WANT_CONNECT: | 213 | case SSL_ERROR_WANT_CONNECT: |
| 223 | BIO_set_retry_special(b); | 214 | BIO_set_retry_special(b); |
| 224 | retry_reason=BIO_RR_CONNECT; | 215 | retry_reason=BIO_RR_CONNECT; |
| @@ -234,10 +225,7 @@ int outl; | |||
| 234 | return(ret); | 225 | return(ret); |
| 235 | } | 226 | } |
| 236 | 227 | ||
| 237 | static int ssl_write(b,out,outl) | 228 | static int ssl_write(BIO *b, const char *out, int outl) |
| 238 | BIO *b; | ||
| 239 | char *out; | ||
| 240 | int outl; | ||
| 241 | { | 229 | { |
| 242 | int ret,r=0; | 230 | int ret,r=0; |
| 243 | int retry_reason=0; | 231 | int retry_reason=0; |
| @@ -305,11 +293,7 @@ int outl; | |||
| 305 | return(ret); | 293 | return(ret); |
| 306 | } | 294 | } |
| 307 | 295 | ||
| 308 | static long ssl_ctrl(b,cmd,num,ptr) | 296 | static long ssl_ctrl(BIO *b, int cmd, long num, void *ptr) |
| 309 | BIO *b; | ||
| 310 | int cmd; | ||
| 311 | long num; | ||
| 312 | char *ptr; | ||
| 313 | { | 297 | { |
| 314 | SSL **sslp,*ssl; | 298 | SSL **sslp,*ssl; |
| 315 | BIO_SSL *bs; | 299 | BIO_SSL *bs; |
| @@ -466,7 +450,14 @@ char *ptr; | |||
| 466 | ret=BIO_ctrl(ssl->rbio,cmd,num,ptr); | 450 | ret=BIO_ctrl(ssl->rbio,cmd,num,ptr); |
| 467 | break; | 451 | break; |
| 468 | case BIO_CTRL_SET_CALLBACK: | 452 | case BIO_CTRL_SET_CALLBACK: |
| 469 | SSL_set_info_callback(ssl,(void (*)())ptr); | 453 | { |
| 454 | #if 0 /* FIXME: Should this be used? -- Richard Levitte */ | ||
| 455 | BIOerr(SSL_F_SSL_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | ||
| 456 | ret = -1; | ||
| 457 | #else | ||
| 458 | ret=0; | ||
| 459 | #endif | ||
| 460 | } | ||
| 470 | break; | 461 | break; |
| 471 | case BIO_CTRL_GET_CALLBACK: | 462 | case BIO_CTRL_GET_CALLBACK: |
| 472 | { | 463 | { |
| @@ -483,9 +474,31 @@ char *ptr; | |||
| 483 | return(ret); | 474 | return(ret); |
| 484 | } | 475 | } |
| 485 | 476 | ||
| 486 | static int ssl_puts(bp,str) | 477 | static long ssl_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp) |
| 487 | BIO *bp; | 478 | { |
| 488 | char *str; | 479 | SSL *ssl; |
| 480 | BIO_SSL *bs; | ||
| 481 | long ret=1; | ||
| 482 | |||
| 483 | bs=(BIO_SSL *)b->ptr; | ||
| 484 | ssl=bs->ssl; | ||
| 485 | switch (cmd) | ||
| 486 | { | ||
| 487 | case BIO_CTRL_SET_CALLBACK: | ||
| 488 | { | ||
| 489 | /* FIXME: setting this via a completely different prototype | ||
| 490 | seems like a crap idea */ | ||
| 491 | SSL_set_info_callback(ssl,(void (*)(const SSL *,int,int))fp); | ||
| 492 | } | ||
| 493 | break; | ||
| 494 | default: | ||
| 495 | ret=BIO_callback_ctrl(ssl->rbio,cmd,fp); | ||
| 496 | break; | ||
| 497 | } | ||
| 498 | return(ret); | ||
| 499 | } | ||
| 500 | |||
| 501 | static int ssl_puts(BIO *bp, const char *str) | ||
| 489 | { | 502 | { |
| 490 | int n,ret; | 503 | int n,ret; |
| 491 | 504 | ||
| @@ -494,8 +507,7 @@ char *str; | |||
| 494 | return(ret); | 507 | return(ret); |
| 495 | } | 508 | } |
| 496 | 509 | ||
| 497 | BIO *BIO_new_buffer_ssl_connect(ctx) | 510 | BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx) |
| 498 | SSL_CTX *ctx; | ||
| 499 | { | 511 | { |
| 500 | BIO *ret=NULL,*buf=NULL,*ssl=NULL; | 512 | BIO *ret=NULL,*buf=NULL,*ssl=NULL; |
| 501 | 513 | ||
| @@ -512,8 +524,7 @@ err: | |||
| 512 | return(NULL); | 524 | return(NULL); |
| 513 | } | 525 | } |
| 514 | 526 | ||
| 515 | BIO *BIO_new_ssl_connect(ctx) | 527 | BIO *BIO_new_ssl_connect(SSL_CTX *ctx) |
| 516 | SSL_CTX *ctx; | ||
| 517 | { | 528 | { |
| 518 | BIO *ret=NULL,*con=NULL,*ssl=NULL; | 529 | BIO *ret=NULL,*con=NULL,*ssl=NULL; |
| 519 | 530 | ||
| @@ -530,9 +541,7 @@ err: | |||
| 530 | return(NULL); | 541 | return(NULL); |
| 531 | } | 542 | } |
| 532 | 543 | ||
| 533 | BIO *BIO_new_ssl(ctx,client) | 544 | BIO *BIO_new_ssl(SSL_CTX *ctx, int client) |
| 534 | SSL_CTX *ctx; | ||
| 535 | int client; | ||
| 536 | { | 545 | { |
| 537 | BIO *ret; | 546 | BIO *ret; |
| 538 | SSL *ssl; | 547 | SSL *ssl; |
| @@ -553,8 +562,7 @@ int client; | |||
| 553 | return(ret); | 562 | return(ret); |
| 554 | } | 563 | } |
| 555 | 564 | ||
| 556 | int BIO_ssl_copy_session_id(t,f) | 565 | int BIO_ssl_copy_session_id(BIO *t, BIO *f) |
| 557 | BIO *t,*f; | ||
| 558 | { | 566 | { |
| 559 | t=BIO_find_type(t,BIO_TYPE_SSL); | 567 | t=BIO_find_type(t,BIO_TYPE_SSL); |
| 560 | f=BIO_find_type(f,BIO_TYPE_SSL); | 568 | f=BIO_find_type(f,BIO_TYPE_SSL); |
| @@ -567,8 +575,7 @@ BIO *t,*f; | |||
| 567 | return(1); | 575 | return(1); |
| 568 | } | 576 | } |
| 569 | 577 | ||
| 570 | void BIO_ssl_shutdown(b) | 578 | void BIO_ssl_shutdown(BIO *b) |
| 571 | BIO *b; | ||
| 572 | { | 579 | { |
| 573 | SSL *s; | 580 | SSL *s; |
| 574 | 581 | ||
diff --git a/src/lib/libssl/doc/openssl.cnf b/src/lib/libssl/doc/openssl.cnf index d70dd25622..eca51c3322 100644 --- a/src/lib/libssl/doc/openssl.cnf +++ b/src/lib/libssl/doc/openssl.cnf | |||
| @@ -3,8 +3,13 @@ | |||
| 3 | # This is mostly being used for generation of certificate requests. | 3 | # This is mostly being used for generation of certificate requests. |
| 4 | # | 4 | # |
| 5 | 5 | ||
| 6 | # This definition stops the following lines choking if HOME isn't | ||
| 7 | # defined. | ||
| 8 | HOME = . | ||
| 6 | RANDFILE = $ENV::HOME/.rnd | 9 | RANDFILE = $ENV::HOME/.rnd |
| 7 | oid_file = $ENV::HOME/.oid | 10 | |
| 11 | # Extra OBJECT IDENTIFIER info: | ||
| 12 | #oid_file = $ENV::HOME/.oid | ||
| 8 | oid_section = new_oids | 13 | oid_section = new_oids |
| 9 | 14 | ||
| 10 | # To use this configuration file with the "-extfile" option of the | 15 | # To use this configuration file with the "-extfile" option of the |
| @@ -43,6 +48,14 @@ RANDFILE = $dir/private/.rand # private random number file | |||
| 43 | 48 | ||
| 44 | x509_extensions = usr_cert # The extentions to add to the cert | 49 | x509_extensions = usr_cert # The extentions to add to the cert |
| 45 | 50 | ||
| 51 | # Comment out the following two lines for the "traditional" | ||
| 52 | # (and highly broken) format. | ||
| 53 | name_opt = ca_default # Subject Name options | ||
| 54 | cert_opt = ca_default # Certificate field options | ||
| 55 | |||
| 56 | # Extension copying option: use with caution. | ||
| 57 | # copy_extensions = copy | ||
| 58 | |||
| 46 | # Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs | 59 | # Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs |
| 47 | # so this is commented out by default to leave a V1 CRL. | 60 | # so this is commented out by default to leave a V1 CRL. |
| 48 | # crl_extensions = crl_ext | 61 | # crl_extensions = crl_ext |
| @@ -86,6 +99,22 @@ distinguished_name = req_distinguished_name | |||
| 86 | attributes = req_attributes | 99 | attributes = req_attributes |
| 87 | x509_extensions = v3_ca # The extentions to add to the self signed cert | 100 | x509_extensions = v3_ca # The extentions to add to the self signed cert |
| 88 | 101 | ||
| 102 | # Passwords for private keys if not present they will be prompted for | ||
| 103 | # input_password = secret | ||
| 104 | # output_password = secret | ||
| 105 | |||
| 106 | # This sets a mask for permitted string types. There are several options. | ||
| 107 | # default: PrintableString, T61String, BMPString. | ||
| 108 | # pkix : PrintableString, BMPString. | ||
| 109 | # utf8only: only UTF8Strings. | ||
| 110 | # nombstr : PrintableString, T61String (no BMPStrings or UTF8Strings). | ||
| 111 | # MASK:XXXX a literal mask value. | ||
| 112 | # WARNING: current versions of Netscape crash on BMPStrings or UTF8Strings | ||
| 113 | # so use this option with caution! | ||
| 114 | string_mask = nombstr | ||
| 115 | |||
| 116 | # req_extensions = v3_req # The extensions to add to a certificate request | ||
| 117 | |||
| 89 | [ req_distinguished_name ] | 118 | [ req_distinguished_name ] |
| 90 | countryName = Country Name (2 letter code) | 119 | countryName = Country Name (2 letter code) |
| 91 | countryName_default = AU | 120 | countryName_default = AU |
| @@ -111,7 +140,7 @@ commonName = Common Name (eg, YOUR name) | |||
| 111 | commonName_max = 64 | 140 | commonName_max = 64 |
| 112 | 141 | ||
| 113 | emailAddress = Email Address | 142 | emailAddress = Email Address |
| 114 | emailAddress_max = 40 | 143 | emailAddress_max = 64 |
| 115 | 144 | ||
| 116 | # SET-ex3 = SET extension number 3 | 145 | # SET-ex3 = SET extension number 3 |
| 117 | 146 | ||
| @@ -159,6 +188,9 @@ authorityKeyIdentifier=keyid,issuer:always | |||
| 159 | # This stuff is for subjectAltName and issuerAltname. | 188 | # This stuff is for subjectAltName and issuerAltname. |
| 160 | # Import the email address. | 189 | # Import the email address. |
| 161 | # subjectAltName=email:copy | 190 | # subjectAltName=email:copy |
| 191 | # An alternative to produce certificates that aren't | ||
| 192 | # deprecated according to PKIX. | ||
| 193 | # subjectAltName=email:move | ||
| 162 | 194 | ||
| 163 | # Copy subject details | 195 | # Copy subject details |
| 164 | # issuerAltName=issuer:copy | 196 | # issuerAltName=issuer:copy |
| @@ -170,8 +202,16 @@ authorityKeyIdentifier=keyid,issuer:always | |||
| 170 | #nsCaPolicyUrl | 202 | #nsCaPolicyUrl |
| 171 | #nsSslServerName | 203 | #nsSslServerName |
| 172 | 204 | ||
| 205 | [ v3_req ] | ||
| 206 | |||
| 207 | # Extensions to add to a certificate request | ||
| 208 | |||
| 209 | basicConstraints = CA:FALSE | ||
| 210 | keyUsage = nonRepudiation, digitalSignature, keyEncipherment | ||
| 211 | |||
| 173 | [ v3_ca ] | 212 | [ v3_ca ] |
| 174 | 213 | ||
| 214 | |||
| 175 | # Extensions for a typical CA | 215 | # Extensions for a typical CA |
| 176 | 216 | ||
| 177 | 217 | ||
| @@ -200,10 +240,11 @@ basicConstraints = CA:true | |||
| 200 | # Copy issuer details | 240 | # Copy issuer details |
| 201 | # issuerAltName=issuer:copy | 241 | # issuerAltName=issuer:copy |
| 202 | 242 | ||
| 203 | # RAW DER hex encoding of an extension: beware experts only! | 243 | # DER hex encoding of an extension: beware experts only! |
| 204 | # 1.2.3.5=RAW:02:03 | 244 | # obj=DER:02:03 |
| 245 | # Where 'obj' is a standard or added object | ||
| 205 | # You can even override a supported extension: | 246 | # You can even override a supported extension: |
| 206 | # basicConstraints= critical, RAW:30:03:01:01:FF | 247 | # basicConstraints= critical, DER:30:03:01:01:FF |
| 207 | 248 | ||
| 208 | [ crl_ext ] | 249 | [ crl_ext ] |
| 209 | 250 | ||
diff --git a/src/lib/libssl/doc/openssl.txt b/src/lib/libssl/doc/openssl.txt index 91b85e5f14..5da519e7e4 100644 --- a/src/lib/libssl/doc/openssl.txt +++ b/src/lib/libssl/doc/openssl.txt | |||
| @@ -1,53 +1,12 @@ | |||
| 1 | 1 | ||
| 2 | This is some preliminary documentation for OpenSSL. | 2 | This is some preliminary documentation for OpenSSL. |
| 3 | 3 | ||
| 4 | ============================================================================== | 4 | Contents: |
| 5 | BUFFER Library | ||
| 6 | ============================================================================== | ||
| 7 | |||
| 8 | The buffer library handles simple character arrays. Buffers are used for | ||
| 9 | various purposes in the library, most notably memory BIOs. | ||
| 10 | |||
| 11 | The library uses the BUF_MEM structure defined in buffer.h: | ||
| 12 | |||
| 13 | typedef struct buf_mem_st | ||
| 14 | { | ||
| 15 | int length; /* current number of bytes */ | ||
| 16 | char *data; | ||
| 17 | int max; /* size of buffer */ | ||
| 18 | } BUF_MEM; | ||
| 19 | |||
| 20 | 'length' is the current size of the buffer in bytes, 'max' is the amount of | ||
| 21 | memory allocated to the buffer. There are three functions which handle these | ||
| 22 | and one "miscellaneous" function. | ||
| 23 | |||
| 24 | BUF_MEM *BUF_MEM_new() | ||
| 25 | |||
| 26 | This allocates a new buffer of zero size. Returns the buffer or NULL on error. | ||
| 27 | |||
| 28 | void BUF_MEM_free(BUF_MEM *a) | ||
| 29 | |||
| 30 | This frees up an already existing buffer. The data is zeroed before freeing | ||
| 31 | up in case the buffer contains sensitive data. | ||
| 32 | |||
| 33 | int BUF_MEM_grow(BUF_MEM *str, int len) | ||
| 34 | 5 | ||
| 35 | This changes the size of an already existing buffer. It returns zero on error | 6 | OpenSSL X509V3 extension configuration |
| 36 | or the new size (i.e. 'len'). Any data already in the buffer is preserved if | 7 | X509V3 Extension code: programmers guide |
| 37 | it increases in size. | 8 | PKCS#12 Library |
| 38 | 9 | ||
| 39 | char * BUF_strdup(char *str) | ||
| 40 | |||
| 41 | This is the previously mentioned strdup function: like the standard library | ||
| 42 | strdup() it copies a null terminated string into a block of allocated memory | ||
| 43 | and returns a pointer to the allocated block. | ||
| 44 | |||
| 45 | Unlike the standard C library strdup() this function uses Malloc() and so | ||
| 46 | should be used in preference to the standard library strdup() because it can | ||
| 47 | be used for memory leak checking or replacing the malloc() function. | ||
| 48 | |||
| 49 | The memory allocated from BUF_strdup() should be freed up using the Free() | ||
| 50 | function. | ||
| 51 | 10 | ||
| 52 | ============================================================================== | 11 | ============================================================================== |
| 53 | OpenSSL X509V3 extension configuration | 12 | OpenSSL X509V3 extension configuration |
| @@ -188,7 +147,7 @@ email.1=steve@here | |||
| 188 | email.2=steve@there | 147 | email.2=steve@there |
| 189 | 148 | ||
| 190 | This is because the configuration file code cannot handle the same name | 149 | This is because the configuration file code cannot handle the same name |
| 191 | occurring twice in the same extension. | 150 | occurring twice in the same section. |
| 192 | 151 | ||
| 193 | The syntax of raw extensions is governed by the extension code: it can | 152 | The syntax of raw extensions is governed by the extension code: it can |
| 194 | for example contain data in multiple sections. The correct syntax to | 153 | for example contain data in multiple sections. The correct syntax to |
| @@ -315,6 +274,41 @@ TRUE. An end user certificate MUST NOT have the CA value set to true. | |||
| 315 | According to PKIX recommendations it should exclude the extension entirely, | 274 | According to PKIX recommendations it should exclude the extension entirely, |
| 316 | however some software may require CA set to FALSE for end entity certificates. | 275 | however some software may require CA set to FALSE for end entity certificates. |
| 317 | 276 | ||
| 277 | Extended Key Usage. | ||
| 278 | |||
| 279 | This extensions consists of a list of usages. | ||
| 280 | |||
| 281 | These can either be object short names of the dotted numerical form of OIDs. | ||
| 282 | While any OID can be used only certain values make sense. In particular the | ||
| 283 | following PKIX, NS and MS values are meaningful: | ||
| 284 | |||
| 285 | Value Meaning | ||
| 286 | ----- ------- | ||
| 287 | serverAuth SSL/TLS Web Server Authentication. | ||
| 288 | clientAuth SSL/TLS Web Client Authentication. | ||
| 289 | codeSigning Code signing. | ||
| 290 | emailProtection E-mail Protection (S/MIME). | ||
| 291 | timeStamping Trusted Timestamping | ||
| 292 | msCodeInd Microsoft Individual Code Signing (authenticode) | ||
| 293 | msCodeCom Microsoft Commercial Code Signing (authenticode) | ||
| 294 | msCTLSign Microsoft Trust List Signing | ||
| 295 | msSGC Microsoft Server Gated Crypto | ||
| 296 | msEFS Microsoft Encrypted File System | ||
| 297 | nsSGC Netscape Server Gated Crypto | ||
| 298 | |||
| 299 | For example, under IE5 a CA can be used for any purpose: by including a list | ||
| 300 | of the above usages the CA can be restricted to only authorised uses. | ||
| 301 | |||
| 302 | Note: software packages may place additional interpretations on certificate | ||
| 303 | use, in particular some usages may only work for selected CAs. Don't for example | ||
| 304 | expect just including msSGC or nsSGC will automatically mean that a certificate | ||
| 305 | can be used for SGC ("step up" encryption) otherwise anyone could use it. | ||
| 306 | |||
| 307 | Examples: | ||
| 308 | |||
| 309 | extendedKeyUsage=critical,codeSigning,1.2.3.4 | ||
| 310 | extendedKeyUsage=nsSGC,msSGC | ||
| 311 | |||
| 318 | Subject Key Identifier. | 312 | Subject Key Identifier. |
| 319 | 313 | ||
| 320 | This is really a string extension and can take two possible values. Either | 314 | This is really a string extension and can take two possible values. Either |
| @@ -361,6 +355,24 @@ that would not make sense. It does support an additional issuer:copy option | |||
| 361 | that will copy all the subject alternative name values from the issuer | 355 | that will copy all the subject alternative name values from the issuer |
| 362 | certificate (if possible). | 356 | certificate (if possible). |
| 363 | 357 | ||
| 358 | Example: | ||
| 359 | |||
| 360 | issuserAltName = issuer:copy | ||
| 361 | |||
| 362 | Authority Info Access. | ||
| 363 | |||
| 364 | The authority information access extension gives details about how to access | ||
| 365 | certain information relating to the CA. Its syntax is accessOID;location | ||
| 366 | where 'location' has the same syntax as subject alternative name (except | ||
| 367 | that email:copy is not supported). accessOID can be any valid OID but only | ||
| 368 | certain values are meaningful for example OCSP and caIssuers. OCSP gives the | ||
| 369 | location of an OCSP responder: this is used by Netscape PSM and other software. | ||
| 370 | |||
| 371 | Example: | ||
| 372 | |||
| 373 | authorityInfoAccess = OCSP;URI:http://ocsp.my.host/ | ||
| 374 | authorityInfoAccess = caIssuers;URI:http://my.ca/ca.html | ||
| 375 | |||
| 364 | CRL distribution points. | 376 | CRL distribution points. |
| 365 | 377 | ||
| 366 | This is a multi-valued extension that supports all the literal options of | 378 | This is a multi-valued extension that supports all the literal options of |
| @@ -459,16 +471,16 @@ extension in a human or machine readable form. | |||
| 459 | 471 | ||
| 460 | 1. Initialisation and cleanup. | 472 | 1. Initialisation and cleanup. |
| 461 | 473 | ||
| 462 | X509V3_add_standard_extensions(); | 474 | No special initialisation is needed before calling the extension functions. |
| 463 | 475 | You used to have to call X509V3_add_standard_extensions(); but this is no longer | |
| 464 | This function should be called before any other extension code. It adds support | 476 | required and this function no longer does anything. |
| 465 | for some common PKIX and Netscape extensions. Additional custom extensions can | ||
| 466 | be added as well (see later). | ||
| 467 | 477 | ||
| 468 | void X509V3_EXT_cleanup(void); | 478 | void X509V3_EXT_cleanup(void); |
| 469 | 479 | ||
| 470 | This function should be called last to cleanup the extension code. After this | 480 | This function should be called to cleanup the extension code if any custom |
| 471 | call no other extension calls should be made. | 481 | extensions have been added. If no custom extensions have been added then this |
| 482 | call does nothing. After this call all custom extension code is freed up but | ||
| 483 | you can still use the standard extensions. | ||
| 472 | 484 | ||
| 473 | 2. Printing and parsing extensions. | 485 | 2. Printing and parsing extensions. |
| 474 | 486 | ||
| @@ -495,6 +507,47 @@ details about the structures returned. The returned structure should be freed | |||
| 495 | after use using the relevant free function, BASIC_CONSTRAINTS_free() for | 507 | after use using the relevant free function, BASIC_CONSTRAINTS_free() for |
| 496 | example. | 508 | example. |
| 497 | 509 | ||
| 510 | void * X509_get_ext_d2i(X509 *x, int nid, int *crit, int *idx); | ||
| 511 | void * X509_CRL_get_ext_d2i(X509_CRL *x, int nid, int *crit, int *idx); | ||
| 512 | void * X509_REVOKED_get_ext_d2i(X509_REVOKED *x, int nid, int *crit, int *idx); | ||
| 513 | void * X509V3_get_d2i(STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx); | ||
| 514 | |||
| 515 | These functions combine the operations of searching for extensions and | ||
| 516 | parsing them. They search a certificate, a CRL a CRL entry or a stack | ||
| 517 | of extensions respectively for extension whose NID is 'nid' and return | ||
| 518 | the parsed result of NULL if an error occurred. For example: | ||
| 519 | |||
| 520 | BASIC_CONSTRAINTS *bs; | ||
| 521 | bs = X509_get_ext_d2i(cert, NID_basic_constraints, NULL, NULL); | ||
| 522 | |||
| 523 | This will search for the basicConstraints extension and either return | ||
| 524 | it value or NULL. NULL can mean either the extension was not found, it | ||
| 525 | occurred more than once or it could not be parsed. | ||
| 526 | |||
| 527 | If 'idx' is NULL then an extension is only parsed if it occurs precisely | ||
| 528 | once. This is standard behaviour because extensions normally cannot occur | ||
| 529 | more than once. If however more than one extension of the same type can | ||
| 530 | occur it can be used to parse successive extensions for example: | ||
| 531 | |||
| 532 | int i; | ||
| 533 | void *ext; | ||
| 534 | |||
| 535 | i = -1; | ||
| 536 | for(;;) { | ||
| 537 | ext = X509_get_ext_d2i(x, nid, crit, &idx); | ||
| 538 | if(ext == NULL) break; | ||
| 539 | /* Do something with ext */ | ||
| 540 | } | ||
| 541 | |||
| 542 | If 'crit' is not NULL and the extension was found then the int it points to | ||
| 543 | is set to 1 for critical extensions and 0 for non critical. Therefore if the | ||
| 544 | function returns NULL but 'crit' is set to 0 or 1 then the extension was | ||
| 545 | found but it could not be parsed. | ||
| 546 | |||
| 547 | The int pointed to by crit will be set to -1 if the extension was not found | ||
| 548 | and -2 if the extension occurred more than once (this will only happen if | ||
| 549 | idx is NULL). In both cases the function will return NULL. | ||
| 550 | |||
| 498 | 3. Generating extensions. | 551 | 3. Generating extensions. |
| 499 | 552 | ||
| 500 | An extension will typically be generated from a configuration file, or some | 553 | An extension will typically be generated from a configuration file, or some |
| @@ -512,7 +565,7 @@ or CRL is due to be signed. Both return 0 on error on non zero for success. | |||
| 512 | In each case 'conf' is the LHASH pointer of the configuration file to use | 565 | In each case 'conf' is the LHASH pointer of the configuration file to use |
| 513 | and 'section' is the section containing the extension details. | 566 | and 'section' is the section containing the extension details. |
| 514 | 567 | ||
| 515 | See the 'context functions' section for a description of the ctx paramater. | 568 | See the 'context functions' section for a description of the ctx parameter. |
| 516 | 569 | ||
| 517 | 570 | ||
| 518 | X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name, | 571 | X509_EXTENSION *X509V3_EXT_conf(LHASH *conf, X509V3_CTX *ctx, char *name, |
| @@ -531,7 +584,7 @@ takes the NID of the extension rather than its name. | |||
| 531 | For example to produce basicConstraints with the CA flag and a path length of | 584 | For example to produce basicConstraints with the CA flag and a path length of |
| 532 | 10: | 585 | 10: |
| 533 | 586 | ||
| 534 | x = X509V3_EXT_conf_nid(NULL, NULL, NID_basicConstraints, "CA:TRUE,pathlen:10"); | 587 | x = X509V3_EXT_conf_nid(NULL, NULL, NID_basic_constraints,"CA:TRUE,pathlen:10"); |
| 535 | 588 | ||
| 536 | 589 | ||
| 537 | X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc); | 590 | X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc); |
| @@ -659,7 +712,7 @@ The same as above but for an unsigned character value. | |||
| 659 | int X509V3_add_value_bool(const char *name, int asn1_bool, | 712 | int X509V3_add_value_bool(const char *name, int asn1_bool, |
| 660 | STACK_OF(CONF_VALUE) **extlist); | 713 | STACK_OF(CONF_VALUE) **extlist); |
| 661 | 714 | ||
| 662 | This adds either "TRUE" or "FALSE" depending on the value of 'ans1_bool' | 715 | This adds either "TRUE" or "FALSE" depending on the value of 'asn1_bool' |
| 663 | 716 | ||
| 664 | int X509V3_add_value_bool_nf(char *name, int asn1_bool, | 717 | int X509V3_add_value_bool_nf(char *name, int asn1_bool, |
| 665 | STACK_OF(CONF_VALUE) **extlist); | 718 | STACK_OF(CONF_VALUE) **extlist); |
| @@ -686,7 +739,7 @@ Multi value extensions are passed a STACK_OF(CONF_VALUE) name and value pairs | |||
| 686 | or return a STACK_OF(CONF_VALUE). | 739 | or return a STACK_OF(CONF_VALUE). |
| 687 | 740 | ||
| 688 | Raw extensions are just passed a BIO or a value and it is the extensions | 741 | Raw extensions are just passed a BIO or a value and it is the extensions |
| 689 | responsiblity to handle all the necessary printing. | 742 | responsibility to handle all the necessary printing. |
| 690 | 743 | ||
| 691 | There are two ways to add an extension. One is simply as an alias to an already | 744 | There are two ways to add an extension. One is simply as an alias to an already |
| 692 | existing extension. An alias is an extension that is identical in ASN1 structure | 745 | existing extension. An alias is an extension that is identical in ASN1 structure |
| @@ -811,7 +864,7 @@ int i2r(struct v3_ext_method *method, void *ext, BIO *out, int indent); | |||
| 811 | 864 | ||
| 812 | This function is passed the internal extension structure in the ext parameter | 865 | This function is passed the internal extension structure in the ext parameter |
| 813 | and sends out a human readable version of the extension to out. The 'indent' | 866 | and sends out a human readable version of the extension to out. The 'indent' |
| 814 | paremeter should be noted to determine the necessary amount of indentation | 867 | parameter should be noted to determine the necessary amount of indentation |
| 815 | needed on the output. | 868 | needed on the output. |
| 816 | 869 | ||
| 817 | void * r2i(struct v3_ext_method *method, struct v3_ext_ctx *ctx, char *str); | 870 | void * r2i(struct v3_ext_method *method, struct v3_ext_ctx *ctx, char *str); |
| @@ -882,7 +935,7 @@ d2i_PKCS12_fp(fp, p12) | |||
| 882 | 935 | ||
| 883 | This is the same but for a FILE pointer. | 936 | This is the same but for a FILE pointer. |
| 884 | 937 | ||
| 885 | 3. Parsing and creation functions. | 938 | 3. High level functions. |
| 886 | 939 | ||
| 887 | 3.1 Parsing with PKCS12_parse(). | 940 | 3.1 Parsing with PKCS12_parse(). |
| 888 | 941 | ||
| @@ -920,6 +973,14 @@ p12 = PKCS12_create(pass, "My Certificate", pkey, cert, NULL, 0,0,0,0,0); | |||
| 920 | i2d_PKCS12_fp(fp, p12); | 973 | i2d_PKCS12_fp(fp, p12); |
| 921 | PKCS12_free(p12); | 974 | PKCS12_free(p12); |
| 922 | 975 | ||
| 976 | 3.3 Changing a PKCS#12 structure password. | ||
| 977 | |||
| 978 | int PKCS12_newpass(PKCS12 *p12, char *oldpass, char *newpass); | ||
| 979 | |||
| 980 | This changes the password of an already existing PKCS#12 structure. oldpass | ||
| 981 | is the old password and newpass is the new one. An error occurs if the old | ||
| 982 | password is incorrect. | ||
| 983 | |||
| 923 | LOW LEVEL FUNCTIONS. | 984 | LOW LEVEL FUNCTIONS. |
| 924 | 985 | ||
| 925 | In some cases the high level functions do not provide the necessary | 986 | In some cases the high level functions do not provide the necessary |
diff --git a/src/lib/libssl/doc/standards.txt b/src/lib/libssl/doc/standards.txt index 61ccc5d7e0..596d9001e6 100644 --- a/src/lib/libssl/doc/standards.txt +++ b/src/lib/libssl/doc/standards.txt | |||
| @@ -24,7 +24,8 @@ http://www.rsasecurity.com/rsalabs/pkcs/. | |||
| 24 | Implemented: | 24 | Implemented: |
| 25 | ------------ | 25 | ------------ |
| 26 | 26 | ||
| 27 | These are documents that describe things that are implemented in OpenSSL. | 27 | These are documents that describe things that are implemented (in |
| 28 | whole or at least great parts) in OpenSSL. | ||
| 28 | 29 | ||
| 29 | 1319 The MD2 Message-Digest Algorithm. B. Kaliski. April 1992. | 30 | 1319 The MD2 Message-Digest Algorithm. B. Kaliski. April 1992. |
| 30 | (Format: TXT=25661 bytes) (Status: INFORMATIONAL) | 31 | (Format: TXT=25661 bytes) (Status: INFORMATIONAL) |
| @@ -59,6 +60,11 @@ PKCS#8: Private-Key Information Syntax Standard | |||
| 59 | 60 | ||
| 60 | PKCS#12: Personal Information Exchange Syntax Standard, version 1.0. | 61 | PKCS#12: Personal Information Exchange Syntax Standard, version 1.0. |
| 61 | 62 | ||
| 63 | 2560 X.509 Internet Public Key Infrastructure Online Certificate | ||
| 64 | Status Protocol - OCSP. M. Myers, R. Ankney, A. Malpani, S. Galperin, | ||
| 65 | C. Adams. June 1999. (Format: TXT=43243 bytes) (Status: PROPOSED | ||
| 66 | STANDARD) | ||
| 67 | |||
| 62 | 68 | ||
| 63 | Related: | 69 | Related: |
| 64 | -------- | 70 | -------- |
| @@ -84,6 +90,10 @@ STARTTLS documents. | |||
| 84 | Certification and Related Services. B. Kaliski. February 1993. | 90 | Certification and Related Services. B. Kaliski. February 1993. |
| 85 | (Format: TXT=17537 bytes) (Status: PROPOSED STANDARD) | 91 | (Format: TXT=17537 bytes) (Status: PROPOSED STANDARD) |
| 86 | 92 | ||
| 93 | 2256 A Summary of the X.500(96) User Schema for use with LDAPv3. M. | ||
| 94 | Wahl. December 1997. (Format: TXT=32377 bytes) (Status: PROPOSED | ||
| 95 | STANDARD) | ||
| 96 | |||
| 87 | 2487 SMTP Service Extension for Secure SMTP over TLS. P. Hoffman. | 97 | 2487 SMTP Service Extension for Secure SMTP over TLS. P. Hoffman. |
| 88 | January 1999. (Format: TXT=15120 bytes) (Status: PROPOSED STANDARD) | 98 | January 1999. (Format: TXT=15120 bytes) (Status: PROPOSED STANDARD) |
| 89 | 99 | ||
| @@ -114,8 +124,7 @@ To be implemented: | |||
| 114 | These are documents that describe things that are planed to be | 124 | These are documents that describe things that are planed to be |
| 115 | implemented in the hopefully short future. | 125 | implemented in the hopefully short future. |
| 116 | 126 | ||
| 117 | 2560 X.509 Internet Public Key Infrastructure Online Certificate | 127 | 2712 Addition of Kerberos Cipher Suites to Transport Layer Security |
| 118 | Status Protocol - OCSP. M. Myers, R. Ankney, A. Malpani, S. Galperin, | 128 | (TLS). A. Medvinsky, M. Hur. October 1999. (Format: TXT=13763 bytes) |
| 119 | C. Adams. June 1999. (Format: TXT=43243 bytes) (Status: PROPOSED | 129 | (Status: PROPOSED STANDARD) |
| 120 | STANDARD) | ||
| 121 | 130 | ||
diff --git a/src/lib/libssl/s23_clnt.c b/src/lib/libssl/s23_clnt.c index a4661ebb68..b2be8340fb 100644 --- a/src/lib/libssl/s23_clnt.c +++ b/src/lib/libssl/s23_clnt.c | |||
| @@ -57,28 +57,22 @@ | |||
| 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 | { |
| 71 | #ifndef OPENSSL_NO_SSL2 | ||
| 79 | if (ver == SSL2_VERSION) | 72 | if (ver == SSL2_VERSION) |
| 80 | return(SSLv2_client_method()); | 73 | return(SSLv2_client_method()); |
| 81 | else if (ver == SSL3_VERSION) | 74 | #endif |
| 75 | if (ver == SSL3_VERSION) | ||
| 82 | return(SSLv3_client_method()); | 76 | return(SSLv3_client_method()); |
| 83 | else if (ver == TLS1_VERSION) | 77 | else if (ver == TLS1_VERSION) |
| 84 | return(TLSv1_client_method()); | 78 | return(TLSv1_client_method()); |
| @@ -86,32 +80,31 @@ int ver; | |||
| 86 | return(NULL); | 80 | return(NULL); |
| 87 | } | 81 | } |
| 88 | 82 | ||
| 89 | SSL_METHOD *SSLv23_client_method() | 83 | SSL_METHOD *SSLv23_client_method(void) |
| 90 | { | 84 | { |
| 91 | static int init=1; | 85 | static int init=1; |
| 92 | static SSL_METHOD SSLv23_client_data; | 86 | static SSL_METHOD SSLv23_client_data; |
| 93 | 87 | ||
| 94 | if (init) | 88 | if (init) |
| 95 | { | 89 | { |
| 96 | init=0; | ||
| 97 | memcpy((char *)&SSLv23_client_data, | 90 | memcpy((char *)&SSLv23_client_data, |
| 98 | (char *)sslv23_base_method(),sizeof(SSL_METHOD)); | 91 | (char *)sslv23_base_method(),sizeof(SSL_METHOD)); |
| 99 | SSLv23_client_data.ssl_connect=ssl23_connect; | 92 | SSLv23_client_data.ssl_connect=ssl23_connect; |
| 100 | SSLv23_client_data.get_ssl_method=ssl23_get_client_method; | 93 | SSLv23_client_data.get_ssl_method=ssl23_get_client_method; |
| 94 | init=0; | ||
| 101 | } | 95 | } |
| 102 | return(&SSLv23_client_data); | 96 | return(&SSLv23_client_data); |
| 103 | } | 97 | } |
| 104 | 98 | ||
| 105 | int ssl23_connect(s) | 99 | int ssl23_connect(SSL *s) |
| 106 | SSL *s; | ||
| 107 | { | 100 | { |
| 108 | BUF_MEM *buf; | 101 | BUF_MEM *buf; |
| 109 | unsigned long Time=time(NULL); | 102 | unsigned long Time=time(NULL); |
| 110 | void (*cb)()=NULL; | 103 | void (*cb)(const SSL *ssl,int type,int val)=NULL; |
| 111 | int ret= -1; | 104 | int ret= -1; |
| 112 | int new_state,state; | 105 | int new_state,state; |
| 113 | 106 | ||
| 114 | RAND_seed((unsigned char *)&Time,sizeof(Time)); | 107 | RAND_add(&Time,sizeof(Time),0); |
| 115 | ERR_clear_error(); | 108 | ERR_clear_error(); |
| 116 | clear_sys_error(); | 109 | clear_sys_error(); |
| 117 | 110 | ||
| @@ -120,8 +113,8 @@ SSL *s; | |||
| 120 | else if (s->ctx->info_callback != NULL) | 113 | else if (s->ctx->info_callback != NULL) |
| 121 | cb=s->ctx->info_callback; | 114 | cb=s->ctx->info_callback; |
| 122 | 115 | ||
| 123 | if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s); | ||
| 124 | s->in_handshake++; | 116 | s->in_handshake++; |
| 117 | if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s); | ||
| 125 | 118 | ||
| 126 | for (;;) | 119 | for (;;) |
| 127 | { | 120 | { |
| @@ -134,6 +127,13 @@ SSL *s; | |||
| 134 | case SSL_ST_BEFORE|SSL_ST_CONNECT: | 127 | case SSL_ST_BEFORE|SSL_ST_CONNECT: |
| 135 | case SSL_ST_OK|SSL_ST_CONNECT: | 128 | case SSL_ST_OK|SSL_ST_CONNECT: |
| 136 | 129 | ||
| 130 | if (s->session != NULL) | ||
| 131 | { | ||
| 132 | SSLerr(SSL_F_SSL23_CONNECT,SSL_R_SSL23_DOING_SESSION_ID_REUSE); | ||
| 133 | ret= -1; | ||
| 134 | goto end; | ||
| 135 | } | ||
| 136 | s->server=0; | ||
| 137 | if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_START,1); | 137 | if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_START,1); |
| 138 | 138 | ||
| 139 | /* s->version=TLS1_VERSION; */ | 139 | /* s->version=TLS1_VERSION; */ |
| @@ -159,7 +159,7 @@ SSL *s; | |||
| 159 | ssl3_init_finished_mac(s); | 159 | ssl3_init_finished_mac(s); |
| 160 | 160 | ||
| 161 | s->state=SSL23_ST_CW_CLNT_HELLO_A; | 161 | s->state=SSL23_ST_CW_CLNT_HELLO_A; |
| 162 | s->ctx->sess_connect++; | 162 | s->ctx->stats.sess_connect++; |
| 163 | s->init_num=0; | 163 | s->init_num=0; |
| 164 | break; | 164 | break; |
| 165 | 165 | ||
| @@ -179,7 +179,7 @@ SSL *s; | |||
| 179 | ret=ssl23_get_server_hello(s); | 179 | ret=ssl23_get_server_hello(s); |
| 180 | if (ret >= 0) cb=NULL; | 180 | if (ret >= 0) cb=NULL; |
| 181 | goto end; | 181 | goto end; |
| 182 | break; | 182 | /* break; */ |
| 183 | 183 | ||
| 184 | default: | 184 | default: |
| 185 | SSLerr(SSL_F_SSL23_CONNECT,SSL_R_UNKNOWN_STATE); | 185 | SSLerr(SSL_F_SSL23_CONNECT,SSL_R_UNKNOWN_STATE); |
| @@ -188,7 +188,7 @@ SSL *s; | |||
| 188 | /* break; */ | 188 | /* break; */ |
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | if (s->debug) BIO_flush(s->wbio); | 191 | if (s->debug) { (void)BIO_flush(s->wbio); } |
| 192 | 192 | ||
| 193 | if ((cb != NULL) && (s->state != state)) | 193 | if ((cb != NULL) && (s->state != state)) |
| 194 | { | 194 | { |
| @@ -206,12 +206,12 @@ end: | |||
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | 208 | ||
| 209 | static int ssl23_client_hello(s) | 209 | static int ssl23_client_hello(SSL *s) |
| 210 | SSL *s; | ||
| 211 | { | 210 | { |
| 212 | unsigned char *buf; | 211 | unsigned char *buf; |
| 213 | unsigned char *p,*d; | 212 | unsigned char *p,*d; |
| 214 | int i,ch_len; | 213 | int i,ch_len; |
| 214 | int ret; | ||
| 215 | 215 | ||
| 216 | buf=(unsigned char *)s->init_buf->data; | 216 | buf=(unsigned char *)s->init_buf->data; |
| 217 | if (s->state == SSL23_ST_CW_CLNT_HELLO_A) | 217 | if (s->state == SSL23_ST_CW_CLNT_HELLO_A) |
| @@ -225,7 +225,7 @@ SSL *s; | |||
| 225 | #endif | 225 | #endif |
| 226 | 226 | ||
| 227 | p=s->s3->client_random; | 227 | p=s->s3->client_random; |
| 228 | RAND_bytes(p,SSL3_RANDOM_SIZE); | 228 | RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE); |
| 229 | 229 | ||
| 230 | /* Do the message type and length last */ | 230 | /* Do the message type and length last */ |
| 231 | d= &(buf[2]); | 231 | d= &(buf[2]); |
| @@ -236,16 +236,19 @@ SSL *s; | |||
| 236 | { | 236 | { |
| 237 | *(d++)=TLS1_VERSION_MAJOR; | 237 | *(d++)=TLS1_VERSION_MAJOR; |
| 238 | *(d++)=TLS1_VERSION_MINOR; | 238 | *(d++)=TLS1_VERSION_MINOR; |
| 239 | s->client_version=TLS1_VERSION; | ||
| 239 | } | 240 | } |
| 240 | else if (!(s->options & SSL_OP_NO_SSLv3)) | 241 | else if (!(s->options & SSL_OP_NO_SSLv3)) |
| 241 | { | 242 | { |
| 242 | *(d++)=SSL3_VERSION_MAJOR; | 243 | *(d++)=SSL3_VERSION_MAJOR; |
| 243 | *(d++)=SSL3_VERSION_MINOR; | 244 | *(d++)=SSL3_VERSION_MINOR; |
| 245 | s->client_version=SSL3_VERSION; | ||
| 244 | } | 246 | } |
| 245 | else if (!(s->options & SSL_OP_NO_SSLv2)) | 247 | else if (!(s->options & SSL_OP_NO_SSLv2)) |
| 246 | { | 248 | { |
| 247 | *(d++)=SSL2_VERSION_MAJOR; | 249 | *(d++)=SSL2_VERSION_MAJOR; |
| 248 | *(d++)=SSL2_VERSION_MINOR; | 250 | *(d++)=SSL2_VERSION_MINOR; |
| 251 | s->client_version=SSL2_VERSION; | ||
| 249 | } | 252 | } |
| 250 | else | 253 | else |
| 251 | { | 254 | { |
| @@ -283,7 +286,7 @@ SSL *s; | |||
| 283 | i=ch_len; | 286 | i=ch_len; |
| 284 | s2n(i,d); | 287 | s2n(i,d); |
| 285 | memset(&(s->s3->client_random[0]),0,SSL3_RANDOM_SIZE); | 288 | memset(&(s->s3->client_random[0]),0,SSL3_RANDOM_SIZE); |
| 286 | RAND_bytes(&(s->s3->client_random[SSL3_RANDOM_SIZE-i]),i); | 289 | RAND_pseudo_bytes(&(s->s3->client_random[SSL3_RANDOM_SIZE-i]),i); |
| 287 | memcpy(p,&(s->s3->client_random[SSL3_RANDOM_SIZE-i]),i); | 290 | memcpy(p,&(s->s3->client_random[SSL3_RANDOM_SIZE-i]),i); |
| 288 | p+=i; | 291 | p+=i; |
| 289 | 292 | ||
| @@ -300,15 +303,18 @@ SSL *s; | |||
| 300 | } | 303 | } |
| 301 | 304 | ||
| 302 | /* SSL3_ST_CW_CLNT_HELLO_B */ | 305 | /* SSL3_ST_CW_CLNT_HELLO_B */ |
| 303 | return(ssl23_write_bytes(s)); | 306 | ret = ssl23_write_bytes(s); |
| 307 | if (ret >= 2) | ||
| 308 | if (s->msg_callback) | ||
| 309 | s->msg_callback(1, SSL2_VERSION, 0, s->init_buf->data+2, ret-2, s, s->msg_callback_arg); /* CLIENT-HELLO */ | ||
| 310 | return ret; | ||
| 304 | } | 311 | } |
| 305 | 312 | ||
| 306 | static int ssl23_get_server_hello(s) | 313 | static int ssl23_get_server_hello(SSL *s) |
| 307 | SSL *s; | ||
| 308 | { | 314 | { |
| 309 | char buf[8]; | 315 | char buf[8]; |
| 310 | unsigned char *p; | 316 | unsigned char *p; |
| 311 | int i,ch_len; | 317 | int i; |
| 312 | int n; | 318 | int n; |
| 313 | 319 | ||
| 314 | n=ssl23_read_bytes(s,7); | 320 | n=ssl23_read_bytes(s,7); |
| @@ -321,9 +327,14 @@ SSL *s; | |||
| 321 | if ((p[0] & 0x80) && (p[2] == SSL2_MT_SERVER_HELLO) && | 327 | if ((p[0] & 0x80) && (p[2] == SSL2_MT_SERVER_HELLO) && |
| 322 | (p[5] == 0x00) && (p[6] == 0x02)) | 328 | (p[5] == 0x00) && (p[6] == 0x02)) |
| 323 | { | 329 | { |
| 330 | #ifdef OPENSSL_NO_SSL2 | ||
| 331 | SSLerr(SSL_F_SSL23_GET_SERVER_HELLO,SSL_R_UNSUPPORTED_PROTOCOL); | ||
| 332 | goto err; | ||
| 333 | #else | ||
| 324 | /* we are talking sslv2 */ | 334 | /* we are talking sslv2 */ |
| 325 | /* we need to clean up the SSLv3 setup and put in the | 335 | /* we need to clean up the SSLv3 setup and put in the |
| 326 | * sslv2 stuff. */ | 336 | * sslv2 stuff. */ |
| 337 | int ch_len; | ||
| 327 | 338 | ||
| 328 | if (s->options & SSL_OP_NO_SSLv2) | 339 | if (s->options & SSL_OP_NO_SSLv2) |
| 329 | { | 340 | { |
| @@ -360,7 +371,9 @@ SSL *s; | |||
| 360 | } | 371 | } |
| 361 | 372 | ||
| 362 | s->state=SSL2_ST_GET_SERVER_HELLO_A; | 373 | s->state=SSL2_ST_GET_SERVER_HELLO_A; |
| 363 | s->s2->ssl2_rollback=1; | 374 | if (!(s->client_version == SSL2_VERSION)) |
| 375 | /* use special padding (SSL 3.0 draft/RFC 2246, App. E.2) */ | ||
| 376 | s->s2->ssl2_rollback=1; | ||
| 364 | 377 | ||
| 365 | /* setup the 5 bytes we have read so we get them from | 378 | /* setup the 5 bytes we have read so we get them from |
| 366 | * the sslv2 buffer */ | 379 | * the sslv2 buffer */ |
| @@ -376,6 +389,7 @@ SSL *s; | |||
| 376 | 389 | ||
| 377 | s->method=SSLv2_client_method(); | 390 | s->method=SSLv2_client_method(); |
| 378 | s->handshake_func=s->method->ssl_connect; | 391 | s->handshake_func=s->method->ssl_connect; |
| 392 | #endif | ||
| 379 | } | 393 | } |
| 380 | else if ((p[0] == SSL3_RT_HANDSHAKE) && | 394 | else if ((p[0] == SSL3_RT_HANDSHAKE) && |
| 381 | (p[1] == SSL3_VERSION_MAJOR) && | 395 | (p[1] == SSL3_VERSION_MAJOR) && |
| @@ -426,7 +440,7 @@ SSL *s; | |||
| 426 | (p[3] == 0) && | 440 | (p[3] == 0) && |
| 427 | (p[4] == 2)) | 441 | (p[4] == 2)) |
| 428 | { | 442 | { |
| 429 | void (*cb)()=NULL; | 443 | void (*cb)(const SSL *ssl,int type,int val)=NULL; |
| 430 | int j; | 444 | int j; |
| 431 | 445 | ||
| 432 | /* An alert */ | 446 | /* An alert */ |
| @@ -443,7 +457,7 @@ SSL *s; | |||
| 443 | } | 457 | } |
| 444 | 458 | ||
| 445 | s->rwstate=SSL_NOTHING; | 459 | s->rwstate=SSL_NOTHING; |
| 446 | SSLerr(SSL_F_SSL23_GET_SERVER_HELLO,1000+p[6]); | 460 | SSLerr(SSL_F_SSL23_GET_SERVER_HELLO,SSL_AD_REASON_OFFSET+p[6]); |
| 447 | goto err; | 461 | goto err; |
| 448 | } | 462 | } |
| 449 | else | 463 | else |
diff --git a/src/lib/libssl/s23_lib.c b/src/lib/libssl/s23_lib.c index e16f641101..b70002a647 100644 --- a/src/lib/libssl/s23_lib.c +++ b/src/lib/libssl/s23_lib.c | |||
| @@ -57,28 +57,18 @@ | |||
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include "objects.h" | 60 | #include <openssl/objects.h> |
| 61 | #include "ssl_locl.h" | 61 | #include "ssl_locl.h" |
| 62 | 62 | ||
| 63 | #ifndef NOPROTO | ||
| 64 | static int ssl23_num_ciphers(void ); | 63 | static int ssl23_num_ciphers(void ); |
| 65 | static SSL_CIPHER *ssl23_get_cipher(unsigned int u); | 64 | static SSL_CIPHER *ssl23_get_cipher(unsigned int u); |
| 66 | static int ssl23_read(SSL *s, char *buf, int len); | 65 | static int ssl23_read(SSL *s, void *buf, int len); |
| 67 | static int ssl23_write(SSL *s, char *buf, int len); | 66 | static int ssl23_peek(SSL *s, void *buf, int len); |
| 67 | static int ssl23_write(SSL *s, const void *buf, int len); | ||
| 68 | static long ssl23_default_timeout(void ); | 68 | static long ssl23_default_timeout(void ); |
| 69 | static int ssl23_put_cipher_by_char(SSL_CIPHER *c, unsigned char *p); | 69 | static int ssl23_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p); |
| 70 | static SSL_CIPHER *ssl23_get_cipher_by_char(unsigned char *p); | 70 | static SSL_CIPHER *ssl23_get_cipher_by_char(const unsigned char *p); |
| 71 | #else | 71 | const char *SSL23_version_str="SSLv2/3 compatibility" OPENSSL_VERSION_PTEXT; |
| 72 | static int ssl23_num_ciphers(); | ||
| 73 | static SSL_CIPHER *ssl23_get_cipher(); | ||
| 74 | static int ssl23_read(); | ||
| 75 | static int ssl23_write(); | ||
| 76 | static long ssl23_default_timeout(); | ||
| 77 | static int ssl23_put_cipher_by_char(); | ||
| 78 | static SSL_CIPHER *ssl23_get_cipher_by_char(); | ||
| 79 | #endif | ||
| 80 | |||
| 81 | char *SSL23_version_str="SSLv2/3 compatablity part of SSLeay 0.7.0 30-Jan-1997"; | ||
| 82 | 72 | ||
| 83 | static SSL_METHOD SSLv23_data= { | 73 | static SSL_METHOD SSLv23_data= { |
| 84 | TLS1_VERSION, | 74 | TLS1_VERSION, |
| @@ -88,10 +78,11 @@ static SSL_METHOD SSLv23_data= { | |||
| 88 | ssl_undefined_function, | 78 | ssl_undefined_function, |
| 89 | ssl_undefined_function, | 79 | ssl_undefined_function, |
| 90 | ssl23_read, | 80 | ssl23_read, |
| 91 | ssl_undefined_function, | 81 | ssl23_peek, |
| 92 | ssl23_write, | 82 | ssl23_write, |
| 93 | ssl_undefined_function, | 83 | ssl_undefined_function, |
| 94 | ssl_undefined_function, | 84 | ssl_undefined_function, |
| 85 | ssl_ok, | ||
| 95 | ssl3_ctrl, | 86 | ssl3_ctrl, |
| 96 | ssl3_ctx_ctrl, | 87 | ssl3_ctx_ctrl, |
| 97 | ssl23_get_cipher_by_char, | 88 | ssl23_get_cipher_by_char, |
| @@ -102,38 +93,47 @@ static SSL_METHOD SSLv23_data= { | |||
| 102 | ssl_bad_method, | 93 | ssl_bad_method, |
| 103 | ssl23_default_timeout, | 94 | ssl23_default_timeout, |
| 104 | &ssl3_undef_enc_method, | 95 | &ssl3_undef_enc_method, |
| 96 | ssl_undefined_function, | ||
| 97 | ssl3_callback_ctrl, | ||
| 98 | ssl3_ctx_callback_ctrl, | ||
| 105 | }; | 99 | }; |
| 106 | 100 | ||
| 107 | static long ssl23_default_timeout() | 101 | static long ssl23_default_timeout(void) |
| 108 | { | 102 | { |
| 109 | return(300); | 103 | return(300); |
| 110 | } | 104 | } |
| 111 | 105 | ||
| 112 | SSL_METHOD *sslv23_base_method() | 106 | SSL_METHOD *sslv23_base_method(void) |
| 113 | { | 107 | { |
| 114 | return(&SSLv23_data); | 108 | return(&SSLv23_data); |
| 115 | } | 109 | } |
| 116 | 110 | ||
| 117 | static int ssl23_num_ciphers() | 111 | static int ssl23_num_ciphers(void) |
| 118 | { | 112 | { |
| 119 | return(ssl3_num_ciphers()+ssl2_num_ciphers()); | 113 | return(ssl3_num_ciphers() |
| 114 | #ifndef OPENSSL_NO_SSL2 | ||
| 115 | + ssl2_num_ciphers() | ||
| 116 | #endif | ||
| 117 | ); | ||
| 120 | } | 118 | } |
| 121 | 119 | ||
| 122 | static SSL_CIPHER *ssl23_get_cipher(u) | 120 | static SSL_CIPHER *ssl23_get_cipher(unsigned int u) |
| 123 | unsigned int u; | ||
| 124 | { | 121 | { |
| 125 | unsigned int uu=ssl3_num_ciphers(); | 122 | unsigned int uu=ssl3_num_ciphers(); |
| 126 | 123 | ||
| 127 | if (u < uu) | 124 | if (u < uu) |
| 128 | return(ssl3_get_cipher(u)); | 125 | return(ssl3_get_cipher(u)); |
| 129 | else | 126 | else |
| 127 | #ifndef OPENSSL_NO_SSL2 | ||
| 130 | return(ssl2_get_cipher(u-uu)); | 128 | return(ssl2_get_cipher(u-uu)); |
| 129 | #else | ||
| 130 | return(NULL); | ||
| 131 | #endif | ||
| 131 | } | 132 | } |
| 132 | 133 | ||
| 133 | /* This function needs to check if the ciphers required are actually | 134 | /* This function needs to check if the ciphers required are actually |
| 134 | * available */ | 135 | * available */ |
| 135 | static SSL_CIPHER *ssl23_get_cipher_by_char(p) | 136 | static SSL_CIPHER *ssl23_get_cipher_by_char(const unsigned char *p) |
| 136 | unsigned char *p; | ||
| 137 | { | 137 | { |
| 138 | SSL_CIPHER c,*cp; | 138 | SSL_CIPHER c,*cp; |
| 139 | unsigned long id; | 139 | unsigned long id; |
| @@ -144,14 +144,14 @@ unsigned char *p; | |||
| 144 | ((unsigned long)p[1]<<8L)|(unsigned long)p[2]; | 144 | ((unsigned long)p[1]<<8L)|(unsigned long)p[2]; |
| 145 | c.id=id; | 145 | c.id=id; |
| 146 | cp=ssl3_get_cipher_by_char(p); | 146 | cp=ssl3_get_cipher_by_char(p); |
| 147 | #ifndef OPENSSL_NO_SSL2 | ||
| 147 | if (cp == NULL) | 148 | if (cp == NULL) |
| 148 | cp=ssl2_get_cipher_by_char(p); | 149 | cp=ssl2_get_cipher_by_char(p); |
| 150 | #endif | ||
| 149 | return(cp); | 151 | return(cp); |
| 150 | } | 152 | } |
| 151 | 153 | ||
| 152 | static int ssl23_put_cipher_by_char(c,p) | 154 | static int ssl23_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p) |
| 153 | SSL_CIPHER *c; | ||
| 154 | unsigned char *p; | ||
| 155 | { | 155 | { |
| 156 | long l; | 156 | long l; |
| 157 | 157 | ||
| @@ -166,20 +166,10 @@ unsigned char *p; | |||
| 166 | return(3); | 166 | return(3); |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | static int ssl23_read(s,buf,len) | 169 | static int ssl23_read(SSL *s, void *buf, int len) |
| 170 | SSL *s; | ||
| 171 | char *buf; | ||
| 172 | int len; | ||
| 173 | { | 170 | { |
| 174 | int n; | 171 | int n; |
| 175 | 172 | ||
| 176 | #if 0 | ||
| 177 | if (s->shutdown & SSL_RECEIVED_SHUTDOWN) | ||
| 178 | { | ||
| 179 | s->rwstate=SSL_NOTHING; | ||
| 180 | return(0); | ||
| 181 | } | ||
| 182 | #endif | ||
| 183 | clear_sys_error(); | 173 | clear_sys_error(); |
| 184 | if (SSL_in_init(s) && (!s->in_handshake)) | 174 | if (SSL_in_init(s) && (!s->in_handshake)) |
| 185 | { | 175 | { |
| @@ -199,20 +189,33 @@ int len; | |||
| 199 | } | 189 | } |
| 200 | } | 190 | } |
| 201 | 191 | ||
| 202 | static int ssl23_write(s,buf,len) | 192 | static int ssl23_peek(SSL *s, void *buf, int len) |
| 203 | SSL *s; | ||
| 204 | char *buf; | ||
| 205 | int len; | ||
| 206 | { | 193 | { |
| 207 | int n; | 194 | int n; |
| 208 | 195 | ||
| 209 | #if 0 | 196 | clear_sys_error(); |
| 210 | if (s->shutdown & SSL_SENT_SHUTDOWN) | 197 | if (SSL_in_init(s) && (!s->in_handshake)) |
| 211 | { | 198 | { |
| 212 | s->rwstate=SSL_NOTHING; | 199 | n=s->handshake_func(s); |
| 213 | return(0); | 200 | if (n < 0) return(n); |
| 201 | if (n == 0) | ||
| 202 | { | ||
| 203 | SSLerr(SSL_F_SSL23_PEEK,SSL_R_SSL_HANDSHAKE_FAILURE); | ||
| 204 | return(-1); | ||
| 205 | } | ||
| 206 | return(SSL_peek(s,buf,len)); | ||
| 214 | } | 207 | } |
| 215 | #endif | 208 | else |
| 209 | { | ||
| 210 | ssl_undefined_function(s); | ||
| 211 | return(-1); | ||
| 212 | } | ||
| 213 | } | ||
| 214 | |||
| 215 | static int ssl23_write(SSL *s, const void *buf, int len) | ||
| 216 | { | ||
| 217 | int n; | ||
| 218 | |||
| 216 | clear_sys_error(); | 219 | clear_sys_error(); |
| 217 | if (SSL_in_init(s) && (!s->in_handshake)) | 220 | if (SSL_in_init(s) && (!s->in_handshake)) |
| 218 | { | 221 | { |
diff --git a/src/lib/libssl/s23_pkt.c b/src/lib/libssl/s23_pkt.c index c25c312772..f45e1ce3d8 100644 --- a/src/lib/libssl/s23_pkt.c +++ b/src/lib/libssl/s23_pkt.c | |||
| @@ -59,12 +59,11 @@ | |||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include <errno.h> | 60 | #include <errno.h> |
| 61 | #define USE_SOCKETS | 61 | #define USE_SOCKETS |
| 62 | #include "evp.h" | 62 | #include <openssl/evp.h> |
| 63 | #include "buffer.h" | 63 | #include <openssl/buffer.h> |
| 64 | #include "ssl_locl.h" | 64 | #include "ssl_locl.h" |
| 65 | 65 | ||
| 66 | int ssl23_write_bytes(s) | 66 | int ssl23_write_bytes(SSL *s) |
| 67 | SSL *s; | ||
| 68 | { | 67 | { |
| 69 | int i,num,tot; | 68 | int i,num,tot; |
| 70 | char *buf; | 69 | char *buf; |
| @@ -76,7 +75,7 @@ SSL *s; | |||
| 76 | { | 75 | { |
| 77 | s->rwstate=SSL_WRITING; | 76 | s->rwstate=SSL_WRITING; |
| 78 | i=BIO_write(s->wbio,&(buf[tot]),num); | 77 | i=BIO_write(s->wbio,&(buf[tot]),num); |
| 79 | if (i < 0) | 78 | if (i <= 0) |
| 80 | { | 79 | { |
| 81 | s->init_off=tot; | 80 | s->init_off=tot; |
| 82 | s->init_num=num; | 81 | s->init_num=num; |
| @@ -90,10 +89,8 @@ SSL *s; | |||
| 90 | } | 89 | } |
| 91 | } | 90 | } |
| 92 | 91 | ||
| 93 | /* only return when we have read 'n' bytes */ | 92 | /* return regularly only when we have read (at least) 'n' bytes */ |
| 94 | int ssl23_read_bytes(s,n) | 93 | int ssl23_read_bytes(SSL *s, int n) |
| 95 | SSL *s; | ||
| 96 | int n; | ||
| 97 | { | 94 | { |
| 98 | unsigned char *p; | 95 | unsigned char *p; |
| 99 | int j; | 96 | int j; |
diff --git a/src/lib/libssl/s23_srvr.c b/src/lib/libssl/s23_srvr.c index c7b9ecbcf2..9e89cc7f9a 100644 --- a/src/lib/libssl/s23_srvr.c +++ b/src/lib/libssl/s23_srvr.c | |||
| @@ -55,28 +55,76 @@ | |||
| 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-2001 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 | ||
| 59 | #include <stdio.h> | 112 | #include <stdio.h> |
| 60 | #include "buffer.h" | 113 | #include <openssl/buffer.h> |
| 61 | #include "rand.h" | 114 | #include <openssl/rand.h> |
| 62 | #include "objects.h" | 115 | #include <openssl/objects.h> |
| 63 | #include "evp.h" | 116 | #include <openssl/evp.h> |
| 64 | #include "ssl_locl.h" | 117 | #include "ssl_locl.h" |
| 65 | 118 | ||
| 66 | #define BREAK break | 119 | static SSL_METHOD *ssl23_get_server_method(int ver); |
| 67 | |||
| 68 | #ifndef NOPROTO | ||
| 69 | int ssl23_get_client_hello(SSL *s); | 120 | int ssl23_get_client_hello(SSL *s); |
| 70 | #else | 121 | static SSL_METHOD *ssl23_get_server_method(int ver) |
| 71 | int ssl23_get_client_hello(); | ||
| 72 | #endif | ||
| 73 | |||
| 74 | static SSL_METHOD *ssl23_get_server_method(ver) | ||
| 75 | int ver; | ||
| 76 | { | 122 | { |
| 123 | #ifndef OPENSSL_NO_SSL2 | ||
| 77 | if (ver == SSL2_VERSION) | 124 | if (ver == SSL2_VERSION) |
| 78 | return(SSLv2_server_method()); | 125 | return(SSLv2_server_method()); |
| 79 | else if (ver == SSL3_VERSION) | 126 | #endif |
| 127 | if (ver == SSL3_VERSION) | ||
| 80 | return(SSLv3_server_method()); | 128 | return(SSLv3_server_method()); |
| 81 | else if (ver == TLS1_VERSION) | 129 | else if (ver == TLS1_VERSION) |
| 82 | return(TLSv1_server_method()); | 130 | return(TLSv1_server_method()); |
| @@ -84,32 +132,31 @@ int ver; | |||
| 84 | return(NULL); | 132 | return(NULL); |
| 85 | } | 133 | } |
| 86 | 134 | ||
| 87 | SSL_METHOD *SSLv23_server_method() | 135 | SSL_METHOD *SSLv23_server_method(void) |
| 88 | { | 136 | { |
| 89 | static int init=1; | 137 | static int init=1; |
| 90 | static SSL_METHOD SSLv23_server_data; | 138 | static SSL_METHOD SSLv23_server_data; |
| 91 | 139 | ||
| 92 | if (init) | 140 | if (init) |
| 93 | { | 141 | { |
| 94 | init=0; | ||
| 95 | memcpy((char *)&SSLv23_server_data, | 142 | memcpy((char *)&SSLv23_server_data, |
| 96 | (char *)sslv23_base_method(),sizeof(SSL_METHOD)); | 143 | (char *)sslv23_base_method(),sizeof(SSL_METHOD)); |
| 97 | SSLv23_server_data.ssl_accept=ssl23_accept; | 144 | SSLv23_server_data.ssl_accept=ssl23_accept; |
| 98 | SSLv23_server_data.get_ssl_method=ssl23_get_server_method; | 145 | SSLv23_server_data.get_ssl_method=ssl23_get_server_method; |
| 146 | init=0; | ||
| 99 | } | 147 | } |
| 100 | return(&SSLv23_server_data); | 148 | return(&SSLv23_server_data); |
| 101 | } | 149 | } |
| 102 | 150 | ||
| 103 | int ssl23_accept(s) | 151 | int ssl23_accept(SSL *s) |
| 104 | SSL *s; | ||
| 105 | { | 152 | { |
| 106 | BUF_MEM *buf; | 153 | BUF_MEM *buf; |
| 107 | unsigned long Time=time(NULL); | 154 | unsigned long Time=time(NULL); |
| 108 | void (*cb)()=NULL; | 155 | void (*cb)(const SSL *ssl,int type,int val)=NULL; |
| 109 | int ret= -1; | 156 | int ret= -1; |
| 110 | int new_state,state; | 157 | int new_state,state; |
| 111 | 158 | ||
| 112 | RAND_seed((unsigned char *)&Time,sizeof(Time)); | 159 | RAND_add(&Time,sizeof(Time),0); |
| 113 | ERR_clear_error(); | 160 | ERR_clear_error(); |
| 114 | clear_sys_error(); | 161 | clear_sys_error(); |
| 115 | 162 | ||
| @@ -118,8 +165,8 @@ SSL *s; | |||
| 118 | else if (s->ctx->info_callback != NULL) | 165 | else if (s->ctx->info_callback != NULL) |
| 119 | cb=s->ctx->info_callback; | 166 | cb=s->ctx->info_callback; |
| 120 | 167 | ||
| 121 | if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s); | ||
| 122 | s->in_handshake++; | 168 | s->in_handshake++; |
| 169 | if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s); | ||
| 123 | 170 | ||
| 124 | for (;;) | 171 | for (;;) |
| 125 | { | 172 | { |
| @@ -132,6 +179,7 @@ SSL *s; | |||
| 132 | case SSL_ST_BEFORE|SSL_ST_ACCEPT: | 179 | case SSL_ST_BEFORE|SSL_ST_ACCEPT: |
| 133 | case SSL_ST_OK|SSL_ST_ACCEPT: | 180 | case SSL_ST_OK|SSL_ST_ACCEPT: |
| 134 | 181 | ||
| 182 | s->server=1; | ||
| 135 | if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_START,1); | 183 | if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_START,1); |
| 136 | 184 | ||
| 137 | /* s->version=SSL3_VERSION; */ | 185 | /* s->version=SSL3_VERSION; */ |
| @@ -155,7 +203,7 @@ SSL *s; | |||
| 155 | ssl3_init_finished_mac(s); | 203 | ssl3_init_finished_mac(s); |
| 156 | 204 | ||
| 157 | s->state=SSL23_ST_SR_CLNT_HELLO_A; | 205 | s->state=SSL23_ST_SR_CLNT_HELLO_A; |
| 158 | s->ctx->sess_accept++; | 206 | s->ctx->stats.sess_accept++; |
| 159 | s->init_num=0; | 207 | s->init_num=0; |
| 160 | break; | 208 | break; |
| 161 | 209 | ||
| @@ -166,7 +214,7 @@ SSL *s; | |||
| 166 | ret=ssl23_get_client_hello(s); | 214 | ret=ssl23_get_client_hello(s); |
| 167 | if (ret >= 0) cb=NULL; | 215 | if (ret >= 0) cb=NULL; |
| 168 | goto end; | 216 | goto end; |
| 169 | break; | 217 | /* break; */ |
| 170 | 218 | ||
| 171 | default: | 219 | default: |
| 172 | SSLerr(SSL_F_SSL23_ACCEPT,SSL_R_UNKNOWN_STATE); | 220 | SSLerr(SSL_F_SSL23_ACCEPT,SSL_R_UNKNOWN_STATE); |
| @@ -184,31 +232,48 @@ SSL *s; | |||
| 184 | } | 232 | } |
| 185 | } | 233 | } |
| 186 | end: | 234 | end: |
| 235 | s->in_handshake--; | ||
| 187 | if (cb != NULL) | 236 | if (cb != NULL) |
| 188 | cb(s,SSL_CB_ACCEPT_EXIT,ret); | 237 | cb(s,SSL_CB_ACCEPT_EXIT,ret); |
| 189 | s->in_handshake--; | ||
| 190 | return(ret); | 238 | return(ret); |
| 191 | } | 239 | } |
| 192 | 240 | ||
| 193 | 241 | ||
| 194 | int ssl23_get_client_hello(s) | 242 | int ssl23_get_client_hello(SSL *s) |
| 195 | SSL *s; | ||
| 196 | { | 243 | { |
| 197 | char buf_space[8]; | 244 | char buf_space[11]; /* Request this many bytes in initial read. |
| 245 | * We can detect SSL 3.0/TLS 1.0 Client Hellos | ||
| 246 | * ('type == 3') correctly only when the following | ||
| 247 | * is in a single record, which is not guaranteed by | ||
| 248 | * the protocol specification: | ||
| 249 | * Byte Content | ||
| 250 | * 0 type \ | ||
| 251 | * 1/2 version > record header | ||
| 252 | * 3/4 length / | ||
| 253 | * 5 msg_type \ | ||
| 254 | * 6-8 length > Client Hello message | ||
| 255 | * 9/10 client_version / | ||
| 256 | */ | ||
| 198 | char *buf= &(buf_space[0]); | 257 | char *buf= &(buf_space[0]); |
| 199 | unsigned char *p,*d,*dd; | 258 | unsigned char *p,*d,*d_len,*dd; |
| 200 | unsigned int i; | 259 | unsigned int i; |
| 201 | unsigned int csl,sil,cl; | 260 | unsigned int csl,sil,cl; |
| 202 | int n=0,j,tls1=0; | 261 | int n=0,j; |
| 203 | int type=0,use_sslv2_strong=0; | 262 | int type=0; |
| 263 | int v[2]; | ||
| 264 | #ifndef OPENSSL_NO_RSA | ||
| 265 | int use_sslv2_strong=0; | ||
| 266 | #endif | ||
| 204 | 267 | ||
| 205 | /* read the initial header */ | ||
| 206 | if (s->state == SSL23_ST_SR_CLNT_HELLO_A) | 268 | if (s->state == SSL23_ST_SR_CLNT_HELLO_A) |
| 207 | { | 269 | { |
| 270 | /* read the initial header */ | ||
| 271 | v[0]=v[1]=0; | ||
| 272 | |||
| 208 | if (!ssl3_setup_buffers(s)) goto err; | 273 | if (!ssl3_setup_buffers(s)) goto err; |
| 209 | 274 | ||
| 210 | n=ssl23_read_bytes(s,7); | 275 | n=ssl23_read_bytes(s, sizeof buf_space); |
| 211 | if (n != 7) return(n); | 276 | if (n != sizeof buf_space) return(n); /* n == -1 || n == 0 */ |
| 212 | 277 | ||
| 213 | p=s->packet; | 278 | p=s->packet; |
| 214 | 279 | ||
| @@ -216,124 +281,135 @@ SSL *s; | |||
| 216 | 281 | ||
| 217 | if ((p[0] & 0x80) && (p[2] == SSL2_MT_CLIENT_HELLO)) | 282 | if ((p[0] & 0x80) && (p[2] == SSL2_MT_CLIENT_HELLO)) |
| 218 | { | 283 | { |
| 219 | /* SSLv2 header */ | 284 | /* |
| 285 | * SSLv2 header | ||
| 286 | */ | ||
| 220 | if ((p[3] == 0x00) && (p[4] == 0x02)) | 287 | if ((p[3] == 0x00) && (p[4] == 0x02)) |
| 221 | { | 288 | { |
| 289 | v[0]=p[3]; v[1]=p[4]; | ||
| 222 | /* SSLv2 */ | 290 | /* SSLv2 */ |
| 223 | if (!(s->options & SSL_OP_NO_SSLv2)) | 291 | if (!(s->options & SSL_OP_NO_SSLv2)) |
| 224 | type=1; | 292 | type=1; |
| 225 | } | 293 | } |
| 226 | else if (p[3] == SSL3_VERSION_MAJOR) | 294 | else if (p[3] == SSL3_VERSION_MAJOR) |
| 227 | { | 295 | { |
| 296 | v[0]=p[3]; v[1]=p[4]; | ||
| 228 | /* SSLv3/TLSv1 */ | 297 | /* SSLv3/TLSv1 */ |
| 229 | if (p[4] >= TLS1_VERSION_MINOR) | 298 | if (p[4] >= TLS1_VERSION_MINOR) |
| 230 | { | 299 | { |
| 231 | if (!(s->options & SSL_OP_NO_TLSv1)) | 300 | if (!(s->options & SSL_OP_NO_TLSv1)) |
| 232 | { | 301 | { |
| 233 | tls1=1; | 302 | s->version=TLS1_VERSION; |
| 303 | /* type=2; */ /* done later to survive restarts */ | ||
| 234 | s->state=SSL23_ST_SR_CLNT_HELLO_B; | 304 | s->state=SSL23_ST_SR_CLNT_HELLO_B; |
| 235 | } | 305 | } |
| 236 | else if (!(s->options & SSL_OP_NO_SSLv3)) | 306 | else if (!(s->options & SSL_OP_NO_SSLv3)) |
| 237 | { | 307 | { |
| 308 | s->version=SSL3_VERSION; | ||
| 309 | /* type=2; */ | ||
| 238 | s->state=SSL23_ST_SR_CLNT_HELLO_B; | 310 | s->state=SSL23_ST_SR_CLNT_HELLO_B; |
| 239 | } | 311 | } |
| 312 | else if (!(s->options & SSL_OP_NO_SSLv2)) | ||
| 313 | { | ||
| 314 | type=1; | ||
| 315 | } | ||
| 240 | } | 316 | } |
| 241 | else if (!(s->options & SSL_OP_NO_SSLv3)) | 317 | else if (!(s->options & SSL_OP_NO_SSLv3)) |
| 242 | s->state=SSL23_ST_SR_CLNT_HELLO_B; | ||
| 243 | |||
| 244 | if (s->options & SSL_OP_NON_EXPORT_FIRST) | ||
| 245 | { | 318 | { |
| 246 | STACK *sk; | 319 | s->version=SSL3_VERSION; |
| 247 | SSL_CIPHER *c; | 320 | /* type=2; */ |
| 248 | int ne2,ne3; | 321 | s->state=SSL23_ST_SR_CLNT_HELLO_B; |
| 249 | |||
| 250 | j=((p[0]&0x7f)<<8)|p[1]; | ||
| 251 | if (j > (1024*4)) | ||
| 252 | { | ||
| 253 | SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_RECORD_TOO_LARGE); | ||
| 254 | goto err; | ||
| 255 | } | ||
| 256 | |||
| 257 | n=ssl23_read_bytes(s,j+2); | ||
| 258 | if (n <= 0) return(n); | ||
| 259 | p=s->packet; | ||
| 260 | |||
| 261 | if ((buf=Malloc(n)) == NULL) | ||
| 262 | { | ||
| 263 | SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,ERR_R_MALLOC_FAILURE); | ||
| 264 | goto err; | ||
| 265 | } | ||
| 266 | memcpy(buf,p,n); | ||
| 267 | |||
| 268 | p+=5; | ||
| 269 | n2s(p,csl); | ||
| 270 | p+=4; | ||
| 271 | |||
| 272 | sk=ssl_bytes_to_cipher_list( | ||
| 273 | s,p,csl,NULL); | ||
| 274 | if (sk != NULL) | ||
| 275 | { | ||
| 276 | ne2=ne3=0; | ||
| 277 | for (j=0; j<sk_num(sk); j++) | ||
| 278 | { | ||
| 279 | c=(SSL_CIPHER *)sk_value(sk,j); | ||
| 280 | if (!(c->algorithms & SSL_EXP)) | ||
| 281 | { | ||
| 282 | if ((c->id>>24L) == 2L) | ||
| 283 | ne2=1; | ||
| 284 | else | ||
| 285 | ne3=1; | ||
| 286 | } | ||
| 287 | } | ||
| 288 | if (ne2 && !ne3) | ||
| 289 | { | ||
| 290 | type=1; | ||
| 291 | use_sslv2_strong=1; | ||
| 292 | goto next_bit; | ||
| 293 | } | ||
| 294 | } | ||
| 295 | } | 322 | } |
| 323 | else if (!(s->options & SSL_OP_NO_SSLv2)) | ||
| 324 | type=1; | ||
| 325 | |||
| 296 | } | 326 | } |
| 297 | } | 327 | } |
| 298 | else if ((p[0] == SSL3_RT_HANDSHAKE) && | 328 | else if ((p[0] == SSL3_RT_HANDSHAKE) && |
| 299 | (p[1] == SSL3_VERSION_MAJOR) && | 329 | (p[1] == SSL3_VERSION_MAJOR) && |
| 300 | (p[5] == SSL3_MT_CLIENT_HELLO)) | 330 | (p[5] == SSL3_MT_CLIENT_HELLO) && |
| 331 | ((p[3] == 0 && p[4] < 5 /* silly record length? */) | ||
| 332 | || (p[9] == p[1]))) | ||
| 301 | { | 333 | { |
| 302 | /* true SSLv3 or tls1 */ | 334 | /* |
| 303 | if (p[2] >= TLS1_VERSION_MINOR) | 335 | * SSLv3 or tls1 header |
| 336 | */ | ||
| 337 | |||
| 338 | v[0]=p[1]; /* major version (= SSL3_VERSION_MAJOR) */ | ||
| 339 | /* We must look at client_version inside the Client Hello message | ||
| 340 | * to get the correct minor version. | ||
| 341 | * However if we have only a pathologically small fragment of the | ||
| 342 | * Client Hello message, this would be difficult, and we'd have | ||
| 343 | * to read more records to find out. | ||
| 344 | * No known SSL 3.0 client fragments ClientHello like this, | ||
| 345 | * so we simply assume TLS 1.0 to avoid protocol version downgrade | ||
| 346 | * attacks. */ | ||
| 347 | if (p[3] == 0 && p[4] < 6) | ||
| 348 | { | ||
| 349 | #if 0 | ||
| 350 | SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_RECORD_TOO_SMALL); | ||
| 351 | goto err; | ||
| 352 | #else | ||
| 353 | v[1] = TLS1_VERSION_MINOR; | ||
| 354 | #endif | ||
| 355 | } | ||
| 356 | else | ||
| 357 | v[1]=p[10]; /* minor version according to client_version */ | ||
| 358 | if (v[1] >= TLS1_VERSION_MINOR) | ||
| 304 | { | 359 | { |
| 305 | if (!(s->options & SSL_OP_NO_TLSv1)) | 360 | if (!(s->options & SSL_OP_NO_TLSv1)) |
| 306 | { | 361 | { |
| 362 | s->version=TLS1_VERSION; | ||
| 307 | type=3; | 363 | type=3; |
| 308 | tls1=1; | ||
| 309 | } | 364 | } |
| 310 | else if (!(s->options & SSL_OP_NO_SSLv3)) | 365 | else if (!(s->options & SSL_OP_NO_SSLv3)) |
| 366 | { | ||
| 367 | s->version=SSL3_VERSION; | ||
| 368 | type=3; | ||
| 369 | } | ||
| 370 | } | ||
| 371 | else | ||
| 372 | { | ||
| 373 | /* client requests SSL 3.0 */ | ||
| 374 | if (!(s->options & SSL_OP_NO_SSLv3)) | ||
| 375 | { | ||
| 376 | s->version=SSL3_VERSION; | ||
| 311 | type=3; | 377 | type=3; |
| 378 | } | ||
| 379 | else if (!(s->options & SSL_OP_NO_TLSv1)) | ||
| 380 | { | ||
| 381 | /* we won't be able to use TLS of course, | ||
| 382 | * but this will send an appropriate alert */ | ||
| 383 | s->version=TLS1_VERSION; | ||
| 384 | type=3; | ||
| 385 | } | ||
| 312 | } | 386 | } |
| 313 | else if (!(s->options & SSL_OP_NO_SSLv3)) | ||
| 314 | type=3; | ||
| 315 | } | 387 | } |
| 316 | else if ((strncmp("GET ", p,4) == 0) || | 388 | else if ((strncmp("GET ", (char *)p,4) == 0) || |
| 317 | (strncmp("POST ",p,5) == 0) || | 389 | (strncmp("POST ",(char *)p,5) == 0) || |
| 318 | (strncmp("HEAD ",p,5) == 0) || | 390 | (strncmp("HEAD ",(char *)p,5) == 0) || |
| 319 | (strncmp("PUT ", p,4) == 0)) | 391 | (strncmp("PUT ", (char *)p,4) == 0)) |
| 320 | { | 392 | { |
| 321 | SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_HTTP_REQUEST); | 393 | SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_HTTP_REQUEST); |
| 322 | goto err; | 394 | goto err; |
| 323 | } | 395 | } |
| 324 | else if (strncmp("CONNECT",p,7) == 0) | 396 | else if (strncmp("CONNECT",(char *)p,7) == 0) |
| 325 | { | 397 | { |
| 326 | SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_HTTPS_PROXY_REQUEST); | 398 | SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_HTTPS_PROXY_REQUEST); |
| 327 | goto err; | 399 | goto err; |
| 328 | } | 400 | } |
| 329 | } | 401 | } |
| 330 | 402 | ||
| 331 | next_bit: | ||
| 332 | if (s->state == SSL23_ST_SR_CLNT_HELLO_B) | 403 | if (s->state == SSL23_ST_SR_CLNT_HELLO_B) |
| 333 | { | 404 | { |
| 334 | /* we have a SSLv3/TLSv1 in a SSLv2 header */ | 405 | /* we have SSLv3/TLSv1 in an SSLv2 header |
| 406 | * (other cases skip this state) */ | ||
| 407 | |||
| 335 | type=2; | 408 | type=2; |
| 336 | p=s->packet; | 409 | p=s->packet; |
| 410 | v[0] = p[3]; /* == SSL3_VERSION_MAJOR */ | ||
| 411 | v[1] = p[4]; | ||
| 412 | |||
| 337 | n=((p[0]&0x7f)<<8)|p[1]; | 413 | n=((p[0]&0x7f)<<8)|p[1]; |
| 338 | if (n > (1024*4)) | 414 | if (n > (1024*4)) |
| 339 | { | 415 | { |
| @@ -344,7 +420,9 @@ next_bit: | |||
| 344 | j=ssl23_read_bytes(s,n+2); | 420 | j=ssl23_read_bytes(s,n+2); |
| 345 | if (j <= 0) return(j); | 421 | if (j <= 0) return(j); |
| 346 | 422 | ||
| 347 | ssl3_finish_mac(s,&(s->packet[2]),s->packet_length-2); | 423 | ssl3_finish_mac(s, s->packet+2, s->packet_length-2); |
| 424 | if (s->msg_callback) | ||
| 425 | s->msg_callback(0, SSL2_VERSION, 0, s->packet+2, s->packet_length-2, s, s->msg_callback_arg); /* CLIENT-HELLO */ | ||
| 348 | 426 | ||
| 349 | p=s->packet; | 427 | p=s->packet; |
| 350 | p+=5; | 428 | p+=5; |
| @@ -358,14 +436,18 @@ next_bit: | |||
| 358 | goto err; | 436 | goto err; |
| 359 | } | 437 | } |
| 360 | 438 | ||
| 361 | *(d++)=SSL3_VERSION_MAJOR; | 439 | /* record header: msg_type ... */ |
| 362 | if (tls1) | 440 | *(d++) = SSL3_MT_CLIENT_HELLO; |
| 363 | *(d++)=TLS1_VERSION_MINOR; | 441 | /* ... and length (actual value will be written later) */ |
| 364 | else | 442 | d_len = d; |
| 365 | *(d++)=SSL3_VERSION_MINOR; | 443 | d += 3; |
| 444 | |||
| 445 | /* client_version */ | ||
| 446 | *(d++) = SSL3_VERSION_MAJOR; /* == v[0] */ | ||
| 447 | *(d++) = v[1]; | ||
| 366 | 448 | ||
| 367 | /* lets populate the random area */ | 449 | /* lets populate the random area */ |
| 368 | /* get the chalenge_length */ | 450 | /* get the challenge_length */ |
| 369 | i=(cl > SSL3_RANDOM_SIZE)?SSL3_RANDOM_SIZE:cl; | 451 | i=(cl > SSL3_RANDOM_SIZE)?SSL3_RANDOM_SIZE:cl; |
| 370 | memset(d,0,SSL3_RANDOM_SIZE); | 452 | memset(d,0,SSL3_RANDOM_SIZE); |
| 371 | memcpy(&(d[SSL3_RANDOM_SIZE-i]),&(p[csl+sil]),i); | 453 | memcpy(&(d[SSL3_RANDOM_SIZE-i]),&(p[csl+sil]),i); |
| @@ -387,11 +469,12 @@ next_bit: | |||
| 387 | } | 469 | } |
| 388 | s2n(j,dd); | 470 | s2n(j,dd); |
| 389 | 471 | ||
| 390 | /* compression */ | 472 | /* COMPRESSION */ |
| 391 | *(d++)=1; | 473 | *(d++)=1; |
| 392 | *(d++)=0; | 474 | *(d++)=0; |
| 393 | 475 | ||
| 394 | i=(d-(unsigned char *)s->init_buf->data); | 476 | i = (d-(unsigned char *)s->init_buf->data) - 4; |
| 477 | l2n3((long)i, d_len); | ||
| 395 | 478 | ||
| 396 | /* get the data reused from the init_buf */ | 479 | /* get the data reused from the init_buf */ |
| 397 | s->s3->tmp.reuse_message=1; | 480 | s->s3->tmp.reuse_message=1; |
| @@ -399,8 +482,15 @@ next_bit: | |||
| 399 | s->s3->tmp.message_size=i; | 482 | s->s3->tmp.message_size=i; |
| 400 | } | 483 | } |
| 401 | 484 | ||
| 485 | /* imaginary new state (for program structure): */ | ||
| 486 | /* s->state = SSL23_SR_CLNT_HELLO_C */ | ||
| 487 | |||
| 402 | if (type == 1) | 488 | if (type == 1) |
| 403 | { | 489 | { |
| 490 | #ifdef OPENSSL_NO_SSL2 | ||
| 491 | SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_UNSUPPORTED_PROTOCOL); | ||
| 492 | goto err; | ||
| 493 | #else | ||
| 404 | /* we are talking sslv2 */ | 494 | /* we are talking sslv2 */ |
| 405 | /* we need to clean up the SSLv3/TLSv1 setup and put in the | 495 | /* we need to clean up the SSLv3/TLSv1 setup and put in the |
| 406 | * sslv2 stuff. */ | 496 | * sslv2 stuff. */ |
| @@ -423,12 +513,15 @@ next_bit: | |||
| 423 | 513 | ||
| 424 | s->state=SSL2_ST_GET_CLIENT_HELLO_A; | 514 | s->state=SSL2_ST_GET_CLIENT_HELLO_A; |
| 425 | if ((s->options & SSL_OP_MSIE_SSLV2_RSA_PADDING) || | 515 | if ((s->options & SSL_OP_MSIE_SSLV2_RSA_PADDING) || |
| 426 | use_sslv2_strong) | 516 | use_sslv2_strong || |
| 517 | (s->options & SSL_OP_NO_TLSv1 && s->options & SSL_OP_NO_SSLv3)) | ||
| 427 | s->s2->ssl2_rollback=0; | 518 | s->s2->ssl2_rollback=0; |
| 428 | else | 519 | else |
| 520 | /* reject SSL 2.0 session if client supports SSL 3.0 or TLS 1.0 | ||
| 521 | * (SSL 3.0 draft/RFC 2246, App. E.2) */ | ||
| 429 | s->s2->ssl2_rollback=1; | 522 | s->s2->ssl2_rollback=1; |
| 430 | 523 | ||
| 431 | /* setup the 5 bytes we have read so we get them from | 524 | /* setup the n bytes we have read so we get them from |
| 432 | * the sslv2 buffer */ | 525 | * the sslv2 buffer */ |
| 433 | s->rstate=SSL_ST_READ_HEADER; | 526 | s->rstate=SSL_ST_READ_HEADER; |
| 434 | s->packet_length=n; | 527 | s->packet_length=n; |
| @@ -439,11 +532,12 @@ next_bit: | |||
| 439 | 532 | ||
| 440 | s->method=SSLv2_server_method(); | 533 | s->method=SSLv2_server_method(); |
| 441 | s->handshake_func=s->method->ssl_accept; | 534 | s->handshake_func=s->method->ssl_accept; |
| 535 | #endif | ||
| 442 | } | 536 | } |
| 443 | 537 | ||
| 444 | if ((type == 2) || (type == 3)) | 538 | if ((type == 2) || (type == 3)) |
| 445 | { | 539 | { |
| 446 | /* we have SSLv3/TLSv1 */ | 540 | /* we have SSLv3/TLSv1 (type 2: SSL2 style, type 3: SSL3/TLS style) */ |
| 447 | 541 | ||
| 448 | if (!ssl_init_wbio_buffer(s,1)) goto err; | 542 | if (!ssl_init_wbio_buffer(s,1)) goto err; |
| 449 | 543 | ||
| @@ -468,16 +562,13 @@ next_bit: | |||
| 468 | s->s3->rbuf.offset=0; | 562 | s->s3->rbuf.offset=0; |
| 469 | } | 563 | } |
| 470 | 564 | ||
| 471 | if (tls1) | 565 | if (s->version == TLS1_VERSION) |
| 472 | { | 566 | s->method = TLSv1_server_method(); |
| 473 | s->version=TLS1_VERSION; | ||
| 474 | s->method=TLSv1_server_method(); | ||
| 475 | } | ||
| 476 | else | 567 | else |
| 477 | { | 568 | s->method = SSLv3_server_method(); |
| 478 | s->version=SSL3_VERSION; | 569 | #if 0 /* ssl3_get_client_hello does this */ |
| 479 | s->method=SSLv3_server_method(); | 570 | s->client_version=(v[0]<<8)|v[1]; |
| 480 | } | 571 | #endif |
| 481 | s->handshake_func=s->method->ssl_accept; | 572 | s->handshake_func=s->method->ssl_accept; |
| 482 | } | 573 | } |
| 483 | 574 | ||
| @@ -489,11 +580,10 @@ next_bit: | |||
| 489 | } | 580 | } |
| 490 | s->init_num=0; | 581 | s->init_num=0; |
| 491 | 582 | ||
| 492 | if (buf != buf_space) Free(buf); | 583 | if (buf != buf_space) OPENSSL_free(buf); |
| 493 | s->first_packet=1; | 584 | s->first_packet=1; |
| 494 | return(SSL_accept(s)); | 585 | return(SSL_accept(s)); |
| 495 | err: | 586 | err: |
| 496 | if (buf != buf_space) Free(buf); | 587 | if (buf != buf_space) OPENSSL_free(buf); |
| 497 | return(-1); | 588 | return(-1); |
| 498 | } | 589 | } |
| 499 | |||
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); |
diff --git a/src/lib/libssl/s3_clnt.c b/src/lib/libssl/s3_clnt.c index 940c6a458f..e5853ede95 100644 --- a/src/lib/libssl/s3_clnt.c +++ b/src/lib/libssl/s3_clnt.c | |||
| @@ -55,29 +55,74 @@ | |||
| 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 | ||
| 59 | #include <stdio.h> | 112 | #include <stdio.h> |
| 60 | #include "buffer.h" | 113 | #include <openssl/buffer.h> |
| 61 | #include "rand.h" | 114 | #include <openssl/rand.h> |
| 62 | #include "objects.h" | 115 | #include <openssl/objects.h> |
| 63 | #include "evp.h" | 116 | #include <openssl/evp.h> |
| 64 | #include "ssl_locl.h" | 117 | #include "ssl_locl.h" |
| 118 | #include "kssl_lcl.h" | ||
| 119 | #include <openssl/md5.h> | ||
| 65 | 120 | ||
| 66 | #define BREAK break | 121 | static SSL_METHOD *ssl3_get_client_method(int ver); |
| 67 | /* SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,ERR_R_MALLOC_FAILURE); | ||
| 68 | * SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,ERR_R_MALLOC_FAILURE); | ||
| 69 | * SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,ERR_R_MALLOC_FAILURE); | ||
| 70 | * SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,ERR_R_MALLOC_FAILURE); | ||
| 71 | * SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST,ERR_R_MALLOC_FAILURE); | ||
| 72 | * SSLerr(SSL_F_SSL3_GET_SERVER_DONE,ERR_R_MALLOC_FAILURE); | ||
| 73 | SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_SSL3_SESSION_ID_TOO_SHORT); | ||
| 74 | */ | ||
| 75 | |||
| 76 | #ifndef NOPROTO | ||
| 77 | static int ssl3_client_hello(SSL *s); | 122 | static int ssl3_client_hello(SSL *s); |
| 78 | static int ssl3_get_server_hello(SSL *s); | 123 | static int ssl3_get_server_hello(SSL *s); |
| 79 | static int ssl3_get_certificate_request(SSL *s); | 124 | static int ssl3_get_certificate_request(SSL *s); |
| 80 | static int ca_dn_cmp(X509_NAME **a,X509_NAME **b); | 125 | static int ca_dn_cmp(const X509_NAME * const *a,const X509_NAME * const *b); |
| 81 | static int ssl3_get_server_done(SSL *s); | 126 | static int ssl3_get_server_done(SSL *s); |
| 82 | static int ssl3_send_client_verify(SSL *s); | 127 | static int ssl3_send_client_verify(SSL *s); |
| 83 | static int ssl3_send_client_certificate(SSL *s); | 128 | static int ssl3_send_client_certificate(SSL *s); |
| @@ -85,22 +130,7 @@ static int ssl3_send_client_key_exchange(SSL *s); | |||
| 85 | static int ssl3_get_key_exchange(SSL *s); | 130 | static int ssl3_get_key_exchange(SSL *s); |
| 86 | static int ssl3_get_server_certificate(SSL *s); | 131 | static int ssl3_get_server_certificate(SSL *s); |
| 87 | static int ssl3_check_cert_and_algorithm(SSL *s); | 132 | static int ssl3_check_cert_and_algorithm(SSL *s); |
| 88 | #else | 133 | static SSL_METHOD *ssl3_get_client_method(int ver) |
| 89 | static int ssl3_client_hello(); | ||
| 90 | static int ssl3_get_server_hello(); | ||
| 91 | static int ssl3_get_certificate_request(); | ||
| 92 | static int ca_dn_cmp(); | ||
| 93 | static int ssl3_get_server_done(); | ||
| 94 | static int ssl3_send_client_verify(); | ||
| 95 | static int ssl3_send_client_certificate(); | ||
| 96 | static int ssl3_send_client_key_exchange(); | ||
| 97 | static int ssl3_get_key_exchange(); | ||
| 98 | static int ssl3_get_server_certificate(); | ||
| 99 | static int ssl3_check_cert_and_algorithm(); | ||
| 100 | #endif | ||
| 101 | |||
| 102 | static SSL_METHOD *ssl3_get_client_method(ver) | ||
| 103 | int ver; | ||
| 104 | { | 134 | { |
| 105 | if (ver == SSL3_VERSION) | 135 | if (ver == SSL3_VERSION) |
| 106 | return(SSLv3_client_method()); | 136 | return(SSLv3_client_method()); |
| @@ -108,7 +138,7 @@ int ver; | |||
| 108 | return(NULL); | 138 | return(NULL); |
| 109 | } | 139 | } |
| 110 | 140 | ||
| 111 | SSL_METHOD *SSLv3_client_method() | 141 | SSL_METHOD *SSLv3_client_method(void) |
| 112 | { | 142 | { |
| 113 | static int init=1; | 143 | static int init=1; |
| 114 | static SSL_METHOD SSLv3_client_data; | 144 | static SSL_METHOD SSLv3_client_data; |
| @@ -124,18 +154,16 @@ SSL_METHOD *SSLv3_client_method() | |||
| 124 | return(&SSLv3_client_data); | 154 | return(&SSLv3_client_data); |
| 125 | } | 155 | } |
| 126 | 156 | ||
| 127 | int ssl3_connect(s) | 157 | int ssl3_connect(SSL *s) |
| 128 | SSL *s; | ||
| 129 | { | 158 | { |
| 130 | BUF_MEM *buf; | 159 | BUF_MEM *buf; |
| 131 | unsigned long Time=time(NULL),l; | 160 | unsigned long Time=time(NULL),l; |
| 132 | long num1; | 161 | long num1; |
| 133 | void (*cb)()=NULL; | 162 | void (*cb)(const SSL *ssl,int type,int val)=NULL; |
| 134 | int ret= -1; | 163 | int ret= -1; |
| 135 | BIO *under; | ||
| 136 | int new_state,state,skip=0;; | 164 | int new_state,state,skip=0;; |
| 137 | 165 | ||
| 138 | RAND_seed((unsigned char *)&Time,sizeof(Time)); | 166 | RAND_add(&Time,sizeof(Time),0); |
| 139 | ERR_clear_error(); | 167 | ERR_clear_error(); |
| 140 | clear_sys_error(); | 168 | clear_sys_error(); |
| 141 | 169 | ||
| @@ -144,8 +172,8 @@ SSL *s; | |||
| 144 | else if (s->ctx->info_callback != NULL) | 172 | else if (s->ctx->info_callback != NULL) |
| 145 | cb=s->ctx->info_callback; | 173 | cb=s->ctx->info_callback; |
| 146 | 174 | ||
| 147 | if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s); | ||
| 148 | s->in_handshake++; | 175 | s->in_handshake++; |
| 176 | if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s); | ||
| 149 | 177 | ||
| 150 | for (;;) | 178 | for (;;) |
| 151 | { | 179 | { |
| @@ -156,17 +184,23 @@ SSL *s; | |||
| 156 | case SSL_ST_RENEGOTIATE: | 184 | case SSL_ST_RENEGOTIATE: |
| 157 | s->new_session=1; | 185 | s->new_session=1; |
| 158 | s->state=SSL_ST_CONNECT; | 186 | s->state=SSL_ST_CONNECT; |
| 159 | s->ctx->sess_connect_renegotiate++; | 187 | s->ctx->stats.sess_connect_renegotiate++; |
| 160 | /* break */ | 188 | /* break */ |
| 161 | case SSL_ST_BEFORE: | 189 | case SSL_ST_BEFORE: |
| 162 | case SSL_ST_CONNECT: | 190 | case SSL_ST_CONNECT: |
| 163 | case SSL_ST_BEFORE|SSL_ST_CONNECT: | 191 | case SSL_ST_BEFORE|SSL_ST_CONNECT: |
| 164 | case SSL_ST_OK|SSL_ST_CONNECT: | 192 | case SSL_ST_OK|SSL_ST_CONNECT: |
| 165 | 193 | ||
| 194 | s->server=0; | ||
| 166 | if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_START,1); | 195 | if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_START,1); |
| 167 | 196 | ||
| 168 | if ((s->version & 0xff00 ) != 0x0300) | 197 | if ((s->version & 0xff00 ) != 0x0300) |
| 169 | abort(); | 198 | { |
| 199 | SSLerr(SSL_F_SSL3_CONNECT, ERR_R_INTERNAL_ERROR); | ||
| 200 | ret = -1; | ||
| 201 | goto end; | ||
| 202 | } | ||
| 203 | |||
| 170 | /* s->version=SSL3_VERSION; */ | 204 | /* s->version=SSL3_VERSION; */ |
| 171 | s->type=SSL_ST_CONNECT; | 205 | s->type=SSL_ST_CONNECT; |
| 172 | 206 | ||
| @@ -195,7 +229,7 @@ SSL *s; | |||
| 195 | ssl3_init_finished_mac(s); | 229 | ssl3_init_finished_mac(s); |
| 196 | 230 | ||
| 197 | s->state=SSL3_ST_CW_CLNT_HELLO_A; | 231 | s->state=SSL3_ST_CW_CLNT_HELLO_A; |
| 198 | s->ctx->sess_connect++; | 232 | s->ctx->stats.sess_connect++; |
| 199 | s->init_num=0; | 233 | s->init_num=0; |
| 200 | break; | 234 | break; |
| 201 | 235 | ||
| @@ -278,6 +312,7 @@ SSL *s; | |||
| 278 | case SSL3_ST_CW_CERT_A: | 312 | case SSL3_ST_CW_CERT_A: |
| 279 | case SSL3_ST_CW_CERT_B: | 313 | case SSL3_ST_CW_CERT_B: |
| 280 | case SSL3_ST_CW_CERT_C: | 314 | case SSL3_ST_CW_CERT_C: |
| 315 | case SSL3_ST_CW_CERT_D: | ||
| 281 | ret=ssl3_send_client_certificate(s); | 316 | ret=ssl3_send_client_certificate(s); |
| 282 | if (ret <= 0) goto end; | 317 | if (ret <= 0) goto end; |
| 283 | s->state=SSL3_ST_CW_KEY_EXCH_A; | 318 | s->state=SSL3_ST_CW_KEY_EXCH_A; |
| @@ -324,6 +359,11 @@ SSL *s; | |||
| 324 | s->init_num=0; | 359 | s->init_num=0; |
| 325 | 360 | ||
| 326 | s->session->cipher=s->s3->tmp.new_cipher; | 361 | s->session->cipher=s->s3->tmp.new_cipher; |
| 362 | if (s->s3->tmp.new_compression == NULL) | ||
| 363 | s->session->compress_meth=0; | ||
| 364 | else | ||
| 365 | s->session->compress_meth= | ||
| 366 | s->s3->tmp.new_compression->id; | ||
| 327 | if (!s->method->ssl3_enc->setup_key_block(s)) | 367 | if (!s->method->ssl3_enc->setup_key_block(s)) |
| 328 | { | 368 | { |
| 329 | ret= -1; | 369 | ret= -1; |
| @@ -343,8 +383,8 @@ SSL *s; | |||
| 343 | case SSL3_ST_CW_FINISHED_B: | 383 | case SSL3_ST_CW_FINISHED_B: |
| 344 | ret=ssl3_send_finished(s, | 384 | ret=ssl3_send_finished(s, |
| 345 | SSL3_ST_CW_FINISHED_A,SSL3_ST_CW_FINISHED_B, | 385 | SSL3_ST_CW_FINISHED_A,SSL3_ST_CW_FINISHED_B, |
| 346 | s->method->ssl3_enc->client_finished, | 386 | s->method->ssl3_enc->client_finished_label, |
| 347 | s->method->ssl3_enc->client_finished_len); | 387 | s->method->ssl3_enc->client_finished_label_len); |
| 348 | if (ret <= 0) goto end; | 388 | if (ret <= 0) goto end; |
| 349 | s->state=SSL3_ST_CW_FLUSH; | 389 | s->state=SSL3_ST_CW_FLUSH; |
| 350 | 390 | ||
| @@ -399,38 +439,33 @@ SSL *s; | |||
| 399 | /* clean a few things up */ | 439 | /* clean a few things up */ |
| 400 | ssl3_cleanup_key_block(s); | 440 | ssl3_cleanup_key_block(s); |
| 401 | 441 | ||
| 402 | BUF_MEM_free(s->init_buf); | 442 | if (s->init_buf != NULL) |
| 403 | s->init_buf=NULL; | ||
| 404 | |||
| 405 | if (!(s->s3->flags & SSL3_FLAGS_POP_BUFFER)) | ||
| 406 | { | 443 | { |
| 407 | /* remove buffering */ | 444 | BUF_MEM_free(s->init_buf); |
| 408 | under=BIO_pop(s->wbio); | 445 | s->init_buf=NULL; |
| 409 | if (under != NULL) | ||
| 410 | s->wbio=under; | ||
| 411 | else | ||
| 412 | abort(); /* ok */ | ||
| 413 | |||
| 414 | BIO_free(s->bbio); | ||
| 415 | s->bbio=NULL; | ||
| 416 | } | 446 | } |
| 417 | /* else do it later */ | 447 | |
| 448 | /* If we are not 'joining' the last two packets, | ||
| 449 | * remove the buffering now */ | ||
| 450 | if (!(s->s3->flags & SSL3_FLAGS_POP_BUFFER)) | ||
| 451 | ssl_free_wbio_buffer(s); | ||
| 452 | /* else do it later in ssl3_write */ | ||
| 418 | 453 | ||
| 419 | s->init_num=0; | 454 | s->init_num=0; |
| 420 | s->new_session=0; | 455 | s->new_session=0; |
| 421 | 456 | ||
| 422 | ssl_update_cache(s,SSL_SESS_CACHE_CLIENT); | 457 | ssl_update_cache(s,SSL_SESS_CACHE_CLIENT); |
| 423 | if (s->hit) s->ctx->sess_hit++; | 458 | if (s->hit) s->ctx->stats.sess_hit++; |
| 424 | 459 | ||
| 425 | ret=1; | 460 | ret=1; |
| 426 | /* s->server=0; */ | 461 | /* s->server=0; */ |
| 427 | s->handshake_func=ssl3_connect; | 462 | s->handshake_func=ssl3_connect; |
| 428 | s->ctx->sess_connect_good++; | 463 | s->ctx->stats.sess_connect_good++; |
| 429 | 464 | ||
| 430 | if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_DONE,1); | 465 | if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_DONE,1); |
| 431 | 466 | ||
| 432 | goto end; | 467 | goto end; |
| 433 | break; | 468 | /* break; */ |
| 434 | 469 | ||
| 435 | default: | 470 | default: |
| 436 | SSLerr(SSL_F_SSL3_CONNECT,SSL_R_UNKNOWN_STATE); | 471 | SSLerr(SSL_F_SSL3_CONNECT,SSL_R_UNKNOWN_STATE); |
| @@ -459,26 +494,27 @@ SSL *s; | |||
| 459 | skip=0; | 494 | skip=0; |
| 460 | } | 495 | } |
| 461 | end: | 496 | end: |
| 497 | s->in_handshake--; | ||
| 462 | if (cb != NULL) | 498 | if (cb != NULL) |
| 463 | cb(s,SSL_CB_CONNECT_EXIT,ret); | 499 | cb(s,SSL_CB_CONNECT_EXIT,ret); |
| 464 | s->in_handshake--; | ||
| 465 | return(ret); | 500 | return(ret); |
| 466 | } | 501 | } |
| 467 | 502 | ||
| 468 | 503 | ||
| 469 | static int ssl3_client_hello(s) | 504 | static int ssl3_client_hello(SSL *s) |
| 470 | SSL *s; | ||
| 471 | { | 505 | { |
| 472 | unsigned char *buf; | 506 | unsigned char *buf; |
| 473 | unsigned char *p,*d; | 507 | unsigned char *p,*d; |
| 474 | int i; | 508 | int i,j; |
| 475 | unsigned long Time,l; | 509 | unsigned long Time,l; |
| 510 | SSL_COMP *comp; | ||
| 476 | 511 | ||
| 477 | buf=(unsigned char *)s->init_buf->data; | 512 | buf=(unsigned char *)s->init_buf->data; |
| 478 | if (s->state == SSL3_ST_CW_CLNT_HELLO_A) | 513 | if (s->state == SSL3_ST_CW_CLNT_HELLO_A) |
| 479 | { | 514 | { |
| 480 | if ((s->session == NULL) || | 515 | if ((s->session == NULL) || |
| 481 | (s->session->ssl_version != s->version)) | 516 | (s->session->ssl_version != s->version) || |
| 517 | (s->session->not_resumable)) | ||
| 482 | { | 518 | { |
| 483 | if (!ssl_get_new_session(s,0)) | 519 | if (!ssl_get_new_session(s,0)) |
| 484 | goto err; | 520 | goto err; |
| @@ -488,13 +524,14 @@ SSL *s; | |||
| 488 | p=s->s3->client_random; | 524 | p=s->s3->client_random; |
| 489 | Time=time(NULL); /* Time */ | 525 | Time=time(NULL); /* Time */ |
| 490 | l2n(Time,p); | 526 | l2n(Time,p); |
| 491 | RAND_bytes(&(p[4]),SSL3_RANDOM_SIZE-sizeof(Time)); | 527 | RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE-sizeof(Time)); |
| 492 | 528 | ||
| 493 | /* Do the message type and length last */ | 529 | /* Do the message type and length last */ |
| 494 | d=p= &(buf[4]); | 530 | d=p= &(buf[4]); |
| 495 | 531 | ||
| 496 | *(p++)=s->version>>8; | 532 | *(p++)=s->version>>8; |
| 497 | *(p++)=s->version&0xff; | 533 | *(p++)=s->version&0xff; |
| 534 | s->client_version=s->version; | ||
| 498 | 535 | ||
| 499 | /* Random stuff */ | 536 | /* Random stuff */ |
| 500 | memcpy(p,s->s3->client_random,SSL3_RANDOM_SIZE); | 537 | memcpy(p,s->s3->client_random,SSL3_RANDOM_SIZE); |
| @@ -522,9 +559,18 @@ SSL *s; | |||
| 522 | s2n(i,p); | 559 | s2n(i,p); |
| 523 | p+=i; | 560 | p+=i; |
| 524 | 561 | ||
| 525 | /* hardwire in the NULL compression algorithm. */ | 562 | /* COMPRESSION */ |
| 526 | *(p++)=1; | 563 | if (s->ctx->comp_methods == NULL) |
| 527 | *(p++)=0; | 564 | j=0; |
| 565 | else | ||
| 566 | j=sk_SSL_COMP_num(s->ctx->comp_methods); | ||
| 567 | *(p++)=1+j; | ||
| 568 | for (i=0; i<j; i++) | ||
| 569 | { | ||
| 570 | comp=sk_SSL_COMP_value(s->ctx->comp_methods,i); | ||
| 571 | *(p++)=comp->id; | ||
| 572 | } | ||
| 573 | *(p++)=0; /* Add the NULL method */ | ||
| 528 | 574 | ||
| 529 | l=(p-d); | 575 | l=(p-d); |
| 530 | d=buf; | 576 | d=buf; |
| @@ -543,15 +589,15 @@ err: | |||
| 543 | return(-1); | 589 | return(-1); |
| 544 | } | 590 | } |
| 545 | 591 | ||
| 546 | static int ssl3_get_server_hello(s) | 592 | static int ssl3_get_server_hello(SSL *s) |
| 547 | SSL *s; | ||
| 548 | { | 593 | { |
| 549 | STACK *sk; | 594 | STACK_OF(SSL_CIPHER) *sk; |
| 550 | SSL_CIPHER *c; | 595 | SSL_CIPHER *c; |
| 551 | unsigned char *p,*d; | 596 | unsigned char *p,*d; |
| 552 | int i,al,ok; | 597 | int i,al,ok; |
| 553 | unsigned int j; | 598 | unsigned int j; |
| 554 | long n; | 599 | long n; |
| 600 | SSL_COMP *comp; | ||
| 555 | 601 | ||
| 556 | n=ssl3_get_message(s, | 602 | n=ssl3_get_message(s, |
| 557 | SSL3_ST_CR_SRVR_HELLO_A, | 603 | SSL3_ST_CR_SRVR_HELLO_A, |
| @@ -561,7 +607,7 @@ SSL *s; | |||
| 561 | &ok); | 607 | &ok); |
| 562 | 608 | ||
| 563 | if (!ok) return((int)n); | 609 | if (!ok) return((int)n); |
| 564 | d=p=(unsigned char *)s->init_buf->data; | 610 | d=p=(unsigned char *)s->init_msg; |
| 565 | 611 | ||
| 566 | if ((p[0] != (s->version>>8)) || (p[1] != (s->version&0xff))) | 612 | if ((p[0] != (s->version>>8)) || (p[1] != (s->version&0xff))) |
| 567 | { | 613 | { |
| @@ -590,9 +636,18 @@ SSL *s; | |||
| 590 | goto f_err; | 636 | goto f_err; |
| 591 | } | 637 | } |
| 592 | } | 638 | } |
| 593 | if ((j != 0) && (j == s->session->session_id_length) && | 639 | if (j != 0 && j == s->session->session_id_length |
| 594 | (memcmp(p,s->session->session_id,j) == 0)) | 640 | && memcmp(p,s->session->session_id,j) == 0) |
| 595 | s->hit=1; | 641 | { |
| 642 | if(s->sid_ctx_length != s->session->sid_ctx_length | ||
| 643 | || memcmp(s->session->sid_ctx,s->sid_ctx,s->sid_ctx_length)) | ||
| 644 | { | ||
| 645 | al=SSL_AD_ILLEGAL_PARAMETER; | ||
| 646 | SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT); | ||
| 647 | goto f_err; | ||
| 648 | } | ||
| 649 | s->hit=1; | ||
| 650 | } | ||
| 596 | else /* a miss or crap from the other end */ | 651 | else /* a miss or crap from the other end */ |
| 597 | { | 652 | { |
| 598 | /* If we were trying for session-id reuse, make a new | 653 | /* If we were trying for session-id reuse, make a new |
| @@ -621,7 +676,7 @@ SSL *s; | |||
| 621 | p+=ssl_put_cipher_by_char(s,NULL,NULL); | 676 | p+=ssl_put_cipher_by_char(s,NULL,NULL); |
| 622 | 677 | ||
| 623 | sk=ssl_get_ciphers_by_id(s); | 678 | sk=ssl_get_ciphers_by_id(s); |
| 624 | i=sk_find(sk,(char *)c); | 679 | i=sk_SSL_CIPHER_find(sk,c); |
| 625 | if (i < 0) | 680 | if (i < 0) |
| 626 | { | 681 | { |
| 627 | /* we did not say we would use this cipher */ | 682 | /* we did not say we would use this cipher */ |
| @@ -643,13 +698,23 @@ SSL *s; | |||
| 643 | s->s3->tmp.new_cipher=c; | 698 | s->s3->tmp.new_cipher=c; |
| 644 | 699 | ||
| 645 | /* lets get the compression algorithm */ | 700 | /* lets get the compression algorithm */ |
| 701 | /* COMPRESSION */ | ||
| 646 | j= *(p++); | 702 | j= *(p++); |
| 647 | if (j != 0) | 703 | if (j == 0) |
| 704 | comp=NULL; | ||
| 705 | else | ||
| 706 | comp=ssl3_comp_find(s->ctx->comp_methods,j); | ||
| 707 | |||
| 708 | if ((j != 0) && (comp == NULL)) | ||
| 648 | { | 709 | { |
| 649 | al=SSL_AD_ILLEGAL_PARAMETER; | 710 | al=SSL_AD_ILLEGAL_PARAMETER; |
| 650 | SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM); | 711 | SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM); |
| 651 | goto f_err; | 712 | goto f_err; |
| 652 | } | 713 | } |
| 714 | else | ||
| 715 | { | ||
| 716 | s->s3->tmp.new_compression=comp; | ||
| 717 | } | ||
| 653 | 718 | ||
| 654 | if (p != (d+n)) | 719 | if (p != (d+n)) |
| 655 | { | 720 | { |
| @@ -666,26 +731,22 @@ err: | |||
| 666 | return(-1); | 731 | return(-1); |
| 667 | } | 732 | } |
| 668 | 733 | ||
| 669 | static int ssl3_get_server_certificate(s) | 734 | static int ssl3_get_server_certificate(SSL *s) |
| 670 | SSL *s; | ||
| 671 | { | 735 | { |
| 672 | int al,i,ok,ret= -1; | 736 | int al,i,ok,ret= -1; |
| 673 | unsigned long n,nc,llen,l; | 737 | unsigned long n,nc,llen,l; |
| 674 | X509 *x=NULL; | 738 | X509 *x=NULL; |
| 675 | unsigned char *p,*d,*q; | 739 | unsigned char *p,*d,*q; |
| 676 | STACK *sk=NULL; | 740 | STACK_OF(X509) *sk=NULL; |
| 677 | CERT *c; | 741 | SESS_CERT *sc; |
| 678 | EVP_PKEY *pkey=NULL; | 742 | EVP_PKEY *pkey=NULL; |
| 743 | int need_cert = 1; /* VRS: 0=> will allow null cert if auth == KRB5 */ | ||
| 679 | 744 | ||
| 680 | n=ssl3_get_message(s, | 745 | n=ssl3_get_message(s, |
| 681 | SSL3_ST_CR_CERT_A, | 746 | SSL3_ST_CR_CERT_A, |
| 682 | SSL3_ST_CR_CERT_B, | 747 | SSL3_ST_CR_CERT_B, |
| 683 | -1, | 748 | -1, |
| 684 | #if defined(MSDOS) && !defined(WIN32) | 749 | s->max_cert_list, |
| 685 | 1024*30, /* 30k max cert list :-) */ | ||
| 686 | #else | ||
| 687 | 1024*100, /* 100k max cert list :-) */ | ||
| 688 | #endif | ||
| 689 | &ok); | 750 | &ok); |
| 690 | 751 | ||
| 691 | if (!ok) return((int)n); | 752 | if (!ok) return((int)n); |
| @@ -702,9 +763,9 @@ SSL *s; | |||
| 702 | SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_BAD_MESSAGE_TYPE); | 763 | SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_BAD_MESSAGE_TYPE); |
| 703 | goto f_err; | 764 | goto f_err; |
| 704 | } | 765 | } |
| 705 | d=p=(unsigned char *)s->init_buf->data; | 766 | d=p=(unsigned char *)s->init_msg; |
| 706 | 767 | ||
| 707 | if ((sk=sk_new_null()) == NULL) | 768 | if ((sk=sk_X509_new_null()) == NULL) |
| 708 | { | 769 | { |
| 709 | SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,ERR_R_MALLOC_FAILURE); | 770 | SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,ERR_R_MALLOC_FAILURE); |
| 710 | goto err; | 771 | goto err; |
| @@ -741,7 +802,7 @@ SSL *s; | |||
| 741 | SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_CERT_LENGTH_MISMATCH); | 802 | SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_CERT_LENGTH_MISMATCH); |
| 742 | goto f_err; | 803 | goto f_err; |
| 743 | } | 804 | } |
| 744 | if (!sk_push(sk,(char *)x)) | 805 | if (!sk_X509_push(sk,x)) |
| 745 | { | 806 | { |
| 746 | SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,ERR_R_MALLOC_FAILURE); | 807 | SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,ERR_R_MALLOC_FAILURE); |
| 747 | goto err; | 808 | goto err; |
| @@ -752,53 +813,91 @@ SSL *s; | |||
| 752 | } | 813 | } |
| 753 | 814 | ||
| 754 | i=ssl_verify_cert_chain(s,sk); | 815 | i=ssl_verify_cert_chain(s,sk); |
| 755 | if ((s->verify_mode != SSL_VERIFY_NONE) && (!i)) | 816 | if ((s->verify_mode != SSL_VERIFY_NONE) && (!i) |
| 817 | #ifndef OPENSSL_NO_KRB5 | ||
| 818 | && (s->s3->tmp.new_cipher->algorithms & (SSL_MKEY_MASK|SSL_AUTH_MASK)) | ||
| 819 | != (SSL_aKRB5|SSL_kKRB5) | ||
| 820 | #endif /* OPENSSL_NO_KRB5 */ | ||
| 821 | ) | ||
| 756 | { | 822 | { |
| 757 | al=ssl_verify_alarm_type(s->verify_result); | 823 | al=ssl_verify_alarm_type(s->verify_result); |
| 758 | SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_CERTIFICATE_VERIFY_FAILED); | 824 | SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_CERTIFICATE_VERIFY_FAILED); |
| 759 | goto f_err; | 825 | goto f_err; |
| 760 | } | 826 | } |
| 827 | ERR_clear_error(); /* but we keep s->verify_result */ | ||
| 761 | 828 | ||
| 762 | c=ssl_cert_new(); | 829 | sc=ssl_sess_cert_new(); |
| 763 | if (c == NULL) goto err; | 830 | if (sc == NULL) goto err; |
| 764 | 831 | ||
| 765 | if (s->session->cert) ssl_cert_free(s->session->cert); | 832 | if (s->session->sess_cert) ssl_sess_cert_free(s->session->sess_cert); |
| 766 | s->session->cert=c; | 833 | s->session->sess_cert=sc; |
| 767 | 834 | ||
| 768 | c->cert_chain=sk; | 835 | sc->cert_chain=sk; |
| 769 | x=(X509 *)sk_value(sk,0); | 836 | /* Inconsistency alert: cert_chain does include the peer's |
| 837 | * certificate, which we don't include in s3_srvr.c */ | ||
| 838 | x=sk_X509_value(sk,0); | ||
| 770 | sk=NULL; | 839 | sk=NULL; |
| 840 | /* VRS 19990621: possible memory leak; sk=null ==> !sk_pop_free() @end*/ | ||
| 771 | 841 | ||
| 772 | pkey=X509_get_pubkey(x); | 842 | pkey=X509_get_pubkey(x); |
| 773 | 843 | ||
| 774 | if (EVP_PKEY_missing_parameters(pkey)) | 844 | /* VRS: allow null cert if auth == KRB5 */ |
| 845 | need_cert = ((s->s3->tmp.new_cipher->algorithms | ||
| 846 | & (SSL_MKEY_MASK|SSL_AUTH_MASK)) | ||
| 847 | == (SSL_aKRB5|SSL_kKRB5))? 0: 1; | ||
| 848 | |||
| 849 | #ifdef KSSL_DEBUG | ||
| 850 | printf("pkey,x = %p, %p\n", pkey,x); | ||
| 851 | printf("ssl_cert_type(x,pkey) = %d\n", ssl_cert_type(x,pkey)); | ||
| 852 | printf("cipher, alg, nc = %s, %lx, %d\n", s->s3->tmp.new_cipher->name, | ||
| 853 | s->s3->tmp.new_cipher->algorithms, need_cert); | ||
| 854 | #endif /* KSSL_DEBUG */ | ||
| 855 | |||
| 856 | if (need_cert && ((pkey == NULL) || EVP_PKEY_missing_parameters(pkey))) | ||
| 775 | { | 857 | { |
| 776 | x=NULL; | 858 | x=NULL; |
| 777 | al=SSL3_AL_FATAL; | 859 | al=SSL3_AL_FATAL; |
| 778 | SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS); | 860 | SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, |
| 861 | SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS); | ||
| 779 | goto f_err; | 862 | goto f_err; |
| 780 | } | 863 | } |
| 781 | 864 | ||
| 782 | i=ssl_cert_type(x,pkey); | 865 | i=ssl_cert_type(x,pkey); |
| 783 | if (i < 0) | 866 | if (need_cert && i < 0) |
| 784 | { | 867 | { |
| 785 | x=NULL; | 868 | x=NULL; |
| 786 | al=SSL3_AL_FATAL; | 869 | al=SSL3_AL_FATAL; |
| 787 | SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_UNKNOWN_CERTIFICATE_TYPE); | 870 | SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, |
| 871 | SSL_R_UNKNOWN_CERTIFICATE_TYPE); | ||
| 788 | goto f_err; | 872 | goto f_err; |
| 789 | } | 873 | } |
| 790 | 874 | ||
| 791 | c->cert_type=i; | 875 | if (need_cert) |
| 792 | CRYPTO_add(&x->references,1,CRYPTO_LOCK_X509); | 876 | { |
| 793 | if (c->pkeys[i].x509 != NULL) | 877 | sc->peer_cert_type=i; |
| 794 | X509_free(c->pkeys[i].x509); | 878 | CRYPTO_add(&x->references,1,CRYPTO_LOCK_X509); |
| 795 | c->pkeys[i].x509=x; | 879 | /* Why would the following ever happen? |
| 796 | c->key= &(c->pkeys[i]); | 880 | * We just created sc a couple of lines ago. */ |
| 797 | 881 | if (sc->peer_pkeys[i].x509 != NULL) | |
| 798 | if ((s->session != NULL) && (s->session->peer != NULL)) | 882 | X509_free(sc->peer_pkeys[i].x509); |
| 799 | X509_free(s->session->peer); | 883 | sc->peer_pkeys[i].x509=x; |
| 800 | CRYPTO_add(&x->references,1,CRYPTO_LOCK_X509); | 884 | sc->peer_key= &(sc->peer_pkeys[i]); |
| 801 | s->session->peer=x; | 885 | |
| 886 | if (s->session->peer != NULL) | ||
| 887 | X509_free(s->session->peer); | ||
| 888 | CRYPTO_add(&x->references,1,CRYPTO_LOCK_X509); | ||
| 889 | s->session->peer=x; | ||
| 890 | } | ||
| 891 | else | ||
| 892 | { | ||
| 893 | sc->peer_cert_type=i; | ||
| 894 | sc->peer_key= NULL; | ||
| 895 | |||
| 896 | if (s->session->peer != NULL) | ||
| 897 | X509_free(s->session->peer); | ||
| 898 | s->session->peer=NULL; | ||
| 899 | } | ||
| 900 | s->session->verify_result = s->verify_result; | ||
| 802 | 901 | ||
| 803 | x=NULL; | 902 | x=NULL; |
| 804 | ret=1; | 903 | ret=1; |
| @@ -809,15 +908,15 @@ f_err: | |||
| 809 | ssl3_send_alert(s,SSL3_AL_FATAL,al); | 908 | ssl3_send_alert(s,SSL3_AL_FATAL,al); |
| 810 | } | 909 | } |
| 811 | err: | 910 | err: |
| 812 | if (x != NULL) X509_free(x); | 911 | EVP_PKEY_free(pkey); |
| 813 | if (sk != NULL) sk_pop_free(sk,X509_free); | 912 | X509_free(x); |
| 913 | sk_X509_pop_free(sk,X509_free); | ||
| 814 | return(ret); | 914 | return(ret); |
| 815 | } | 915 | } |
| 816 | 916 | ||
| 817 | static int ssl3_get_key_exchange(s) | 917 | static int ssl3_get_key_exchange(SSL *s) |
| 818 | SSL *s; | ||
| 819 | { | 918 | { |
| 820 | #ifndef NO_RSA | 919 | #ifndef OPENSSL_NO_RSA |
| 821 | unsigned char *q,md_buf[EVP_MAX_MD_SIZE*2]; | 920 | unsigned char *q,md_buf[EVP_MAX_MD_SIZE*2]; |
| 822 | #endif | 921 | #endif |
| 823 | EVP_MD_CTX md_ctx; | 922 | EVP_MD_CTX md_ctx; |
| @@ -825,16 +924,20 @@ SSL *s; | |||
| 825 | int al,i,j,param_len,ok; | 924 | int al,i,j,param_len,ok; |
| 826 | long n,alg; | 925 | long n,alg; |
| 827 | EVP_PKEY *pkey=NULL; | 926 | EVP_PKEY *pkey=NULL; |
| 927 | #ifndef OPENSSL_NO_RSA | ||
| 828 | RSA *rsa=NULL; | 928 | RSA *rsa=NULL; |
| 829 | #ifndef NO_DH | 929 | #endif |
| 930 | #ifndef OPENSSL_NO_DH | ||
| 830 | DH *dh=NULL; | 931 | DH *dh=NULL; |
| 831 | #endif | 932 | #endif |
| 832 | 933 | ||
| 934 | /* use same message size as in ssl3_get_certificate_request() | ||
| 935 | * as ServerKeyExchange message may be skipped */ | ||
| 833 | n=ssl3_get_message(s, | 936 | n=ssl3_get_message(s, |
| 834 | SSL3_ST_CR_KEY_EXCH_A, | 937 | SSL3_ST_CR_KEY_EXCH_A, |
| 835 | SSL3_ST_CR_KEY_EXCH_B, | 938 | SSL3_ST_CR_KEY_EXCH_B, |
| 836 | -1, | 939 | -1, |
| 837 | 1024*8, /* ?? */ | 940 | s->max_cert_list, |
| 838 | &ok); | 941 | &ok); |
| 839 | 942 | ||
| 840 | if (!ok) return((int)n); | 943 | if (!ok) return((int)n); |
| @@ -845,34 +948,35 @@ SSL *s; | |||
| 845 | return(1); | 948 | return(1); |
| 846 | } | 949 | } |
| 847 | 950 | ||
| 848 | param=p=(unsigned char *)s->init_buf->data; | 951 | param=p=(unsigned char *)s->init_msg; |
| 849 | 952 | ||
| 850 | if (s->session->cert != NULL) | 953 | if (s->session->sess_cert != NULL) |
| 851 | { | 954 | { |
| 852 | #ifndef NO_RSA | 955 | #ifndef OPENSSL_NO_RSA |
| 853 | if (s->session->cert->rsa_tmp != NULL) | 956 | if (s->session->sess_cert->peer_rsa_tmp != NULL) |
| 854 | { | 957 | { |
| 855 | RSA_free(s->session->cert->rsa_tmp); | 958 | RSA_free(s->session->sess_cert->peer_rsa_tmp); |
| 856 | s->session->cert->rsa_tmp=NULL; | 959 | s->session->sess_cert->peer_rsa_tmp=NULL; |
| 857 | } | 960 | } |
| 858 | #endif | 961 | #endif |
| 859 | #ifndef NO_DH | 962 | #ifndef OPENSSL_NO_DH |
| 860 | if (s->session->cert->dh_tmp) | 963 | if (s->session->sess_cert->peer_dh_tmp) |
| 861 | { | 964 | { |
| 862 | DH_free(s->session->cert->dh_tmp); | 965 | DH_free(s->session->sess_cert->peer_dh_tmp); |
| 863 | s->session->cert->dh_tmp=NULL; | 966 | s->session->sess_cert->peer_dh_tmp=NULL; |
| 864 | } | 967 | } |
| 865 | #endif | 968 | #endif |
| 866 | } | 969 | } |
| 867 | else | 970 | else |
| 868 | { | 971 | { |
| 869 | s->session->cert=ssl_cert_new(); | 972 | s->session->sess_cert=ssl_sess_cert_new(); |
| 870 | } | 973 | } |
| 871 | 974 | ||
| 872 | param_len=0; | 975 | param_len=0; |
| 873 | alg=s->s3->tmp.new_cipher->algorithms; | 976 | alg=s->s3->tmp.new_cipher->algorithms; |
| 977 | EVP_MD_CTX_init(&md_ctx); | ||
| 874 | 978 | ||
| 875 | #ifndef NO_RSA | 979 | #ifndef OPENSSL_NO_RSA |
| 876 | if (alg & SSL_kRSA) | 980 | if (alg & SSL_kRSA) |
| 877 | { | 981 | { |
| 878 | if ((rsa=RSA_new()) == NULL) | 982 | if ((rsa=RSA_new()) == NULL) |
| @@ -911,21 +1015,23 @@ SSL *s; | |||
| 911 | p+=i; | 1015 | p+=i; |
| 912 | n-=param_len; | 1016 | n-=param_len; |
| 913 | 1017 | ||
| 914 | /* s->session->cert->rsa_tmp=rsa;*/ | ||
| 915 | /* this should be because we are using an export cipher */ | 1018 | /* this should be because we are using an export cipher */ |
| 916 | if (alg & SSL_aRSA) | 1019 | if (alg & SSL_aRSA) |
| 917 | pkey=X509_get_pubkey(s->session->cert->pkeys[SSL_PKEY_RSA_ENC].x509); | 1020 | pkey=X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_RSA_ENC].x509); |
| 918 | else | 1021 | else |
| 919 | { | 1022 | { |
| 920 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_INTERNAL_ERROR); | 1023 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,ERR_R_INTERNAL_ERROR); |
| 921 | goto err; | 1024 | goto err; |
| 922 | } | 1025 | } |
| 923 | s->session->cert->rsa_tmp=rsa; | 1026 | s->session->sess_cert->peer_rsa_tmp=rsa; |
| 1027 | rsa=NULL; | ||
| 924 | } | 1028 | } |
| 925 | else | 1029 | #else /* OPENSSL_NO_RSA */ |
| 1030 | if (0) | ||
| 1031 | ; | ||
| 926 | #endif | 1032 | #endif |
| 927 | #ifndef NO_DH | 1033 | #ifndef OPENSSL_NO_DH |
| 928 | if (alg & SSL_kEDH) | 1034 | else if (alg & SSL_kEDH) |
| 929 | { | 1035 | { |
| 930 | if ((dh=DH_new()) == NULL) | 1036 | if ((dh=DH_new()) == NULL) |
| 931 | { | 1037 | { |
| @@ -978,18 +1084,21 @@ SSL *s; | |||
| 978 | p+=i; | 1084 | p+=i; |
| 979 | n-=param_len; | 1085 | n-=param_len; |
| 980 | 1086 | ||
| 981 | #ifndef NO_RSA | 1087 | #ifndef OPENSSL_NO_RSA |
| 982 | if (alg & SSL_aRSA) | 1088 | if (alg & SSL_aRSA) |
| 983 | pkey=X509_get_pubkey(s->session->cert->pkeys[SSL_PKEY_RSA_ENC].x509); | 1089 | pkey=X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_RSA_ENC].x509); |
| 984 | else | 1090 | #else |
| 1091 | if (0) | ||
| 1092 | ; | ||
| 985 | #endif | 1093 | #endif |
| 986 | #ifndef NO_DSA | 1094 | #ifndef OPENSSL_NO_DSA |
| 987 | if (alg & SSL_aDSS) | 1095 | else if (alg & SSL_aDSS) |
| 988 | pkey=X509_get_pubkey(s->session->cert->pkeys[SSL_PKEY_DSA_SIGN].x509); | 1096 | pkey=X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_DSA_SIGN].x509); |
| 989 | #endif | 1097 | #endif |
| 990 | /* else anonymous DH, so no certificate or pkey. */ | 1098 | /* else anonymous DH, so no certificate or pkey. */ |
| 991 | 1099 | ||
| 992 | s->session->cert->dh_tmp=dh; | 1100 | s->session->sess_cert->peer_dh_tmp=dh; |
| 1101 | dh=NULL; | ||
| 993 | } | 1102 | } |
| 994 | else if ((alg & SSL_kDHr) || (alg & SSL_kDHd)) | 1103 | else if ((alg & SSL_kDHr) || (alg & SSL_kDHd)) |
| 995 | { | 1104 | { |
| @@ -997,7 +1106,14 @@ SSL *s; | |||
| 997 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_TRIED_TO_USE_UNSUPPORTED_CIPHER); | 1106 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_TRIED_TO_USE_UNSUPPORTED_CIPHER); |
| 998 | goto f_err; | 1107 | goto f_err; |
| 999 | } | 1108 | } |
| 1000 | #endif | 1109 | #endif /* !OPENSSL_NO_DH */ |
| 1110 | if (alg & SSL_aFZA) | ||
| 1111 | { | ||
| 1112 | al=SSL_AD_HANDSHAKE_FAILURE; | ||
| 1113 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_TRIED_TO_USE_UNSUPPORTED_CIPHER); | ||
| 1114 | goto f_err; | ||
| 1115 | } | ||
| 1116 | |||
| 1001 | 1117 | ||
| 1002 | /* p points to the next byte, there are 'n' bytes left */ | 1118 | /* p points to the next byte, there are 'n' bytes left */ |
| 1003 | 1119 | ||
| @@ -1014,10 +1130,10 @@ SSL *s; | |||
| 1014 | /* wrong packet length */ | 1130 | /* wrong packet length */ |
| 1015 | al=SSL_AD_DECODE_ERROR; | 1131 | al=SSL_AD_DECODE_ERROR; |
| 1016 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_WRONG_SIGNATURE_LENGTH); | 1132 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_WRONG_SIGNATURE_LENGTH); |
| 1017 | goto err; | 1133 | goto f_err; |
| 1018 | } | 1134 | } |
| 1019 | 1135 | ||
| 1020 | #ifndef NO_RSA | 1136 | #ifndef OPENSSL_NO_RSA |
| 1021 | if (pkey->type == EVP_PKEY_RSA) | 1137 | if (pkey->type == EVP_PKEY_RSA) |
| 1022 | { | 1138 | { |
| 1023 | int num; | 1139 | int num; |
| @@ -1026,24 +1142,24 @@ SSL *s; | |||
| 1026 | q=md_buf; | 1142 | q=md_buf; |
| 1027 | for (num=2; num > 0; num--) | 1143 | for (num=2; num > 0; num--) |
| 1028 | { | 1144 | { |
| 1029 | EVP_DigestInit(&md_ctx,(num == 2) | 1145 | EVP_DigestInit_ex(&md_ctx,(num == 2) |
| 1030 | ?s->ctx->md5:s->ctx->sha1); | 1146 | ?s->ctx->md5:s->ctx->sha1, NULL); |
| 1031 | EVP_DigestUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE); | 1147 | EVP_DigestUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE); |
| 1032 | EVP_DigestUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE); | 1148 | EVP_DigestUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE); |
| 1033 | EVP_DigestUpdate(&md_ctx,param,param_len); | 1149 | EVP_DigestUpdate(&md_ctx,param,param_len); |
| 1034 | EVP_DigestFinal(&md_ctx,q,(unsigned int *)&i); | 1150 | EVP_DigestFinal_ex(&md_ctx,q,(unsigned int *)&i); |
| 1035 | q+=i; | 1151 | q+=i; |
| 1036 | j+=i; | 1152 | j+=i; |
| 1037 | } | 1153 | } |
| 1038 | i=RSA_public_decrypt((int)n,p,p,pkey->pkey.rsa, | 1154 | i=RSA_verify(NID_md5_sha1, md_buf, j, p, n, |
| 1039 | RSA_PKCS1_PADDING); | 1155 | pkey->pkey.rsa); |
| 1040 | if (i <= 0) | 1156 | if (i < 0) |
| 1041 | { | 1157 | { |
| 1042 | al=SSL_AD_DECRYPT_ERROR; | 1158 | al=SSL_AD_DECRYPT_ERROR; |
| 1043 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_BAD_RSA_DECRYPT); | 1159 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_BAD_RSA_DECRYPT); |
| 1044 | goto f_err; | 1160 | goto f_err; |
| 1045 | } | 1161 | } |
| 1046 | if ((j != i) || (memcmp(p,md_buf,i) != 0)) | 1162 | if (i == 0) |
| 1047 | { | 1163 | { |
| 1048 | /* bad signature */ | 1164 | /* bad signature */ |
| 1049 | al=SSL_AD_DECRYPT_ERROR; | 1165 | al=SSL_AD_DECRYPT_ERROR; |
| @@ -1053,11 +1169,11 @@ SSL *s; | |||
| 1053 | } | 1169 | } |
| 1054 | else | 1170 | else |
| 1055 | #endif | 1171 | #endif |
| 1056 | #ifndef NO_DSA | 1172 | #ifndef OPENSSL_NO_DSA |
| 1057 | if (pkey->type == EVP_PKEY_DSA) | 1173 | if (pkey->type == EVP_PKEY_DSA) |
| 1058 | { | 1174 | { |
| 1059 | /* lets do DSS */ | 1175 | /* lets do DSS */ |
| 1060 | EVP_VerifyInit(&md_ctx,EVP_dss1()); | 1176 | EVP_VerifyInit_ex(&md_ctx,EVP_dss1(), NULL); |
| 1061 | EVP_VerifyUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE); | 1177 | EVP_VerifyUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE); |
| 1062 | EVP_VerifyUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE); | 1178 | EVP_VerifyUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE); |
| 1063 | EVP_VerifyUpdate(&md_ctx,param,param_len); | 1179 | EVP_VerifyUpdate(&md_ctx,param,param_len); |
| @@ -1072,7 +1188,7 @@ SSL *s; | |||
| 1072 | else | 1188 | else |
| 1073 | #endif | 1189 | #endif |
| 1074 | { | 1190 | { |
| 1075 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_INTERNAL_ERROR); | 1191 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,ERR_R_INTERNAL_ERROR); |
| 1076 | goto err; | 1192 | goto err; |
| 1077 | } | 1193 | } |
| 1078 | } | 1194 | } |
| @@ -1081,7 +1197,7 @@ SSL *s; | |||
| 1081 | /* still data left over */ | 1197 | /* still data left over */ |
| 1082 | if (!(alg & SSL_aNULL)) | 1198 | if (!(alg & SSL_aNULL)) |
| 1083 | { | 1199 | { |
| 1084 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,SSL_R_INTERNAL_ERROR); | 1200 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,ERR_R_INTERNAL_ERROR); |
| 1085 | goto err; | 1201 | goto err; |
| 1086 | } | 1202 | } |
| 1087 | if (n != 0) | 1203 | if (n != 0) |
| @@ -1091,33 +1207,39 @@ SSL *s; | |||
| 1091 | goto f_err; | 1207 | goto f_err; |
| 1092 | } | 1208 | } |
| 1093 | } | 1209 | } |
| 1094 | 1210 | EVP_PKEY_free(pkey); | |
| 1211 | EVP_MD_CTX_cleanup(&md_ctx); | ||
| 1095 | return(1); | 1212 | return(1); |
| 1096 | f_err: | 1213 | f_err: |
| 1097 | ssl3_send_alert(s,SSL3_AL_FATAL,al); | 1214 | ssl3_send_alert(s,SSL3_AL_FATAL,al); |
| 1098 | err: | 1215 | err: |
| 1216 | EVP_PKEY_free(pkey); | ||
| 1217 | #ifndef OPENSSL_NO_RSA | ||
| 1218 | if (rsa != NULL) | ||
| 1219 | RSA_free(rsa); | ||
| 1220 | #endif | ||
| 1221 | #ifndef OPENSSL_NO_DH | ||
| 1222 | if (dh != NULL) | ||
| 1223 | DH_free(dh); | ||
| 1224 | #endif | ||
| 1225 | EVP_MD_CTX_cleanup(&md_ctx); | ||
| 1099 | return(-1); | 1226 | return(-1); |
| 1100 | } | 1227 | } |
| 1101 | 1228 | ||
| 1102 | static int ssl3_get_certificate_request(s) | 1229 | static int ssl3_get_certificate_request(SSL *s) |
| 1103 | SSL *s; | ||
| 1104 | { | 1230 | { |
| 1105 | int ok,ret=0; | 1231 | int ok,ret=0; |
| 1106 | unsigned long n,nc,l; | 1232 | unsigned long n,nc,l; |
| 1107 | unsigned int llen,ctype_num,i; | 1233 | unsigned int llen,ctype_num,i; |
| 1108 | X509_NAME *xn=NULL; | 1234 | X509_NAME *xn=NULL; |
| 1109 | unsigned char *p,*d,*q; | 1235 | unsigned char *p,*d,*q; |
| 1110 | STACK *ca_sk=NULL; | 1236 | STACK_OF(X509_NAME) *ca_sk=NULL; |
| 1111 | 1237 | ||
| 1112 | n=ssl3_get_message(s, | 1238 | n=ssl3_get_message(s, |
| 1113 | SSL3_ST_CR_CERT_REQ_A, | 1239 | SSL3_ST_CR_CERT_REQ_A, |
| 1114 | SSL3_ST_CR_CERT_REQ_B, | 1240 | SSL3_ST_CR_CERT_REQ_B, |
| 1115 | -1, | 1241 | -1, |
| 1116 | #if defined(MSDOS) && !defined(WIN32) | 1242 | s->max_cert_list, |
| 1117 | 1024*30, /* 30k max cert list :-) */ | ||
| 1118 | #else | ||
| 1119 | 1024*100, /* 100k max cert list :-) */ | ||
| 1120 | #endif | ||
| 1121 | &ok); | 1243 | &ok); |
| 1122 | 1244 | ||
| 1123 | if (!ok) return((int)n); | 1245 | if (!ok) return((int)n); |
| @@ -1149,9 +1271,9 @@ SSL *s; | |||
| 1149 | } | 1271 | } |
| 1150 | } | 1272 | } |
| 1151 | 1273 | ||
| 1152 | d=p=(unsigned char *)s->init_buf->data; | 1274 | d=p=(unsigned char *)s->init_msg; |
| 1153 | 1275 | ||
| 1154 | if ((ca_sk=sk_new(ca_dn_cmp)) == NULL) | 1276 | if ((ca_sk=sk_X509_NAME_new(ca_dn_cmp)) == NULL) |
| 1155 | { | 1277 | { |
| 1156 | SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST,ERR_R_MALLOC_FAILURE); | 1278 | SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST,ERR_R_MALLOC_FAILURE); |
| 1157 | goto err; | 1279 | goto err; |
| @@ -1167,6 +1289,15 @@ SSL *s; | |||
| 1167 | 1289 | ||
| 1168 | /* get the CA RDNs */ | 1290 | /* get the CA RDNs */ |
| 1169 | n2s(p,llen); | 1291 | n2s(p,llen); |
| 1292 | #if 0 | ||
| 1293 | { | ||
| 1294 | FILE *out; | ||
| 1295 | out=fopen("/tmp/vsign.der","w"); | ||
| 1296 | fwrite(p,1,llen,out); | ||
| 1297 | fclose(out); | ||
| 1298 | } | ||
| 1299 | #endif | ||
| 1300 | |||
| 1170 | if ((llen+ctype_num+2+1) != n) | 1301 | if ((llen+ctype_num+2+1) != n) |
| 1171 | { | 1302 | { |
| 1172 | ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECODE_ERROR); | 1303 | ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECODE_ERROR); |
| @@ -1190,7 +1321,7 @@ SSL *s; | |||
| 1190 | 1321 | ||
| 1191 | if ((xn=d2i_X509_NAME(NULL,&q,l)) == NULL) | 1322 | if ((xn=d2i_X509_NAME(NULL,&q,l)) == NULL) |
| 1192 | { | 1323 | { |
| 1193 | /* If netscape tollerance is on, ignore errors */ | 1324 | /* If netscape tolerance is on, ignore errors */ |
| 1194 | if (s->options & SSL_OP_NETSCAPE_CA_DN_BUG) | 1325 | if (s->options & SSL_OP_NETSCAPE_CA_DN_BUG) |
| 1195 | goto cont; | 1326 | goto cont; |
| 1196 | else | 1327 | else |
| @@ -1207,7 +1338,7 @@ SSL *s; | |||
| 1207 | SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST,SSL_R_CA_DN_LENGTH_MISMATCH); | 1338 | SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST,SSL_R_CA_DN_LENGTH_MISMATCH); |
| 1208 | goto err; | 1339 | goto err; |
| 1209 | } | 1340 | } |
| 1210 | if (!sk_push(ca_sk,(char *)xn)) | 1341 | if (!sk_X509_NAME_push(ca_sk,xn)) |
| 1211 | { | 1342 | { |
| 1212 | SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST,ERR_R_MALLOC_FAILURE); | 1343 | SSLerr(SSL_F_SSL3_GET_CERTIFICATE_REQUEST,ERR_R_MALLOC_FAILURE); |
| 1213 | goto err; | 1344 | goto err; |
| @@ -1223,28 +1354,26 @@ cont: | |||
| 1223 | ERR_clear_error(); | 1354 | ERR_clear_error(); |
| 1224 | } | 1355 | } |
| 1225 | 1356 | ||
| 1226 | /* we should setup a certficate to return.... */ | 1357 | /* we should setup a certificate to return.... */ |
| 1227 | s->s3->tmp.cert_req=1; | 1358 | s->s3->tmp.cert_req=1; |
| 1228 | s->s3->tmp.ctype_num=ctype_num; | 1359 | s->s3->tmp.ctype_num=ctype_num; |
| 1229 | if (s->s3->tmp.ca_names != NULL) | 1360 | if (s->s3->tmp.ca_names != NULL) |
| 1230 | sk_pop_free(s->s3->tmp.ca_names,X509_NAME_free); | 1361 | sk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free); |
| 1231 | s->s3->tmp.ca_names=ca_sk; | 1362 | s->s3->tmp.ca_names=ca_sk; |
| 1232 | ca_sk=NULL; | 1363 | ca_sk=NULL; |
| 1233 | 1364 | ||
| 1234 | ret=1; | 1365 | ret=1; |
| 1235 | err: | 1366 | err: |
| 1236 | if (ca_sk != NULL) sk_pop_free(ca_sk,X509_NAME_free); | 1367 | if (ca_sk != NULL) sk_X509_NAME_pop_free(ca_sk,X509_NAME_free); |
| 1237 | return(ret); | 1368 | return(ret); |
| 1238 | } | 1369 | } |
| 1239 | 1370 | ||
| 1240 | static int ca_dn_cmp(a,b) | 1371 | static int ca_dn_cmp(const X509_NAME * const *a, const X509_NAME * const *b) |
| 1241 | X509_NAME **a,**b; | ||
| 1242 | { | 1372 | { |
| 1243 | return(X509_NAME_cmp(*a,*b)); | 1373 | return(X509_NAME_cmp(*a,*b)); |
| 1244 | } | 1374 | } |
| 1245 | 1375 | ||
| 1246 | static int ssl3_get_server_done(s) | 1376 | static int ssl3_get_server_done(SSL *s) |
| 1247 | SSL *s; | ||
| 1248 | { | 1377 | { |
| 1249 | int ok,ret=0; | 1378 | int ok,ret=0; |
| 1250 | long n; | 1379 | long n; |
| @@ -1262,18 +1391,24 @@ SSL *s; | |||
| 1262 | /* should contain no data */ | 1391 | /* should contain no data */ |
| 1263 | ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECODE_ERROR); | 1392 | ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECODE_ERROR); |
| 1264 | SSLerr(SSL_F_SSL3_GET_SERVER_DONE,SSL_R_LENGTH_MISMATCH); | 1393 | SSLerr(SSL_F_SSL3_GET_SERVER_DONE,SSL_R_LENGTH_MISMATCH); |
| 1394 | return -1; | ||
| 1265 | } | 1395 | } |
| 1266 | ret=1; | 1396 | ret=1; |
| 1267 | return(ret); | 1397 | return(ret); |
| 1268 | } | 1398 | } |
| 1269 | 1399 | ||
| 1270 | static int ssl3_send_client_key_exchange(s) | 1400 | static int ssl3_send_client_key_exchange(SSL *s) |
| 1271 | SSL *s; | ||
| 1272 | { | 1401 | { |
| 1273 | unsigned char *p,*q,*d; | 1402 | unsigned char *p,*d; |
| 1274 | int n; | 1403 | int n; |
| 1275 | unsigned long l; | 1404 | unsigned long l; |
| 1405 | #ifndef OPENSSL_NO_RSA | ||
| 1406 | unsigned char *q; | ||
| 1276 | EVP_PKEY *pkey=NULL; | 1407 | EVP_PKEY *pkey=NULL; |
| 1408 | #endif | ||
| 1409 | #ifndef OPENSSL_NO_KRB5 | ||
| 1410 | KSSL_ERR kssl_err; | ||
| 1411 | #endif /* OPENSSL_NO_KRB5 */ | ||
| 1277 | 1412 | ||
| 1278 | if (s->state == SSL3_ST_CW_KEY_EXCH_A) | 1413 | if (s->state == SSL3_ST_CW_KEY_EXCH_A) |
| 1279 | { | 1414 | { |
| @@ -1282,30 +1417,34 @@ SSL *s; | |||
| 1282 | 1417 | ||
| 1283 | l=s->s3->tmp.new_cipher->algorithms; | 1418 | l=s->s3->tmp.new_cipher->algorithms; |
| 1284 | 1419 | ||
| 1285 | #ifndef NO_RSA | 1420 | /* Fool emacs indentation */ |
| 1286 | if (l & SSL_kRSA) | 1421 | if (0) {} |
| 1422 | #ifndef OPENSSL_NO_RSA | ||
| 1423 | else if (l & SSL_kRSA) | ||
| 1287 | { | 1424 | { |
| 1288 | RSA *rsa; | 1425 | RSA *rsa; |
| 1289 | unsigned char tmp_buf[48]; | 1426 | unsigned char tmp_buf[SSL_MAX_MASTER_KEY_LENGTH]; |
| 1290 | 1427 | ||
| 1291 | if (s->session->cert->rsa_tmp != NULL) | 1428 | if (s->session->sess_cert->peer_rsa_tmp != NULL) |
| 1292 | rsa=s->session->cert->rsa_tmp; | 1429 | rsa=s->session->sess_cert->peer_rsa_tmp; |
| 1293 | else | 1430 | else |
| 1294 | { | 1431 | { |
| 1295 | pkey=X509_get_pubkey(s->session->cert->pkeys[SSL_PKEY_RSA_ENC].x509); | 1432 | pkey=X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_RSA_ENC].x509); |
| 1296 | if ((pkey == NULL) || | 1433 | if ((pkey == NULL) || |
| 1297 | (pkey->type != EVP_PKEY_RSA) || | 1434 | (pkey->type != EVP_PKEY_RSA) || |
| 1298 | (pkey->pkey.rsa == NULL)) | 1435 | (pkey->pkey.rsa == NULL)) |
| 1299 | { | 1436 | { |
| 1300 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,SSL_R_INTERNAL_ERROR); | 1437 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,ERR_R_INTERNAL_ERROR); |
| 1301 | goto err; | 1438 | goto err; |
| 1302 | } | 1439 | } |
| 1303 | rsa=pkey->pkey.rsa; | 1440 | rsa=pkey->pkey.rsa; |
| 1441 | EVP_PKEY_free(pkey); | ||
| 1304 | } | 1442 | } |
| 1305 | 1443 | ||
| 1306 | tmp_buf[0]=s->version>>8; | 1444 | tmp_buf[0]=s->client_version>>8; |
| 1307 | tmp_buf[1]=s->version&0xff; | 1445 | tmp_buf[1]=s->client_version&0xff; |
| 1308 | RAND_bytes(&(tmp_buf[2]),SSL_MAX_MASTER_KEY_LENGTH-2); | 1446 | if (RAND_bytes(&(tmp_buf[2]),SSL_MAX_MASTER_KEY_LENGTH-2) <= 0) |
| 1447 | goto err; | ||
| 1309 | 1448 | ||
| 1310 | s->session->master_key_length=SSL_MAX_MASTER_KEY_LENGTH; | 1449 | s->session->master_key_length=SSL_MAX_MASTER_KEY_LENGTH; |
| 1311 | 1450 | ||
| @@ -1315,6 +1454,10 @@ SSL *s; | |||
| 1315 | p+=2; | 1454 | p+=2; |
| 1316 | n=RSA_public_encrypt(SSL_MAX_MASTER_KEY_LENGTH, | 1455 | n=RSA_public_encrypt(SSL_MAX_MASTER_KEY_LENGTH, |
| 1317 | tmp_buf,p,rsa,RSA_PKCS1_PADDING); | 1456 | tmp_buf,p,rsa,RSA_PKCS1_PADDING); |
| 1457 | #ifdef PKCS1_CHECK | ||
| 1458 | if (s->options & SSL_OP_PKCS1_CHECK_1) p[1]++; | ||
| 1459 | if (s->options & SSL_OP_PKCS1_CHECK_2) tmp_buf[0]=0x70; | ||
| 1460 | #endif | ||
| 1318 | if (n <= 0) | 1461 | if (n <= 0) |
| 1319 | { | 1462 | { |
| 1320 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,SSL_R_BAD_RSA_ENCRYPT); | 1463 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,SSL_R_BAD_RSA_ENCRYPT); |
| @@ -1331,18 +1474,144 @@ SSL *s; | |||
| 1331 | s->session->master_key_length= | 1474 | s->session->master_key_length= |
| 1332 | s->method->ssl3_enc->generate_master_secret(s, | 1475 | s->method->ssl3_enc->generate_master_secret(s, |
| 1333 | s->session->master_key, | 1476 | s->session->master_key, |
| 1334 | tmp_buf,48); | 1477 | tmp_buf,SSL_MAX_MASTER_KEY_LENGTH); |
| 1335 | memset(tmp_buf,0,48); | 1478 | memset(tmp_buf,0,SSL_MAX_MASTER_KEY_LENGTH); |
| 1336 | } | 1479 | } |
| 1337 | else | ||
| 1338 | #endif | 1480 | #endif |
| 1339 | #ifndef NO_DH | 1481 | #ifndef OPENSSL_NO_KRB5 |
| 1340 | if (l & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) | 1482 | else if (l & SSL_kKRB5) |
| 1483 | { | ||
| 1484 | krb5_error_code krb5rc; | ||
| 1485 | KSSL_CTX *kssl_ctx = s->kssl_ctx; | ||
| 1486 | /* krb5_data krb5_ap_req; */ | ||
| 1487 | krb5_data *enc_ticket; | ||
| 1488 | krb5_data authenticator, *authp = NULL; | ||
| 1489 | EVP_CIPHER_CTX ciph_ctx; | ||
| 1490 | EVP_CIPHER *enc = NULL; | ||
| 1491 | unsigned char iv[EVP_MAX_IV_LENGTH]; | ||
| 1492 | unsigned char tmp_buf[SSL_MAX_MASTER_KEY_LENGTH]; | ||
| 1493 | unsigned char epms[SSL_MAX_MASTER_KEY_LENGTH | ||
| 1494 | + EVP_MAX_IV_LENGTH]; | ||
| 1495 | int padl, outl = sizeof(epms); | ||
| 1496 | |||
| 1497 | EVP_CIPHER_CTX_init(&ciph_ctx); | ||
| 1498 | |||
| 1499 | #ifdef KSSL_DEBUG | ||
| 1500 | printf("ssl3_send_client_key_exchange(%lx & %lx)\n", | ||
| 1501 | l, SSL_kKRB5); | ||
| 1502 | #endif /* KSSL_DEBUG */ | ||
| 1503 | |||
| 1504 | authp = NULL; | ||
| 1505 | #ifdef KRB5SENDAUTH | ||
| 1506 | if (KRB5SENDAUTH) authp = &authenticator; | ||
| 1507 | #endif /* KRB5SENDAUTH */ | ||
| 1508 | |||
| 1509 | krb5rc = kssl_cget_tkt(kssl_ctx, &enc_ticket, authp, | ||
| 1510 | &kssl_err); | ||
| 1511 | enc = kssl_map_enc(kssl_ctx->enctype); | ||
| 1512 | if (enc == NULL) | ||
| 1513 | goto err; | ||
| 1514 | #ifdef KSSL_DEBUG | ||
| 1515 | { | ||
| 1516 | printf("kssl_cget_tkt rtn %d\n", krb5rc); | ||
| 1517 | if (krb5rc && kssl_err.text) | ||
| 1518 | printf("kssl_cget_tkt kssl_err=%s\n", kssl_err.text); | ||
| 1519 | } | ||
| 1520 | #endif /* KSSL_DEBUG */ | ||
| 1521 | |||
| 1522 | if (krb5rc) | ||
| 1523 | { | ||
| 1524 | ssl3_send_alert(s,SSL3_AL_FATAL, | ||
| 1525 | SSL_AD_HANDSHAKE_FAILURE); | ||
| 1526 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, | ||
| 1527 | kssl_err.reason); | ||
| 1528 | goto err; | ||
| 1529 | } | ||
| 1530 | |||
| 1531 | /* 20010406 VRS - Earlier versions used KRB5 AP_REQ | ||
| 1532 | ** in place of RFC 2712 KerberosWrapper, as in: | ||
| 1533 | ** | ||
| 1534 | ** Send ticket (copy to *p, set n = length) | ||
| 1535 | ** n = krb5_ap_req.length; | ||
| 1536 | ** memcpy(p, krb5_ap_req.data, krb5_ap_req.length); | ||
| 1537 | ** if (krb5_ap_req.data) | ||
| 1538 | ** kssl_krb5_free_data_contents(NULL,&krb5_ap_req); | ||
| 1539 | ** | ||
| 1540 | ** Now using real RFC 2712 KerberosWrapper | ||
| 1541 | ** (Thanks to Simon Wilkinson <sxw@sxw.org.uk>) | ||
| 1542 | ** Note: 2712 "opaque" types are here replaced | ||
| 1543 | ** with a 2-byte length followed by the value. | ||
| 1544 | ** Example: | ||
| 1545 | ** KerberosWrapper= xx xx asn1ticket 0 0 xx xx encpms | ||
| 1546 | ** Where "xx xx" = length bytes. Shown here with | ||
| 1547 | ** optional authenticator omitted. | ||
| 1548 | */ | ||
| 1549 | |||
| 1550 | /* KerberosWrapper.Ticket */ | ||
| 1551 | s2n(enc_ticket->length,p); | ||
| 1552 | memcpy(p, enc_ticket->data, enc_ticket->length); | ||
| 1553 | p+= enc_ticket->length; | ||
| 1554 | n = enc_ticket->length + 2; | ||
| 1555 | |||
| 1556 | /* KerberosWrapper.Authenticator */ | ||
| 1557 | if (authp && authp->length) | ||
| 1558 | { | ||
| 1559 | s2n(authp->length,p); | ||
| 1560 | memcpy(p, authp->data, authp->length); | ||
| 1561 | p+= authp->length; | ||
| 1562 | n+= authp->length + 2; | ||
| 1563 | |||
| 1564 | free(authp->data); | ||
| 1565 | authp->data = NULL; | ||
| 1566 | authp->length = 0; | ||
| 1567 | } | ||
| 1568 | else | ||
| 1569 | { | ||
| 1570 | s2n(0,p);/* null authenticator length */ | ||
| 1571 | n+=2; | ||
| 1572 | } | ||
| 1573 | |||
| 1574 | if (RAND_bytes(tmp_buf,SSL_MAX_MASTER_KEY_LENGTH) <= 0) | ||
| 1575 | goto err; | ||
| 1576 | |||
| 1577 | /* 20010420 VRS. Tried it this way; failed. | ||
| 1578 | ** EVP_EncryptInit_ex(&ciph_ctx,enc, NULL,NULL); | ||
| 1579 | ** EVP_CIPHER_CTX_set_key_length(&ciph_ctx, | ||
| 1580 | ** kssl_ctx->length); | ||
| 1581 | ** EVP_EncryptInit_ex(&ciph_ctx,NULL, key,iv); | ||
| 1582 | */ | ||
| 1583 | |||
| 1584 | memset(iv, 0, EVP_MAX_IV_LENGTH); /* per RFC 1510 */ | ||
| 1585 | EVP_EncryptInit_ex(&ciph_ctx,enc, NULL, | ||
| 1586 | kssl_ctx->key,iv); | ||
| 1587 | EVP_EncryptUpdate(&ciph_ctx,epms,&outl,tmp_buf, | ||
| 1588 | SSL_MAX_MASTER_KEY_LENGTH); | ||
| 1589 | EVP_EncryptFinal_ex(&ciph_ctx,&(epms[outl]),&padl); | ||
| 1590 | outl += padl; | ||
| 1591 | EVP_CIPHER_CTX_cleanup(&ciph_ctx); | ||
| 1592 | |||
| 1593 | /* KerberosWrapper.EncryptedPreMasterSecret */ | ||
| 1594 | s2n(outl,p); | ||
| 1595 | memcpy(p, epms, outl); | ||
| 1596 | p+=outl; | ||
| 1597 | n+=outl + 2; | ||
| 1598 | |||
| 1599 | s->session->master_key_length= | ||
| 1600 | s->method->ssl3_enc->generate_master_secret(s, | ||
| 1601 | s->session->master_key, | ||
| 1602 | tmp_buf, SSL_MAX_MASTER_KEY_LENGTH); | ||
| 1603 | |||
| 1604 | memset(tmp_buf, 0, SSL_MAX_MASTER_KEY_LENGTH); | ||
| 1605 | memset(epms, 0, outl); | ||
| 1606 | } | ||
| 1607 | #endif | ||
| 1608 | #ifndef OPENSSL_NO_DH | ||
| 1609 | else if (l & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) | ||
| 1341 | { | 1610 | { |
| 1342 | DH *dh_srvr,*dh_clnt; | 1611 | DH *dh_srvr,*dh_clnt; |
| 1343 | 1612 | ||
| 1344 | if (s->session->cert->dh_tmp != NULL) | 1613 | if (s->session->sess_cert->peer_dh_tmp != NULL) |
| 1345 | dh_srvr=s->session->cert->dh_tmp; | 1614 | dh_srvr=s->session->sess_cert->peer_dh_tmp; |
| 1346 | else | 1615 | else |
| 1347 | { | 1616 | { |
| 1348 | /* we get them from the cert */ | 1617 | /* we get them from the cert */ |
| @@ -1391,11 +1660,11 @@ SSL *s; | |||
| 1391 | 1660 | ||
| 1392 | /* perhaps clean things up a bit EAY EAY EAY EAY*/ | 1661 | /* perhaps clean things up a bit EAY EAY EAY EAY*/ |
| 1393 | } | 1662 | } |
| 1394 | else | ||
| 1395 | #endif | 1663 | #endif |
| 1664 | else | ||
| 1396 | { | 1665 | { |
| 1397 | ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_HANDSHAKE_FAILURE); | 1666 | ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_HANDSHAKE_FAILURE); |
| 1398 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,SSL_R_INTERNAL_ERROR); | 1667 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,ERR_R_INTERNAL_ERROR); |
| 1399 | goto err; | 1668 | goto err; |
| 1400 | } | 1669 | } |
| 1401 | 1670 | ||
| @@ -1414,15 +1683,16 @@ err: | |||
| 1414 | return(-1); | 1683 | return(-1); |
| 1415 | } | 1684 | } |
| 1416 | 1685 | ||
| 1417 | static int ssl3_send_client_verify(s) | 1686 | static int ssl3_send_client_verify(SSL *s) |
| 1418 | SSL *s; | ||
| 1419 | { | 1687 | { |
| 1420 | unsigned char *p,*d; | 1688 | unsigned char *p,*d; |
| 1421 | unsigned char data[MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH]; | 1689 | unsigned char data[MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH]; |
| 1422 | EVP_PKEY *pkey; | 1690 | EVP_PKEY *pkey; |
| 1423 | int i=0; | 1691 | #ifndef OPENSSL_NO_RSA |
| 1692 | unsigned u=0; | ||
| 1693 | #endif | ||
| 1424 | unsigned long n; | 1694 | unsigned long n; |
| 1425 | #ifndef NO_DSA | 1695 | #ifndef OPENSSL_NO_DSA |
| 1426 | int j; | 1696 | int j; |
| 1427 | #endif | 1697 | #endif |
| 1428 | 1698 | ||
| @@ -1435,26 +1705,24 @@ SSL *s; | |||
| 1435 | s->method->ssl3_enc->cert_verify_mac(s,&(s->s3->finish_dgst2), | 1705 | s->method->ssl3_enc->cert_verify_mac(s,&(s->s3->finish_dgst2), |
| 1436 | &(data[MD5_DIGEST_LENGTH])); | 1706 | &(data[MD5_DIGEST_LENGTH])); |
| 1437 | 1707 | ||
| 1438 | #ifndef NO_RSA | 1708 | #ifndef OPENSSL_NO_RSA |
| 1439 | if (pkey->type == EVP_PKEY_RSA) | 1709 | if (pkey->type == EVP_PKEY_RSA) |
| 1440 | { | 1710 | { |
| 1441 | s->method->ssl3_enc->cert_verify_mac(s, | 1711 | s->method->ssl3_enc->cert_verify_mac(s, |
| 1442 | &(s->s3->finish_dgst1),&(data[0])); | 1712 | &(s->s3->finish_dgst1),&(data[0])); |
| 1443 | i=RSA_private_encrypt( | 1713 | if (RSA_sign(NID_md5_sha1, data, |
| 1444 | MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH, | 1714 | MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH, |
| 1445 | data,&(p[2]),pkey->pkey.rsa, | 1715 | &(p[2]), &u, pkey->pkey.rsa) <= 0 ) |
| 1446 | RSA_PKCS1_PADDING); | ||
| 1447 | if (i <= 0) | ||
| 1448 | { | 1716 | { |
| 1449 | SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY,ERR_R_RSA_LIB); | 1717 | SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY,ERR_R_RSA_LIB); |
| 1450 | goto err; | 1718 | goto err; |
| 1451 | } | 1719 | } |
| 1452 | s2n(i,p); | 1720 | s2n(u,p); |
| 1453 | n=i+2; | 1721 | n=u+2; |
| 1454 | } | 1722 | } |
| 1455 | else | 1723 | else |
| 1456 | #endif | 1724 | #endif |
| 1457 | #ifndef NO_DSA | 1725 | #ifndef OPENSSL_NO_DSA |
| 1458 | if (pkey->type == EVP_PKEY_DSA) | 1726 | if (pkey->type == EVP_PKEY_DSA) |
| 1459 | { | 1727 | { |
| 1460 | if (!DSA_sign(pkey->save_type, | 1728 | if (!DSA_sign(pkey->save_type, |
| @@ -1471,7 +1739,7 @@ SSL *s; | |||
| 1471 | else | 1739 | else |
| 1472 | #endif | 1740 | #endif |
| 1473 | { | 1741 | { |
| 1474 | SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY,SSL_R_INTERNAL_ERROR); | 1742 | SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY,ERR_R_INTERNAL_ERROR); |
| 1475 | goto err; | 1743 | goto err; |
| 1476 | } | 1744 | } |
| 1477 | *(d++)=SSL3_MT_CERTIFICATE_VERIFY; | 1745 | *(d++)=SSL3_MT_CERTIFICATE_VERIFY; |
| @@ -1485,8 +1753,7 @@ err: | |||
| 1485 | return(-1); | 1753 | return(-1); |
| 1486 | } | 1754 | } |
| 1487 | 1755 | ||
| 1488 | static int ssl3_send_client_certificate(s) | 1756 | static int ssl3_send_client_certificate(SSL *s) |
| 1489 | SSL *s; | ||
| 1490 | { | 1757 | { |
| 1491 | X509 *x509=NULL; | 1758 | X509 *x509=NULL; |
| 1492 | EVP_PKEY *pkey=NULL; | 1759 | EVP_PKEY *pkey=NULL; |
| @@ -1565,38 +1832,46 @@ SSL *s; | |||
| 1565 | 1832 | ||
| 1566 | #define has_bits(i,m) (((i)&(m)) == (m)) | 1833 | #define has_bits(i,m) (((i)&(m)) == (m)) |
| 1567 | 1834 | ||
| 1568 | static int ssl3_check_cert_and_algorithm(s) | 1835 | static int ssl3_check_cert_and_algorithm(SSL *s) |
| 1569 | SSL *s; | ||
| 1570 | { | 1836 | { |
| 1571 | int i,idx; | 1837 | int i,idx; |
| 1572 | long algs; | 1838 | long algs; |
| 1573 | EVP_PKEY *pkey=NULL; | 1839 | EVP_PKEY *pkey=NULL; |
| 1574 | CERT *c; | 1840 | SESS_CERT *sc; |
| 1841 | #ifndef OPENSSL_NO_RSA | ||
| 1575 | RSA *rsa; | 1842 | RSA *rsa; |
| 1843 | #endif | ||
| 1844 | #ifndef OPENSSL_NO_DH | ||
| 1576 | DH *dh; | 1845 | DH *dh; |
| 1846 | #endif | ||
| 1577 | 1847 | ||
| 1578 | c=s->session->cert; | 1848 | sc=s->session->sess_cert; |
| 1579 | 1849 | ||
| 1580 | if (c == NULL) | 1850 | if (sc == NULL) |
| 1581 | { | 1851 | { |
| 1582 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_INTERNAL_ERROR); | 1852 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,ERR_R_INTERNAL_ERROR); |
| 1583 | goto err; | 1853 | goto err; |
| 1584 | } | 1854 | } |
| 1585 | 1855 | ||
| 1586 | algs=s->s3->tmp.new_cipher->algorithms; | 1856 | algs=s->s3->tmp.new_cipher->algorithms; |
| 1587 | 1857 | ||
| 1588 | /* we don't have a certificate */ | 1858 | /* we don't have a certificate */ |
| 1589 | if (algs & (SSL_aDH|SSL_aNULL)) | 1859 | if (algs & (SSL_aDH|SSL_aNULL|SSL_aKRB5)) |
| 1590 | return(1); | 1860 | return(1); |
| 1591 | 1861 | ||
| 1592 | rsa=s->session->cert->rsa_tmp; | 1862 | #ifndef OPENSSL_NO_RSA |
| 1593 | dh=s->session->cert->dh_tmp; | 1863 | rsa=s->session->sess_cert->peer_rsa_tmp; |
| 1864 | #endif | ||
| 1865 | #ifndef OPENSSL_NO_DH | ||
| 1866 | dh=s->session->sess_cert->peer_dh_tmp; | ||
| 1867 | #endif | ||
| 1594 | 1868 | ||
| 1595 | /* This is the passed certificate */ | 1869 | /* This is the passed certificate */ |
| 1596 | 1870 | ||
| 1597 | idx=c->cert_type; | 1871 | idx=sc->peer_cert_type; |
| 1598 | pkey=X509_get_pubkey(c->pkeys[idx].x509); | 1872 | pkey=X509_get_pubkey(sc->peer_pkeys[idx].x509); |
| 1599 | i=X509_certificate_type(c->pkeys[idx].x509,pkey); | 1873 | i=X509_certificate_type(sc->peer_pkeys[idx].x509,pkey); |
| 1874 | EVP_PKEY_free(pkey); | ||
| 1600 | 1875 | ||
| 1601 | 1876 | ||
| 1602 | /* Check that we have a certificate if we require one */ | 1877 | /* Check that we have a certificate if we require one */ |
| @@ -1605,22 +1880,23 @@ SSL *s; | |||
| 1605 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_RSA_SIGNING_CERT); | 1880 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_RSA_SIGNING_CERT); |
| 1606 | goto f_err; | 1881 | goto f_err; |
| 1607 | } | 1882 | } |
| 1608 | #ifndef NO_DSA | 1883 | #ifndef OPENSSL_NO_DSA |
| 1609 | else if ((algs & SSL_aDSS) && !has_bits(i,EVP_PK_DSA|EVP_PKT_SIGN)) | 1884 | else if ((algs & SSL_aDSS) && !has_bits(i,EVP_PK_DSA|EVP_PKT_SIGN)) |
| 1610 | { | 1885 | { |
| 1611 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DSA_SIGNING_CERT); | 1886 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DSA_SIGNING_CERT); |
| 1612 | goto f_err; | 1887 | goto f_err; |
| 1613 | } | 1888 | } |
| 1614 | #endif | 1889 | #endif |
| 1615 | 1890 | #ifndef OPENSSL_NO_RSA | |
| 1616 | if ((algs & SSL_kRSA) && | 1891 | if ((algs & SSL_kRSA) && |
| 1617 | !(has_bits(i,EVP_PK_RSA|EVP_PKT_ENC) || (rsa != NULL))) | 1892 | !(has_bits(i,EVP_PK_RSA|EVP_PKT_ENC) || (rsa != NULL))) |
| 1618 | { | 1893 | { |
| 1619 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_RSA_ENCRYPTING_CERT); | 1894 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_RSA_ENCRYPTING_CERT); |
| 1620 | goto f_err; | 1895 | goto f_err; |
| 1621 | } | 1896 | } |
| 1622 | #ifndef NO_DH | 1897 | #endif |
| 1623 | else if ((algs & SSL_kEDH) && | 1898 | #ifndef OPENSSL_NO_DH |
| 1899 | if ((algs & SSL_kEDH) && | ||
| 1624 | !(has_bits(i,EVP_PK_DH|EVP_PKT_EXCH) || (dh != NULL))) | 1900 | !(has_bits(i,EVP_PK_DH|EVP_PKT_EXCH) || (dh != NULL))) |
| 1625 | { | 1901 | { |
| 1626 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DH_KEY); | 1902 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DH_KEY); |
| @@ -1631,7 +1907,7 @@ SSL *s; | |||
| 1631 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DH_RSA_CERT); | 1907 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DH_RSA_CERT); |
| 1632 | goto f_err; | 1908 | goto f_err; |
| 1633 | } | 1909 | } |
| 1634 | #ifndef NO_DSA | 1910 | #ifndef OPENSSL_NO_DSA |
| 1635 | else if ((algs & SSL_kDHd) && !has_bits(i,EVP_PK_DH|EVP_PKS_DSA)) | 1911 | else if ((algs & SSL_kDHd) && !has_bits(i,EVP_PK_DH|EVP_PKS_DSA)) |
| 1636 | { | 1912 | { |
| 1637 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DH_DSA_CERT); | 1913 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DH_DSA_CERT); |
| @@ -1640,12 +1916,13 @@ SSL *s; | |||
| 1640 | #endif | 1916 | #endif |
| 1641 | #endif | 1917 | #endif |
| 1642 | 1918 | ||
| 1643 | if ((algs & SSL_EXP) && !has_bits(i,EVP_PKT_EXP)) | 1919 | if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && !has_bits(i,EVP_PKT_EXP)) |
| 1644 | { | 1920 | { |
| 1645 | #ifndef NO_RSA | 1921 | #ifndef OPENSSL_NO_RSA |
| 1646 | if (algs & SSL_kRSA) | 1922 | if (algs & SSL_kRSA) |
| 1647 | { | 1923 | { |
| 1648 | if ((rsa == NULL) || (RSA_size(rsa) > 512)) | 1924 | if (rsa == NULL |
| 1925 | || RSA_size(rsa) > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) | ||
| 1649 | { | 1926 | { |
| 1650 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_EXPORT_TMP_RSA_KEY); | 1927 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_EXPORT_TMP_RSA_KEY); |
| 1651 | goto f_err; | 1928 | goto f_err; |
| @@ -1653,10 +1930,11 @@ SSL *s; | |||
| 1653 | } | 1930 | } |
| 1654 | else | 1931 | else |
| 1655 | #endif | 1932 | #endif |
| 1656 | #ifndef NO_DH | 1933 | #ifndef OPENSSL_NO_DH |
| 1657 | if (algs & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) | 1934 | if (algs & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) |
| 1658 | { | 1935 | { |
| 1659 | if ((dh == NULL) || (DH_size(dh) > 512)) | 1936 | if (dh == NULL |
| 1937 | || DH_size(dh) > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) | ||
| 1660 | { | 1938 | { |
| 1661 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_EXPORT_TMP_DH_KEY); | 1939 | SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_EXPORT_TMP_DH_KEY); |
| 1662 | goto f_err; | 1940 | goto f_err; |
diff --git a/src/lib/libssl/s3_lib.c b/src/lib/libssl/s3_lib.c index 0fd945025d..686992406c 100644 --- a/src/lib/libssl/s3_lib.c +++ b/src/lib/libssl/s3_lib.c | |||
| @@ -55,40 +55,99 @@ | |||
| 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 | ||
| 59 | #include <stdio.h> | 112 | #include <stdio.h> |
| 60 | #include "objects.h" | 113 | #include <openssl/objects.h> |
| 61 | #include "ssl_locl.h" | 114 | #include "ssl_locl.h" |
| 115 | #include "kssl_lcl.h" | ||
| 116 | #include <openssl/md5.h> | ||
| 62 | 117 | ||
| 63 | char *ssl3_version_str="SSLv3 part of SSLeay 0.9.0b 29-Jun-1998"; | 118 | const char *ssl3_version_str="SSLv3" OPENSSL_VERSION_PTEXT; |
| 64 | 119 | ||
| 65 | #define SSL3_NUM_CIPHERS (sizeof(ssl3_ciphers)/sizeof(SSL_CIPHER)) | 120 | #define SSL3_NUM_CIPHERS (sizeof(ssl3_ciphers)/sizeof(SSL_CIPHER)) |
| 66 | 121 | ||
| 67 | #ifndef NOPROTO | ||
| 68 | static long ssl3_default_timeout(void ); | 122 | static long ssl3_default_timeout(void ); |
| 69 | #else | ||
| 70 | static long ssl3_default_timeout(); | ||
| 71 | #endif | ||
| 72 | 123 | ||
| 73 | SSL_CIPHER ssl3_ciphers[]={ | 124 | OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={ |
| 74 | /* The RSA ciphers */ | 125 | /* The RSA ciphers */ |
| 75 | /* Cipher 01 */ | 126 | /* Cipher 01 */ |
| 76 | { | 127 | { |
| 77 | 1, | 128 | 1, |
| 78 | SSL3_TXT_RSA_NULL_MD5, | 129 | SSL3_TXT_RSA_NULL_MD5, |
| 79 | SSL3_CK_RSA_NULL_MD5, | 130 | SSL3_CK_RSA_NULL_MD5, |
| 80 | SSL_kRSA|SSL_aRSA|SSL_eNULL |SSL_MD5|SSL_NOT_EXP|SSL_SSLV3, | 131 | SSL_kRSA|SSL_aRSA|SSL_eNULL |SSL_MD5|SSL_SSLV3, |
| 132 | SSL_NOT_EXP, | ||
| 133 | 0, | ||
| 134 | 0, | ||
| 81 | 0, | 135 | 0, |
| 82 | SSL_ALL_CIPHERS, | 136 | SSL_ALL_CIPHERS, |
| 137 | SSL_ALL_STRENGTHS, | ||
| 83 | }, | 138 | }, |
| 84 | /* Cipher 02 */ | 139 | /* Cipher 02 */ |
| 85 | { | 140 | { |
| 86 | 1, | 141 | 1, |
| 87 | SSL3_TXT_RSA_NULL_SHA, | 142 | SSL3_TXT_RSA_NULL_SHA, |
| 88 | SSL3_CK_RSA_NULL_SHA, | 143 | SSL3_CK_RSA_NULL_SHA, |
| 89 | SSL_kRSA|SSL_aRSA|SSL_eNULL |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3, | 144 | SSL_kRSA|SSL_aRSA|SSL_eNULL |SSL_SHA1|SSL_SSLV3, |
| 145 | SSL_NOT_EXP, | ||
| 146 | 0, | ||
| 147 | 0, | ||
| 90 | 0, | 148 | 0, |
| 91 | SSL_ALL_CIPHERS, | 149 | SSL_ALL_CIPHERS, |
| 150 | SSL_ALL_STRENGTHS, | ||
| 92 | }, | 151 | }, |
| 93 | 152 | ||
| 94 | /* anon DH */ | 153 | /* anon DH */ |
| @@ -97,45 +156,65 @@ SSL_CIPHER ssl3_ciphers[]={ | |||
| 97 | 1, | 156 | 1, |
| 98 | SSL3_TXT_ADH_RC4_40_MD5, | 157 | SSL3_TXT_ADH_RC4_40_MD5, |
| 99 | SSL3_CK_ADH_RC4_40_MD5, | 158 | SSL3_CK_ADH_RC4_40_MD5, |
| 100 | SSL_kEDH |SSL_aNULL|SSL_RC4 |SSL_MD5 |SSL_EXP|SSL_SSLV3, | 159 | SSL_kEDH |SSL_aNULL|SSL_RC4 |SSL_MD5 |SSL_SSLV3, |
| 160 | SSL_EXPORT|SSL_EXP40, | ||
| 101 | 0, | 161 | 0, |
| 162 | 40, | ||
| 163 | 128, | ||
| 102 | SSL_ALL_CIPHERS, | 164 | SSL_ALL_CIPHERS, |
| 165 | SSL_ALL_STRENGTHS, | ||
| 103 | }, | 166 | }, |
| 104 | /* Cipher 18 */ | 167 | /* Cipher 18 */ |
| 105 | { | 168 | { |
| 106 | 1, | 169 | 1, |
| 107 | SSL3_TXT_ADH_RC4_128_MD5, | 170 | SSL3_TXT_ADH_RC4_128_MD5, |
| 108 | SSL3_CK_ADH_RC4_128_MD5, | 171 | SSL3_CK_ADH_RC4_128_MD5, |
| 109 | SSL_kEDH |SSL_aNULL|SSL_RC4 |SSL_MD5|SSL_NOT_EXP|SSL_SSLV3, | 172 | SSL_kEDH |SSL_aNULL|SSL_RC4 |SSL_MD5 |SSL_SSLV3, |
| 173 | SSL_NOT_EXP|SSL_MEDIUM, | ||
| 110 | 0, | 174 | 0, |
| 175 | 128, | ||
| 176 | 128, | ||
| 111 | SSL_ALL_CIPHERS, | 177 | SSL_ALL_CIPHERS, |
| 178 | SSL_ALL_STRENGTHS, | ||
| 112 | }, | 179 | }, |
| 113 | /* Cipher 19 */ | 180 | /* Cipher 19 */ |
| 114 | { | 181 | { |
| 115 | 1, | 182 | 1, |
| 116 | SSL3_TXT_ADH_DES_40_CBC_SHA, | 183 | SSL3_TXT_ADH_DES_40_CBC_SHA, |
| 117 | SSL3_CK_ADH_DES_40_CBC_SHA, | 184 | SSL3_CK_ADH_DES_40_CBC_SHA, |
| 118 | SSL_kEDH |SSL_aNULL|SSL_DES|SSL_SHA1|SSL_EXP|SSL_SSLV3, | 185 | SSL_kEDH |SSL_aNULL|SSL_DES|SSL_SHA1|SSL_SSLV3, |
| 186 | SSL_EXPORT|SSL_EXP40, | ||
| 119 | 0, | 187 | 0, |
| 188 | 40, | ||
| 189 | 128, | ||
| 120 | SSL_ALL_CIPHERS, | 190 | SSL_ALL_CIPHERS, |
| 191 | SSL_ALL_STRENGTHS, | ||
| 121 | }, | 192 | }, |
| 122 | /* Cipher 1A */ | 193 | /* Cipher 1A */ |
| 123 | { | 194 | { |
| 124 | 1, | 195 | 1, |
| 125 | SSL3_TXT_ADH_DES_64_CBC_SHA, | 196 | SSL3_TXT_ADH_DES_64_CBC_SHA, |
| 126 | SSL3_CK_ADH_DES_64_CBC_SHA, | 197 | SSL3_CK_ADH_DES_64_CBC_SHA, |
| 127 | SSL_kEDH |SSL_aNULL|SSL_DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3, | 198 | SSL_kEDH |SSL_aNULL|SSL_DES |SSL_SHA1|SSL_SSLV3, |
| 199 | SSL_NOT_EXP|SSL_LOW, | ||
| 128 | 0, | 200 | 0, |
| 201 | 56, | ||
| 202 | 56, | ||
| 129 | SSL_ALL_CIPHERS, | 203 | SSL_ALL_CIPHERS, |
| 204 | SSL_ALL_STRENGTHS, | ||
| 130 | }, | 205 | }, |
| 131 | /* Cipher 1B */ | 206 | /* Cipher 1B */ |
| 132 | { | 207 | { |
| 133 | 1, | 208 | 1, |
| 134 | SSL3_TXT_ADH_DES_192_CBC_SHA, | 209 | SSL3_TXT_ADH_DES_192_CBC_SHA, |
| 135 | SSL3_CK_ADH_DES_192_CBC_SHA, | 210 | SSL3_CK_ADH_DES_192_CBC_SHA, |
| 136 | SSL_kEDH |SSL_aNULL|SSL_3DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3, | 211 | SSL_kEDH |SSL_aNULL|SSL_3DES |SSL_SHA1|SSL_SSLV3, |
| 212 | SSL_NOT_EXP|SSL_HIGH, | ||
| 137 | 0, | 213 | 0, |
| 214 | 168, | ||
| 215 | 168, | ||
| 138 | SSL_ALL_CIPHERS, | 216 | SSL_ALL_CIPHERS, |
| 217 | SSL_ALL_STRENGTHS, | ||
| 139 | }, | 218 | }, |
| 140 | 219 | ||
| 141 | /* RSA again */ | 220 | /* RSA again */ |
| @@ -144,72 +223,104 @@ SSL_CIPHER ssl3_ciphers[]={ | |||
| 144 | 1, | 223 | 1, |
| 145 | SSL3_TXT_RSA_RC4_40_MD5, | 224 | SSL3_TXT_RSA_RC4_40_MD5, |
| 146 | SSL3_CK_RSA_RC4_40_MD5, | 225 | SSL3_CK_RSA_RC4_40_MD5, |
| 147 | SSL_kRSA|SSL_aRSA|SSL_RC4 |SSL_MD5 |SSL_EXP|SSL_SSLV3, | 226 | SSL_kRSA|SSL_aRSA|SSL_RC4 |SSL_MD5 |SSL_SSLV3, |
| 227 | SSL_EXPORT|SSL_EXP40, | ||
| 148 | 0, | 228 | 0, |
| 229 | 40, | ||
| 230 | 128, | ||
| 149 | SSL_ALL_CIPHERS, | 231 | SSL_ALL_CIPHERS, |
| 232 | SSL_ALL_STRENGTHS, | ||
| 150 | }, | 233 | }, |
| 151 | /* Cipher 04 */ | 234 | /* Cipher 04 */ |
| 152 | { | 235 | { |
| 153 | 1, | 236 | 1, |
| 154 | SSL3_TXT_RSA_RC4_128_MD5, | 237 | SSL3_TXT_RSA_RC4_128_MD5, |
| 155 | SSL3_CK_RSA_RC4_128_MD5, | 238 | SSL3_CK_RSA_RC4_128_MD5, |
| 156 | SSL_kRSA|SSL_aRSA|SSL_RC4 |SSL_MD5|SSL_NOT_EXP|SSL_SSLV3|SSL_MEDIUM, | 239 | SSL_kRSA|SSL_aRSA|SSL_RC4 |SSL_MD5|SSL_SSLV3, |
| 240 | SSL_NOT_EXP|SSL_MEDIUM, | ||
| 157 | 0, | 241 | 0, |
| 242 | 128, | ||
| 243 | 128, | ||
| 158 | SSL_ALL_CIPHERS, | 244 | SSL_ALL_CIPHERS, |
| 245 | SSL_ALL_STRENGTHS, | ||
| 159 | }, | 246 | }, |
| 160 | /* Cipher 05 */ | 247 | /* Cipher 05 */ |
| 161 | { | 248 | { |
| 162 | 1, | 249 | 1, |
| 163 | SSL3_TXT_RSA_RC4_128_SHA, | 250 | SSL3_TXT_RSA_RC4_128_SHA, |
| 164 | SSL3_CK_RSA_RC4_128_SHA, | 251 | SSL3_CK_RSA_RC4_128_SHA, |
| 165 | SSL_kRSA|SSL_aRSA|SSL_RC4 |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_MEDIUM, | 252 | SSL_kRSA|SSL_aRSA|SSL_RC4 |SSL_SHA1|SSL_SSLV3, |
| 253 | SSL_NOT_EXP|SSL_MEDIUM, | ||
| 166 | 0, | 254 | 0, |
| 255 | 128, | ||
| 256 | 128, | ||
| 167 | SSL_ALL_CIPHERS, | 257 | SSL_ALL_CIPHERS, |
| 258 | SSL_ALL_STRENGTHS, | ||
| 168 | }, | 259 | }, |
| 169 | /* Cipher 06 */ | 260 | /* Cipher 06 */ |
| 170 | { | 261 | { |
| 171 | 1, | 262 | 1, |
| 172 | SSL3_TXT_RSA_RC2_40_MD5, | 263 | SSL3_TXT_RSA_RC2_40_MD5, |
| 173 | SSL3_CK_RSA_RC2_40_MD5, | 264 | SSL3_CK_RSA_RC2_40_MD5, |
| 174 | SSL_kRSA|SSL_aRSA|SSL_RC2 |SSL_MD5 |SSL_EXP|SSL_SSLV3, | 265 | SSL_kRSA|SSL_aRSA|SSL_RC2 |SSL_MD5 |SSL_SSLV3, |
| 266 | SSL_EXPORT|SSL_EXP40, | ||
| 175 | 0, | 267 | 0, |
| 268 | 40, | ||
| 269 | 128, | ||
| 176 | SSL_ALL_CIPHERS, | 270 | SSL_ALL_CIPHERS, |
| 271 | SSL_ALL_STRENGTHS, | ||
| 177 | }, | 272 | }, |
| 178 | /* Cipher 07 */ | 273 | /* Cipher 07 */ |
| 179 | { | 274 | { |
| 180 | 1, | 275 | 1, |
| 181 | SSL3_TXT_RSA_IDEA_128_SHA, | 276 | SSL3_TXT_RSA_IDEA_128_SHA, |
| 182 | SSL3_CK_RSA_IDEA_128_SHA, | 277 | SSL3_CK_RSA_IDEA_128_SHA, |
| 183 | SSL_kRSA|SSL_aRSA|SSL_IDEA |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_MEDIUM, | 278 | SSL_kRSA|SSL_aRSA|SSL_IDEA |SSL_SHA1|SSL_SSLV3, |
| 279 | SSL_NOT_EXP|SSL_MEDIUM, | ||
| 184 | 0, | 280 | 0, |
| 281 | 128, | ||
| 282 | 128, | ||
| 185 | SSL_ALL_CIPHERS, | 283 | SSL_ALL_CIPHERS, |
| 284 | SSL_ALL_STRENGTHS, | ||
| 186 | }, | 285 | }, |
| 187 | /* Cipher 08 */ | 286 | /* Cipher 08 */ |
| 188 | { | 287 | { |
| 189 | 1, | 288 | 1, |
| 190 | SSL3_TXT_RSA_DES_40_CBC_SHA, | 289 | SSL3_TXT_RSA_DES_40_CBC_SHA, |
| 191 | SSL3_CK_RSA_DES_40_CBC_SHA, | 290 | SSL3_CK_RSA_DES_40_CBC_SHA, |
| 192 | SSL_kRSA|SSL_aRSA|SSL_DES|SSL_SHA1|SSL_EXP|SSL_SSLV3, | 291 | SSL_kRSA|SSL_aRSA|SSL_DES|SSL_SHA1|SSL_SSLV3, |
| 292 | SSL_EXPORT|SSL_EXP40, | ||
| 193 | 0, | 293 | 0, |
| 294 | 40, | ||
| 295 | 56, | ||
| 194 | SSL_ALL_CIPHERS, | 296 | SSL_ALL_CIPHERS, |
| 297 | SSL_ALL_STRENGTHS, | ||
| 195 | }, | 298 | }, |
| 196 | /* Cipher 09 */ | 299 | /* Cipher 09 */ |
| 197 | { | 300 | { |
| 198 | 1, | 301 | 1, |
| 199 | SSL3_TXT_RSA_DES_64_CBC_SHA, | 302 | SSL3_TXT_RSA_DES_64_CBC_SHA, |
| 200 | SSL3_CK_RSA_DES_64_CBC_SHA, | 303 | SSL3_CK_RSA_DES_64_CBC_SHA, |
| 201 | SSL_kRSA|SSL_aRSA|SSL_DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_LOW, | 304 | SSL_kRSA|SSL_aRSA|SSL_DES |SSL_SHA1|SSL_SSLV3, |
| 305 | SSL_NOT_EXP|SSL_LOW, | ||
| 202 | 0, | 306 | 0, |
| 307 | 56, | ||
| 308 | 56, | ||
| 203 | SSL_ALL_CIPHERS, | 309 | SSL_ALL_CIPHERS, |
| 310 | SSL_ALL_STRENGTHS, | ||
| 204 | }, | 311 | }, |
| 205 | /* Cipher 0A */ | 312 | /* Cipher 0A */ |
| 206 | { | 313 | { |
| 207 | 1, | 314 | 1, |
| 208 | SSL3_TXT_RSA_DES_192_CBC3_SHA, | 315 | SSL3_TXT_RSA_DES_192_CBC3_SHA, |
| 209 | SSL3_CK_RSA_DES_192_CBC3_SHA, | 316 | SSL3_CK_RSA_DES_192_CBC3_SHA, |
| 210 | SSL_kRSA|SSL_aRSA|SSL_3DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_HIGH, | 317 | SSL_kRSA|SSL_aRSA|SSL_3DES |SSL_SHA1|SSL_SSLV3, |
| 318 | SSL_NOT_EXP|SSL_HIGH, | ||
| 211 | 0, | 319 | 0, |
| 320 | 168, | ||
| 321 | 168, | ||
| 212 | SSL_ALL_CIPHERS, | 322 | SSL_ALL_CIPHERS, |
| 323 | SSL_ALL_STRENGTHS, | ||
| 213 | }, | 324 | }, |
| 214 | 325 | ||
| 215 | /* The DH ciphers */ | 326 | /* The DH ciphers */ |
| @@ -218,54 +329,78 @@ SSL_CIPHER ssl3_ciphers[]={ | |||
| 218 | 0, | 329 | 0, |
| 219 | SSL3_TXT_DH_DSS_DES_40_CBC_SHA, | 330 | SSL3_TXT_DH_DSS_DES_40_CBC_SHA, |
| 220 | SSL3_CK_DH_DSS_DES_40_CBC_SHA, | 331 | SSL3_CK_DH_DSS_DES_40_CBC_SHA, |
| 221 | SSL_kDHd |SSL_aDH|SSL_DES|SSL_SHA1|SSL_EXP|SSL_SSLV3, | 332 | SSL_kDHd |SSL_aDH|SSL_DES|SSL_SHA1|SSL_SSLV3, |
| 333 | SSL_EXPORT|SSL_EXP40, | ||
| 222 | 0, | 334 | 0, |
| 335 | 40, | ||
| 336 | 56, | ||
| 223 | SSL_ALL_CIPHERS, | 337 | SSL_ALL_CIPHERS, |
| 338 | SSL_ALL_STRENGTHS, | ||
| 224 | }, | 339 | }, |
| 225 | /* Cipher 0C */ | 340 | /* Cipher 0C */ |
| 226 | { | 341 | { |
| 227 | 0, | 342 | 0, |
| 228 | SSL3_TXT_DH_DSS_DES_64_CBC_SHA, | 343 | SSL3_TXT_DH_DSS_DES_64_CBC_SHA, |
| 229 | SSL3_CK_DH_DSS_DES_64_CBC_SHA, | 344 | SSL3_CK_DH_DSS_DES_64_CBC_SHA, |
| 230 | SSL_kDHd |SSL_aDH|SSL_DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_LOW, | 345 | SSL_kDHd |SSL_aDH|SSL_DES |SSL_SHA1|SSL_SSLV3, |
| 346 | SSL_NOT_EXP|SSL_LOW, | ||
| 231 | 0, | 347 | 0, |
| 348 | 56, | ||
| 349 | 56, | ||
| 232 | SSL_ALL_CIPHERS, | 350 | SSL_ALL_CIPHERS, |
| 351 | SSL_ALL_STRENGTHS, | ||
| 233 | }, | 352 | }, |
| 234 | /* Cipher 0D */ | 353 | /* Cipher 0D */ |
| 235 | { | 354 | { |
| 236 | 0, | 355 | 0, |
| 237 | SSL3_TXT_DH_DSS_DES_192_CBC3_SHA, | 356 | SSL3_TXT_DH_DSS_DES_192_CBC3_SHA, |
| 238 | SSL3_CK_DH_DSS_DES_192_CBC3_SHA, | 357 | SSL3_CK_DH_DSS_DES_192_CBC3_SHA, |
| 239 | SSL_kDHd |SSL_aDH|SSL_3DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_HIGH, | 358 | SSL_kDHd |SSL_aDH|SSL_3DES |SSL_SHA1|SSL_SSLV3, |
| 359 | SSL_NOT_EXP|SSL_HIGH, | ||
| 240 | 0, | 360 | 0, |
| 361 | 168, | ||
| 362 | 168, | ||
| 241 | SSL_ALL_CIPHERS, | 363 | SSL_ALL_CIPHERS, |
| 364 | SSL_ALL_STRENGTHS, | ||
| 242 | }, | 365 | }, |
| 243 | /* Cipher 0E */ | 366 | /* Cipher 0E */ |
| 244 | { | 367 | { |
| 245 | 0, | 368 | 0, |
| 246 | SSL3_TXT_DH_RSA_DES_40_CBC_SHA, | 369 | SSL3_TXT_DH_RSA_DES_40_CBC_SHA, |
| 247 | SSL3_CK_DH_RSA_DES_40_CBC_SHA, | 370 | SSL3_CK_DH_RSA_DES_40_CBC_SHA, |
| 248 | SSL_kDHr |SSL_aDH|SSL_DES|SSL_SHA1|SSL_EXP|SSL_SSLV3, | 371 | SSL_kDHr |SSL_aDH|SSL_DES|SSL_SHA1|SSL_SSLV3, |
| 372 | SSL_EXPORT|SSL_EXP40, | ||
| 249 | 0, | 373 | 0, |
| 374 | 40, | ||
| 375 | 56, | ||
| 250 | SSL_ALL_CIPHERS, | 376 | SSL_ALL_CIPHERS, |
| 377 | SSL_ALL_STRENGTHS, | ||
| 251 | }, | 378 | }, |
| 252 | /* Cipher 0F */ | 379 | /* Cipher 0F */ |
| 253 | { | 380 | { |
| 254 | 0, | 381 | 0, |
| 255 | SSL3_TXT_DH_RSA_DES_64_CBC_SHA, | 382 | SSL3_TXT_DH_RSA_DES_64_CBC_SHA, |
| 256 | SSL3_CK_DH_RSA_DES_64_CBC_SHA, | 383 | SSL3_CK_DH_RSA_DES_64_CBC_SHA, |
| 257 | SSL_kDHr |SSL_aDH|SSL_DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_LOW, | 384 | SSL_kDHr |SSL_aDH|SSL_DES |SSL_SHA1|SSL_SSLV3, |
| 385 | SSL_NOT_EXP|SSL_LOW, | ||
| 258 | 0, | 386 | 0, |
| 387 | 56, | ||
| 388 | 56, | ||
| 259 | SSL_ALL_CIPHERS, | 389 | SSL_ALL_CIPHERS, |
| 390 | SSL_ALL_STRENGTHS, | ||
| 260 | }, | 391 | }, |
| 261 | /* Cipher 10 */ | 392 | /* Cipher 10 */ |
| 262 | { | 393 | { |
| 263 | 0, | 394 | 0, |
| 264 | SSL3_TXT_DH_RSA_DES_192_CBC3_SHA, | 395 | SSL3_TXT_DH_RSA_DES_192_CBC3_SHA, |
| 265 | SSL3_CK_DH_RSA_DES_192_CBC3_SHA, | 396 | SSL3_CK_DH_RSA_DES_192_CBC3_SHA, |
| 266 | SSL_kDHr |SSL_aDH|SSL_3DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_HIGH, | 397 | SSL_kDHr |SSL_aDH|SSL_3DES |SSL_SHA1|SSL_SSLV3, |
| 398 | SSL_NOT_EXP|SSL_HIGH, | ||
| 267 | 0, | 399 | 0, |
| 400 | 168, | ||
| 401 | 168, | ||
| 268 | SSL_ALL_CIPHERS, | 402 | SSL_ALL_CIPHERS, |
| 403 | SSL_ALL_STRENGTHS, | ||
| 269 | }, | 404 | }, |
| 270 | 405 | ||
| 271 | /* The Ephemeral DH ciphers */ | 406 | /* The Ephemeral DH ciphers */ |
| @@ -274,54 +409,78 @@ SSL_CIPHER ssl3_ciphers[]={ | |||
| 274 | 1, | 409 | 1, |
| 275 | SSL3_TXT_EDH_DSS_DES_40_CBC_SHA, | 410 | SSL3_TXT_EDH_DSS_DES_40_CBC_SHA, |
| 276 | SSL3_CK_EDH_DSS_DES_40_CBC_SHA, | 411 | SSL3_CK_EDH_DSS_DES_40_CBC_SHA, |
| 277 | SSL_kEDH|SSL_aDSS|SSL_DES|SSL_SHA1|SSL_EXP|SSL_SSLV3, | 412 | SSL_kEDH|SSL_aDSS|SSL_DES|SSL_SHA1|SSL_SSLV3, |
| 413 | SSL_EXPORT|SSL_EXP40, | ||
| 278 | 0, | 414 | 0, |
| 415 | 40, | ||
| 416 | 56, | ||
| 279 | SSL_ALL_CIPHERS, | 417 | SSL_ALL_CIPHERS, |
| 418 | SSL_ALL_STRENGTHS, | ||
| 280 | }, | 419 | }, |
| 281 | /* Cipher 12 */ | 420 | /* Cipher 12 */ |
| 282 | { | 421 | { |
| 283 | 1, | 422 | 1, |
| 284 | SSL3_TXT_EDH_DSS_DES_64_CBC_SHA, | 423 | SSL3_TXT_EDH_DSS_DES_64_CBC_SHA, |
| 285 | SSL3_CK_EDH_DSS_DES_64_CBC_SHA, | 424 | SSL3_CK_EDH_DSS_DES_64_CBC_SHA, |
| 286 | SSL_kEDH|SSL_aDSS|SSL_DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_LOW, | 425 | SSL_kEDH|SSL_aDSS|SSL_DES |SSL_SHA1|SSL_SSLV3, |
| 426 | SSL_NOT_EXP|SSL_LOW, | ||
| 287 | 0, | 427 | 0, |
| 428 | 56, | ||
| 429 | 56, | ||
| 288 | SSL_ALL_CIPHERS, | 430 | SSL_ALL_CIPHERS, |
| 431 | SSL_ALL_STRENGTHS, | ||
| 289 | }, | 432 | }, |
| 290 | /* Cipher 13 */ | 433 | /* Cipher 13 */ |
| 291 | { | 434 | { |
| 292 | 1, | 435 | 1, |
| 293 | SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA, | 436 | SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA, |
| 294 | SSL3_CK_EDH_DSS_DES_192_CBC3_SHA, | 437 | SSL3_CK_EDH_DSS_DES_192_CBC3_SHA, |
| 295 | SSL_kEDH|SSL_aDSS|SSL_3DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_HIGH, | 438 | SSL_kEDH|SSL_aDSS|SSL_3DES |SSL_SHA1|SSL_SSLV3, |
| 439 | SSL_NOT_EXP|SSL_HIGH, | ||
| 296 | 0, | 440 | 0, |
| 441 | 168, | ||
| 442 | 168, | ||
| 297 | SSL_ALL_CIPHERS, | 443 | SSL_ALL_CIPHERS, |
| 444 | SSL_ALL_STRENGTHS, | ||
| 298 | }, | 445 | }, |
| 299 | /* Cipher 14 */ | 446 | /* Cipher 14 */ |
| 300 | { | 447 | { |
| 301 | 1, | 448 | 1, |
| 302 | SSL3_TXT_EDH_RSA_DES_40_CBC_SHA, | 449 | SSL3_TXT_EDH_RSA_DES_40_CBC_SHA, |
| 303 | SSL3_CK_EDH_RSA_DES_40_CBC_SHA, | 450 | SSL3_CK_EDH_RSA_DES_40_CBC_SHA, |
| 304 | SSL_kEDH|SSL_aRSA|SSL_DES|SSL_SHA1|SSL_EXP|SSL_SSLV3, | 451 | SSL_kEDH|SSL_aRSA|SSL_DES|SSL_SHA1|SSL_SSLV3, |
| 452 | SSL_EXPORT|SSL_EXP40, | ||
| 305 | 0, | 453 | 0, |
| 454 | 40, | ||
| 455 | 56, | ||
| 306 | SSL_ALL_CIPHERS, | 456 | SSL_ALL_CIPHERS, |
| 457 | SSL_ALL_STRENGTHS, | ||
| 307 | }, | 458 | }, |
| 308 | /* Cipher 15 */ | 459 | /* Cipher 15 */ |
| 309 | { | 460 | { |
| 310 | 1, | 461 | 1, |
| 311 | SSL3_TXT_EDH_RSA_DES_64_CBC_SHA, | 462 | SSL3_TXT_EDH_RSA_DES_64_CBC_SHA, |
| 312 | SSL3_CK_EDH_RSA_DES_64_CBC_SHA, | 463 | SSL3_CK_EDH_RSA_DES_64_CBC_SHA, |
| 313 | SSL_kEDH|SSL_aRSA|SSL_DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_LOW, | 464 | SSL_kEDH|SSL_aRSA|SSL_DES |SSL_SHA1|SSL_SSLV3, |
| 465 | SSL_NOT_EXP|SSL_LOW, | ||
| 314 | 0, | 466 | 0, |
| 467 | 56, | ||
| 468 | 56, | ||
| 315 | SSL_ALL_CIPHERS, | 469 | SSL_ALL_CIPHERS, |
| 470 | SSL_ALL_STRENGTHS, | ||
| 316 | }, | 471 | }, |
| 317 | /* Cipher 16 */ | 472 | /* Cipher 16 */ |
| 318 | { | 473 | { |
| 319 | 1, | 474 | 1, |
| 320 | SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA, | 475 | SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA, |
| 321 | SSL3_CK_EDH_RSA_DES_192_CBC3_SHA, | 476 | SSL3_CK_EDH_RSA_DES_192_CBC3_SHA, |
| 322 | SSL_kEDH|SSL_aRSA|SSL_3DES |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3|SSL_HIGH, | 477 | SSL_kEDH|SSL_aRSA|SSL_3DES |SSL_SHA1|SSL_SSLV3, |
| 478 | SSL_NOT_EXP|SSL_HIGH, | ||
| 323 | 0, | 479 | 0, |
| 480 | 168, | ||
| 481 | 168, | ||
| 324 | SSL_ALL_CIPHERS, | 482 | SSL_ALL_CIPHERS, |
| 483 | SSL_ALL_STRENGTHS, | ||
| 325 | }, | 484 | }, |
| 326 | 485 | ||
| 327 | /* Fortezza */ | 486 | /* Fortezza */ |
| @@ -330,9 +489,13 @@ SSL_CIPHER ssl3_ciphers[]={ | |||
| 330 | 0, | 489 | 0, |
| 331 | SSL3_TXT_FZA_DMS_NULL_SHA, | 490 | SSL3_TXT_FZA_DMS_NULL_SHA, |
| 332 | SSL3_CK_FZA_DMS_NULL_SHA, | 491 | SSL3_CK_FZA_DMS_NULL_SHA, |
| 333 | SSL_kFZA|SSL_aFZA |SSL_eNULL |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3, | 492 | SSL_kFZA|SSL_aFZA |SSL_eNULL |SSL_SHA1|SSL_SSLV3, |
| 493 | SSL_NOT_EXP, | ||
| 494 | 0, | ||
| 495 | 0, | ||
| 334 | 0, | 496 | 0, |
| 335 | SSL_ALL_CIPHERS, | 497 | SSL_ALL_CIPHERS, |
| 498 | SSL_ALL_STRENGTHS, | ||
| 336 | }, | 499 | }, |
| 337 | 500 | ||
| 338 | /* Cipher 1D */ | 501 | /* Cipher 1D */ |
| @@ -340,9 +503,13 @@ SSL_CIPHER ssl3_ciphers[]={ | |||
| 340 | 0, | 503 | 0, |
| 341 | SSL3_TXT_FZA_DMS_FZA_SHA, | 504 | SSL3_TXT_FZA_DMS_FZA_SHA, |
| 342 | SSL3_CK_FZA_DMS_FZA_SHA, | 505 | SSL3_CK_FZA_DMS_FZA_SHA, |
| 343 | SSL_kFZA|SSL_aFZA |SSL_eFZA |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3, | 506 | SSL_kFZA|SSL_aFZA |SSL_eFZA |SSL_SHA1|SSL_SSLV3, |
| 507 | SSL_NOT_EXP, | ||
| 508 | 0, | ||
| 509 | 0, | ||
| 344 | 0, | 510 | 0, |
| 345 | SSL_ALL_CIPHERS, | 511 | SSL_ALL_CIPHERS, |
| 512 | SSL_ALL_STRENGTHS, | ||
| 346 | }, | 513 | }, |
| 347 | 514 | ||
| 348 | /* Cipher 1E */ | 515 | /* Cipher 1E */ |
| @@ -350,10 +517,359 @@ SSL_CIPHER ssl3_ciphers[]={ | |||
| 350 | 0, | 517 | 0, |
| 351 | SSL3_TXT_FZA_DMS_RC4_SHA, | 518 | SSL3_TXT_FZA_DMS_RC4_SHA, |
| 352 | SSL3_CK_FZA_DMS_RC4_SHA, | 519 | SSL3_CK_FZA_DMS_RC4_SHA, |
| 353 | SSL_kFZA|SSL_aFZA |SSL_RC4 |SSL_SHA1|SSL_NOT_EXP|SSL_SSLV3, | 520 | SSL_kFZA|SSL_aFZA |SSL_RC4 |SSL_SHA1|SSL_SSLV3, |
| 521 | SSL_NOT_EXP|SSL_MEDIUM, | ||
| 522 | 0, | ||
| 523 | 128, | ||
| 524 | 128, | ||
| 525 | SSL_ALL_CIPHERS, | ||
| 526 | SSL_ALL_STRENGTHS, | ||
| 527 | }, | ||
| 528 | |||
| 529 | #ifndef OPENSSL_NO_KRB5 | ||
| 530 | /* The Kerberos ciphers | ||
| 531 | ** 20000107 VRS: And the first shall be last, | ||
| 532 | ** in hopes of avoiding the lynx ssl renegotiation problem. | ||
| 533 | */ | ||
| 534 | /* Cipher 21 VRS */ | ||
| 535 | { | ||
| 536 | 1, | ||
| 537 | SSL3_TXT_KRB5_DES_40_CBC_SHA, | ||
| 538 | SSL3_CK_KRB5_DES_40_CBC_SHA, | ||
| 539 | SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_SHA1 |SSL_SSLV3, | ||
| 540 | SSL_EXPORT|SSL_EXP40, | ||
| 541 | 0, | ||
| 542 | 40, | ||
| 543 | 56, | ||
| 544 | SSL_ALL_CIPHERS, | ||
| 545 | SSL_ALL_STRENGTHS, | ||
| 546 | }, | ||
| 547 | |||
| 548 | /* Cipher 22 VRS */ | ||
| 549 | { | ||
| 550 | 1, | ||
| 551 | SSL3_TXT_KRB5_DES_40_CBC_MD5, | ||
| 552 | SSL3_CK_KRB5_DES_40_CBC_MD5, | ||
| 553 | SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_MD5 |SSL_SSLV3, | ||
| 554 | SSL_EXPORT|SSL_EXP40, | ||
| 555 | 0, | ||
| 556 | 40, | ||
| 557 | 56, | ||
| 558 | SSL_ALL_CIPHERS, | ||
| 559 | SSL_ALL_STRENGTHS, | ||
| 560 | }, | ||
| 561 | |||
| 562 | /* Cipher 23 VRS */ | ||
| 563 | { | ||
| 564 | 1, | ||
| 565 | SSL3_TXT_KRB5_DES_64_CBC_SHA, | ||
| 566 | SSL3_CK_KRB5_DES_64_CBC_SHA, | ||
| 567 | SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_SHA1 |SSL_SSLV3, | ||
| 568 | SSL_NOT_EXP|SSL_LOW, | ||
| 569 | 0, | ||
| 570 | 56, | ||
| 571 | 56, | ||
| 572 | SSL_ALL_CIPHERS, | ||
| 573 | SSL_ALL_STRENGTHS, | ||
| 574 | }, | ||
| 575 | |||
| 576 | /* Cipher 24 VRS */ | ||
| 577 | { | ||
| 578 | 1, | ||
| 579 | SSL3_TXT_KRB5_DES_64_CBC_MD5, | ||
| 580 | SSL3_CK_KRB5_DES_64_CBC_MD5, | ||
| 581 | SSL_kKRB5|SSL_aKRB5| SSL_DES|SSL_MD5 |SSL_SSLV3, | ||
| 582 | SSL_NOT_EXP|SSL_LOW, | ||
| 583 | 0, | ||
| 584 | 56, | ||
| 585 | 56, | ||
| 586 | SSL_ALL_CIPHERS, | ||
| 587 | SSL_ALL_STRENGTHS, | ||
| 588 | }, | ||
| 589 | |||
| 590 | /* Cipher 25 VRS */ | ||
| 591 | { | ||
| 592 | 1, | ||
| 593 | SSL3_TXT_KRB5_DES_192_CBC3_SHA, | ||
| 594 | SSL3_CK_KRB5_DES_192_CBC3_SHA, | ||
| 595 | SSL_kKRB5|SSL_aKRB5| SSL_3DES|SSL_SHA1 |SSL_SSLV3, | ||
| 596 | SSL_NOT_EXP|SSL_HIGH, | ||
| 597 | 0, | ||
| 598 | 112, | ||
| 599 | 168, | ||
| 600 | SSL_ALL_CIPHERS, | ||
| 601 | SSL_ALL_STRENGTHS, | ||
| 602 | }, | ||
| 603 | |||
| 604 | /* Cipher 26 VRS */ | ||
| 605 | { | ||
| 606 | 1, | ||
| 607 | SSL3_TXT_KRB5_DES_192_CBC3_MD5, | ||
| 608 | SSL3_CK_KRB5_DES_192_CBC3_MD5, | ||
| 609 | SSL_kKRB5|SSL_aKRB5| SSL_3DES|SSL_MD5 |SSL_SSLV3, | ||
| 610 | SSL_NOT_EXP|SSL_HIGH, | ||
| 354 | 0, | 611 | 0, |
| 612 | 112, | ||
| 613 | 168, | ||
| 355 | SSL_ALL_CIPHERS, | 614 | SSL_ALL_CIPHERS, |
| 615 | SSL_ALL_STRENGTHS, | ||
| 356 | }, | 616 | }, |
| 617 | #endif /* OPENSSL_NO_KRB5 */ | ||
| 618 | |||
| 619 | |||
| 620 | #if TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES | ||
| 621 | /* New TLS Export CipherSuites */ | ||
| 622 | /* Cipher 60 */ | ||
| 623 | { | ||
| 624 | 1, | ||
| 625 | TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5, | ||
| 626 | TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5, | ||
| 627 | SSL_kRSA|SSL_aRSA|SSL_RC4|SSL_MD5|SSL_TLSV1, | ||
| 628 | SSL_EXPORT|SSL_EXP56, | ||
| 629 | 0, | ||
| 630 | 56, | ||
| 631 | 128, | ||
| 632 | SSL_ALL_CIPHERS, | ||
| 633 | SSL_ALL_STRENGTHS, | ||
| 634 | }, | ||
| 635 | /* Cipher 61 */ | ||
| 636 | { | ||
| 637 | 1, | ||
| 638 | TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5, | ||
| 639 | TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5, | ||
| 640 | SSL_kRSA|SSL_aRSA|SSL_RC2|SSL_MD5|SSL_TLSV1, | ||
| 641 | SSL_EXPORT|SSL_EXP56, | ||
| 642 | 0, | ||
| 643 | 56, | ||
| 644 | 128, | ||
| 645 | SSL_ALL_CIPHERS, | ||
| 646 | SSL_ALL_STRENGTHS, | ||
| 647 | }, | ||
| 648 | /* Cipher 62 */ | ||
| 649 | { | ||
| 650 | 1, | ||
| 651 | TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA, | ||
| 652 | TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA, | ||
| 653 | SSL_kRSA|SSL_aRSA|SSL_DES|SSL_SHA|SSL_TLSV1, | ||
| 654 | SSL_EXPORT|SSL_EXP56, | ||
| 655 | 0, | ||
| 656 | 56, | ||
| 657 | 56, | ||
| 658 | SSL_ALL_CIPHERS, | ||
| 659 | SSL_ALL_STRENGTHS, | ||
| 660 | }, | ||
| 661 | /* Cipher 63 */ | ||
| 662 | { | ||
| 663 | 1, | ||
| 664 | TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA, | ||
| 665 | TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA, | ||
| 666 | SSL_kEDH|SSL_aDSS|SSL_DES|SSL_SHA|SSL_TLSV1, | ||
| 667 | SSL_EXPORT|SSL_EXP56, | ||
| 668 | 0, | ||
| 669 | 56, | ||
| 670 | 56, | ||
| 671 | SSL_ALL_CIPHERS, | ||
| 672 | SSL_ALL_STRENGTHS, | ||
| 673 | }, | ||
| 674 | /* Cipher 64 */ | ||
| 675 | { | ||
| 676 | 1, | ||
| 677 | TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA, | ||
| 678 | TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA, | ||
| 679 | SSL_kRSA|SSL_aRSA|SSL_RC4|SSL_SHA|SSL_TLSV1, | ||
| 680 | SSL_EXPORT|SSL_EXP56, | ||
| 681 | 0, | ||
| 682 | 56, | ||
| 683 | 128, | ||
| 684 | SSL_ALL_CIPHERS, | ||
| 685 | SSL_ALL_STRENGTHS, | ||
| 686 | }, | ||
| 687 | /* Cipher 65 */ | ||
| 688 | { | ||
| 689 | 1, | ||
| 690 | TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA, | ||
| 691 | TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA, | ||
| 692 | SSL_kEDH|SSL_aDSS|SSL_RC4|SSL_SHA|SSL_TLSV1, | ||
| 693 | SSL_EXPORT|SSL_EXP56, | ||
| 694 | 0, | ||
| 695 | 56, | ||
| 696 | 128, | ||
| 697 | SSL_ALL_CIPHERS, | ||
| 698 | SSL_ALL_STRENGTHS, | ||
| 699 | }, | ||
| 700 | /* Cipher 66 */ | ||
| 701 | { | ||
| 702 | 1, | ||
| 703 | TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA, | ||
| 704 | TLS1_CK_DHE_DSS_WITH_RC4_128_SHA, | ||
| 705 | SSL_kEDH|SSL_aDSS|SSL_RC4|SSL_SHA|SSL_TLSV1, | ||
| 706 | SSL_NOT_EXP|SSL_MEDIUM, | ||
| 707 | 0, | ||
| 708 | 128, | ||
| 709 | 128, | ||
| 710 | SSL_ALL_CIPHERS, | ||
| 711 | SSL_ALL_STRENGTHS | ||
| 712 | }, | ||
| 713 | #endif | ||
| 714 | /* New AES ciphersuites */ | ||
| 715 | |||
| 716 | /* Cipher 2F */ | ||
| 717 | { | ||
| 718 | 1, | ||
| 719 | TLS1_TXT_RSA_WITH_AES_128_SHA, | ||
| 720 | TLS1_CK_RSA_WITH_AES_128_SHA, | ||
| 721 | SSL_kRSA|SSL_aRSA|SSL_AES|SSL_SHA |SSL_TLSV1, | ||
| 722 | SSL_NOT_EXP|SSL_MEDIUM, | ||
| 723 | 0, | ||
| 724 | 128, | ||
| 725 | 128, | ||
| 726 | SSL_ALL_CIPHERS, | ||
| 727 | SSL_ALL_STRENGTHS, | ||
| 728 | }, | ||
| 729 | /* Cipher 30 */ | ||
| 730 | { | ||
| 731 | 0, | ||
| 732 | TLS1_TXT_DH_DSS_WITH_AES_128_SHA, | ||
| 733 | TLS1_CK_DH_DSS_WITH_AES_128_SHA, | ||
| 734 | SSL_kDHd|SSL_aDH|SSL_AES|SSL_SHA|SSL_TLSV1, | ||
| 735 | SSL_NOT_EXP|SSL_MEDIUM, | ||
| 736 | 0, | ||
| 737 | 128, | ||
| 738 | 128, | ||
| 739 | SSL_ALL_CIPHERS, | ||
| 740 | SSL_ALL_STRENGTHS, | ||
| 741 | }, | ||
| 742 | /* Cipher 31 */ | ||
| 743 | { | ||
| 744 | 0, | ||
| 745 | TLS1_TXT_DH_RSA_WITH_AES_128_SHA, | ||
| 746 | TLS1_CK_DH_RSA_WITH_AES_128_SHA, | ||
| 747 | SSL_kDHr|SSL_aDH|SSL_AES|SSL_SHA|SSL_TLSV1, | ||
| 748 | SSL_NOT_EXP|SSL_MEDIUM, | ||
| 749 | 0, | ||
| 750 | 128, | ||
| 751 | 128, | ||
| 752 | SSL_ALL_CIPHERS, | ||
| 753 | SSL_ALL_STRENGTHS, | ||
| 754 | }, | ||
| 755 | /* Cipher 32 */ | ||
| 756 | { | ||
| 757 | 1, | ||
| 758 | TLS1_TXT_DHE_DSS_WITH_AES_128_SHA, | ||
| 759 | TLS1_CK_DHE_DSS_WITH_AES_128_SHA, | ||
| 760 | SSL_kEDH|SSL_aDSS|SSL_AES|SSL_SHA|SSL_TLSV1, | ||
| 761 | SSL_NOT_EXP|SSL_MEDIUM, | ||
| 762 | 0, | ||
| 763 | 128, | ||
| 764 | 128, | ||
| 765 | SSL_ALL_CIPHERS, | ||
| 766 | SSL_ALL_STRENGTHS, | ||
| 767 | }, | ||
| 768 | /* Cipher 33 */ | ||
| 769 | { | ||
| 770 | 1, | ||
| 771 | TLS1_TXT_DHE_RSA_WITH_AES_128_SHA, | ||
| 772 | TLS1_CK_DHE_RSA_WITH_AES_128_SHA, | ||
| 773 | SSL_kEDH|SSL_aRSA|SSL_AES|SSL_SHA|SSL_TLSV1, | ||
| 774 | SSL_NOT_EXP|SSL_MEDIUM, | ||
| 775 | 0, | ||
| 776 | 128, | ||
| 777 | 128, | ||
| 778 | SSL_ALL_CIPHERS, | ||
| 779 | SSL_ALL_STRENGTHS, | ||
| 780 | }, | ||
| 781 | /* Cipher 34 */ | ||
| 782 | { | ||
| 783 | 1, | ||
| 784 | TLS1_TXT_ADH_WITH_AES_128_SHA, | ||
| 785 | TLS1_CK_ADH_WITH_AES_128_SHA, | ||
| 786 | SSL_kEDH|SSL_aNULL|SSL_AES|SSL_SHA|SSL_TLSV1, | ||
| 787 | SSL_NOT_EXP|SSL_MEDIUM, | ||
| 788 | 0, | ||
| 789 | 128, | ||
| 790 | 128, | ||
| 791 | SSL_ALL_CIPHERS, | ||
| 792 | SSL_ALL_STRENGTHS, | ||
| 793 | }, | ||
| 794 | |||
| 795 | /* Cipher 35 */ | ||
| 796 | { | ||
| 797 | 1, | ||
| 798 | TLS1_TXT_RSA_WITH_AES_256_SHA, | ||
| 799 | TLS1_CK_RSA_WITH_AES_256_SHA, | ||
| 800 | SSL_kRSA|SSL_aRSA|SSL_AES|SSL_SHA |SSL_TLSV1, | ||
| 801 | SSL_NOT_EXP|SSL_HIGH, | ||
| 802 | 0, | ||
| 803 | 256, | ||
| 804 | 256, | ||
| 805 | SSL_ALL_CIPHERS, | ||
| 806 | SSL_ALL_STRENGTHS, | ||
| 807 | }, | ||
| 808 | /* Cipher 36 */ | ||
| 809 | { | ||
| 810 | 0, | ||
| 811 | TLS1_TXT_DH_DSS_WITH_AES_256_SHA, | ||
| 812 | TLS1_CK_DH_DSS_WITH_AES_256_SHA, | ||
| 813 | SSL_kDHd|SSL_aDH|SSL_AES|SSL_SHA|SSL_TLSV1, | ||
| 814 | SSL_NOT_EXP|SSL_HIGH, | ||
| 815 | 0, | ||
| 816 | 256, | ||
| 817 | 256, | ||
| 818 | SSL_ALL_CIPHERS, | ||
| 819 | SSL_ALL_STRENGTHS, | ||
| 820 | }, | ||
| 821 | /* Cipher 37 */ | ||
| 822 | { | ||
| 823 | 0, | ||
| 824 | TLS1_TXT_DH_RSA_WITH_AES_256_SHA, | ||
| 825 | TLS1_CK_DH_RSA_WITH_AES_256_SHA, | ||
| 826 | SSL_kDHr|SSL_aDH|SSL_AES|SSL_SHA|SSL_TLSV1, | ||
| 827 | SSL_NOT_EXP|SSL_HIGH, | ||
| 828 | 0, | ||
| 829 | 256, | ||
| 830 | 256, | ||
| 831 | SSL_ALL_CIPHERS, | ||
| 832 | SSL_ALL_STRENGTHS, | ||
| 833 | }, | ||
| 834 | /* Cipher 38 */ | ||
| 835 | { | ||
| 836 | 1, | ||
| 837 | TLS1_TXT_DHE_DSS_WITH_AES_256_SHA, | ||
| 838 | TLS1_CK_DHE_DSS_WITH_AES_256_SHA, | ||
| 839 | SSL_kEDH|SSL_aDSS|SSL_AES|SSL_SHA|SSL_TLSV1, | ||
| 840 | SSL_NOT_EXP|SSL_HIGH, | ||
| 841 | 0, | ||
| 842 | 256, | ||
| 843 | 256, | ||
| 844 | SSL_ALL_CIPHERS, | ||
| 845 | SSL_ALL_STRENGTHS, | ||
| 846 | }, | ||
| 847 | /* Cipher 39 */ | ||
| 848 | { | ||
| 849 | 1, | ||
| 850 | TLS1_TXT_DHE_RSA_WITH_AES_256_SHA, | ||
| 851 | TLS1_CK_DHE_RSA_WITH_AES_256_SHA, | ||
| 852 | SSL_kEDH|SSL_aRSA|SSL_AES|SSL_SHA|SSL_TLSV1, | ||
| 853 | SSL_NOT_EXP|SSL_HIGH, | ||
| 854 | 0, | ||
| 855 | 256, | ||
| 856 | 256, | ||
| 857 | SSL_ALL_CIPHERS, | ||
| 858 | SSL_ALL_STRENGTHS, | ||
| 859 | }, | ||
| 860 | /* Cipher 3A */ | ||
| 861 | { | ||
| 862 | 1, | ||
| 863 | TLS1_TXT_ADH_WITH_AES_256_SHA, | ||
| 864 | TLS1_CK_ADH_WITH_AES_256_SHA, | ||
| 865 | SSL_kEDH|SSL_aNULL|SSL_AES|SSL_SHA|SSL_TLSV1, | ||
| 866 | SSL_NOT_EXP|SSL_HIGH, | ||
| 867 | 0, | ||
| 868 | 256, | ||
| 869 | 256, | ||
| 870 | SSL_ALL_CIPHERS, | ||
| 871 | SSL_ALL_STRENGTHS, | ||
| 872 | }, | ||
| 357 | 873 | ||
| 358 | /* end of list */ | 874 | /* end of list */ |
| 359 | }; | 875 | }; |
| @@ -384,6 +900,7 @@ static SSL_METHOD SSLv3_data= { | |||
| 384 | ssl3_write, | 900 | ssl3_write, |
| 385 | ssl3_shutdown, | 901 | ssl3_shutdown, |
| 386 | ssl3_renegotiate, | 902 | ssl3_renegotiate, |
| 903 | ssl3_renegotiate_check, | ||
| 387 | ssl3_ctrl, | 904 | ssl3_ctrl, |
| 388 | ssl3_ctx_ctrl, | 905 | ssl3_ctx_ctrl, |
| 389 | ssl3_get_cipher_by_char, | 906 | ssl3_get_cipher_by_char, |
| @@ -394,27 +911,29 @@ static SSL_METHOD SSLv3_data= { | |||
| 394 | ssl_bad_method, | 911 | ssl_bad_method, |
| 395 | ssl3_default_timeout, | 912 | ssl3_default_timeout, |
| 396 | &SSLv3_enc_data, | 913 | &SSLv3_enc_data, |
| 914 | ssl_undefined_function, | ||
| 915 | ssl3_callback_ctrl, | ||
| 916 | ssl3_ctx_callback_ctrl, | ||
| 397 | }; | 917 | }; |
| 398 | 918 | ||
| 399 | static long ssl3_default_timeout() | 919 | static long ssl3_default_timeout(void) |
| 400 | { | 920 | { |
| 401 | /* 2 hours, the 24 hours mentioned in the SSLv3 spec | 921 | /* 2 hours, the 24 hours mentioned in the SSLv3 spec |
| 402 | * is way too long for http, the cache would over fill */ | 922 | * is way too long for http, the cache would over fill */ |
| 403 | return(60*60*2); | 923 | return(60*60*2); |
| 404 | } | 924 | } |
| 405 | 925 | ||
| 406 | SSL_METHOD *sslv3_base_method() | 926 | SSL_METHOD *sslv3_base_method(void) |
| 407 | { | 927 | { |
| 408 | return(&SSLv3_data); | 928 | return(&SSLv3_data); |
| 409 | } | 929 | } |
| 410 | 930 | ||
| 411 | int ssl3_num_ciphers() | 931 | int ssl3_num_ciphers(void) |
| 412 | { | 932 | { |
| 413 | return(SSL3_NUM_CIPHERS); | 933 | return(SSL3_NUM_CIPHERS); |
| 414 | } | 934 | } |
| 415 | 935 | ||
| 416 | SSL_CIPHER *ssl3_get_cipher(u) | 936 | SSL_CIPHER *ssl3_get_cipher(unsigned int u) |
| 417 | unsigned int u; | ||
| 418 | { | 937 | { |
| 419 | if (u < SSL3_NUM_CIPHERS) | 938 | if (u < SSL3_NUM_CIPHERS) |
| 420 | return(&(ssl3_ciphers[SSL3_NUM_CIPHERS-1-u])); | 939 | return(&(ssl3_ciphers[SSL3_NUM_CIPHERS-1-u])); |
| @@ -422,29 +941,24 @@ unsigned int u; | |||
| 422 | return(NULL); | 941 | return(NULL); |
| 423 | } | 942 | } |
| 424 | 943 | ||
| 425 | /* The problem is that it may not be the correct record type */ | 944 | int ssl3_pending(SSL *s) |
| 426 | int ssl3_pending(s) | ||
| 427 | SSL *s; | ||
| 428 | { | 945 | { |
| 429 | return(s->s3->rrec.length); | 946 | if (s->rstate == SSL_ST_READ_BODY) |
| 947 | return 0; | ||
| 948 | |||
| 949 | return (s->s3->rrec.type == SSL3_RT_APPLICATION_DATA) ? s->s3->rrec.length : 0; | ||
| 430 | } | 950 | } |
| 431 | 951 | ||
| 432 | int ssl3_new(s) | 952 | int ssl3_new(SSL *s) |
| 433 | SSL *s; | ||
| 434 | { | 953 | { |
| 435 | SSL3_CTX *s3; | 954 | SSL3_STATE *s3; |
| 436 | 955 | ||
| 437 | if ((s3=(SSL3_CTX *)Malloc(sizeof(SSL3_CTX))) == NULL) goto err; | 956 | if ((s3=OPENSSL_malloc(sizeof *s3)) == NULL) goto err; |
| 438 | memset(s3,0,sizeof(SSL3_CTX)); | 957 | memset(s3,0,sizeof *s3); |
| 958 | EVP_MD_CTX_init(&s3->finish_dgst1); | ||
| 959 | EVP_MD_CTX_init(&s3->finish_dgst2); | ||
| 439 | 960 | ||
| 440 | s->s3=s3; | 961 | s->s3=s3; |
| 441 | /* | ||
| 442 | s->s3->tmp.ca_names=NULL; | ||
| 443 | s->s3->tmp.key_block=NULL; | ||
| 444 | s->s3->tmp.key_block_length=0; | ||
| 445 | s->s3->rbuf.buf=NULL; | ||
| 446 | s->s3->wbuf.buf=NULL; | ||
| 447 | */ | ||
| 448 | 962 | ||
| 449 | s->method->ssl_clear(s); | 963 | s->method->ssl_clear(s); |
| 450 | return(1); | 964 | return(1); |
| @@ -452,40 +966,66 @@ err: | |||
| 452 | return(0); | 966 | return(0); |
| 453 | } | 967 | } |
| 454 | 968 | ||
| 455 | void ssl3_free(s) | 969 | void ssl3_free(SSL *s) |
| 456 | SSL *s; | ||
| 457 | { | 970 | { |
| 971 | if(s == NULL) | ||
| 972 | return; | ||
| 973 | |||
| 458 | ssl3_cleanup_key_block(s); | 974 | ssl3_cleanup_key_block(s); |
| 459 | if (s->s3->rbuf.buf != NULL) | 975 | if (s->s3->rbuf.buf != NULL) |
| 460 | Free(s->s3->rbuf.buf); | 976 | OPENSSL_free(s->s3->rbuf.buf); |
| 461 | if (s->s3->wbuf.buf != NULL) | 977 | if (s->s3->wbuf.buf != NULL) |
| 462 | Free(s->s3->wbuf.buf); | 978 | OPENSSL_free(s->s3->wbuf.buf); |
| 463 | #ifndef NO_DH | 979 | if (s->s3->rrec.comp != NULL) |
| 980 | OPENSSL_free(s->s3->rrec.comp); | ||
| 981 | #ifndef OPENSSL_NO_DH | ||
| 464 | if (s->s3->tmp.dh != NULL) | 982 | if (s->s3->tmp.dh != NULL) |
| 465 | DH_free(s->s3->tmp.dh); | 983 | DH_free(s->s3->tmp.dh); |
| 466 | #endif | 984 | #endif |
| 467 | if (s->s3->tmp.ca_names != NULL) | 985 | if (s->s3->tmp.ca_names != NULL) |
| 468 | sk_pop_free(s->s3->tmp.ca_names,X509_NAME_free); | 986 | sk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free); |
| 469 | memset(s->s3,0,sizeof(SSL3_CTX)); | 987 | EVP_MD_CTX_cleanup(&s->s3->finish_dgst1); |
| 470 | Free(s->s3); | 988 | EVP_MD_CTX_cleanup(&s->s3->finish_dgst2); |
| 989 | memset(s->s3,0,sizeof *s->s3); | ||
| 990 | OPENSSL_free(s->s3); | ||
| 471 | s->s3=NULL; | 991 | s->s3=NULL; |
| 472 | } | 992 | } |
| 473 | 993 | ||
| 474 | void ssl3_clear(s) | 994 | void ssl3_clear(SSL *s) |
| 475 | SSL *s; | ||
| 476 | { | 995 | { |
| 477 | unsigned char *rp,*wp; | 996 | unsigned char *rp,*wp; |
| 997 | size_t rlen, wlen; | ||
| 478 | 998 | ||
| 479 | ssl3_cleanup_key_block(s); | 999 | ssl3_cleanup_key_block(s); |
| 480 | if (s->s3->tmp.ca_names != NULL) | 1000 | if (s->s3->tmp.ca_names != NULL) |
| 481 | sk_pop_free(s->s3->tmp.ca_names,X509_NAME_free); | 1001 | sk_X509_NAME_pop_free(s->s3->tmp.ca_names,X509_NAME_free); |
| 482 | 1002 | ||
| 483 | rp=s->s3->rbuf.buf; | 1003 | if (s->s3->rrec.comp != NULL) |
| 484 | wp=s->s3->wbuf.buf; | 1004 | { |
| 1005 | OPENSSL_free(s->s3->rrec.comp); | ||
| 1006 | s->s3->rrec.comp=NULL; | ||
| 1007 | } | ||
| 1008 | #ifndef OPENSSL_NO_DH | ||
| 1009 | if (s->s3->tmp.dh != NULL) | ||
| 1010 | DH_free(s->s3->tmp.dh); | ||
| 1011 | #endif | ||
| 1012 | |||
| 1013 | rp = s->s3->rbuf.buf; | ||
| 1014 | wp = s->s3->wbuf.buf; | ||
| 1015 | rlen = s->s3->rbuf.len; | ||
| 1016 | wlen = s->s3->wbuf.len; | ||
| 1017 | |||
| 1018 | EVP_MD_CTX_cleanup(&s->s3->finish_dgst1); | ||
| 1019 | EVP_MD_CTX_cleanup(&s->s3->finish_dgst2); | ||
| 1020 | |||
| 1021 | memset(s->s3,0,sizeof *s->s3); | ||
| 1022 | s->s3->rbuf.buf = rp; | ||
| 1023 | s->s3->wbuf.buf = wp; | ||
| 1024 | s->s3->rbuf.len = rlen; | ||
| 1025 | s->s3->wbuf.len = wlen; | ||
| 1026 | |||
| 1027 | ssl_free_wbio_buffer(s); | ||
| 485 | 1028 | ||
| 486 | memset(s->s3,0,sizeof(SSL3_CTX)); | ||
| 487 | if (rp != NULL) s->s3->rbuf.buf=rp; | ||
| 488 | if (wp != NULL) s->s3->wbuf.buf=wp; | ||
| 489 | s->packet_length=0; | 1029 | s->packet_length=0; |
| 490 | s->s3->renegotiate=0; | 1030 | s->s3->renegotiate=0; |
| 491 | s->s3->total_renegotiations=0; | 1031 | s->s3->total_renegotiations=0; |
| @@ -494,14 +1034,30 @@ SSL *s; | |||
| 494 | s->version=SSL3_VERSION; | 1034 | s->version=SSL3_VERSION; |
| 495 | } | 1035 | } |
| 496 | 1036 | ||
| 497 | long ssl3_ctrl(s,cmd,larg,parg) | 1037 | long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg) |
| 498 | SSL *s; | ||
| 499 | int cmd; | ||
| 500 | long larg; | ||
| 501 | char *parg; | ||
| 502 | { | 1038 | { |
| 503 | int ret=0; | 1039 | int ret=0; |
| 504 | 1040 | ||
| 1041 | #if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA) | ||
| 1042 | if ( | ||
| 1043 | #ifndef OPENSSL_NO_RSA | ||
| 1044 | cmd == SSL_CTRL_SET_TMP_RSA || | ||
| 1045 | cmd == SSL_CTRL_SET_TMP_RSA_CB || | ||
| 1046 | #endif | ||
| 1047 | #ifndef OPENSSL_NO_DSA | ||
| 1048 | cmd == SSL_CTRL_SET_TMP_DH || | ||
| 1049 | cmd == SSL_CTRL_SET_TMP_DH_CB || | ||
| 1050 | #endif | ||
| 1051 | 0) | ||
| 1052 | { | ||
| 1053 | if (!ssl_cert_inst(&s->cert)) | ||
| 1054 | { | ||
| 1055 | SSLerr(SSL_F_SSL3_CTRL, ERR_R_MALLOC_FAILURE); | ||
| 1056 | return(0); | ||
| 1057 | } | ||
| 1058 | } | ||
| 1059 | #endif | ||
| 1060 | |||
| 505 | switch (cmd) | 1061 | switch (cmd) |
| 506 | { | 1062 | { |
| 507 | case SSL_CTRL_GET_SESSION_REUSED: | 1063 | case SSL_CTRL_GET_SESSION_REUSED: |
| @@ -519,25 +1075,137 @@ char *parg; | |||
| 519 | case SSL_CTRL_GET_TOTAL_RENEGOTIATIONS: | 1075 | case SSL_CTRL_GET_TOTAL_RENEGOTIATIONS: |
| 520 | ret=s->s3->total_renegotiations; | 1076 | ret=s->s3->total_renegotiations; |
| 521 | break; | 1077 | break; |
| 1078 | case SSL_CTRL_GET_FLAGS: | ||
| 1079 | ret=(int)(s->s3->flags); | ||
| 1080 | break; | ||
| 1081 | #ifndef OPENSSL_NO_RSA | ||
| 1082 | case SSL_CTRL_NEED_TMP_RSA: | ||
| 1083 | if ((s->cert != NULL) && (s->cert->rsa_tmp == NULL) && | ||
| 1084 | ((s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) || | ||
| 1085 | (EVP_PKEY_size(s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey) > (512/8)))) | ||
| 1086 | ret = 1; | ||
| 1087 | break; | ||
| 1088 | case SSL_CTRL_SET_TMP_RSA: | ||
| 1089 | { | ||
| 1090 | RSA *rsa = (RSA *)parg; | ||
| 1091 | if (rsa == NULL) | ||
| 1092 | { | ||
| 1093 | SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER); | ||
| 1094 | return(ret); | ||
| 1095 | } | ||
| 1096 | if ((rsa = RSAPrivateKey_dup(rsa)) == NULL) | ||
| 1097 | { | ||
| 1098 | SSLerr(SSL_F_SSL3_CTRL, ERR_R_RSA_LIB); | ||
| 1099 | return(ret); | ||
| 1100 | } | ||
| 1101 | if (s->cert->rsa_tmp != NULL) | ||
| 1102 | RSA_free(s->cert->rsa_tmp); | ||
| 1103 | s->cert->rsa_tmp = rsa; | ||
| 1104 | ret = 1; | ||
| 1105 | } | ||
| 1106 | break; | ||
| 1107 | case SSL_CTRL_SET_TMP_RSA_CB: | ||
| 1108 | { | ||
| 1109 | SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | ||
| 1110 | return(ret); | ||
| 1111 | } | ||
| 1112 | break; | ||
| 1113 | #endif | ||
| 1114 | #ifndef OPENSSL_NO_DH | ||
| 1115 | case SSL_CTRL_SET_TMP_DH: | ||
| 1116 | { | ||
| 1117 | DH *dh = (DH *)parg; | ||
| 1118 | if (dh == NULL) | ||
| 1119 | { | ||
| 1120 | SSLerr(SSL_F_SSL3_CTRL, ERR_R_PASSED_NULL_PARAMETER); | ||
| 1121 | return(ret); | ||
| 1122 | } | ||
| 1123 | if ((dh = DHparams_dup(dh)) == NULL) | ||
| 1124 | { | ||
| 1125 | SSLerr(SSL_F_SSL3_CTRL, ERR_R_DH_LIB); | ||
| 1126 | return(ret); | ||
| 1127 | } | ||
| 1128 | if (!(s->options & SSL_OP_SINGLE_DH_USE)) | ||
| 1129 | { | ||
| 1130 | if (!DH_generate_key(dh)) | ||
| 1131 | { | ||
| 1132 | DH_free(dh); | ||
| 1133 | SSLerr(SSL_F_SSL3_CTRL, ERR_R_DH_LIB); | ||
| 1134 | return(ret); | ||
| 1135 | } | ||
| 1136 | } | ||
| 1137 | if (s->cert->dh_tmp != NULL) | ||
| 1138 | DH_free(s->cert->dh_tmp); | ||
| 1139 | s->cert->dh_tmp = dh; | ||
| 1140 | ret = 1; | ||
| 1141 | } | ||
| 1142 | break; | ||
| 1143 | case SSL_CTRL_SET_TMP_DH_CB: | ||
| 1144 | { | ||
| 1145 | SSLerr(SSL_F_SSL3_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | ||
| 1146 | return(ret); | ||
| 1147 | } | ||
| 1148 | break; | ||
| 1149 | #endif | ||
| 522 | default: | 1150 | default: |
| 523 | break; | 1151 | break; |
| 524 | } | 1152 | } |
| 525 | return(ret); | 1153 | return(ret); |
| 526 | } | 1154 | } |
| 527 | 1155 | ||
| 528 | long ssl3_ctx_ctrl(ctx,cmd,larg,parg) | 1156 | long ssl3_callback_ctrl(SSL *s, int cmd, void (*fp)()) |
| 529 | SSL_CTX *ctx; | 1157 | { |
| 530 | int cmd; | 1158 | int ret=0; |
| 531 | long larg; | 1159 | |
| 532 | char *parg; | 1160 | #if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA) |
| 1161 | if ( | ||
| 1162 | #ifndef OPENSSL_NO_RSA | ||
| 1163 | cmd == SSL_CTRL_SET_TMP_RSA_CB || | ||
| 1164 | #endif | ||
| 1165 | #ifndef OPENSSL_NO_DSA | ||
| 1166 | cmd == SSL_CTRL_SET_TMP_DH_CB || | ||
| 1167 | #endif | ||
| 1168 | 0) | ||
| 1169 | { | ||
| 1170 | if (!ssl_cert_inst(&s->cert)) | ||
| 1171 | { | ||
| 1172 | SSLerr(SSL_F_SSL3_CALLBACK_CTRL, ERR_R_MALLOC_FAILURE); | ||
| 1173 | return(0); | ||
| 1174 | } | ||
| 1175 | } | ||
| 1176 | #endif | ||
| 1177 | |||
| 1178 | switch (cmd) | ||
| 1179 | { | ||
| 1180 | #ifndef OPENSSL_NO_RSA | ||
| 1181 | case SSL_CTRL_SET_TMP_RSA_CB: | ||
| 1182 | { | ||
| 1183 | s->cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp; | ||
| 1184 | } | ||
| 1185 | break; | ||
| 1186 | #endif | ||
| 1187 | #ifndef OPENSSL_NO_DH | ||
| 1188 | case SSL_CTRL_SET_TMP_DH_CB: | ||
| 1189 | { | ||
| 1190 | s->cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp; | ||
| 1191 | } | ||
| 1192 | break; | ||
| 1193 | #endif | ||
| 1194 | default: | ||
| 1195 | break; | ||
| 1196 | } | ||
| 1197 | return(ret); | ||
| 1198 | } | ||
| 1199 | |||
| 1200 | long ssl3_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg) | ||
| 533 | { | 1201 | { |
| 534 | CERT *cert; | 1202 | CERT *cert; |
| 535 | 1203 | ||
| 536 | cert=ctx->default_cert; | 1204 | cert=ctx->cert; |
| 537 | 1205 | ||
| 538 | switch (cmd) | 1206 | switch (cmd) |
| 539 | { | 1207 | { |
| 540 | #ifndef NO_RSA | 1208 | #ifndef OPENSSL_NO_RSA |
| 541 | case SSL_CTRL_NEED_TMP_RSA: | 1209 | case SSL_CTRL_NEED_TMP_RSA: |
| 542 | if ( (cert->rsa_tmp == NULL) && | 1210 | if ( (cert->rsa_tmp == NULL) && |
| 543 | ((cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) || | 1211 | ((cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) || |
| @@ -546,7 +1214,7 @@ char *parg; | |||
| 546 | return(1); | 1214 | return(1); |
| 547 | else | 1215 | else |
| 548 | return(0); | 1216 | return(0); |
| 549 | break; | 1217 | /* break; */ |
| 550 | case SSL_CTRL_SET_TMP_RSA: | 1218 | case SSL_CTRL_SET_TMP_RSA: |
| 551 | { | 1219 | { |
| 552 | RSA *rsa; | 1220 | RSA *rsa; |
| @@ -574,35 +1242,83 @@ char *parg; | |||
| 574 | return(1); | 1242 | return(1); |
| 575 | } | 1243 | } |
| 576 | } | 1244 | } |
| 577 | break; | 1245 | /* break; */ |
| 578 | case SSL_CTRL_SET_TMP_RSA_CB: | 1246 | case SSL_CTRL_SET_TMP_RSA_CB: |
| 579 | cert->rsa_tmp_cb=(RSA *(*)())parg; | 1247 | { |
| 1248 | SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | ||
| 1249 | return(0); | ||
| 1250 | } | ||
| 580 | break; | 1251 | break; |
| 581 | #endif | 1252 | #endif |
| 582 | #ifndef NO_DH | 1253 | #ifndef OPENSSL_NO_DH |
| 583 | case SSL_CTRL_SET_TMP_DH: | 1254 | case SSL_CTRL_SET_TMP_DH: |
| 584 | { | 1255 | { |
| 585 | DH *new=NULL,*dh; | 1256 | DH *new=NULL,*dh; |
| 586 | 1257 | ||
| 587 | dh=(DH *)parg; | 1258 | dh=(DH *)parg; |
| 588 | if ( ((new=DHparams_dup(dh)) == NULL) || | 1259 | if ((new=DHparams_dup(dh)) == NULL) |
| 589 | (!DH_generate_key(new))) | ||
| 590 | { | 1260 | { |
| 591 | SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_DH_LIB); | 1261 | SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_DH_LIB); |
| 592 | if (new != NULL) DH_free(new); | 1262 | return 0; |
| 593 | return(0); | ||
| 594 | } | 1263 | } |
| 595 | else | 1264 | if (!(ctx->options & SSL_OP_SINGLE_DH_USE)) |
| 596 | { | 1265 | { |
| 597 | if (cert->dh_tmp != NULL) | 1266 | if (!DH_generate_key(new)) |
| 598 | DH_free(cert->dh_tmp); | 1267 | { |
| 599 | cert->dh_tmp=new; | 1268 | SSLerr(SSL_F_SSL3_CTX_CTRL,ERR_R_DH_LIB); |
| 600 | return(1); | 1269 | DH_free(new); |
| 1270 | return 0; | ||
| 1271 | } | ||
| 601 | } | 1272 | } |
| 1273 | if (cert->dh_tmp != NULL) | ||
| 1274 | DH_free(cert->dh_tmp); | ||
| 1275 | cert->dh_tmp=new; | ||
| 1276 | return 1; | ||
| 1277 | } | ||
| 1278 | /*break; */ | ||
| 1279 | case SSL_CTRL_SET_TMP_DH_CB: | ||
| 1280 | { | ||
| 1281 | SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | ||
| 1282 | return(0); | ||
| 602 | } | 1283 | } |
| 603 | break; | 1284 | break; |
| 1285 | #endif | ||
| 1286 | /* A Thawte special :-) */ | ||
| 1287 | case SSL_CTRL_EXTRA_CHAIN_CERT: | ||
| 1288 | if (ctx->extra_certs == NULL) | ||
| 1289 | { | ||
| 1290 | if ((ctx->extra_certs=sk_X509_new_null()) == NULL) | ||
| 1291 | return(0); | ||
| 1292 | } | ||
| 1293 | sk_X509_push(ctx->extra_certs,(X509 *)parg); | ||
| 1294 | break; | ||
| 1295 | |||
| 1296 | default: | ||
| 1297 | return(0); | ||
| 1298 | } | ||
| 1299 | return(1); | ||
| 1300 | } | ||
| 1301 | |||
| 1302 | long ssl3_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)()) | ||
| 1303 | { | ||
| 1304 | CERT *cert; | ||
| 1305 | |||
| 1306 | cert=ctx->cert; | ||
| 1307 | |||
| 1308 | switch (cmd) | ||
| 1309 | { | ||
| 1310 | #ifndef OPENSSL_NO_RSA | ||
| 1311 | case SSL_CTRL_SET_TMP_RSA_CB: | ||
| 1312 | { | ||
| 1313 | cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp; | ||
| 1314 | } | ||
| 1315 | break; | ||
| 1316 | #endif | ||
| 1317 | #ifndef OPENSSL_NO_DH | ||
| 604 | case SSL_CTRL_SET_TMP_DH_CB: | 1318 | case SSL_CTRL_SET_TMP_DH_CB: |
| 605 | cert->dh_tmp_cb=(DH *(*)())parg; | 1319 | { |
| 1320 | cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))fp; | ||
| 1321 | } | ||
| 606 | break; | 1322 | break; |
| 607 | #endif | 1323 | #endif |
| 608 | default: | 1324 | default: |
| @@ -613,8 +1329,7 @@ char *parg; | |||
| 613 | 1329 | ||
| 614 | /* This function needs to check if the ciphers required are actually | 1330 | /* This function needs to check if the ciphers required are actually |
| 615 | * available */ | 1331 | * available */ |
| 616 | SSL_CIPHER *ssl3_get_cipher_by_char(p) | 1332 | SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p) |
| 617 | unsigned char *p; | ||
| 618 | { | 1333 | { |
| 619 | static int init=1; | 1334 | static int init=1; |
| 620 | static SSL_CIPHER *sorted[SSL3_NUM_CIPHERS]; | 1335 | static SSL_CIPHER *sorted[SSL3_NUM_CIPHERS]; |
| @@ -624,7 +1339,7 @@ unsigned char *p; | |||
| 624 | 1339 | ||
| 625 | if (init) | 1340 | if (init) |
| 626 | { | 1341 | { |
| 627 | init=0; | 1342 | CRYPTO_w_lock(CRYPTO_LOCK_SSL); |
| 628 | 1343 | ||
| 629 | for (i=0; i<SSL3_NUM_CIPHERS; i++) | 1344 | for (i=0; i<SSL3_NUM_CIPHERS; i++) |
| 630 | sorted[i]= &(ssl3_ciphers[i]); | 1345 | sorted[i]= &(ssl3_ciphers[i]); |
| @@ -632,6 +1347,10 @@ unsigned char *p; | |||
| 632 | qsort( (char *)sorted, | 1347 | qsort( (char *)sorted, |
| 633 | SSL3_NUM_CIPHERS,sizeof(SSL_CIPHER *), | 1348 | SSL3_NUM_CIPHERS,sizeof(SSL_CIPHER *), |
| 634 | FP_ICC ssl_cipher_ptr_id_cmp); | 1349 | FP_ICC ssl_cipher_ptr_id_cmp); |
| 1350 | |||
| 1351 | CRYPTO_w_unlock(CRYPTO_LOCK_SSL); | ||
| 1352 | |||
| 1353 | init=0; | ||
| 635 | } | 1354 | } |
| 636 | 1355 | ||
| 637 | id=0x03000000L|((unsigned long)p[0]<<8L)|(unsigned long)p[1]; | 1356 | id=0x03000000L|((unsigned long)p[0]<<8L)|(unsigned long)p[1]; |
| @@ -639,16 +1358,14 @@ unsigned char *p; | |||
| 639 | cpp=(SSL_CIPHER **)OBJ_bsearch((char *)&cp, | 1358 | cpp=(SSL_CIPHER **)OBJ_bsearch((char *)&cp, |
| 640 | (char *)sorted, | 1359 | (char *)sorted, |
| 641 | SSL3_NUM_CIPHERS,sizeof(SSL_CIPHER *), | 1360 | SSL3_NUM_CIPHERS,sizeof(SSL_CIPHER *), |
| 642 | (int (*)())ssl_cipher_ptr_id_cmp); | 1361 | FP_ICC ssl_cipher_ptr_id_cmp); |
| 643 | if ((cpp == NULL) || !(*cpp)->valid) | 1362 | if ((cpp == NULL) || !(*cpp)->valid) |
| 644 | return(NULL); | 1363 | return(NULL); |
| 645 | else | 1364 | else |
| 646 | return(*cpp); | 1365 | return(*cpp); |
| 647 | } | 1366 | } |
| 648 | 1367 | ||
| 649 | int ssl3_put_cipher_by_char(c,p) | 1368 | int ssl3_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p) |
| 650 | SSL_CIPHER *c; | ||
| 651 | unsigned char *p; | ||
| 652 | { | 1369 | { |
| 653 | long l; | 1370 | long l; |
| 654 | 1371 | ||
| @@ -662,114 +1379,141 @@ unsigned char *p; | |||
| 662 | return(2); | 1379 | return(2); |
| 663 | } | 1380 | } |
| 664 | 1381 | ||
| 665 | int ssl3_part_read(s,i) | 1382 | SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt, |
| 666 | SSL *s; | 1383 | STACK_OF(SSL_CIPHER) *srvr) |
| 667 | int i; | ||
| 668 | { | ||
| 669 | s->rwstate=SSL_READING; | ||
| 670 | |||
| 671 | if (i < 0) | ||
| 672 | { | ||
| 673 | return(i); | ||
| 674 | } | ||
| 675 | else | ||
| 676 | { | ||
| 677 | s->init_num+=i; | ||
| 678 | return(0); | ||
| 679 | } | ||
| 680 | } | ||
| 681 | |||
| 682 | SSL_CIPHER *ssl3_choose_cipher(s,have,pref) | ||
| 683 | SSL *s; | ||
| 684 | STACK *have,*pref; | ||
| 685 | { | 1384 | { |
| 686 | SSL_CIPHER *c,*ret=NULL; | 1385 | SSL_CIPHER *c,*ret=NULL; |
| 1386 | STACK_OF(SSL_CIPHER) *prio, *allow; | ||
| 687 | int i,j,ok; | 1387 | int i,j,ok; |
| 688 | CERT *cert; | 1388 | CERT *cert; |
| 689 | unsigned long alg,mask,emask; | 1389 | unsigned long alg,mask,emask; |
| 690 | 1390 | ||
| 691 | /* Lets see which ciphers we can supported */ | 1391 | /* Let's see which ciphers we can support */ |
| 692 | if (s->cert != NULL) | 1392 | cert=s->cert; |
| 693 | cert=s->cert; | 1393 | |
| 1394 | #if 0 | ||
| 1395 | /* Do not set the compare functions, because this may lead to a | ||
| 1396 | * reordering by "id". We want to keep the original ordering. | ||
| 1397 | * We may pay a price in performance during sk_SSL_CIPHER_find(), | ||
| 1398 | * but would have to pay with the price of sk_SSL_CIPHER_dup(). | ||
| 1399 | */ | ||
| 1400 | sk_SSL_CIPHER_set_cmp_func(srvr, ssl_cipher_ptr_id_cmp); | ||
| 1401 | sk_SSL_CIPHER_set_cmp_func(clnt, ssl_cipher_ptr_id_cmp); | ||
| 1402 | #endif | ||
| 1403 | |||
| 1404 | #ifdef CIPHER_DEBUG | ||
| 1405 | printf("Server has %d from %p:\n", sk_SSL_CIPHER_num(srvr), srvr); | ||
| 1406 | for(i=0 ; i < sk_SSL_CIPHER_num(srvr) ; ++i) | ||
| 1407 | { | ||
| 1408 | c=sk_SSL_CIPHER_value(srvr,i); | ||
| 1409 | printf("%p:%s\n",c,c->name); | ||
| 1410 | } | ||
| 1411 | printf("Client sent %d from %p:\n", sk_SSL_CIPHER_num(clnt), clnt); | ||
| 1412 | for(i=0 ; i < sk_SSL_CIPHER_num(clnt) ; ++i) | ||
| 1413 | { | ||
| 1414 | c=sk_SSL_CIPHER_value(clnt,i); | ||
| 1415 | printf("%p:%s\n",c,c->name); | ||
| 1416 | } | ||
| 1417 | #endif | ||
| 1418 | |||
| 1419 | if (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE) | ||
| 1420 | { | ||
| 1421 | prio = srvr; | ||
| 1422 | allow = clnt; | ||
| 1423 | } | ||
| 694 | else | 1424 | else |
| 695 | cert=s->ctx->default_cert; | 1425 | { |
| 1426 | prio = clnt; | ||
| 1427 | allow = srvr; | ||
| 1428 | } | ||
| 1429 | |||
| 1430 | for (i=0; i<sk_SSL_CIPHER_num(prio); i++) | ||
| 1431 | { | ||
| 1432 | c=sk_SSL_CIPHER_value(prio,i); | ||
| 696 | 1433 | ||
| 697 | ssl_set_cert_masks(cert); | 1434 | ssl_set_cert_masks(cert,c); |
| 698 | mask=cert->mask; | 1435 | mask=cert->mask; |
| 699 | emask=cert->export_mask; | 1436 | emask=cert->export_mask; |
| 700 | 1437 | ||
| 701 | sk_set_cmp_func(pref,ssl_cipher_ptr_id_cmp); | 1438 | #ifdef KSSL_DEBUG |
| 1439 | printf("ssl3_choose_cipher %d alg= %lx\n", i,c->algorithms); | ||
| 1440 | #endif /* KSSL_DEBUG */ | ||
| 702 | 1441 | ||
| 703 | for (i=0; i<sk_num(have); i++) | ||
| 704 | { | ||
| 705 | c=(SSL_CIPHER *)sk_value(have,i); | ||
| 706 | alg=c->algorithms&(SSL_MKEY_MASK|SSL_AUTH_MASK); | 1442 | alg=c->algorithms&(SSL_MKEY_MASK|SSL_AUTH_MASK); |
| 707 | if (alg & SSL_EXPORT) | 1443 | #ifndef OPENSSL_NO_KRB5 |
| 1444 | if (alg & SSL_KRB5) | ||
| 1445 | { | ||
| 1446 | if ( !kssl_keytab_is_available(s->kssl_ctx) ) | ||
| 1447 | continue; | ||
| 1448 | } | ||
| 1449 | #endif /* OPENSSL_NO_KRB5 */ | ||
| 1450 | if (SSL_C_IS_EXPORT(c)) | ||
| 708 | { | 1451 | { |
| 709 | ok=((alg & emask) == alg)?1:0; | 1452 | ok=((alg & emask) == alg)?1:0; |
| 710 | #ifdef CIPHER_DEBUG | 1453 | #ifdef CIPHER_DEBUG |
| 711 | printf("%d:[%08lX:%08lX]%s\n",ok,alg,mask,c->name); | 1454 | printf("%d:[%08lX:%08lX]%p:%s (export)\n",ok,alg,emask, |
| 1455 | c,c->name); | ||
| 712 | #endif | 1456 | #endif |
| 713 | } | 1457 | } |
| 714 | else | 1458 | else |
| 715 | { | 1459 | { |
| 716 | ok=((alg & mask) == alg)?1:0; | 1460 | ok=((alg & mask) == alg)?1:0; |
| 717 | #ifdef CIPHER_DEBUG | 1461 | #ifdef CIPHER_DEBUG |
| 718 | printf("%d:[%08lX:%08lX]%s\n",ok,alg,mask,c->name); | 1462 | printf("%d:[%08lX:%08lX]%p:%s\n",ok,alg,mask,c, |
| 1463 | c->name); | ||
| 719 | #endif | 1464 | #endif |
| 720 | } | 1465 | } |
| 721 | 1466 | ||
| 722 | if (!ok) continue; | 1467 | if (!ok) continue; |
| 723 | 1468 | ||
| 724 | j=sk_find(pref,(char *)c); | 1469 | j=sk_SSL_CIPHER_find(allow,c); |
| 725 | if (j >= 0) | 1470 | if (j >= 0) |
| 726 | { | 1471 | { |
| 727 | ret=(SSL_CIPHER *)sk_value(pref,j); | 1472 | ret=sk_SSL_CIPHER_value(allow,j); |
| 728 | break; | 1473 | break; |
| 729 | } | 1474 | } |
| 730 | } | 1475 | } |
| 731 | return(ret); | 1476 | return(ret); |
| 732 | } | 1477 | } |
| 733 | 1478 | ||
| 734 | int ssl3_get_req_cert_type(s,p) | 1479 | int ssl3_get_req_cert_type(SSL *s, unsigned char *p) |
| 735 | SSL *s; | ||
| 736 | unsigned char *p; | ||
| 737 | { | 1480 | { |
| 738 | int ret=0; | 1481 | int ret=0; |
| 739 | unsigned long alg; | 1482 | unsigned long alg; |
| 740 | 1483 | ||
| 741 | alg=s->s3->tmp.new_cipher->algorithms; | 1484 | alg=s->s3->tmp.new_cipher->algorithms; |
| 742 | 1485 | ||
| 743 | #ifndef NO_DH | 1486 | #ifndef OPENSSL_NO_DH |
| 744 | if (alg & (SSL_kDHr|SSL_kEDH)) | 1487 | if (alg & (SSL_kDHr|SSL_kEDH)) |
| 745 | { | 1488 | { |
| 746 | #ifndef NO_RSA | 1489 | # ifndef OPENSSL_NO_RSA |
| 747 | p[ret++]=SSL3_CT_RSA_FIXED_DH; | 1490 | p[ret++]=SSL3_CT_RSA_FIXED_DH; |
| 748 | #endif | 1491 | # endif |
| 749 | #ifndef NO_DSA | 1492 | # ifndef OPENSSL_NO_DSA |
| 750 | p[ret++]=SSL3_CT_DSS_FIXED_DH; | 1493 | p[ret++]=SSL3_CT_DSS_FIXED_DH; |
| 751 | #endif | 1494 | # endif |
| 752 | } | 1495 | } |
| 753 | if ((s->version == SSL3_VERSION) && | 1496 | if ((s->version == SSL3_VERSION) && |
| 754 | (alg & (SSL_kEDH|SSL_kDHd|SSL_kDHr))) | 1497 | (alg & (SSL_kEDH|SSL_kDHd|SSL_kDHr))) |
| 755 | { | 1498 | { |
| 756 | #ifndef NO_RSA | 1499 | # ifndef OPENSSL_NO_RSA |
| 757 | p[ret++]=SSL3_CT_RSA_EPHEMERAL_DH; | 1500 | p[ret++]=SSL3_CT_RSA_EPHEMERAL_DH; |
| 758 | #endif | 1501 | # endif |
| 759 | #ifndef NO_DSA | 1502 | # ifndef OPENSSL_NO_DSA |
| 760 | p[ret++]=SSL3_CT_DSS_EPHEMERAL_DH; | 1503 | p[ret++]=SSL3_CT_DSS_EPHEMERAL_DH; |
| 761 | #endif | 1504 | # endif |
| 762 | } | 1505 | } |
| 763 | #endif /* !NO_DH */ | 1506 | #endif /* !OPENSSL_NO_DH */ |
| 764 | #ifndef NO_RSA | 1507 | #ifndef OPENSSL_NO_RSA |
| 765 | p[ret++]=SSL3_CT_RSA_SIGN; | 1508 | p[ret++]=SSL3_CT_RSA_SIGN; |
| 766 | #endif | 1509 | #endif |
| 1510 | #ifndef OPENSSL_NO_DSA | ||
| 767 | p[ret++]=SSL3_CT_DSS_SIGN; | 1511 | p[ret++]=SSL3_CT_DSS_SIGN; |
| 1512 | #endif | ||
| 768 | return(ret); | 1513 | return(ret); |
| 769 | } | 1514 | } |
| 770 | 1515 | ||
| 771 | int ssl3_shutdown(s) | 1516 | int ssl3_shutdown(SSL *s) |
| 772 | SSL *s; | ||
| 773 | { | 1517 | { |
| 774 | 1518 | ||
| 775 | /* Don't do anything much if we have not done the handshake or | 1519 | /* Don't do anything much if we have not done the handshake or |
| @@ -799,7 +1543,7 @@ SSL *s; | |||
| 799 | else if (!(s->shutdown & SSL_RECEIVED_SHUTDOWN)) | 1543 | else if (!(s->shutdown & SSL_RECEIVED_SHUTDOWN)) |
| 800 | { | 1544 | { |
| 801 | /* If we are waiting for a close from our peer, we are closed */ | 1545 | /* If we are waiting for a close from our peer, we are closed */ |
| 802 | ssl3_read_bytes(s,0,NULL,0); | 1546 | ssl3_read_bytes(s,0,NULL,0,0); |
| 803 | } | 1547 | } |
| 804 | 1548 | ||
| 805 | if ((s->shutdown == (SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN)) && | 1549 | if ((s->shutdown == (SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN)) && |
| @@ -809,13 +1553,9 @@ SSL *s; | |||
| 809 | return(0); | 1553 | return(0); |
| 810 | } | 1554 | } |
| 811 | 1555 | ||
| 812 | int ssl3_write(s,buf,len) | 1556 | int ssl3_write(SSL *s, const void *buf, int len) |
| 813 | SSL *s; | ||
| 814 | char *buf; | ||
| 815 | int len; | ||
| 816 | { | 1557 | { |
| 817 | int ret,n; | 1558 | int ret,n; |
| 818 | BIO *under; | ||
| 819 | 1559 | ||
| 820 | #if 0 | 1560 | #if 0 |
| 821 | if (s->shutdown & SSL_SEND_SHUTDOWN) | 1561 | if (s->shutdown & SSL_SEND_SHUTDOWN) |
| @@ -838,7 +1578,7 @@ int len; | |||
| 838 | if (s->s3->delay_buf_pop_ret == 0) | 1578 | if (s->s3->delay_buf_pop_ret == 0) |
| 839 | { | 1579 | { |
| 840 | ret=ssl3_write_bytes(s,SSL3_RT_APPLICATION_DATA, | 1580 | ret=ssl3_write_bytes(s,SSL3_RT_APPLICATION_DATA, |
| 841 | (char *)buf,len); | 1581 | buf,len); |
| 842 | if (ret <= 0) return(ret); | 1582 | if (ret <= 0) return(ret); |
| 843 | 1583 | ||
| 844 | s->s3->delay_buf_pop_ret=ret; | 1584 | s->s3->delay_buf_pop_ret=ret; |
| @@ -849,43 +1589,40 @@ int len; | |||
| 849 | if (n <= 0) return(n); | 1589 | if (n <= 0) return(n); |
| 850 | s->rwstate=SSL_NOTHING; | 1590 | s->rwstate=SSL_NOTHING; |
| 851 | 1591 | ||
| 852 | /* We have flushed the buffer */ | 1592 | /* We have flushed the buffer, so remove it */ |
| 853 | under=BIO_pop(s->wbio); | 1593 | ssl_free_wbio_buffer(s); |
| 854 | s->wbio=under; | 1594 | s->s3->flags&= ~SSL3_FLAGS_POP_BUFFER; |
| 855 | BIO_free(s->bbio); | 1595 | |
| 856 | s->bbio=NULL; | ||
| 857 | ret=s->s3->delay_buf_pop_ret; | 1596 | ret=s->s3->delay_buf_pop_ret; |
| 858 | s->s3->delay_buf_pop_ret=0; | 1597 | s->s3->delay_buf_pop_ret=0; |
| 859 | |||
| 860 | s->s3->flags&= ~SSL3_FLAGS_POP_BUFFER; | ||
| 861 | } | 1598 | } |
| 862 | else | 1599 | else |
| 863 | { | 1600 | { |
| 864 | ret=ssl3_write_bytes(s,SSL3_RT_APPLICATION_DATA, | 1601 | ret=ssl3_write_bytes(s,SSL3_RT_APPLICATION_DATA, |
| 865 | (char *)buf,len); | 1602 | buf,len); |
| 866 | if (ret <= 0) return(ret); | 1603 | if (ret <= 0) return(ret); |
| 867 | } | 1604 | } |
| 868 | 1605 | ||
| 869 | return(ret); | 1606 | return(ret); |
| 870 | } | 1607 | } |
| 871 | 1608 | ||
| 872 | int ssl3_read(s,buf,len) | 1609 | static int ssl3_read_internal(SSL *s, void *buf, int len, int peek) |
| 873 | SSL *s; | ||
| 874 | char *buf; | ||
| 875 | int len; | ||
| 876 | { | 1610 | { |
| 877 | int ret; | 1611 | int ret; |
| 878 | 1612 | ||
| 879 | clear_sys_error(); | 1613 | clear_sys_error(); |
| 880 | if (s->s3->renegotiate) ssl3_renegotiate_check(s); | 1614 | if (s->s3->renegotiate) ssl3_renegotiate_check(s); |
| 881 | s->s3->in_read_app_data=1; | 1615 | s->s3->in_read_app_data=1; |
| 882 | ret=ssl3_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len); | 1616 | ret=ssl3_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len,peek); |
| 883 | if ((ret == -1) && (s->s3->in_read_app_data == 0)) | 1617 | if ((ret == -1) && (s->s3->in_read_app_data == 2)) |
| 884 | { | 1618 | { |
| 885 | ERR_get_error(); /* clear the error */ | 1619 | /* ssl3_read_bytes decided to call s->handshake_func, which |
| 886 | s->s3->in_read_app_data=0; | 1620 | * called ssl3_read_bytes to read handshake data. |
| 1621 | * However, ssl3_read_bytes actually found application data | ||
| 1622 | * and thinks that application data makes sense here; so disable | ||
| 1623 | * handshake processing and try to read application data again. */ | ||
| 887 | s->in_handshake++; | 1624 | s->in_handshake++; |
| 888 | ret=ssl3_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len); | 1625 | ret=ssl3_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len,peek); |
| 889 | s->in_handshake--; | 1626 | s->in_handshake--; |
| 890 | } | 1627 | } |
| 891 | else | 1628 | else |
| @@ -894,33 +1631,17 @@ int len; | |||
| 894 | return(ret); | 1631 | return(ret); |
| 895 | } | 1632 | } |
| 896 | 1633 | ||
| 897 | int ssl3_peek(s,buf,len) | 1634 | int ssl3_read(SSL *s, void *buf, int len) |
| 898 | SSL *s; | ||
| 899 | char *buf; | ||
| 900 | int len; | ||
| 901 | { | 1635 | { |
| 902 | SSL3_RECORD *rr; | 1636 | return ssl3_read_internal(s, buf, len, 0); |
| 903 | int n; | 1637 | } |
| 904 | |||
| 905 | rr= &(s->s3->rrec); | ||
| 906 | if ((rr->length == 0) || (rr->type != SSL3_RT_APPLICATION_DATA)) | ||
| 907 | { | ||
| 908 | n=ssl3_read(s,buf,1); | ||
| 909 | if (n <= 0) return(n); | ||
| 910 | rr->length++; | ||
| 911 | rr->off--; | ||
| 912 | } | ||
| 913 | 1638 | ||
| 914 | if ((unsigned int)len > rr->length) | 1639 | int ssl3_peek(SSL *s, void *buf, int len) |
| 915 | n=rr->length; | 1640 | { |
| 916 | else | 1641 | return ssl3_read_internal(s, buf, len, 1); |
| 917 | n=len; | ||
| 918 | memcpy(buf,&(rr->data[rr->off]),(unsigned int)n); | ||
| 919 | return(n); | ||
| 920 | } | 1642 | } |
| 921 | 1643 | ||
| 922 | int ssl3_renegotiate(s) | 1644 | int ssl3_renegotiate(SSL *s) |
| 923 | SSL *s; | ||
| 924 | { | 1645 | { |
| 925 | if (s->handshake_func == NULL) | 1646 | if (s->handshake_func == NULL) |
| 926 | return(1); | 1647 | return(1); |
| @@ -932,8 +1653,7 @@ SSL *s; | |||
| 932 | return(1); | 1653 | return(1); |
| 933 | } | 1654 | } |
| 934 | 1655 | ||
| 935 | int ssl3_renegotiate_check(s) | 1656 | int ssl3_renegotiate_check(SSL *s) |
| 936 | SSL *s; | ||
| 937 | { | 1657 | { |
| 938 | int ret=0; | 1658 | int ret=0; |
| 939 | 1659 | ||
| @@ -945,7 +1665,7 @@ SSL *s; | |||
| 945 | { | 1665 | { |
| 946 | /* | 1666 | /* |
| 947 | if we are the server, and we have sent a 'RENEGOTIATE' message, we | 1667 | if we are the server, and we have sent a 'RENEGOTIATE' message, we |
| 948 | need to go to SSL_ST_ACCEPT. | 1668 | need to go to SSL_ST_ACCEPT. |
| 949 | */ | 1669 | */ |
| 950 | /* SSL_ST_ACCEPT */ | 1670 | /* SSL_ST_ACCEPT */ |
| 951 | s->state=SSL_ST_RENEGOTIATE; | 1671 | s->state=SSL_ST_RENEGOTIATE; |
| @@ -958,4 +1678,3 @@ need to go to SSL_ST_ACCEPT. | |||
| 958 | return(ret); | 1678 | return(ret); |
| 959 | } | 1679 | } |
| 960 | 1680 | ||
| 961 | |||
diff --git a/src/lib/libssl/s3_pkt.c b/src/lib/libssl/s3_pkt.c index 2385080347..43e8502b66 100644 --- a/src/lib/libssl/s3_pkt.c +++ b/src/lib/libssl/s3_pkt.c | |||
| @@ -55,150 +55,165 @@ | |||
| 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 | ||
| 59 | #include <stdio.h> | 112 | #include <stdio.h> |
| 60 | #include <errno.h> | 113 | #include <errno.h> |
| 61 | #define USE_SOCKETS | 114 | #define USE_SOCKETS |
| 62 | #include "evp.h" | 115 | #include <openssl/evp.h> |
| 63 | #include "buffer.h" | 116 | #include <openssl/buffer.h> |
| 64 | #include "ssl_locl.h" | 117 | #include "ssl_locl.h" |
| 65 | 118 | ||
| 66 | /* SSLerr(SSL_F_GET_SERVER_HELLO,SSL_R_SSLV3_ALERT_PEER_ERROR_NO_CIPHER); | 119 | static int do_ssl3_write(SSL *s, int type, const unsigned char *buf, |
| 67 | * SSLerr(SSL_F_GET_SERVER_HELLO,SSL_R_SSLV3_ALERT_PEER_ERROR_NO_CERTIFICATE); | 120 | unsigned int len, int create_empty_fragment); |
| 68 | * SSLerr(SSL_F_GET_SERVER_HELLO,SSL_R_SSLV3_ALERT_PEER_ERROR_CERTIFICATE); | 121 | static int ssl3_write_pending(SSL *s, int type, const unsigned char *buf, |
| 69 | * SSLerr(SSL_F_GET_SERVER_HELLO,SSL_R_SSLV3_ALERT_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE); | 122 | unsigned int len); |
| 70 | * SSLerr(SSL_F_GET_SERVER_HELLO,SSL_R_SSLV3_ALERT_UNKNOWN_REMOTE_ERROR_TYPE); | ||
| 71 | * SSLerr(SSL_F_GET_SERVER_HELLO,SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE); | ||
| 72 | * SSLerr(SSL_F_GET_SERVER_HELLO,SSL_R_SSLV3_ALERT_BAD_RECORD_MAC); | ||
| 73 | * SSLerr(SSL_F_GET_SERVER_HELLO,SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE); | ||
| 74 | * SSLerr(SSL_F_GET_SERVER_HELLO,SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE); | ||
| 75 | * SSLerr(SSL_F_GET_SERVER_HELLO,SSL_R_SSLV3_ALERT_NO_CERTIFICATE); | ||
| 76 | * SSLerr(SSL_F_GET_SERVER_HELLO,SSL_R_SSLV3_ALERT_BAD_CERTIFICATE); | ||
| 77 | * SSLerr(SSL_F_GET_SERVER_HELLO,SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE); | ||
| 78 | * SSLerr(SSL_F_GET_SERVER_HELLO,SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED); | ||
| 79 | * SSLerr(SSL_F_GET_SERVER_HELLO,SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED); | ||
| 80 | * SSLerr(SSL_F_GET_SERVER_HELLO,SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN); | ||
| 81 | * SSLerr(SSL_F_GET_SERVER_HELLO,SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER); | ||
| 82 | */ | ||
| 83 | |||
| 84 | #ifndef NOPROTO | ||
| 85 | static int do_ssl3_write(SSL *s, int type, char *buf, unsigned int len); | ||
| 86 | static int ssl3_write_pending(SSL *s, int type, char *buf, unsigned int len); | ||
| 87 | static int ssl3_get_record(SSL *s); | 123 | static int ssl3_get_record(SSL *s); |
| 88 | static int do_compress(SSL *ssl); | 124 | static int do_compress(SSL *ssl); |
| 89 | static int do_uncompress(SSL *ssl); | 125 | static int do_uncompress(SSL *ssl); |
| 90 | static int do_change_cipher_spec(SSL *ssl); | 126 | static int do_change_cipher_spec(SSL *ssl); |
| 91 | #else | ||
| 92 | static int do_ssl3_write(); | ||
| 93 | static int ssl3_write_pending(); | ||
| 94 | static int ssl3_get_record(); | ||
| 95 | static int do_compress(); | ||
| 96 | static int do_uncompress(); | ||
| 97 | static int do_change_cipher_spec(); | ||
| 98 | #endif | ||
| 99 | 127 | ||
| 100 | static int ssl3_read_n(s,n,max,extend) | 128 | /* used only by ssl3_get_record */ |
| 101 | SSL *s; | 129 | static int ssl3_read_n(SSL *s, int n, int max, int extend) |
| 102 | int n; | ||
| 103 | int max; | ||
| 104 | int extend; | ||
| 105 | { | 130 | { |
| 131 | /* If extend == 0, obtain new n-byte packet; if extend == 1, increase | ||
| 132 | * packet by another n bytes. | ||
| 133 | * The packet will be in the sub-array of s->s3->rbuf.buf specified | ||
| 134 | * by s->packet and s->packet_length. | ||
| 135 | * (If s->read_ahead is set, 'max' bytes may be stored in rbuf | ||
| 136 | * [plus s->packet_length bytes if extend == 1].) | ||
| 137 | */ | ||
| 106 | int i,off,newb; | 138 | int i,off,newb; |
| 107 | 139 | ||
| 108 | /* if there is stuff still in the buffer from a previous read, | 140 | if (!extend) |
| 109 | * and there is more than we want, take some. */ | 141 | { |
| 142 | /* start with empty packet ... */ | ||
| 143 | if (s->s3->rbuf.left == 0) | ||
| 144 | s->s3->rbuf.offset = 0; | ||
| 145 | s->packet = s->s3->rbuf.buf + s->s3->rbuf.offset; | ||
| 146 | s->packet_length = 0; | ||
| 147 | /* ... now we can act as if 'extend' was set */ | ||
| 148 | } | ||
| 149 | |||
| 150 | /* if there is enough in the buffer from a previous read, take some */ | ||
| 110 | if (s->s3->rbuf.left >= (int)n) | 151 | if (s->s3->rbuf.left >= (int)n) |
| 111 | { | 152 | { |
| 112 | if (extend) | 153 | s->packet_length+=n; |
| 113 | s->packet_length+=n; | ||
| 114 | else | ||
| 115 | { | ||
| 116 | s->packet= &(s->s3->rbuf.buf[s->s3->rbuf.offset]); | ||
| 117 | s->packet_length=n; | ||
| 118 | } | ||
| 119 | s->s3->rbuf.left-=n; | 154 | s->s3->rbuf.left-=n; |
| 120 | s->s3->rbuf.offset+=n; | 155 | s->s3->rbuf.offset+=n; |
| 121 | return(n); | 156 | return(n); |
| 122 | } | 157 | } |
| 123 | 158 | ||
| 124 | /* else we need to read more data */ | 159 | /* else we need to read more data */ |
| 125 | if (!s->read_ahead) max=n; | 160 | if (!s->read_ahead) |
| 126 | if (max > SSL3_RT_MAX_PACKET_SIZE) | 161 | max=n; |
| 127 | max=SSL3_RT_MAX_PACKET_SIZE; | ||
| 128 | |||
| 129 | /* First check if there is some left or we want to extend */ | ||
| 130 | off=0; | ||
| 131 | if ( (s->s3->rbuf.left != 0) || | ||
| 132 | ((s->packet_length != 0) && extend)) | ||
| 133 | { | ||
| 134 | newb=s->s3->rbuf.left; | ||
| 135 | if (extend) | ||
| 136 | { | ||
| 137 | /* Copy bytes back to the front of the buffer | ||
| 138 | * Take the bytes already pointed to by 'packet' | ||
| 139 | * and take the extra ones on the end. */ | ||
| 140 | off=s->packet_length; | ||
| 141 | if (s->packet != s->s3->rbuf.buf) | ||
| 142 | memcpy(s->s3->rbuf.buf,s->packet,newb+off); | ||
| 143 | } | ||
| 144 | else if (s->s3->rbuf.offset != 0) | ||
| 145 | { /* so the data is not at the start of the buffer */ | ||
| 146 | memcpy(s->s3->rbuf.buf, | ||
| 147 | &(s->s3->rbuf.buf[s->s3->rbuf.offset]),newb); | ||
| 148 | s->s3->rbuf.offset=0; | ||
| 149 | } | ||
| 150 | 162 | ||
| 151 | s->s3->rbuf.left=0; | 163 | { |
| 164 | /* avoid buffer overflow */ | ||
| 165 | int max_max = s->s3->rbuf.len - s->packet_length; | ||
| 166 | if (max > max_max) | ||
| 167 | max = max_max; | ||
| 168 | } | ||
| 169 | if (n > max) /* does not happen */ | ||
| 170 | { | ||
| 171 | SSLerr(SSL_F_SSL3_READ_N,ERR_R_INTERNAL_ERROR); | ||
| 172 | return -1; | ||
| 152 | } | 173 | } |
| 153 | else | ||
| 154 | newb=0; | ||
| 155 | 174 | ||
| 156 | /* So we now have 'newb' bytes at the front of | 175 | off = s->packet_length; |
| 157 | * s->s3->rbuf.buf and need to read some more in on the end | 176 | newb = s->s3->rbuf.left; |
| 158 | * We start reading into the buffer at 's->s3->rbuf.offset' | 177 | /* Move any available bytes to front of buffer: |
| 159 | */ | 178 | * 'off' bytes already pointed to by 'packet', |
| 160 | s->packet=s->s3->rbuf.buf; | 179 | * 'newb' extra ones at the end */ |
| 180 | if (s->packet != s->s3->rbuf.buf) | ||
| 181 | { | ||
| 182 | /* off > 0 */ | ||
| 183 | memmove(s->s3->rbuf.buf, s->packet, off+newb); | ||
| 184 | s->packet = s->s3->rbuf.buf; | ||
| 185 | } | ||
| 161 | 186 | ||
| 162 | while (newb < n) | 187 | while (newb < n) |
| 163 | { | 188 | { |
| 189 | /* Now we have off+newb bytes at the front of s->s3->rbuf.buf and need | ||
| 190 | * to read in more until we have off+n (up to off+max if possible) */ | ||
| 191 | |||
| 164 | clear_sys_error(); | 192 | clear_sys_error(); |
| 165 | if (s->rbio != NULL) | 193 | if (s->rbio != NULL) |
| 166 | { | 194 | { |
| 167 | s->rwstate=SSL_READING; | 195 | s->rwstate=SSL_READING; |
| 168 | i=BIO_read(s->rbio, | 196 | i=BIO_read(s->rbio, &(s->s3->rbuf.buf[off+newb]), max-newb); |
| 169 | (char *)&(s->s3->rbuf.buf[off+newb]), | ||
| 170 | max-newb); | ||
| 171 | } | 197 | } |
| 172 | else | 198 | else |
| 173 | { | 199 | { |
| 174 | SSLerr(SSL_F_SSL3_READ_N,SSL_R_READ_BIO_NOT_SET); | 200 | SSLerr(SSL_F_SSL3_READ_N,SSL_R_READ_BIO_NOT_SET); |
| 175 | i= -1; | 201 | i = -1; |
| 176 | } | 202 | } |
| 177 | 203 | ||
| 178 | if (i <= 0) | 204 | if (i <= 0) |
| 179 | { | 205 | { |
| 180 | s->s3->rbuf.left+=newb; | 206 | s->s3->rbuf.left = newb; |
| 181 | return(i); | 207 | return(i); |
| 182 | } | 208 | } |
| 183 | newb+=i; | 209 | newb+=i; |
| 184 | } | 210 | } |
| 185 | 211 | ||
| 186 | /* record used data read */ | 212 | /* done reading, now the book-keeping */ |
| 187 | if (newb > n) | 213 | s->s3->rbuf.offset = off + n; |
| 188 | { | 214 | s->s3->rbuf.left = newb - n; |
| 189 | s->s3->rbuf.offset=n+off; | 215 | s->packet_length += n; |
| 190 | s->s3->rbuf.left=newb-n; | 216 | s->rwstate=SSL_NOTHING; |
| 191 | } | ||
| 192 | else | ||
| 193 | { | ||
| 194 | s->s3->rbuf.offset=0; | ||
| 195 | s->s3->rbuf.left=0; | ||
| 196 | } | ||
| 197 | |||
| 198 | if (extend) | ||
| 199 | s->packet_length+=n; | ||
| 200 | else | ||
| 201 | s->packet_length+=n; | ||
| 202 | return(n); | 217 | return(n); |
| 203 | } | 218 | } |
| 204 | 219 | ||
| @@ -206,41 +221,45 @@ int extend; | |||
| 206 | * It will return <= 0 if more data is needed, normally due to an error | 221 | * It will return <= 0 if more data is needed, normally due to an error |
| 207 | * or non-blocking IO. | 222 | * or non-blocking IO. |
| 208 | * When it finishes, one packet has been decoded and can be found in | 223 | * When it finishes, one packet has been decoded and can be found in |
| 209 | * ssl->s3->rrec.type - is the type of record | 224 | * ssl->s3->rrec.type - is the type of record |
| 210 | * ssl->s3->rrec.data, - data | 225 | * ssl->s3->rrec.data, - data |
| 211 | * ssl->s3->rrec.length, - number of bytes | 226 | * ssl->s3->rrec.length, - number of bytes |
| 212 | */ | 227 | */ |
| 213 | static int ssl3_get_record(s) | 228 | /* used only by ssl3_read_bytes */ |
| 214 | SSL *s; | 229 | static int ssl3_get_record(SSL *s) |
| 215 | { | 230 | { |
| 216 | char tmp_buf[512]; | ||
| 217 | int ssl_major,ssl_minor,al; | 231 | int ssl_major,ssl_minor,al; |
| 218 | int n,i,ret= -1; | 232 | int enc_err,n,i,ret= -1; |
| 219 | SSL3_BUFFER *rb; | ||
| 220 | SSL3_RECORD *rr; | 233 | SSL3_RECORD *rr; |
| 221 | SSL_SESSION *sess; | 234 | SSL_SESSION *sess; |
| 222 | unsigned char *p; | 235 | unsigned char *p; |
| 223 | unsigned char md[EVP_MAX_MD_SIZE]; | 236 | unsigned char md[EVP_MAX_MD_SIZE]; |
| 224 | short version; | 237 | short version; |
| 225 | unsigned int mac_size; | 238 | unsigned int mac_size; |
| 226 | int clear=0,extra; | 239 | int clear=0; |
| 240 | size_t extra; | ||
| 227 | 241 | ||
| 228 | rr= &(s->s3->rrec); | 242 | rr= &(s->s3->rrec); |
| 229 | rb= &(s->s3->rbuf); | ||
| 230 | sess=s->session; | 243 | sess=s->session; |
| 231 | 244 | ||
| 232 | if (s->options & SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER) | 245 | if (s->options & SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER) |
| 233 | extra=SSL3_RT_MAX_EXTRA; | 246 | extra=SSL3_RT_MAX_EXTRA; |
| 234 | else | 247 | else |
| 235 | extra=0; | 248 | extra=0; |
| 249 | if (extra != s->s3->rbuf.len - SSL3_RT_MAX_PACKET_SIZE) | ||
| 250 | { | ||
| 251 | /* actually likely an application error: SLS_OP_MICROSOFT_BIG_SSLV3_BUFFER | ||
| 252 | * set after ssl3_setup_buffers() was done */ | ||
| 253 | SSLerr(SSL_F_SSL3_GET_RECORD, ERR_R_INTERNAL_ERROR); | ||
| 254 | return -1; | ||
| 255 | } | ||
| 236 | 256 | ||
| 237 | again: | 257 | again: |
| 238 | /* check if we have the header */ | 258 | /* check if we have the header */ |
| 239 | if ( (s->rstate != SSL_ST_READ_BODY) || | 259 | if ( (s->rstate != SSL_ST_READ_BODY) || |
| 240 | (s->packet_length < SSL3_RT_HEADER_LENGTH)) | 260 | (s->packet_length < SSL3_RT_HEADER_LENGTH)) |
| 241 | { | 261 | { |
| 242 | n=ssl3_read_n(s,SSL3_RT_HEADER_LENGTH, | 262 | n=ssl3_read_n(s, SSL3_RT_HEADER_LENGTH, s->s3->rbuf.len, 0); |
| 243 | SSL3_RT_MAX_PACKET_SIZE,0); | ||
| 244 | if (n <= 0) return(n); /* error or non-blocking */ | 263 | if (n <= 0) return(n); /* error or non-blocking */ |
| 245 | s->rstate=SSL_ST_READ_BODY; | 264 | s->rstate=SSL_ST_READ_BODY; |
| 246 | 265 | ||
| @@ -277,35 +296,33 @@ again: | |||
| 277 | goto err; | 296 | goto err; |
| 278 | } | 297 | } |
| 279 | 298 | ||
| 280 | if (rr->length > | 299 | if (rr->length > SSL3_RT_MAX_ENCRYPTED_LENGTH+extra) |
| 281 | (unsigned int)SSL3_RT_MAX_ENCRYPTED_LENGTH+extra) | ||
| 282 | { | 300 | { |
| 283 | al=SSL_AD_RECORD_OVERFLOW; | 301 | al=SSL_AD_RECORD_OVERFLOW; |
| 284 | SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_PACKET_LENGTH_TOO_LONG); | 302 | SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_PACKET_LENGTH_TOO_LONG); |
| 285 | goto f_err; | 303 | goto f_err; |
| 286 | } | 304 | } |
| 287 | 305 | ||
| 288 | s->rstate=SSL_ST_READ_BODY; | 306 | /* now s->rstate == SSL_ST_READ_BODY */ |
| 289 | } | 307 | } |
| 290 | 308 | ||
| 291 | /* get and decode the data */ | 309 | /* s->rstate == SSL_ST_READ_BODY, get and decode the data */ |
| 292 | if (s->rstate == SSL_ST_READ_BODY) | 310 | |
| 311 | if (rr->length > s->packet_length-SSL3_RT_HEADER_LENGTH) | ||
| 293 | { | 312 | { |
| 294 | if (rr->length > (s->packet_length-SSL3_RT_HEADER_LENGTH)) | 313 | /* now s->packet_length == SSL3_RT_HEADER_LENGTH */ |
| 295 | { | 314 | i=rr->length; |
| 296 | i=rr->length; | 315 | n=ssl3_read_n(s,i,i,1); |
| 297 | /*-(s->packet_length-SSL3_RT_HEADER_LENGTH); */ | 316 | if (n <= 0) return(n); /* error or non-blocking io */ |
| 298 | n=ssl3_read_n(s,i,i,1); | 317 | /* now n == rr->length, |
| 299 | if (n <= 0) return(n); /* error or non-blocking io */ | 318 | * and s->packet_length == SSL3_RT_HEADER_LENGTH + rr->length */ |
| 300 | } | ||
| 301 | s->rstate=SSL_ST_READ_HEADER; | ||
| 302 | } | 319 | } |
| 303 | 320 | ||
| 304 | /* At this point, we have the data in s->packet and there should be | 321 | s->rstate=SSL_ST_READ_HEADER; /* set state for later operations */ |
| 305 | * s->packet_length bytes, we must not 'overrun' this buffer :-) | ||
| 306 | * One of the following functions will copy the data from the | ||
| 307 | * s->packet buffer */ | ||
| 308 | 322 | ||
| 323 | /* At this point, s->packet_length == SSL3_RT_HEADER_LNGTH + rr->length, | ||
| 324 | * and we have that many bytes in s->packet | ||
| 325 | */ | ||
| 309 | rr->input= &(s->packet[SSL3_RT_HEADER_LENGTH]); | 326 | rr->input= &(s->packet[SSL3_RT_HEADER_LENGTH]); |
| 310 | 327 | ||
| 311 | /* ok, we can now read from 's->packet' data into 'rr' | 328 | /* ok, we can now read from 's->packet' data into 'rr' |
| @@ -315,14 +332,11 @@ again: | |||
| 315 | * When the data is 'copied' into the rr->data buffer, | 332 | * When the data is 'copied' into the rr->data buffer, |
| 316 | * rr->input will be pointed at the new buffer */ | 333 | * rr->input will be pointed at the new buffer */ |
| 317 | 334 | ||
| 318 | /* Set the state for the following operations */ | ||
| 319 | s->rstate=SSL_ST_READ_HEADER; | ||
| 320 | |||
| 321 | /* We now have - encrypted [ MAC [ compressed [ plain ] ] ] | 335 | /* We now have - encrypted [ MAC [ compressed [ plain ] ] ] |
| 322 | * rr->length bytes of encrypted compressed stuff. */ | 336 | * rr->length bytes of encrypted compressed stuff. */ |
| 323 | 337 | ||
| 324 | /* check is not needed I belive */ | 338 | /* check is not needed I believe */ |
| 325 | if (rr->length > (unsigned int)SSL3_RT_MAX_ENCRYPTED_LENGTH+extra) | 339 | if (rr->length > SSL3_RT_MAX_ENCRYPTED_LENGTH+extra) |
| 326 | { | 340 | { |
| 327 | al=SSL_AD_RECORD_OVERFLOW; | 341 | al=SSL_AD_RECORD_OVERFLOW; |
| 328 | SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_ENCRYPTED_LENGTH_TOO_LONG); | 342 | SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_ENCRYPTED_LENGTH_TOO_LONG); |
| @@ -331,18 +345,24 @@ again: | |||
| 331 | 345 | ||
| 332 | /* decrypt in place in 'rr->input' */ | 346 | /* decrypt in place in 'rr->input' */ |
| 333 | rr->data=rr->input; | 347 | rr->data=rr->input; |
| 334 | memcpy(tmp_buf,rr->input,(rr->length > 512)?512:rr->length); | ||
| 335 | 348 | ||
| 336 | if (!s->method->ssl3_enc->enc(s,0)) | 349 | enc_err = s->method->ssl3_enc->enc(s,0); |
| 350 | if (enc_err <= 0) | ||
| 337 | { | 351 | { |
| 338 | al=SSL_AD_DECRYPT_ERROR; | 352 | if (enc_err == 0) |
| 339 | goto f_err; | 353 | /* SSLerr() and ssl3_send_alert() have been called */ |
| 354 | goto err; | ||
| 355 | |||
| 356 | /* otherwise enc_err == -1 */ | ||
| 357 | goto decryption_failed_or_bad_record_mac; | ||
| 340 | } | 358 | } |
| 359 | |||
| 341 | #ifdef TLS_DEBUG | 360 | #ifdef TLS_DEBUG |
| 342 | printf("dec %d\n",rr->length); | 361 | printf("dec %d\n",rr->length); |
| 343 | { int z; for (z=0; z<rr->length; z++) printf("%02X%c",rr->data[z],((z+1)%16)?' ':'\n'); } | 362 | { unsigned int z; for (z=0; z<rr->length; z++) printf("%02X%c",rr->data[z],((z+1)%16)?' ':'\n'); } |
| 344 | printf("\n"); | 363 | printf("\n"); |
| 345 | #endif | 364 | #endif |
| 365 | |||
| 346 | /* r->length is now the compressed data plus mac */ | 366 | /* r->length is now the compressed data plus mac */ |
| 347 | if ( (sess == NULL) || | 367 | if ( (sess == NULL) || |
| 348 | (s->enc_read_ctx == NULL) || | 368 | (s->enc_read_ctx == NULL) || |
| @@ -355,33 +375,37 @@ printf("\n"); | |||
| 355 | 375 | ||
| 356 | if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH+extra+mac_size) | 376 | if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH+extra+mac_size) |
| 357 | { | 377 | { |
| 378 | #if 0 /* OK only for stream ciphers (then rr->length is visible from ciphertext anyway) */ | ||
| 358 | al=SSL_AD_RECORD_OVERFLOW; | 379 | al=SSL_AD_RECORD_OVERFLOW; |
| 359 | SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_PRE_MAC_LENGTH_TOO_LONG); | 380 | SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_PRE_MAC_LENGTH_TOO_LONG); |
| 360 | goto f_err; | 381 | goto f_err; |
| 382 | #else | ||
| 383 | goto decryption_failed_or_bad_record_mac; | ||
| 384 | #endif | ||
| 361 | } | 385 | } |
| 362 | /* check MAC for rr->input' */ | 386 | /* check the MAC for rr->input (it's in mac_size bytes at the tail) */ |
| 363 | if (rr->length < mac_size) | 387 | if (rr->length < mac_size) |
| 364 | { | 388 | { |
| 389 | #if 0 /* OK only for stream ciphers */ | ||
| 365 | al=SSL_AD_DECODE_ERROR; | 390 | al=SSL_AD_DECODE_ERROR; |
| 366 | SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_LENGTH_TOO_SHORT); | 391 | SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_LENGTH_TOO_SHORT); |
| 367 | goto f_err; | 392 | goto f_err; |
| 393 | #else | ||
| 394 | goto decryption_failed_or_bad_record_mac; | ||
| 395 | #endif | ||
| 368 | } | 396 | } |
| 369 | rr->length-=mac_size; | 397 | rr->length-=mac_size; |
| 370 | i=s->method->ssl3_enc->mac(s,md,0); | 398 | i=s->method->ssl3_enc->mac(s,md,0); |
| 371 | if (memcmp(md,&(rr->data[rr->length]),mac_size) != 0) | 399 | if (memcmp(md,&(rr->data[rr->length]),mac_size) != 0) |
| 372 | { | 400 | { |
| 373 | al=SSL_AD_BAD_RECORD_MAC; | 401 | goto decryption_failed_or_bad_record_mac; |
| 374 | SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_BAD_MAC_DECODE); | ||
| 375 | ret= -1; | ||
| 376 | goto f_err; | ||
| 377 | } | 402 | } |
| 378 | } | 403 | } |
| 379 | 404 | ||
| 380 | /* r->length is now just compressed */ | 405 | /* r->length is now just compressed */ |
| 381 | if ((sess != NULL) && (sess->read_compression != NULL)) | 406 | if (s->expand != NULL) |
| 382 | { | 407 | { |
| 383 | if (rr->length > | 408 | if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH+extra) |
| 384 | (unsigned int)SSL3_RT_MAX_COMPRESSED_LENGTH+extra) | ||
| 385 | { | 409 | { |
| 386 | al=SSL_AD_RECORD_OVERFLOW; | 410 | al=SSL_AD_RECORD_OVERFLOW; |
| 387 | SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_COMPRESSED_LENGTH_TOO_LONG); | 411 | SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_COMPRESSED_LENGTH_TOO_LONG); |
| @@ -395,7 +419,7 @@ printf("\n"); | |||
| 395 | } | 419 | } |
| 396 | } | 420 | } |
| 397 | 421 | ||
| 398 | if (rr->length > (unsigned int)SSL3_RT_MAX_PLAIN_LENGTH+extra) | 422 | if (rr->length > SSL3_RT_MAX_PLAIN_LENGTH+extra) |
| 399 | { | 423 | { |
| 400 | al=SSL_AD_RECORD_OVERFLOW; | 424 | al=SSL_AD_RECORD_OVERFLOW; |
| 401 | SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_DATA_LENGTH_TOO_LONG); | 425 | SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_DATA_LENGTH_TOO_LONG); |
| @@ -418,33 +442,62 @@ printf("\n"); | |||
| 418 | if (rr->length == 0) goto again; | 442 | if (rr->length == 0) goto again; |
| 419 | 443 | ||
| 420 | return(1); | 444 | return(1); |
| 445 | |||
| 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); | ||
| 421 | f_err: | 454 | f_err: |
| 422 | ssl3_send_alert(s,SSL3_AL_FATAL,al); | 455 | ssl3_send_alert(s,SSL3_AL_FATAL,al); |
| 423 | err: | 456 | err: |
| 424 | return(ret); | 457 | return(ret); |
| 425 | } | 458 | } |
| 426 | 459 | ||
| 427 | static int do_uncompress(ssl) | 460 | static int do_uncompress(SSL *ssl) |
| 428 | SSL *ssl; | ||
| 429 | { | 461 | { |
| 462 | int i; | ||
| 463 | SSL3_RECORD *rr; | ||
| 464 | |||
| 465 | rr= &(ssl->s3->rrec); | ||
| 466 | i=COMP_expand_block(ssl->expand,rr->comp, | ||
| 467 | SSL3_RT_MAX_PLAIN_LENGTH,rr->data,(int)rr->length); | ||
| 468 | if (i < 0) | ||
| 469 | return(0); | ||
| 470 | else | ||
| 471 | rr->length=i; | ||
| 472 | rr->data=rr->comp; | ||
| 473 | |||
| 430 | return(1); | 474 | return(1); |
| 431 | } | 475 | } |
| 432 | 476 | ||
| 433 | static int do_compress(ssl) | 477 | static int do_compress(SSL *ssl) |
| 434 | SSL *ssl; | ||
| 435 | { | 478 | { |
| 479 | int i; | ||
| 480 | SSL3_RECORD *wr; | ||
| 481 | |||
| 482 | wr= &(ssl->s3->wrec); | ||
| 483 | i=COMP_compress_block(ssl->compress,wr->data, | ||
| 484 | SSL3_RT_MAX_COMPRESSED_LENGTH, | ||
| 485 | wr->input,(int)wr->length); | ||
| 486 | if (i < 0) | ||
| 487 | return(0); | ||
| 488 | else | ||
| 489 | wr->length=i; | ||
| 490 | |||
| 491 | wr->input=wr->data; | ||
| 436 | return(1); | 492 | return(1); |
| 437 | } | 493 | } |
| 438 | 494 | ||
| 439 | /* Call this to write data | 495 | /* Call this to write data in records of type 'type' |
| 440 | * It will return <= 0 if not all data has been sent or non-blocking IO. | 496 | * It will return <= 0 if not all data has been sent or non-blocking IO. |
| 441 | */ | 497 | */ |
| 442 | int ssl3_write_bytes(s,type,buf,len) | 498 | int ssl3_write_bytes(SSL *s, int type, const void *buf_, int len) |
| 443 | SSL *s; | ||
| 444 | int type; | ||
| 445 | char *buf; | ||
| 446 | int len; | ||
| 447 | { | 499 | { |
| 500 | const unsigned char *buf=buf_; | ||
| 448 | unsigned int tot,n,nw; | 501 | unsigned int tot,n,nw; |
| 449 | int i; | 502 | int i; |
| 450 | 503 | ||
| @@ -459,7 +512,7 @@ int len; | |||
| 459 | if (i == 0) | 512 | if (i == 0) |
| 460 | { | 513 | { |
| 461 | SSLerr(SSL_F_SSL3_WRITE_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE); | 514 | SSLerr(SSL_F_SSL3_WRITE_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE); |
| 462 | return(-1); | 515 | return -1; |
| 463 | } | 516 | } |
| 464 | } | 517 | } |
| 465 | 518 | ||
| @@ -470,37 +523,41 @@ int len; | |||
| 470 | nw=SSL3_RT_MAX_PLAIN_LENGTH; | 523 | nw=SSL3_RT_MAX_PLAIN_LENGTH; |
| 471 | else | 524 | else |
| 472 | nw=n; | 525 | nw=n; |
| 473 | 526 | ||
| 474 | i=do_ssl3_write(s,type,&(buf[tot]),nw); | 527 | i=do_ssl3_write(s, type, &(buf[tot]), nw, 0); |
| 475 | if (i <= 0) | 528 | if (i <= 0) |
| 476 | { | 529 | { |
| 477 | s->s3->wnum=tot; | 530 | s->s3->wnum=tot; |
| 478 | return(i); | 531 | return i; |
| 479 | } | 532 | } |
| 480 | 533 | ||
| 481 | if (type == SSL3_RT_HANDSHAKE) | 534 | if ((i == (int)n) || |
| 482 | ssl3_finish_mac(s,(unsigned char *)&(buf[tot]),i); | 535 | (type == SSL3_RT_APPLICATION_DATA && |
| 483 | 536 | (s->mode & SSL_MODE_ENABLE_PARTIAL_WRITE))) | |
| 484 | if (i == (int)n) return(tot+i); | 537 | { |
| 538 | /* next chunk of data should get another prepended empty fragment | ||
| 539 | * in ciphersuites with known-IV weakness: */ | ||
| 540 | s->s3->empty_fragment_done = 0; | ||
| 541 | |||
| 542 | return tot+i; | ||
| 543 | } | ||
| 485 | 544 | ||
| 486 | n-=i; | 545 | n-=i; |
| 487 | tot+=i; | 546 | tot+=i; |
| 488 | } | 547 | } |
| 489 | } | 548 | } |
| 490 | 549 | ||
| 491 | static int do_ssl3_write(s,type,buf,len) | 550 | static int do_ssl3_write(SSL *s, int type, const unsigned char *buf, |
| 492 | SSL *s; | 551 | unsigned int len, int create_empty_fragment) |
| 493 | int type; | ||
| 494 | char *buf; | ||
| 495 | unsigned int len; | ||
| 496 | { | 552 | { |
| 497 | unsigned char *p,*plen; | 553 | unsigned char *p,*plen; |
| 498 | int i,mac_size,clear=0; | 554 | int i,mac_size,clear=0; |
| 555 | int prefix_len = 0; | ||
| 499 | SSL3_RECORD *wr; | 556 | SSL3_RECORD *wr; |
| 500 | SSL3_BUFFER *wb; | 557 | SSL3_BUFFER *wb; |
| 501 | SSL_SESSION *sess; | 558 | SSL_SESSION *sess; |
| 502 | 559 | ||
| 503 | /* first check is there is a SSL3_RECORD still being written | 560 | /* first check if there is a SSL3_BUFFER still being written |
| 504 | * out. This will happen with non blocking IO */ | 561 | * out. This will happen with non blocking IO */ |
| 505 | if (s->s3->wbuf.left != 0) | 562 | if (s->s3->wbuf.left != 0) |
| 506 | return(ssl3_write_pending(s,type,buf,len)); | 563 | return(ssl3_write_pending(s,type,buf,len)); |
| @@ -514,8 +571,9 @@ unsigned int len; | |||
| 514 | /* if it went, fall through and send more stuff */ | 571 | /* if it went, fall through and send more stuff */ |
| 515 | } | 572 | } |
| 516 | 573 | ||
| 517 | if (len <= 0) return(len); | 574 | if (len == 0 && !create_empty_fragment) |
| 518 | 575 | return 0; | |
| 576 | |||
| 519 | wr= &(s->s3->wrec); | 577 | wr= &(s->s3->wrec); |
| 520 | wb= &(s->s3->wbuf); | 578 | wb= &(s->s3->wbuf); |
| 521 | sess=s->session; | 579 | sess=s->session; |
| @@ -530,19 +588,47 @@ unsigned int len; | |||
| 530 | else | 588 | else |
| 531 | mac_size=EVP_MD_size(s->write_hash); | 589 | mac_size=EVP_MD_size(s->write_hash); |
| 532 | 590 | ||
| 533 | p=wb->buf; | 591 | /* 'create_empty_fragment' is true only when this function calls itself */ |
| 592 | if (!clear && !create_empty_fragment && !s->s3->empty_fragment_done) | ||
| 593 | { | ||
| 594 | /* countermeasure against known-IV weakness in CBC ciphersuites | ||
| 595 | * (see http://www.openssl.org/~bodo/tls-cbc.txt) */ | ||
| 596 | |||
| 597 | if (s->s3->need_empty_fragments && type == SSL3_RT_APPLICATION_DATA) | ||
| 598 | { | ||
| 599 | /* recursive function call with 'create_empty_fragment' set; | ||
| 600 | * this prepares and buffers the data for an empty fragment | ||
| 601 | * (these 'prefix_len' bytes are sent out later | ||
| 602 | * together with the actual payload) */ | ||
| 603 | prefix_len = do_ssl3_write(s, type, buf, 0, 1); | ||
| 604 | if (prefix_len <= 0) | ||
| 605 | goto err; | ||
| 606 | |||
| 607 | if (s->s3->wbuf.len < (size_t)prefix_len + SSL3_RT_MAX_PACKET_SIZE) | ||
| 608 | { | ||
| 609 | /* insufficient space */ | ||
| 610 | SSLerr(SSL_F_DO_SSL3_WRITE, ERR_R_INTERNAL_ERROR); | ||
| 611 | goto err; | ||
| 612 | } | ||
| 613 | } | ||
| 614 | |||
| 615 | s->s3->empty_fragment_done = 1; | ||
| 616 | } | ||
| 617 | |||
| 618 | p = wb->buf + prefix_len; | ||
| 534 | 619 | ||
| 535 | /* write the header */ | 620 | /* write the header */ |
| 621 | |||
| 536 | *(p++)=type&0xff; | 622 | *(p++)=type&0xff; |
| 537 | wr->type=type; | 623 | wr->type=type; |
| 538 | 624 | ||
| 539 | *(p++)=(s->version>>8); | 625 | *(p++)=(s->version>>8); |
| 540 | *(p++)=s->version&0xff; | 626 | *(p++)=s->version&0xff; |
| 541 | 627 | ||
| 542 | /* record where we are to write out packet length */ | 628 | /* field where we are to write out packet length */ |
| 543 | plen=p; | 629 | plen=p; |
| 544 | p+=2; | 630 | p+=2; |
| 545 | 631 | ||
| 546 | /* lets setup the record stuff. */ | 632 | /* lets setup the record stuff. */ |
| 547 | wr->data=p; | 633 | wr->data=p; |
| 548 | wr->length=(int)len; | 634 | wr->length=(int)len; |
| @@ -552,7 +638,7 @@ unsigned int len; | |||
| 552 | * wr->data */ | 638 | * wr->data */ |
| 553 | 639 | ||
| 554 | /* first we compress */ | 640 | /* first we compress */ |
| 555 | if ((sess != NULL) && (sess->write_compression != NULL)) | 641 | if (s->compress != NULL) |
| 556 | { | 642 | { |
| 557 | if (!do_compress(s)) | 643 | if (!do_compress(s)) |
| 558 | { | 644 | { |
| @@ -590,32 +676,40 @@ unsigned int len; | |||
| 590 | wr->type=type; /* not needed but helps for debugging */ | 676 | wr->type=type; /* not needed but helps for debugging */ |
| 591 | wr->length+=SSL3_RT_HEADER_LENGTH; | 677 | wr->length+=SSL3_RT_HEADER_LENGTH; |
| 592 | 678 | ||
| 593 | /* Now lets setup wb */ | 679 | if (create_empty_fragment) |
| 594 | wb->left=wr->length; | 680 | { |
| 595 | wb->offset=0; | 681 | /* we are in a recursive call; |
| 682 | * just return the length, don't write out anything here | ||
| 683 | */ | ||
| 684 | return wr->length; | ||
| 685 | } | ||
| 686 | |||
| 687 | /* now let's set up wb */ | ||
| 688 | wb->left = prefix_len + wr->length; | ||
| 689 | wb->offset = 0; | ||
| 596 | 690 | ||
| 691 | /* memorize arguments so that ssl3_write_pending can detect bad write retries later */ | ||
| 597 | s->s3->wpend_tot=len; | 692 | s->s3->wpend_tot=len; |
| 598 | s->s3->wpend_buf=buf; | 693 | s->s3->wpend_buf=buf; |
| 599 | s->s3->wpend_type=type; | 694 | s->s3->wpend_type=type; |
| 600 | s->s3->wpend_ret=len; | 695 | s->s3->wpend_ret=len; |
| 601 | 696 | ||
| 602 | /* we now just need to write the buffer */ | 697 | /* we now just need to write the buffer */ |
| 603 | return(ssl3_write_pending(s,type,buf,len)); | 698 | return ssl3_write_pending(s,type,buf,len); |
| 604 | err: | 699 | err: |
| 605 | return(-1); | 700 | return -1; |
| 606 | } | 701 | } |
| 607 | 702 | ||
| 608 | /* if s->s3->wbuf.left != 0, we need to call this */ | 703 | /* if s->s3->wbuf.left != 0, we need to call this */ |
| 609 | static int ssl3_write_pending(s,type,buf,len) | 704 | static int ssl3_write_pending(SSL *s, int type, const unsigned char *buf, |
| 610 | SSL *s; | 705 | unsigned int len) |
| 611 | int type; | ||
| 612 | char *buf; | ||
| 613 | unsigned int len; | ||
| 614 | { | 706 | { |
| 615 | int i; | 707 | int i; |
| 616 | 708 | ||
| 617 | /* XXXX */ | 709 | /* XXXX */ |
| 618 | if ((s->s3->wpend_tot > (int)len) || (s->s3->wpend_buf != buf) | 710 | if ((s->s3->wpend_tot > (int)len) |
| 711 | || ((s->s3->wpend_buf != buf) && | ||
| 712 | !(s->mode & SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER)) | ||
| 619 | || (s->s3->wpend_type != type)) | 713 | || (s->s3->wpend_type != type)) |
| 620 | { | 714 | { |
| 621 | SSLerr(SSL_F_SSL3_WRITE_PENDING,SSL_R_BAD_WRITE_RETRY); | 715 | SSLerr(SSL_F_SSL3_WRITE_PENDING,SSL_R_BAD_WRITE_RETRY); |
| @@ -650,23 +744,77 @@ unsigned int len; | |||
| 650 | } | 744 | } |
| 651 | } | 745 | } |
| 652 | 746 | ||
| 653 | int ssl3_read_bytes(s,type,buf,len) | 747 | /* Return up to 'len' payload bytes received in 'type' records. |
| 654 | SSL *s; | 748 | * 'type' is one of the following: |
| 655 | int type; | 749 | * |
| 656 | char *buf; | 750 | * - SSL3_RT_HANDSHAKE (when ssl3_get_message calls us) |
| 657 | int len; | 751 | * - SSL3_RT_APPLICATION_DATA (when ssl3_read calls us) |
| 752 | * - 0 (during a shutdown, no data has to be returned) | ||
| 753 | * | ||
| 754 | * If we don't have stored data to work from, read a SSL/TLS record first | ||
| 755 | * (possibly multiple records if we still don't have anything to return). | ||
| 756 | * | ||
| 757 | * This function must handle any surprises the peer may have for us, such as | ||
| 758 | * Alert records (e.g. close_notify), ChangeCipherSpec records (not really | ||
| 759 | * a surprise, but handled as if it were), or renegotiation requests. | ||
| 760 | * Also if record payloads contain fragments too small to process, we store | ||
| 761 | * them until there is enough for the respective protocol (the record protocol | ||
| 762 | * may use arbitrary fragmentation and even interleaving): | ||
| 763 | * Change cipher spec protocol | ||
| 764 | * just 1 byte needed, no need for keeping anything stored | ||
| 765 | * Alert protocol | ||
| 766 | * 2 bytes needed (AlertLevel, AlertDescription) | ||
| 767 | * Handshake protocol | ||
| 768 | * 4 bytes needed (HandshakeType, uint24 length) -- we just have | ||
| 769 | * to detect unexpected Client Hello and Hello Request messages | ||
| 770 | * here, anything else is handled by higher layers | ||
| 771 | * Application data protocol | ||
| 772 | * none of our business | ||
| 773 | */ | ||
| 774 | int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) | ||
| 658 | { | 775 | { |
| 659 | int al,i,j,n,ret; | 776 | int al,i,j,ret; |
| 777 | unsigned int n; | ||
| 660 | SSL3_RECORD *rr; | 778 | SSL3_RECORD *rr; |
| 661 | void (*cb)()=NULL; | 779 | void (*cb)(const SSL *ssl,int type2,int val)=NULL; |
| 662 | BIO *bio; | ||
| 663 | 780 | ||
| 664 | if (s->s3->rbuf.buf == NULL) /* Not initalised yet */ | 781 | if (s->s3->rbuf.buf == NULL) /* Not initialized yet */ |
| 665 | if (!ssl3_setup_buffers(s)) | 782 | if (!ssl3_setup_buffers(s)) |
| 666 | return(-1); | 783 | return(-1); |
| 667 | 784 | ||
| 785 | if ((type && (type != SSL3_RT_APPLICATION_DATA) && (type != SSL3_RT_HANDSHAKE) && type) || | ||
| 786 | (peek && (type != SSL3_RT_APPLICATION_DATA))) | ||
| 787 | { | ||
| 788 | SSLerr(SSL_F_SSL3_READ_BYTES, ERR_R_INTERNAL_ERROR); | ||
| 789 | return -1; | ||
| 790 | } | ||
| 791 | |||
| 792 | if ((type == SSL3_RT_HANDSHAKE) && (s->s3->handshake_fragment_len > 0)) | ||
| 793 | /* (partially) satisfy request from storage */ | ||
| 794 | { | ||
| 795 | unsigned char *src = s->s3->handshake_fragment; | ||
| 796 | unsigned char *dst = buf; | ||
| 797 | unsigned int k; | ||
| 798 | |||
| 799 | /* peek == 0 */ | ||
| 800 | n = 0; | ||
| 801 | while ((len > 0) && (s->s3->handshake_fragment_len > 0)) | ||
| 802 | { | ||
| 803 | *dst++ = *src++; | ||
| 804 | len--; s->s3->handshake_fragment_len--; | ||
| 805 | n++; | ||
| 806 | } | ||
| 807 | /* move any remaining fragment bytes: */ | ||
| 808 | for (k = 0; k < s->s3->handshake_fragment_len; k++) | ||
| 809 | s->s3->handshake_fragment[k] = *src++; | ||
| 810 | return n; | ||
| 811 | } | ||
| 812 | |||
| 813 | /* Now s->s3->handshake_fragment_len == 0 if type == SSL3_RT_HANDSHAKE. */ | ||
| 814 | |||
| 668 | if (!s->in_handshake && SSL_in_init(s)) | 815 | if (!s->in_handshake && SSL_in_init(s)) |
| 669 | { | 816 | { |
| 817 | /* type == SSL3_RT_APPLICATION_DATA */ | ||
| 670 | i=s->handshake_func(s); | 818 | i=s->handshake_func(s); |
| 671 | if (i < 0) return(i); | 819 | if (i < 0) return(i); |
| 672 | if (i == 0) | 820 | if (i == 0) |
| @@ -678,13 +826,13 @@ int len; | |||
| 678 | start: | 826 | start: |
| 679 | s->rwstate=SSL_NOTHING; | 827 | s->rwstate=SSL_NOTHING; |
| 680 | 828 | ||
| 681 | /* s->s3->rrec.type - is the type of record | 829 | /* s->s3->rrec.type - is the type of record |
| 682 | * s->s3->rrec.data, - data | 830 | * s->s3->rrec.data, - data |
| 683 | * s->s3->rrec.off, - ofset into 'data' for next read | 831 | * s->s3->rrec.off, - offset into 'data' for next read |
| 684 | * s->s3->rrec.length, - number of bytes. */ | 832 | * s->s3->rrec.length, - number of bytes. */ |
| 685 | rr= &(s->s3->rrec); | 833 | rr = &(s->s3->rrec); |
| 686 | 834 | ||
| 687 | /* get new packet */ | 835 | /* get new packet if necessary */ |
| 688 | if ((rr->length == 0) || (s->rstate == SSL_ST_READ_BODY)) | 836 | if ((rr->length == 0) || (s->rstate == SSL_ST_READ_BODY)) |
| 689 | { | 837 | { |
| 690 | ret=ssl3_get_record(s); | 838 | ret=ssl3_get_record(s); |
| @@ -693,14 +841,17 @@ start: | |||
| 693 | 841 | ||
| 694 | /* we now have a packet which can be read and processed */ | 842 | /* we now have a packet which can be read and processed */ |
| 695 | 843 | ||
| 696 | if (s->s3->change_cipher_spec && (rr->type != SSL3_RT_HANDSHAKE)) | 844 | if (s->s3->change_cipher_spec /* set when we receive ChangeCipherSpec, |
| 845 | * reset by ssl3_get_finished */ | ||
| 846 | && (rr->type != SSL3_RT_HANDSHAKE)) | ||
| 697 | { | 847 | { |
| 698 | al=SSL_AD_UNEXPECTED_MESSAGE; | 848 | al=SSL_AD_UNEXPECTED_MESSAGE; |
| 699 | SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_DATA_BETWEEN_CCS_AND_FINISHED); | 849 | SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_DATA_BETWEEN_CCS_AND_FINISHED); |
| 700 | goto err; | 850 | goto err; |
| 701 | } | 851 | } |
| 702 | 852 | ||
| 703 | /* If the other end has shutdown, throw anything we read away */ | 853 | /* If the other end has shut down, throw anything we read away |
| 854 | * (even in 'peek' mode) */ | ||
| 704 | if (s->shutdown & SSL_RECEIVED_SHUTDOWN) | 855 | if (s->shutdown & SSL_RECEIVED_SHUTDOWN) |
| 705 | { | 856 | { |
| 706 | rr->length=0; | 857 | rr->length=0; |
| @@ -708,19 +859,107 @@ start: | |||
| 708 | return(0); | 859 | return(0); |
| 709 | } | 860 | } |
| 710 | 861 | ||
| 711 | /* Check for an incoming 'Client Request' message */ | 862 | |
| 712 | if ((rr->type == SSL3_RT_HANDSHAKE) && (rr->length == 4) && | 863 | if (type == rr->type) /* SSL3_RT_APPLICATION_DATA or SSL3_RT_HANDSHAKE */ |
| 713 | (rr->data[0] == SSL3_MT_CLIENT_REQUEST) && | 864 | { |
| 865 | /* make sure that we are not getting application data when we | ||
| 866 | * are doing a handshake for the first time */ | ||
| 867 | if (SSL_in_init(s) && (type == SSL3_RT_APPLICATION_DATA) && | ||
| 868 | (s->enc_read_ctx == NULL)) | ||
| 869 | { | ||
| 870 | al=SSL_AD_UNEXPECTED_MESSAGE; | ||
| 871 | SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_APP_DATA_IN_HANDSHAKE); | ||
| 872 | goto f_err; | ||
| 873 | } | ||
| 874 | |||
| 875 | if (len <= 0) return(len); | ||
| 876 | |||
| 877 | if ((unsigned int)len > rr->length) | ||
| 878 | n = rr->length; | ||
| 879 | else | ||
| 880 | n = (unsigned int)len; | ||
| 881 | |||
| 882 | memcpy(buf,&(rr->data[rr->off]),n); | ||
| 883 | if (!peek) | ||
| 884 | { | ||
| 885 | rr->length-=n; | ||
| 886 | rr->off+=n; | ||
| 887 | if (rr->length == 0) | ||
| 888 | { | ||
| 889 | s->rstate=SSL_ST_READ_HEADER; | ||
| 890 | rr->off=0; | ||
| 891 | } | ||
| 892 | } | ||
| 893 | return(n); | ||
| 894 | } | ||
| 895 | |||
| 896 | |||
| 897 | /* If we get here, then type != rr->type; if we have a handshake | ||
| 898 | * message, then it was unexpected (Hello Request or Client Hello). */ | ||
| 899 | |||
| 900 | /* In case of record types for which we have 'fragment' storage, | ||
| 901 | * fill that so that we can process the data at a fixed place. | ||
| 902 | */ | ||
| 903 | { | ||
| 904 | unsigned int dest_maxlen = 0; | ||
| 905 | unsigned char *dest = NULL; | ||
| 906 | unsigned int *dest_len = NULL; | ||
| 907 | |||
| 908 | if (rr->type == SSL3_RT_HANDSHAKE) | ||
| 909 | { | ||
| 910 | dest_maxlen = sizeof s->s3->handshake_fragment; | ||
| 911 | dest = s->s3->handshake_fragment; | ||
| 912 | dest_len = &s->s3->handshake_fragment_len; | ||
| 913 | } | ||
| 914 | else if (rr->type == SSL3_RT_ALERT) | ||
| 915 | { | ||
| 916 | dest_maxlen = sizeof s->s3->alert_fragment; | ||
| 917 | dest = s->s3->alert_fragment; | ||
| 918 | dest_len = &s->s3->alert_fragment_len; | ||
| 919 | } | ||
| 920 | |||
| 921 | if (dest_maxlen > 0) | ||
| 922 | { | ||
| 923 | n = dest_maxlen - *dest_len; /* available space in 'dest' */ | ||
| 924 | if (rr->length < n) | ||
| 925 | n = rr->length; /* available bytes */ | ||
| 926 | |||
| 927 | /* now move 'n' bytes: */ | ||
| 928 | while (n-- > 0) | ||
| 929 | { | ||
| 930 | dest[(*dest_len)++] = rr->data[rr->off++]; | ||
| 931 | rr->length--; | ||
| 932 | } | ||
| 933 | |||
| 934 | if (*dest_len < dest_maxlen) | ||
| 935 | goto start; /* fragment was too small */ | ||
| 936 | } | ||
| 937 | } | ||
| 938 | |||
| 939 | /* s->s3->handshake_fragment_len == 4 iff rr->type == SSL3_RT_HANDSHAKE; | ||
| 940 | * s->s3->alert_fragment_len == 2 iff rr->type == SSL3_RT_ALERT. | ||
| 941 | * (Possibly rr is 'empty' now, i.e. rr->length may be 0.) */ | ||
| 942 | |||
| 943 | /* If we are a client, check for an incoming 'Hello Request': */ | ||
| 944 | if ((!s->server) && | ||
| 945 | (s->s3->handshake_fragment_len >= 4) && | ||
| 946 | (s->s3->handshake_fragment[0] == SSL3_MT_HELLO_REQUEST) && | ||
| 714 | (s->session != NULL) && (s->session->cipher != NULL)) | 947 | (s->session != NULL) && (s->session->cipher != NULL)) |
| 715 | { | 948 | { |
| 716 | if ((rr->data[1] != 0) || (rr->data[2] != 0) || | 949 | s->s3->handshake_fragment_len = 0; |
| 717 | (rr->data[3] != 0)) | 950 | |
| 951 | if ((s->s3->handshake_fragment[1] != 0) || | ||
| 952 | (s->s3->handshake_fragment[2] != 0) || | ||
| 953 | (s->s3->handshake_fragment[3] != 0)) | ||
| 718 | { | 954 | { |
| 719 | al=SSL_AD_DECODE_ERROR; | 955 | al=SSL_AD_DECODE_ERROR; |
| 720 | SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_BAD_CLIENT_REQUEST); | 956 | SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_BAD_HELLO_REQUEST); |
| 721 | goto err; | 957 | goto err; |
| 722 | } | 958 | } |
| 723 | 959 | ||
| 960 | if (s->msg_callback) | ||
| 961 | s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, s->s3->handshake_fragment, 4, s, s->msg_callback_arg); | ||
| 962 | |||
| 724 | if (SSL_is_init_finished(s) && | 963 | if (SSL_is_init_finished(s) && |
| 725 | !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS) && | 964 | !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS) && |
| 726 | !s->s3->renegotiate) | 965 | !s->s3->renegotiate) |
| @@ -728,228 +967,231 @@ start: | |||
| 728 | ssl3_renegotiate(s); | 967 | ssl3_renegotiate(s); |
| 729 | if (ssl3_renegotiate_check(s)) | 968 | if (ssl3_renegotiate_check(s)) |
| 730 | { | 969 | { |
| 731 | n=s->handshake_func(s); | 970 | i=s->handshake_func(s); |
| 732 | if (n < 0) return(n); | 971 | if (i < 0) return(i); |
| 733 | if (n == 0) | 972 | if (i == 0) |
| 734 | { | 973 | { |
| 735 | SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE); | 974 | SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE); |
| 736 | return(-1); | 975 | return(-1); |
| 737 | } | 976 | } |
| 977 | |||
| 978 | if (!(s->mode & SSL_MODE_AUTO_RETRY)) | ||
| 979 | { | ||
| 980 | if (s->s3->rbuf.left == 0) /* no read-ahead left? */ | ||
| 981 | { | ||
| 982 | BIO *bio; | ||
| 983 | /* In the case where we try to read application data, | ||
| 984 | * but we trigger an SSL handshake, we return -1 with | ||
| 985 | * the retry option set. Otherwise renegotiation may | ||
| 986 | * cause nasty problems in the blocking world */ | ||
| 987 | s->rwstate=SSL_READING; | ||
| 988 | bio=SSL_get_rbio(s); | ||
| 989 | BIO_clear_retry_flags(bio); | ||
| 990 | BIO_set_retry_read(bio); | ||
| 991 | return(-1); | ||
| 992 | } | ||
| 993 | } | ||
| 738 | } | 994 | } |
| 739 | } | 995 | } |
| 740 | rr->length=0; | 996 | /* we either finished a handshake or ignored the request, |
| 741 | /* ZZZ */ goto start; | 997 | * now try again to obtain the (application) data we were asked for */ |
| 998 | goto start; | ||
| 742 | } | 999 | } |
| 743 | 1000 | ||
| 744 | /* if it is not the type we want, or we have shutdown and want | 1001 | if (s->s3->alert_fragment_len >= 2) |
| 745 | * the peer shutdown */ | ||
| 746 | if ((rr->type != type) || (s->shutdown & SSL_SENT_SHUTDOWN)) | ||
| 747 | { | 1002 | { |
| 748 | if (rr->type == SSL3_RT_ALERT) | 1003 | int alert_level = s->s3->alert_fragment[0]; |
| 749 | { | 1004 | int alert_descr = s->s3->alert_fragment[1]; |
| 750 | if ((rr->length != 2) || (rr->off != 0)) | ||
| 751 | { | ||
| 752 | al=SSL_AD_DECODE_ERROR; | ||
| 753 | SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_BAD_ALERT_RECORD); | ||
| 754 | goto f_err; | ||
| 755 | } | ||
| 756 | 1005 | ||
| 757 | i=rr->data[0]; | 1006 | s->s3->alert_fragment_len = 0; |
| 758 | n=rr->data[1]; | ||
| 759 | 1007 | ||
| 760 | /* clear from buffer */ | 1008 | if (s->msg_callback) |
| 761 | rr->length=0; | 1009 | s->msg_callback(0, s->version, SSL3_RT_ALERT, s->s3->alert_fragment, 2, s, s->msg_callback_arg); |
| 762 | 1010 | ||
| 763 | if (s->info_callback != NULL) | 1011 | if (s->info_callback != NULL) |
| 764 | cb=s->info_callback; | 1012 | cb=s->info_callback; |
| 765 | else if (s->ctx->info_callback != NULL) | 1013 | else if (s->ctx->info_callback != NULL) |
| 766 | cb=s->ctx->info_callback; | 1014 | cb=s->ctx->info_callback; |
| 767 | 1015 | ||
| 768 | if (cb != NULL) | 1016 | if (cb != NULL) |
| 769 | { | 1017 | { |
| 770 | j=(i<<8)|n; | 1018 | j = (alert_level << 8) | alert_descr; |
| 771 | cb(s,SSL_CB_READ_ALERT,j); | 1019 | cb(s, SSL_CB_READ_ALERT, j); |
| 772 | } | 1020 | } |
| 773 | 1021 | ||
| 774 | if (i == 1) | 1022 | if (alert_level == 1) /* warning */ |
| 775 | { | 1023 | { |
| 776 | s->s3->warn_alert=n; | 1024 | s->s3->warn_alert = alert_descr; |
| 777 | if (n == SSL_AD_CLOSE_NOTIFY) | 1025 | if (alert_descr == SSL_AD_CLOSE_NOTIFY) |
| 778 | { | ||
| 779 | s->shutdown|=SSL_RECEIVED_SHUTDOWN; | ||
| 780 | return(0); | ||
| 781 | } | ||
| 782 | } | ||
| 783 | else if (i == 2) | ||
| 784 | { | 1026 | { |
| 785 | char tmp[16]; | 1027 | s->shutdown |= SSL_RECEIVED_SHUTDOWN; |
| 786 | |||
| 787 | s->rwstate=SSL_NOTHING; | ||
| 788 | s->s3->fatal_alert=n; | ||
| 789 | SSLerr(SSL_F_SSL3_READ_BYTES,1000+n); | ||
| 790 | sprintf(tmp,"%d",n); | ||
| 791 | ERR_add_error_data(2,"SSL alert number ",tmp); | ||
| 792 | s->shutdown|=SSL_RECEIVED_SHUTDOWN; | ||
| 793 | SSL_CTX_remove_session(s->ctx,s->session); | ||
| 794 | return(0); | 1028 | return(0); |
| 795 | } | 1029 | } |
| 796 | else | ||
| 797 | { | ||
| 798 | al=SSL_AD_ILLEGAL_PARAMETER; | ||
| 799 | SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNKNOWN_ALERT_TYPE); | ||
| 800 | goto f_err; | ||
| 801 | } | ||
| 802 | |||
| 803 | rr->length=0; | ||
| 804 | goto start; | ||
| 805 | } | 1030 | } |
| 806 | 1031 | else if (alert_level == 2) /* fatal */ | |
| 807 | if (s->shutdown & SSL_SENT_SHUTDOWN) | ||
| 808 | { | 1032 | { |
| 1033 | char tmp[16]; | ||
| 1034 | |||
| 809 | s->rwstate=SSL_NOTHING; | 1035 | s->rwstate=SSL_NOTHING; |
| 810 | rr->length=0; | 1036 | s->s3->fatal_alert = alert_descr; |
| 1037 | SSLerr(SSL_F_SSL3_READ_BYTES, SSL_AD_REASON_OFFSET + alert_descr); | ||
| 1038 | BIO_snprintf(tmp,sizeof tmp,"%d",alert_descr); | ||
| 1039 | ERR_add_error_data(2,"SSL alert number ",tmp); | ||
| 1040 | s->shutdown|=SSL_RECEIVED_SHUTDOWN; | ||
| 1041 | SSL_CTX_remove_session(s->ctx,s->session); | ||
| 811 | return(0); | 1042 | return(0); |
| 812 | } | 1043 | } |
| 813 | 1044 | else | |
| 814 | if (rr->type == SSL3_RT_CHANGE_CIPHER_SPEC) | ||
| 815 | { | 1045 | { |
| 816 | if ( (rr->length != 1) || (rr->off != 0) || | 1046 | al=SSL_AD_ILLEGAL_PARAMETER; |
| 817 | (rr->data[0] != SSL3_MT_CCS)) | 1047 | SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNKNOWN_ALERT_TYPE); |
| 818 | { | 1048 | goto f_err; |
| 819 | i=SSL_AD_ILLEGAL_PARAMETER; | ||
| 820 | SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_BAD_CHANGE_CIPHER_SPEC); | ||
| 821 | goto err; | ||
| 822 | } | ||
| 823 | |||
| 824 | rr->length=0; | ||
| 825 | s->s3->change_cipher_spec=1; | ||
| 826 | if (!do_change_cipher_spec(s)) | ||
| 827 | goto err; | ||
| 828 | else | ||
| 829 | goto start; | ||
| 830 | } | 1049 | } |
| 831 | 1050 | ||
| 832 | /* else we have a handshake */ | 1051 | goto start; |
| 833 | if ((rr->type == SSL3_RT_HANDSHAKE) && | 1052 | } |
| 834 | !s->in_handshake) | 1053 | |
| 1054 | if (s->shutdown & SSL_SENT_SHUTDOWN) /* but we have not received a shutdown */ | ||
| 1055 | { | ||
| 1056 | s->rwstate=SSL_NOTHING; | ||
| 1057 | rr->length=0; | ||
| 1058 | return(0); | ||
| 1059 | } | ||
| 1060 | |||
| 1061 | if (rr->type == SSL3_RT_CHANGE_CIPHER_SPEC) | ||
| 1062 | { | ||
| 1063 | /* 'Change Cipher Spec' is just a single byte, so we know | ||
| 1064 | * exactly what the record payload has to look like */ | ||
| 1065 | if ( (rr->length != 1) || (rr->off != 0) || | ||
| 1066 | (rr->data[0] != SSL3_MT_CCS)) | ||
| 835 | { | 1067 | { |
| 836 | if (((s->state&SSL_ST_MASK) == SSL_ST_OK) && | 1068 | i=SSL_AD_ILLEGAL_PARAMETER; |
| 837 | !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS)) | 1069 | SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_BAD_CHANGE_CIPHER_SPEC); |
| 838 | { | 1070 | goto err; |
| 839 | s->state=SSL_ST_BEFORE; | 1071 | } |
| 840 | s->new_session=1; | 1072 | |
| 841 | } | 1073 | rr->length=0; |
| 842 | n=s->handshake_func(s); | ||
| 843 | if (n < 0) return(n); | ||
| 844 | if (n == 0) | ||
| 845 | { | ||
| 846 | SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE); | ||
| 847 | return(-1); | ||
| 848 | } | ||
| 849 | 1074 | ||
| 850 | /* In the case where we try to read application data | 1075 | if (s->msg_callback) |
| 851 | * the first time, but we trigger an SSL handshake, we | 1076 | s->msg_callback(0, s->version, SSL3_RT_CHANGE_CIPHER_SPEC, rr->data, 1, s, s->msg_callback_arg); |
| 852 | * return -1 with the retry option set. I do this | ||
| 853 | * otherwise renegotiation can cause nasty problems | ||
| 854 | * in the non-blocking world */ | ||
| 855 | 1077 | ||
| 856 | s->rwstate=SSL_READING; | 1078 | s->s3->change_cipher_spec=1; |
| 857 | bio=SSL_get_rbio(s); | 1079 | if (!do_change_cipher_spec(s)) |
| 858 | BIO_clear_retry_flags(bio); | 1080 | goto err; |
| 859 | BIO_set_retry_read(bio); | 1081 | else |
| 1082 | goto start; | ||
| 1083 | } | ||
| 1084 | |||
| 1085 | /* Unexpected handshake message (Client Hello, or protocol violation) */ | ||
| 1086 | if ((s->s3->handshake_fragment_len >= 4) && !s->in_handshake) | ||
| 1087 | { | ||
| 1088 | if (((s->state&SSL_ST_MASK) == SSL_ST_OK) && | ||
| 1089 | !(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS)) | ||
| 1090 | { | ||
| 1091 | #if 0 /* worked only because C operator preferences are not as expected (and | ||
| 1092 | * because this is not really needed for clients except for detecting | ||
| 1093 | * protocol violations): */ | ||
| 1094 | s->state=SSL_ST_BEFORE|(s->server) | ||
| 1095 | ?SSL_ST_ACCEPT | ||
| 1096 | :SSL_ST_CONNECT; | ||
| 1097 | #else | ||
| 1098 | s->state = s->server ? SSL_ST_ACCEPT : SSL_ST_CONNECT; | ||
| 1099 | #endif | ||
| 1100 | s->new_session=1; | ||
| 1101 | } | ||
| 1102 | i=s->handshake_func(s); | ||
| 1103 | if (i < 0) return(i); | ||
| 1104 | if (i == 0) | ||
| 1105 | { | ||
| 1106 | SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE); | ||
| 860 | return(-1); | 1107 | return(-1); |
| 861 | } | 1108 | } |
| 862 | 1109 | ||
| 863 | switch (rr->type) | 1110 | if (!(s->mode & SSL_MODE_AUTO_RETRY)) |
| 864 | { | 1111 | { |
| 865 | default: | 1112 | if (s->s3->rbuf.left == 0) /* no read-ahead left? */ |
| 866 | #ifndef NO_TLS | ||
| 867 | /* TLS just ignores unknown message types */ | ||
| 868 | if (s->version == TLS1_VERSION) | ||
| 869 | { | ||
| 870 | goto start; | ||
| 871 | } | ||
| 872 | #endif | ||
| 873 | case SSL3_RT_CHANGE_CIPHER_SPEC: | ||
| 874 | case SSL3_RT_ALERT: | ||
| 875 | case SSL3_RT_HANDSHAKE: | ||
| 876 | al=SSL_AD_UNEXPECTED_MESSAGE; | ||
| 877 | SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNEXPECTED_RECORD); | ||
| 878 | goto f_err; | ||
| 879 | case SSL3_RT_APPLICATION_DATA: | ||
| 880 | /* At this point, we were expecting something else, | ||
| 881 | * but have application data. What we do is set the | ||
| 882 | * error, and return -1. On the way out, if the | ||
| 883 | * library was running inside ssl3_read() and it makes | ||
| 884 | * sense to read application data at this point, we | ||
| 885 | * will indulge it. This will mostly happen during | ||
| 886 | * session renegotiation. | ||
| 887 | */ | ||
| 888 | if (s->s3->in_read_app_data && | ||
| 889 | (s->s3->total_renegotiations != 0) && | ||
| 890 | (( | ||
| 891 | (s->state & SSL_ST_CONNECT) && | ||
| 892 | (s->state >= SSL3_ST_CW_CLNT_HELLO_A) && | ||
| 893 | (s->state <= SSL3_ST_CR_SRVR_HELLO_A) | ||
| 894 | ) || ( | ||
| 895 | (s->state & SSL_ST_ACCEPT) && | ||
| 896 | (s->state <= SSL3_ST_SW_HELLO_REQ_A) && | ||
| 897 | (s->state >= SSL3_ST_SR_CLNT_HELLO_A) | ||
| 898 | ) | ||
| 899 | )) | ||
| 900 | { | 1113 | { |
| 901 | s->s3->in_read_app_data=0; | 1114 | BIO *bio; |
| 1115 | /* In the case where we try to read application data, | ||
| 1116 | * but we trigger an SSL handshake, we return -1 with | ||
| 1117 | * the retry option set. Otherwise renegotiation may | ||
| 1118 | * cause nasty problems in the blocking world */ | ||
| 1119 | s->rwstate=SSL_READING; | ||
| 1120 | bio=SSL_get_rbio(s); | ||
| 1121 | BIO_clear_retry_flags(bio); | ||
| 1122 | BIO_set_retry_read(bio); | ||
| 902 | return(-1); | 1123 | return(-1); |
| 903 | } | 1124 | } |
| 904 | else | ||
| 905 | { | ||
| 906 | al=SSL_AD_UNEXPECTED_MESSAGE; | ||
| 907 | SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNEXPECTED_RECORD); | ||
| 908 | goto f_err; | ||
| 909 | } | ||
| 910 | } | 1125 | } |
| 1126 | goto start; | ||
| 911 | } | 1127 | } |
| 912 | 1128 | ||
| 913 | /* make sure that we are not getting application data when we | 1129 | switch (rr->type) |
| 914 | * are doing a handshake for the first time */ | ||
| 915 | if (SSL_in_init(s) && (type == SSL3_RT_APPLICATION_DATA) && | ||
| 916 | (s->enc_read_ctx == NULL)) | ||
| 917 | { | 1130 | { |
| 1131 | default: | ||
| 1132 | #ifndef OPENSSL_NO_TLS | ||
| 1133 | /* TLS just ignores unknown message types */ | ||
| 1134 | if (s->version == TLS1_VERSION) | ||
| 1135 | { | ||
| 1136 | rr->length = 0; | ||
| 1137 | goto start; | ||
| 1138 | } | ||
| 1139 | #endif | ||
| 918 | al=SSL_AD_UNEXPECTED_MESSAGE; | 1140 | al=SSL_AD_UNEXPECTED_MESSAGE; |
| 919 | SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_APP_DATA_IN_HANDSHAKE); | 1141 | SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNEXPECTED_RECORD); |
| 920 | goto f_err; | 1142 | goto f_err; |
| 1143 | case SSL3_RT_CHANGE_CIPHER_SPEC: | ||
| 1144 | case SSL3_RT_ALERT: | ||
| 1145 | case SSL3_RT_HANDSHAKE: | ||
| 1146 | /* we already handled all of these, with the possible exception | ||
| 1147 | * of SSL3_RT_HANDSHAKE when s->in_handshake is set, but that | ||
| 1148 | * should not happen when type != rr->type */ | ||
| 1149 | al=SSL_AD_UNEXPECTED_MESSAGE; | ||
| 1150 | SSLerr(SSL_F_SSL3_READ_BYTES,ERR_R_INTERNAL_ERROR); | ||
| 1151 | goto f_err; | ||
| 1152 | case SSL3_RT_APPLICATION_DATA: | ||
| 1153 | /* At this point, we were expecting handshake data, | ||
| 1154 | * but have application data. If the library was | ||
| 1155 | * running inside ssl3_read() (i.e. in_read_app_data | ||
| 1156 | * is set) and it makes sense to read application data | ||
| 1157 | * at this point (session renegotiation not yet started), | ||
| 1158 | * we will indulge it. | ||
| 1159 | */ | ||
| 1160 | if (s->s3->in_read_app_data && | ||
| 1161 | (s->s3->total_renegotiations != 0) && | ||
| 1162 | (( | ||
| 1163 | (s->state & SSL_ST_CONNECT) && | ||
| 1164 | (s->state >= SSL3_ST_CW_CLNT_HELLO_A) && | ||
| 1165 | (s->state <= SSL3_ST_CR_SRVR_HELLO_A) | ||
| 1166 | ) || ( | ||
| 1167 | (s->state & SSL_ST_ACCEPT) && | ||
| 1168 | (s->state <= SSL3_ST_SW_HELLO_REQ_A) && | ||
| 1169 | (s->state >= SSL3_ST_SR_CLNT_HELLO_A) | ||
| 1170 | ) | ||
| 1171 | )) | ||
| 1172 | { | ||
| 1173 | s->s3->in_read_app_data=2; | ||
| 1174 | return(-1); | ||
| 1175 | } | ||
| 1176 | else | ||
| 1177 | { | ||
| 1178 | al=SSL_AD_UNEXPECTED_MESSAGE; | ||
| 1179 | SSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNEXPECTED_RECORD); | ||
| 1180 | goto f_err; | ||
| 1181 | } | ||
| 921 | } | 1182 | } |
| 1183 | /* not reached */ | ||
| 922 | 1184 | ||
| 923 | if (len <= 0) return(len); | ||
| 924 | |||
| 925 | if ((unsigned int)len > rr->length) | ||
| 926 | n=rr->length; | ||
| 927 | else | ||
| 928 | n=len; | ||
| 929 | |||
| 930 | memcpy(buf,&(rr->data[rr->off]),(unsigned int)n); | ||
| 931 | rr->length-=n; | ||
| 932 | rr->off+=n; | ||
| 933 | if (rr->length <= 0) | ||
| 934 | { | ||
| 935 | s->rstate=SSL_ST_READ_HEADER; | ||
| 936 | rr->off=0; | ||
| 937 | } | ||
| 938 | |||
| 939 | if (type == SSL3_RT_HANDSHAKE) | ||
| 940 | ssl3_finish_mac(s,(unsigned char *)buf,n); | ||
| 941 | return(n); | ||
| 942 | f_err: | 1185 | f_err: |
| 943 | ssl3_send_alert(s,SSL3_AL_FATAL,al); | 1186 | ssl3_send_alert(s,SSL3_AL_FATAL,al); |
| 944 | err: | 1187 | err: |
| 945 | return(-1); | 1188 | return(-1); |
| 946 | } | 1189 | } |
| 947 | 1190 | ||
| 948 | static int do_change_cipher_spec(s) | 1191 | static int do_change_cipher_spec(SSL *s) |
| 949 | SSL *s; | ||
| 950 | { | 1192 | { |
| 951 | int i; | 1193 | int i; |
| 952 | unsigned char *sender; | 1194 | const char *sender; |
| 953 | int slen; | 1195 | int slen; |
| 954 | 1196 | ||
| 955 | if (s->state & SSL_ST_ACCEPT) | 1197 | if (s->state & SSL_ST_ACCEPT) |
| @@ -971,46 +1213,29 @@ SSL *s; | |||
| 971 | * the finished message */ | 1213 | * the finished message */ |
| 972 | if (s->state & SSL_ST_CONNECT) | 1214 | if (s->state & SSL_ST_CONNECT) |
| 973 | { | 1215 | { |
| 974 | sender=s->method->ssl3_enc->server_finished; | 1216 | sender=s->method->ssl3_enc->server_finished_label; |
| 975 | slen=s->method->ssl3_enc->server_finished_len; | 1217 | slen=s->method->ssl3_enc->server_finished_label_len; |
| 976 | } | 1218 | } |
| 977 | else | 1219 | else |
| 978 | { | 1220 | { |
| 979 | sender=s->method->ssl3_enc->client_finished; | 1221 | sender=s->method->ssl3_enc->client_finished_label; |
| 980 | slen=s->method->ssl3_enc->client_finished_len; | 1222 | slen=s->method->ssl3_enc->client_finished_label_len; |
| 981 | } | 1223 | } |
| 982 | 1224 | ||
| 983 | s->method->ssl3_enc->final_finish_mac(s, | 1225 | s->s3->tmp.peer_finish_md_len = s->method->ssl3_enc->final_finish_mac(s, |
| 984 | &(s->s3->finish_dgst1), | 1226 | &(s->s3->finish_dgst1), |
| 985 | &(s->s3->finish_dgst2), | 1227 | &(s->s3->finish_dgst2), |
| 986 | sender,slen,&(s->s3->tmp.finish_md[0])); | 1228 | sender,slen,s->s3->tmp.peer_finish_md); |
| 987 | 1229 | ||
| 988 | return(1); | 1230 | return(1); |
| 989 | } | 1231 | } |
| 990 | 1232 | ||
| 991 | int ssl3_do_write(s,type) | 1233 | void ssl3_send_alert(SSL *s, int level, int desc) |
| 992 | SSL *s; | ||
| 993 | int type; | ||
| 994 | { | ||
| 995 | int ret; | ||
| 996 | |||
| 997 | ret=ssl3_write_bytes(s,type,(char *) | ||
| 998 | &(s->init_buf->data[s->init_off]),s->init_num); | ||
| 999 | if (ret == s->init_num) | ||
| 1000 | return(1); | ||
| 1001 | if (ret < 0) return(-1); | ||
| 1002 | s->init_off+=ret; | ||
| 1003 | s->init_num-=ret; | ||
| 1004 | return(0); | ||
| 1005 | } | ||
| 1006 | |||
| 1007 | void ssl3_send_alert(s,level,desc) | ||
| 1008 | SSL *s; | ||
| 1009 | int level; | ||
| 1010 | int desc; | ||
| 1011 | { | 1234 | { |
| 1012 | /* Map tls/ssl alert value to correct one */ | 1235 | /* Map tls/ssl alert value to correct one */ |
| 1013 | desc=s->method->ssl3_enc->alert_value(desc); | 1236 | desc=s->method->ssl3_enc->alert_value(desc); |
| 1237 | if (s->version == SSL3_VERSION && desc == SSL_AD_PROTOCOL_VERSION) | ||
| 1238 | desc = SSL_AD_HANDSHAKE_FAILURE; /* SSL 3.0 does not have protocol_version alerts */ | ||
| 1014 | if (desc < 0) return; | 1239 | if (desc < 0) return; |
| 1015 | /* If a fatal one, remove from cache */ | 1240 | /* If a fatal one, remove from cache */ |
| 1016 | if ((level == 2) && (s->session != NULL)) | 1241 | if ((level == 2) && (s->session != NULL)) |
| @@ -1019,37 +1244,39 @@ int desc; | |||
| 1019 | s->s3->alert_dispatch=1; | 1244 | s->s3->alert_dispatch=1; |
| 1020 | s->s3->send_alert[0]=level; | 1245 | s->s3->send_alert[0]=level; |
| 1021 | s->s3->send_alert[1]=desc; | 1246 | s->s3->send_alert[1]=desc; |
| 1022 | if (s->s3->wbuf.left == 0) /* data still being written out */ | 1247 | if (s->s3->wbuf.left == 0) /* data still being written out? */ |
| 1023 | ssl3_dispatch_alert(s); | 1248 | ssl3_dispatch_alert(s); |
| 1024 | /* else data is still being written out, we will get written | 1249 | /* else data is still being written out, we will get written |
| 1025 | * some time in the future */ | 1250 | * some time in the future */ |
| 1026 | } | 1251 | } |
| 1027 | 1252 | ||
| 1028 | int ssl3_dispatch_alert(s) | 1253 | int ssl3_dispatch_alert(SSL *s) |
| 1029 | SSL *s; | ||
| 1030 | { | 1254 | { |
| 1031 | int i,j; | 1255 | int i,j; |
| 1032 | void (*cb)()=NULL; | 1256 | void (*cb)(const SSL *ssl,int type,int val)=NULL; |
| 1033 | 1257 | ||
| 1034 | s->s3->alert_dispatch=0; | 1258 | s->s3->alert_dispatch=0; |
| 1035 | i=do_ssl3_write(s,SSL3_RT_ALERT,&(s->s3->send_alert[0]),2); | 1259 | i = do_ssl3_write(s, SSL3_RT_ALERT, &s->s3->send_alert[0], 2, 0); |
| 1036 | if (i <= 0) | 1260 | if (i <= 0) |
| 1037 | { | 1261 | { |
| 1038 | s->s3->alert_dispatch=1; | 1262 | s->s3->alert_dispatch=1; |
| 1039 | } | 1263 | } |
| 1040 | else | 1264 | else |
| 1041 | { | 1265 | { |
| 1042 | /* If it is important, send it now. If the message | 1266 | /* Alert sent to BIO. If it is important, flush it now. |
| 1043 | * does not get sent due to non-blocking IO, we will | 1267 | * If the message does not get sent due to non-blocking IO, |
| 1044 | * not worry too much. */ | 1268 | * we will not worry too much. */ |
| 1045 | if (s->s3->send_alert[0] == SSL3_AL_FATAL) | 1269 | if (s->s3->send_alert[0] == SSL3_AL_FATAL) |
| 1046 | BIO_flush(s->wbio); | 1270 | (void)BIO_flush(s->wbio); |
| 1271 | |||
| 1272 | if (s->msg_callback) | ||
| 1273 | s->msg_callback(1, s->version, SSL3_RT_ALERT, s->s3->send_alert, 2, s, s->msg_callback_arg); | ||
| 1047 | 1274 | ||
| 1048 | if (s->info_callback != NULL) | 1275 | if (s->info_callback != NULL) |
| 1049 | cb=s->info_callback; | 1276 | cb=s->info_callback; |
| 1050 | else if (s->ctx->info_callback != NULL) | 1277 | else if (s->ctx->info_callback != NULL) |
| 1051 | cb=s->ctx->info_callback; | 1278 | cb=s->ctx->info_callback; |
| 1052 | 1279 | ||
| 1053 | if (cb != NULL) | 1280 | if (cb != NULL) |
| 1054 | { | 1281 | { |
| 1055 | j=(s->s3->send_alert[0]<<8)|s->s3->send_alert[1]; | 1282 | j=(s->s3->send_alert[0]<<8)|s->s3->send_alert[1]; |
| @@ -1058,4 +1285,3 @@ SSL *s; | |||
| 1058 | } | 1285 | } |
| 1059 | return(i); | 1286 | return(i); |
| 1060 | } | 1287 | } |
| 1061 | |||
diff --git a/src/lib/libssl/s3_srvr.c b/src/lib/libssl/s3_srvr.c index 64903af151..99b6a86983 100644 --- a/src/lib/libssl/s3_srvr.c +++ b/src/lib/libssl/s3_srvr.c | |||
| @@ -55,52 +55,88 @@ | |||
| 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 | ||
| 59 | #define REUSE_CIPHER_BUG | 112 | #define REUSE_CIPHER_BUG |
| 113 | #define NETSCAPE_HANG_BUG | ||
| 114 | |||
| 60 | 115 | ||
| 61 | #include <stdio.h> | 116 | #include <stdio.h> |
| 62 | #include "buffer.h" | 117 | #include <openssl/buffer.h> |
| 63 | #include "rand.h" | 118 | #include <openssl/rand.h> |
| 64 | #include "objects.h" | 119 | #include <openssl/objects.h> |
| 65 | #include "evp.h" | 120 | #include <openssl/evp.h> |
| 66 | #include "x509.h" | 121 | #include <openssl/x509.h> |
| 122 | #include <openssl/krb5_asn.h> | ||
| 67 | #include "ssl_locl.h" | 123 | #include "ssl_locl.h" |
| 124 | #include "kssl_lcl.h" | ||
| 125 | #include <openssl/md5.h> | ||
| 68 | 126 | ||
| 69 | #define BREAK break | 127 | static SSL_METHOD *ssl3_get_server_method(int ver); |
| 70 | /* SSLerr(SSL_F_SSL3_ACCEPT,ERR_R_MALLOC_FAILURE); | ||
| 71 | * SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,ERR_R_MALLOC_FAILURE); | ||
| 72 | * SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,ERR_R_MALLOC_FAILURE); | ||
| 73 | * SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,ERR_R_MALLOC_FAILURE); | ||
| 74 | * SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,ERR_R_MALLOC_FAILURE); | ||
| 75 | */ | ||
| 76 | |||
| 77 | #ifndef NOPROTO | ||
| 78 | static int ssl3_get_client_hello(SSL *s); | 128 | static int ssl3_get_client_hello(SSL *s); |
| 129 | static int ssl3_check_client_hello(SSL *s); | ||
| 79 | static int ssl3_send_server_hello(SSL *s); | 130 | static int ssl3_send_server_hello(SSL *s); |
| 80 | static int ssl3_send_server_key_exchange(SSL *s); | 131 | static int ssl3_send_server_key_exchange(SSL *s); |
| 81 | static int ssl3_send_certificate_request(SSL *s); | 132 | static int ssl3_send_certificate_request(SSL *s); |
| 82 | static int ssl3_send_server_done(SSL *s); | 133 | static int ssl3_send_server_done(SSL *s); |
| 83 | static int ssl3_get_cert_verify(SSL *s); | ||
| 84 | static int ssl3_get_client_key_exchange(SSL *s); | 134 | static int ssl3_get_client_key_exchange(SSL *s); |
| 85 | static int ssl3_get_client_certificate(SSL *s); | 135 | static int ssl3_get_client_certificate(SSL *s); |
| 136 | static int ssl3_get_cert_verify(SSL *s); | ||
| 86 | static int ssl3_send_hello_request(SSL *s); | 137 | static int ssl3_send_hello_request(SSL *s); |
| 87 | 138 | ||
| 88 | #else | 139 | static SSL_METHOD *ssl3_get_server_method(int ver) |
| 89 | |||
| 90 | static int ssl3_get_client_hello(); | ||
| 91 | static int ssl3_send_server_hello(); | ||
| 92 | static int ssl3_send_server_key_exchange(); | ||
| 93 | static int ssl3_send_certificate_request(); | ||
| 94 | static int ssl3_send_server_done(); | ||
| 95 | static int ssl3_get_cert_verify(); | ||
| 96 | static int ssl3_get_client_key_exchange(); | ||
| 97 | static int ssl3_get_client_certificate(); | ||
| 98 | static int ssl3_send_hello_request(); | ||
| 99 | |||
| 100 | #endif | ||
| 101 | |||
| 102 | static SSL_METHOD *ssl3_get_server_method(ver) | ||
| 103 | int ver; | ||
| 104 | { | 140 | { |
| 105 | if (ver == SSL3_VERSION) | 141 | if (ver == SSL3_VERSION) |
| 106 | return(SSLv3_server_method()); | 142 | return(SSLv3_server_method()); |
| @@ -108,35 +144,32 @@ int ver; | |||
| 108 | return(NULL); | 144 | return(NULL); |
| 109 | } | 145 | } |
| 110 | 146 | ||
| 111 | SSL_METHOD *SSLv3_server_method() | 147 | SSL_METHOD *SSLv3_server_method(void) |
| 112 | { | 148 | { |
| 113 | static int init=1; | 149 | static int init=1; |
| 114 | static SSL_METHOD SSLv3_server_data; | 150 | static SSL_METHOD SSLv3_server_data; |
| 115 | 151 | ||
| 116 | if (init) | 152 | if (init) |
| 117 | { | 153 | { |
| 118 | init=0; | ||
| 119 | memcpy((char *)&SSLv3_server_data,(char *)sslv3_base_method(), | 154 | memcpy((char *)&SSLv3_server_data,(char *)sslv3_base_method(), |
| 120 | sizeof(SSL_METHOD)); | 155 | sizeof(SSL_METHOD)); |
| 121 | SSLv3_server_data.ssl_accept=ssl3_accept; | 156 | SSLv3_server_data.ssl_accept=ssl3_accept; |
| 122 | SSLv3_server_data.get_ssl_method=ssl3_get_server_method; | 157 | SSLv3_server_data.get_ssl_method=ssl3_get_server_method; |
| 158 | init=0; | ||
| 123 | } | 159 | } |
| 124 | return(&SSLv3_server_data); | 160 | return(&SSLv3_server_data); |
| 125 | } | 161 | } |
| 126 | 162 | ||
| 127 | int ssl3_accept(s) | 163 | int ssl3_accept(SSL *s) |
| 128 | SSL *s; | ||
| 129 | { | 164 | { |
| 130 | BUF_MEM *buf; | 165 | BUF_MEM *buf; |
| 131 | unsigned long l,Time=time(NULL); | 166 | unsigned long l,Time=time(NULL); |
| 132 | void (*cb)()=NULL; | 167 | void (*cb)(const SSL *ssl,int type,int val)=NULL; |
| 133 | long num1; | 168 | long num1; |
| 134 | int ret= -1; | 169 | int ret= -1; |
| 135 | CERT *ct; | ||
| 136 | BIO *under; | ||
| 137 | int new_state,state,skip=0; | 170 | int new_state,state,skip=0; |
| 138 | 171 | ||
| 139 | RAND_seed((unsigned char *)&Time,sizeof(Time)); | 172 | RAND_add(&Time,sizeof(Time),0); |
| 140 | ERR_clear_error(); | 173 | ERR_clear_error(); |
| 141 | clear_sys_error(); | 174 | clear_sys_error(); |
| 142 | 175 | ||
| @@ -146,20 +179,14 @@ SSL *s; | |||
| 146 | cb=s->ctx->info_callback; | 179 | cb=s->ctx->info_callback; |
| 147 | 180 | ||
| 148 | /* init things to blank */ | 181 | /* init things to blank */ |
| 149 | if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s); | ||
| 150 | s->in_handshake++; | 182 | s->in_handshake++; |
| 183 | if (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s); | ||
| 151 | 184 | ||
| 152 | #ifdef undef | 185 | if (s->cert == NULL) |
| 153 | /* FIX THIS EAY EAY EAY */ | ||
| 154 | /* we don't actually need a cert, we just need a cert or a DH_tmp */ | ||
| 155 | if (((s->session == NULL) || (s->session->cert == NULL)) && | ||
| 156 | (s->cert == NULL)) | ||
| 157 | { | 186 | { |
| 158 | SSLerr(SSL_F_SSL3_ACCEPT,SSL_R_NO_CERTIFICATE_SET); | 187 | SSLerr(SSL_F_SSL3_ACCEPT,SSL_R_NO_CERTIFICATE_SET); |
| 159 | ret= -1; | 188 | return(-1); |
| 160 | goto end; | ||
| 161 | } | 189 | } |
| 162 | #endif | ||
| 163 | 190 | ||
| 164 | for (;;) | 191 | for (;;) |
| 165 | { | 192 | { |
| @@ -176,11 +203,14 @@ SSL *s; | |||
| 176 | case SSL_ST_BEFORE|SSL_ST_ACCEPT: | 203 | case SSL_ST_BEFORE|SSL_ST_ACCEPT: |
| 177 | case SSL_ST_OK|SSL_ST_ACCEPT: | 204 | case SSL_ST_OK|SSL_ST_ACCEPT: |
| 178 | 205 | ||
| 206 | s->server=1; | ||
| 179 | if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_START,1); | 207 | if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_START,1); |
| 180 | 208 | ||
| 181 | if ((s->version>>8) != 3) | 209 | if ((s->version>>8) != 3) |
| 182 | abort(); | 210 | { |
| 183 | /* s->version=SSL3_VERSION; */ | 211 | SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR); |
| 212 | return -1; | ||
| 213 | } | ||
| 184 | s->type=SSL_ST_ACCEPT; | 214 | s->type=SSL_ST_ACCEPT; |
| 185 | 215 | ||
| 186 | if (s->init_buf == NULL) | 216 | if (s->init_buf == NULL) |
| @@ -204,22 +234,24 @@ SSL *s; | |||
| 204 | goto end; | 234 | goto end; |
| 205 | } | 235 | } |
| 206 | 236 | ||
| 207 | /* Ok, we now need to push on a buffering BIO so that | ||
| 208 | * the output is sent in a way that TCP likes :-) | ||
| 209 | */ | ||
| 210 | if (!ssl_init_wbio_buffer(s,1)) { ret= -1; goto end; } | ||
| 211 | |||
| 212 | s->init_num=0; | 237 | s->init_num=0; |
| 213 | 238 | ||
| 214 | if (s->state != SSL_ST_RENEGOTIATE) | 239 | if (s->state != SSL_ST_RENEGOTIATE) |
| 215 | { | 240 | { |
| 216 | s->state=SSL3_ST_SR_CLNT_HELLO_A; | 241 | /* Ok, we now need to push on a buffering BIO so that |
| 242 | * the output is sent in a way that TCP likes :-) | ||
| 243 | */ | ||
| 244 | if (!ssl_init_wbio_buffer(s,1)) { ret= -1; goto end; } | ||
| 245 | |||
| 217 | ssl3_init_finished_mac(s); | 246 | ssl3_init_finished_mac(s); |
| 218 | s->ctx->sess_accept++; | 247 | s->state=SSL3_ST_SR_CLNT_HELLO_A; |
| 248 | s->ctx->stats.sess_accept++; | ||
| 219 | } | 249 | } |
| 220 | else | 250 | else |
| 221 | { | 251 | { |
| 222 | s->ctx->sess_accept_renegotiate++; | 252 | /* s->state == SSL_ST_RENEGOTIATE, |
| 253 | * we will just send a HelloRequest */ | ||
| 254 | s->ctx->stats.sess_accept_renegotiate++; | ||
| 223 | s->state=SSL3_ST_SW_HELLO_REQ_A; | 255 | s->state=SSL3_ST_SW_HELLO_REQ_A; |
| 224 | } | 256 | } |
| 225 | break; | 257 | break; |
| @@ -238,19 +270,8 @@ SSL *s; | |||
| 238 | break; | 270 | break; |
| 239 | 271 | ||
| 240 | case SSL3_ST_SW_HELLO_REQ_C: | 272 | case SSL3_ST_SW_HELLO_REQ_C: |
| 241 | /* remove buffering on output */ | ||
| 242 | under=BIO_pop(s->wbio); | ||
| 243 | if (under != NULL) | ||
| 244 | s->wbio=under; | ||
| 245 | else | ||
| 246 | abort(); /* ok */ | ||
| 247 | BIO_free(s->bbio); | ||
| 248 | s->bbio=NULL; | ||
| 249 | |||
| 250 | s->state=SSL_ST_OK; | 273 | s->state=SSL_ST_OK; |
| 251 | ret=1; | 274 | break; |
| 252 | goto end; | ||
| 253 | /* break; */ | ||
| 254 | 275 | ||
| 255 | case SSL3_ST_SR_CLNT_HELLO_A: | 276 | case SSL3_ST_SR_CLNT_HELLO_A: |
| 256 | case SSL3_ST_SR_CLNT_HELLO_B: | 277 | case SSL3_ST_SR_CLNT_HELLO_B: |
| @@ -259,6 +280,7 @@ SSL *s; | |||
| 259 | s->shutdown=0; | 280 | s->shutdown=0; |
| 260 | ret=ssl3_get_client_hello(s); | 281 | ret=ssl3_get_client_hello(s); |
| 261 | if (ret <= 0) goto end; | 282 | if (ret <= 0) goto end; |
| 283 | s->new_session = 2; | ||
| 262 | s->state=SSL3_ST_SW_SRVR_HELLO_A; | 284 | s->state=SSL3_ST_SW_SRVR_HELLO_A; |
| 263 | s->init_num=0; | 285 | s->init_num=0; |
| 264 | break; | 286 | break; |
| @@ -292,40 +314,34 @@ SSL *s; | |||
| 292 | case SSL3_ST_SW_KEY_EXCH_A: | 314 | case SSL3_ST_SW_KEY_EXCH_A: |
| 293 | case SSL3_ST_SW_KEY_EXCH_B: | 315 | case SSL3_ST_SW_KEY_EXCH_B: |
| 294 | l=s->s3->tmp.new_cipher->algorithms; | 316 | l=s->s3->tmp.new_cipher->algorithms; |
| 295 | if (s->session->cert == NULL) | ||
| 296 | { | ||
| 297 | if (s->cert != NULL) | ||
| 298 | { | ||
| 299 | CRYPTO_add(&s->cert->references,1,CRYPTO_LOCK_SSL_CERT); | ||
| 300 | s->session->cert=s->cert; | ||
| 301 | } | ||
| 302 | else | ||
| 303 | { | ||
| 304 | CRYPTO_add(&s->ctx->default_cert->references,1,CRYPTO_LOCK_SSL_CERT); | ||
| 305 | s->session->cert=s->ctx->default_cert; | ||
| 306 | } | ||
| 307 | } | ||
| 308 | ct=s->session->cert; | ||
| 309 | 317 | ||
| 310 | /* clear this, it may get reset by | 318 | /* clear this, it may get reset by |
| 311 | * send_server_key_exchange */ | 319 | * send_server_key_exchange */ |
| 312 | if (s->options & SSL_OP_EPHEMERAL_RSA) | 320 | if ((s->options & SSL_OP_EPHEMERAL_RSA) |
| 321 | #ifndef OPENSSL_NO_KRB5 | ||
| 322 | && !(l & SSL_KRB5) | ||
| 323 | #endif /* OPENSSL_NO_KRB5 */ | ||
| 324 | ) | ||
| 325 | /* option SSL_OP_EPHEMERAL_RSA sends temporary RSA key | ||
| 326 | * even when forbidden by protocol specs | ||
| 327 | * (handshake may fail as clients are not required to | ||
| 328 | * be able to handle this) */ | ||
| 313 | s->s3->tmp.use_rsa_tmp=1; | 329 | s->s3->tmp.use_rsa_tmp=1; |
| 314 | else | 330 | else |
| 315 | s->s3->tmp.use_rsa_tmp=0; | 331 | s->s3->tmp.use_rsa_tmp=0; |
| 316 | 332 | ||
| 317 | /* only send if a DH key exchange, fortezza or | 333 | /* only send if a DH key exchange, fortezza or |
| 318 | * RSA but we have a sign only certificate */ | 334 | * RSA but we have a sign only certificate */ |
| 319 | if ( s->s3->tmp.use_rsa_tmp || | 335 | if (s->s3->tmp.use_rsa_tmp |
| 320 | (l & (SSL_DH|SSL_kFZA)) || | 336 | || (l & (SSL_DH|SSL_kFZA)) |
| 321 | ((l & SSL_kRSA) && | 337 | || ((l & SSL_kRSA) |
| 322 | ((ct->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL)|| | 338 | && (s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL |
| 323 | ((l & SSL_EXPORT) && | 339 | || (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) |
| 324 | (EVP_PKEY_size(ct->pkeys[SSL_PKEY_RSA_ENC].privatekey)*8 > 512) | 340 | && EVP_PKEY_size(s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey)*8 > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher) |
| 325 | ) | 341 | ) |
| 326 | ) | 342 | ) |
| 343 | ) | ||
| 327 | ) | 344 | ) |
| 328 | ) | ||
| 329 | { | 345 | { |
| 330 | ret=ssl3_send_server_key_exchange(s); | 346 | ret=ssl3_send_server_key_exchange(s); |
| 331 | if (ret <= 0) goto end; | 347 | if (ret <= 0) goto end; |
| @@ -339,9 +355,21 @@ SSL *s; | |||
| 339 | 355 | ||
| 340 | case SSL3_ST_SW_CERT_REQ_A: | 356 | case SSL3_ST_SW_CERT_REQ_A: |
| 341 | case SSL3_ST_SW_CERT_REQ_B: | 357 | case SSL3_ST_SW_CERT_REQ_B: |
| 342 | if (!(s->verify_mode & SSL_VERIFY_PEER) || | 358 | if (/* don't request cert unless asked for it: */ |
| 359 | !(s->verify_mode & SSL_VERIFY_PEER) || | ||
| 360 | /* if SSL_VERIFY_CLIENT_ONCE is set, | ||
| 361 | * don't request cert during re-negotiation: */ | ||
| 343 | ((s->session->peer != NULL) && | 362 | ((s->session->peer != NULL) && |
| 344 | (s->verify_mode & SSL_VERIFY_CLIENT_ONCE))) | 363 | (s->verify_mode & SSL_VERIFY_CLIENT_ONCE)) || |
| 364 | /* never request cert in anonymous ciphersuites | ||
| 365 | * (see section "Certificate request" in SSL 3 drafts | ||
| 366 | * and in RFC 2246): */ | ||
| 367 | ((s->s3->tmp.new_cipher->algorithms & SSL_aNULL) && | ||
| 368 | /* ... except when the application insists on verification | ||
| 369 | * (against the specs, but s3_clnt.c accepts this for SSL 3) */ | ||
| 370 | !(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) || | ||
| 371 | /* never request cert in Kerberos ciphersuites */ | ||
| 372 | (s->s3->tmp.new_cipher->algorithms & SSL_aKRB5)) | ||
| 345 | { | 373 | { |
| 346 | /* no cert request */ | 374 | /* no cert request */ |
| 347 | skip=1; | 375 | skip=1; |
| @@ -353,7 +381,12 @@ SSL *s; | |||
| 353 | s->s3->tmp.cert_request=1; | 381 | s->s3->tmp.cert_request=1; |
| 354 | ret=ssl3_send_certificate_request(s); | 382 | ret=ssl3_send_certificate_request(s); |
| 355 | if (ret <= 0) goto end; | 383 | if (ret <= 0) goto end; |
| 384 | #ifndef NETSCAPE_HANG_BUG | ||
| 356 | s->state=SSL3_ST_SW_SRVR_DONE_A; | 385 | s->state=SSL3_ST_SW_SRVR_DONE_A; |
| 386 | #else | ||
| 387 | s->state=SSL3_ST_SW_FLUSH; | ||
| 388 | s->s3->tmp.next_state=SSL3_ST_SR_CERT_A; | ||
| 389 | #endif | ||
| 357 | s->init_num=0; | 390 | s->init_num=0; |
| 358 | } | 391 | } |
| 359 | break; | 392 | break; |
| @@ -383,12 +416,20 @@ SSL *s; | |||
| 383 | 416 | ||
| 384 | case SSL3_ST_SR_CERT_A: | 417 | case SSL3_ST_SR_CERT_A: |
| 385 | case SSL3_ST_SR_CERT_B: | 418 | case SSL3_ST_SR_CERT_B: |
| 386 | /* could be sent for a DH cert, even if we | 419 | /* Check for second client hello (MS SGC) */ |
| 387 | * have not asked for it :-) */ | 420 | ret = ssl3_check_client_hello(s); |
| 388 | ret=ssl3_get_client_certificate(s); | 421 | if (ret <= 0) |
| 389 | if (ret <= 0) goto end; | 422 | goto end; |
| 390 | s->init_num=0; | 423 | if (ret == 2) |
| 391 | s->state=SSL3_ST_SR_KEY_EXCH_A; | 424 | s->state = SSL3_ST_SR_CLNT_HELLO_C; |
| 425 | else { | ||
| 426 | /* could be sent for a DH cert, even if we | ||
| 427 | * have not asked for it :-) */ | ||
| 428 | ret=ssl3_get_client_certificate(s); | ||
| 429 | if (ret <= 0) goto end; | ||
| 430 | s->init_num=0; | ||
| 431 | s->state=SSL3_ST_SR_KEY_EXCH_A; | ||
| 432 | } | ||
| 392 | break; | 433 | break; |
| 393 | 434 | ||
| 394 | case SSL3_ST_SR_KEY_EXCH_A: | 435 | case SSL3_ST_SR_KEY_EXCH_A: |
| @@ -402,10 +443,10 @@ SSL *s; | |||
| 402 | * a client cert, it can be verified */ | 443 | * a client cert, it can be verified */ |
| 403 | s->method->ssl3_enc->cert_verify_mac(s, | 444 | s->method->ssl3_enc->cert_verify_mac(s, |
| 404 | &(s->s3->finish_dgst1), | 445 | &(s->s3->finish_dgst1), |
| 405 | &(s->s3->tmp.finish_md[0])); | 446 | &(s->s3->tmp.cert_verify_md[0])); |
| 406 | s->method->ssl3_enc->cert_verify_mac(s, | 447 | s->method->ssl3_enc->cert_verify_mac(s, |
| 407 | &(s->s3->finish_dgst2), | 448 | &(s->s3->finish_dgst2), |
| 408 | &(s->s3->tmp.finish_md[MD5_DIGEST_LENGTH])); | 449 | &(s->s3->tmp.cert_verify_md[MD5_DIGEST_LENGTH])); |
| 409 | 450 | ||
| 410 | break; | 451 | break; |
| 411 | 452 | ||
| @@ -459,8 +500,8 @@ SSL *s; | |||
| 459 | case SSL3_ST_SW_FINISHED_B: | 500 | case SSL3_ST_SW_FINISHED_B: |
| 460 | ret=ssl3_send_finished(s, | 501 | ret=ssl3_send_finished(s, |
| 461 | SSL3_ST_SW_FINISHED_A,SSL3_ST_SW_FINISHED_B, | 502 | SSL3_ST_SW_FINISHED_A,SSL3_ST_SW_FINISHED_B, |
| 462 | s->method->ssl3_enc->server_finished, | 503 | s->method->ssl3_enc->server_finished_label, |
| 463 | s->method->ssl3_enc->server_finished_len); | 504 | s->method->ssl3_enc->server_finished_label_len); |
| 464 | if (ret <= 0) goto end; | 505 | if (ret <= 0) goto end; |
| 465 | s->state=SSL3_ST_SW_FLUSH; | 506 | s->state=SSL3_ST_SW_FLUSH; |
| 466 | if (s->hit) | 507 | if (s->hit) |
| @@ -478,26 +519,27 @@ SSL *s; | |||
| 478 | s->init_buf=NULL; | 519 | s->init_buf=NULL; |
| 479 | 520 | ||
| 480 | /* remove buffering on output */ | 521 | /* remove buffering on output */ |
| 481 | under=BIO_pop(s->wbio); | 522 | ssl_free_wbio_buffer(s); |
| 482 | if (under != NULL) | ||
| 483 | s->wbio=under; | ||
| 484 | else | ||
| 485 | abort(); /* ok */ | ||
| 486 | BIO_free(s->bbio); | ||
| 487 | s->bbio=NULL; | ||
| 488 | 523 | ||
| 489 | s->new_session=0; | ||
| 490 | s->init_num=0; | 524 | s->init_num=0; |
| 491 | 525 | ||
| 492 | ssl_update_cache(s,SSL_SESS_CACHE_SERVER); | 526 | if (s->new_session == 2) /* skipped if we just sent a HelloRequest */ |
| 493 | 527 | { | |
| 494 | s->ctx->sess_accept_good++; | 528 | /* actually not necessarily a 'new' session unless |
| 495 | /* s->server=1; */ | 529 | * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is set */ |
| 496 | s->handshake_func=ssl3_accept; | 530 | |
| 497 | ret=1; | 531 | s->new_session=0; |
| 498 | 532 | ||
| 499 | if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_DONE,1); | 533 | ssl_update_cache(s,SSL_SESS_CACHE_SERVER); |
| 500 | 534 | ||
| 535 | s->ctx->stats.sess_accept_good++; | ||
| 536 | /* s->server=1; */ | ||
| 537 | s->handshake_func=ssl3_accept; | ||
| 538 | |||
| 539 | if (cb != NULL) cb(s,SSL_CB_HANDSHAKE_DONE,1); | ||
| 540 | } | ||
| 541 | |||
| 542 | ret = 1; | ||
| 501 | goto end; | 543 | goto end; |
| 502 | /* break; */ | 544 | /* break; */ |
| 503 | 545 | ||
| @@ -530,21 +572,20 @@ SSL *s; | |||
| 530 | end: | 572 | end: |
| 531 | /* BIO_flush(s->wbio); */ | 573 | /* BIO_flush(s->wbio); */ |
| 532 | 574 | ||
| 575 | s->in_handshake--; | ||
| 533 | if (cb != NULL) | 576 | if (cb != NULL) |
| 534 | cb(s,SSL_CB_ACCEPT_EXIT,ret); | 577 | cb(s,SSL_CB_ACCEPT_EXIT,ret); |
| 535 | s->in_handshake--; | ||
| 536 | return(ret); | 578 | return(ret); |
| 537 | } | 579 | } |
| 538 | 580 | ||
| 539 | static int ssl3_send_hello_request(s) | 581 | static int ssl3_send_hello_request(SSL *s) |
| 540 | SSL *s; | ||
| 541 | { | 582 | { |
| 542 | unsigned char *p; | 583 | unsigned char *p; |
| 543 | 584 | ||
| 544 | if (s->state == SSL3_ST_SW_HELLO_REQ_A) | 585 | if (s->state == SSL3_ST_SW_HELLO_REQ_A) |
| 545 | { | 586 | { |
| 546 | p=(unsigned char *)s->init_buf->data; | 587 | p=(unsigned char *)s->init_buf->data; |
| 547 | *(p++)=SSL3_MT_CLIENT_REQUEST; | 588 | *(p++)=SSL3_MT_HELLO_REQUEST; |
| 548 | *(p++)=0; | 589 | *(p++)=0; |
| 549 | *(p++)=0; | 590 | *(p++)=0; |
| 550 | *(p++)=0; | 591 | *(p++)=0; |
| @@ -559,15 +600,48 @@ SSL *s; | |||
| 559 | return(ssl3_do_write(s,SSL3_RT_HANDSHAKE)); | 600 | return(ssl3_do_write(s,SSL3_RT_HANDSHAKE)); |
| 560 | } | 601 | } |
| 561 | 602 | ||
| 562 | static int ssl3_get_client_hello(s) | 603 | static int ssl3_check_client_hello(SSL *s) |
| 563 | SSL *s; | 604 | { |
| 605 | int ok; | ||
| 606 | long n; | ||
| 607 | |||
| 608 | /* this function is called when we really expect a Certificate message, | ||
| 609 | * so permit appropriate message length */ | ||
| 610 | n=ssl3_get_message(s, | ||
| 611 | SSL3_ST_SR_CERT_A, | ||
| 612 | SSL3_ST_SR_CERT_B, | ||
| 613 | -1, | ||
| 614 | s->max_cert_list, | ||
| 615 | &ok); | ||
| 616 | if (!ok) return((int)n); | ||
| 617 | s->s3->tmp.reuse_message = 1; | ||
| 618 | if (s->s3->tmp.message_type == SSL3_MT_CLIENT_HELLO) | ||
| 619 | { | ||
| 620 | /* Throw away what we have done so far in the current handshake, | ||
| 621 | * which will now be aborted. (A full SSL_clear would be too much.) | ||
| 622 | * I hope that tmp.dh is the only thing that may need to be cleared | ||
| 623 | * when a handshake is not completed ... */ | ||
| 624 | #ifndef OPENSSL_NO_DH | ||
| 625 | if (s->s3->tmp.dh != NULL) | ||
| 626 | { | ||
| 627 | DH_free(s->s3->tmp.dh); | ||
| 628 | s->s3->tmp.dh = NULL; | ||
| 629 | } | ||
| 630 | #endif | ||
| 631 | return 2; | ||
| 632 | } | ||
| 633 | return 1; | ||
| 634 | } | ||
| 635 | |||
| 636 | static int ssl3_get_client_hello(SSL *s) | ||
| 564 | { | 637 | { |
| 565 | int i,j,ok,al,ret= -1; | 638 | int i,j,ok,al,ret= -1; |
| 566 | long n; | 639 | long n; |
| 567 | unsigned long id; | 640 | unsigned long id; |
| 568 | unsigned char *p,*d; | 641 | unsigned char *p,*d,*q; |
| 569 | SSL_CIPHER *c; | 642 | SSL_CIPHER *c; |
| 570 | STACK *ciphers=NULL; | 643 | SSL_COMP *comp=NULL; |
| 644 | STACK_OF(SSL_CIPHER) *ciphers=NULL; | ||
| 571 | 645 | ||
| 572 | /* We do this so that we will respond with our native type. | 646 | /* We do this so that we will respond with our native type. |
| 573 | * If we are TLSv1 and we get SSLv3, we will respond with TLSv1, | 647 | * If we are TLSv1 and we get SSLv3, we will respond with TLSv1, |
| @@ -588,13 +662,25 @@ SSL *s; | |||
| 588 | &ok); | 662 | &ok); |
| 589 | 663 | ||
| 590 | if (!ok) return((int)n); | 664 | if (!ok) return((int)n); |
| 591 | d=p=(unsigned char *)s->init_buf->data; | 665 | d=p=(unsigned char *)s->init_msg; |
| 592 | 666 | ||
| 593 | /* The version number has already been checked in ssl3_get_message. | 667 | /* use version from inside client hello, not from record header |
| 594 | * I a native TLSv1/SSLv3 method, the match must be correct except | 668 | * (may differ: see RFC 2246, Appendix E, second paragraph) */ |
| 595 | * perhaps for the first message */ | 669 | s->client_version=(((int)p[0])<<8)|(int)p[1]; |
| 596 | p+=2; | 670 | p+=2; |
| 597 | 671 | ||
| 672 | if (s->client_version < s->version) | ||
| 673 | { | ||
| 674 | SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_WRONG_VERSION_NUMBER); | ||
| 675 | if ((s->client_version>>8) == SSL3_VERSION_MAJOR) | ||
| 676 | { | ||
| 677 | /* similar to ssl3_get_record, send alert using remote version number */ | ||
| 678 | s->version = s->client_version; | ||
| 679 | } | ||
| 680 | al = SSL_AD_PROTOCOL_VERSION; | ||
| 681 | goto f_err; | ||
| 682 | } | ||
| 683 | |||
| 598 | /* load the client random */ | 684 | /* load the client random */ |
| 599 | memcpy(s->s3->client_random,p,SSL3_RANDOM_SIZE); | 685 | memcpy(s->s3->client_random,p,SSL3_RANDOM_SIZE); |
| 600 | p+=SSL3_RANDOM_SIZE; | 686 | p+=SSL3_RANDOM_SIZE; |
| @@ -603,7 +689,15 @@ SSL *s; | |||
| 603 | j= *(p++); | 689 | j= *(p++); |
| 604 | 690 | ||
| 605 | s->hit=0; | 691 | s->hit=0; |
| 606 | if (j == 0) | 692 | /* Versions before 0.9.7 always allow session reuse during renegotiation |
| 693 | * (i.e. when s->new_session is true), option | ||
| 694 | * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is new with 0.9.7. | ||
| 695 | * Maybe this optional behaviour should always have been the default, | ||
| 696 | * but we cannot safely change the default behaviour (or new applications | ||
| 697 | * might be written that become totally unsecure when compiled with | ||
| 698 | * an earlier library version) | ||
| 699 | */ | ||
| 700 | if (j == 0 || (s->new_session && (s->options & SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION))) | ||
| 607 | { | 701 | { |
| 608 | if (!ssl_get_new_session(s,1)) | 702 | if (!ssl_get_new_session(s,1)) |
| 609 | goto err; | 703 | goto err; |
| @@ -615,7 +709,9 @@ SSL *s; | |||
| 615 | { /* previous session */ | 709 | { /* previous session */ |
| 616 | s->hit=1; | 710 | s->hit=1; |
| 617 | } | 711 | } |
| 618 | else | 712 | else if (i == -1) |
| 713 | goto err; | ||
| 714 | else /* i == 0 */ | ||
| 619 | { | 715 | { |
| 620 | if (!ssl_get_new_session(s,1)) | 716 | if (!ssl_get_new_session(s,1)) |
| 621 | goto err; | 717 | goto err; |
| @@ -631,7 +727,7 @@ SSL *s; | |||
| 631 | SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_NO_CIPHERS_SPECIFIED); | 727 | SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_NO_CIPHERS_SPECIFIED); |
| 632 | goto f_err; | 728 | goto f_err; |
| 633 | } | 729 | } |
| 634 | if ((i+p) > (d+n)) | 730 | if ((p+i) >= (d+n)) |
| 635 | { | 731 | { |
| 636 | /* not enough data */ | 732 | /* not enough data */ |
| 637 | al=SSL_AD_DECODE_ERROR; | 733 | al=SSL_AD_DECODE_ERROR; |
| @@ -651,9 +747,16 @@ SSL *s; | |||
| 651 | j=0; | 747 | j=0; |
| 652 | id=s->session->cipher->id; | 748 | id=s->session->cipher->id; |
| 653 | 749 | ||
| 654 | for (i=0; i<sk_num(ciphers); i++) | 750 | #ifdef CIPHER_DEBUG |
| 751 | printf("client sent %d ciphers\n",sk_num(ciphers)); | ||
| 752 | #endif | ||
| 753 | for (i=0; i<sk_SSL_CIPHER_num(ciphers); i++) | ||
| 655 | { | 754 | { |
| 656 | c=(SSL_CIPHER *)sk_value(ciphers,i); | 755 | c=sk_SSL_CIPHER_value(ciphers,i); |
| 756 | #ifdef CIPHER_DEBUG | ||
| 757 | printf("client [%2d of %2d]:%s\n", | ||
| 758 | i,sk_num(ciphers),SSL_CIPHER_get_name(c)); | ||
| 759 | #endif | ||
| 657 | if (c->id == id) | 760 | if (c->id == id) |
| 658 | { | 761 | { |
| 659 | j=1; | 762 | j=1; |
| @@ -662,11 +765,11 @@ SSL *s; | |||
| 662 | } | 765 | } |
| 663 | if (j == 0) | 766 | if (j == 0) |
| 664 | { | 767 | { |
| 665 | if ((s->options & SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG) && (sk_num(ciphers) == 1)) | 768 | if ((s->options & SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG) && (sk_SSL_CIPHER_num(ciphers) == 1)) |
| 666 | { | 769 | { |
| 667 | /* Very bad for multi-threading.... */ | 770 | /* Very bad for multi-threading.... */ |
| 668 | s->session->cipher= | 771 | s->session->cipher=sk_SSL_CIPHER_value(ciphers, |
| 669 | (SSL_CIPHER *)sk_value(ciphers,0); | 772 | 0); |
| 670 | } | 773 | } |
| 671 | else | 774 | else |
| 672 | { | 775 | { |
| @@ -681,8 +784,18 @@ SSL *s; | |||
| 681 | 784 | ||
| 682 | /* compression */ | 785 | /* compression */ |
| 683 | i= *(p++); | 786 | i= *(p++); |
| 787 | if ((p+i) > (d+n)) | ||
| 788 | { | ||
| 789 | /* not enough data */ | ||
| 790 | al=SSL_AD_DECODE_ERROR; | ||
| 791 | SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_LENGTH_MISMATCH); | ||
| 792 | goto f_err; | ||
| 793 | } | ||
| 794 | q=p; | ||
| 684 | for (j=0; j<i; j++) | 795 | for (j=0; j<i; j++) |
| 796 | { | ||
| 685 | if (p[j] == 0) break; | 797 | if (p[j] == 0) break; |
| 798 | } | ||
| 686 | 799 | ||
| 687 | p+=i; | 800 | p+=i; |
| 688 | if (j >= i) | 801 | if (j >= i) |
| @@ -693,10 +806,39 @@ SSL *s; | |||
| 693 | goto f_err; | 806 | goto f_err; |
| 694 | } | 807 | } |
| 695 | 808 | ||
| 809 | /* Worst case, we will use the NULL compression, but if we have other | ||
| 810 | * options, we will now look for them. We have i-1 compression | ||
| 811 | * algorithms from the client, starting at q. */ | ||
| 812 | s->s3->tmp.new_compression=NULL; | ||
| 813 | if (s->ctx->comp_methods != NULL) | ||
| 814 | { /* See if we have a match */ | ||
| 815 | int m,nn,o,v,done=0; | ||
| 816 | |||
| 817 | nn=sk_SSL_COMP_num(s->ctx->comp_methods); | ||
| 818 | for (m=0; m<nn; m++) | ||
| 819 | { | ||
| 820 | comp=sk_SSL_COMP_value(s->ctx->comp_methods,m); | ||
| 821 | v=comp->id; | ||
| 822 | for (o=0; o<i; o++) | ||
| 823 | { | ||
| 824 | if (v == q[o]) | ||
| 825 | { | ||
| 826 | done=1; | ||
| 827 | break; | ||
| 828 | } | ||
| 829 | } | ||
| 830 | if (done) break; | ||
| 831 | } | ||
| 832 | if (done) | ||
| 833 | s->s3->tmp.new_compression=comp; | ||
| 834 | else | ||
| 835 | comp=NULL; | ||
| 836 | } | ||
| 837 | |||
| 696 | /* TLS does not mind if there is extra stuff */ | 838 | /* TLS does not mind if there is extra stuff */ |
| 697 | if (s->version == SSL3_VERSION) | 839 | if (s->version == SSL3_VERSION) |
| 698 | { | 840 | { |
| 699 | if (p > (d+n)) | 841 | if (p < (d+n)) |
| 700 | { | 842 | { |
| 701 | /* wrong number of bytes, | 843 | /* wrong number of bytes, |
| 702 | * there could be more to follow */ | 844 | * there could be more to follow */ |
| @@ -706,15 +848,14 @@ SSL *s; | |||
| 706 | } | 848 | } |
| 707 | } | 849 | } |
| 708 | 850 | ||
| 709 | /* do nothing with compression */ | 851 | /* Given s->session->ciphers and SSL_get_ciphers, we must |
| 710 | |||
| 711 | /* Given s->session->ciphers and ssl_get_ciphers_by_id(s), we must | ||
| 712 | * pick a cipher */ | 852 | * pick a cipher */ |
| 713 | 853 | ||
| 714 | if (!s->hit) | 854 | if (!s->hit) |
| 715 | { | 855 | { |
| 856 | s->session->compress_meth=(comp == NULL)?0:comp->id; | ||
| 716 | if (s->session->ciphers != NULL) | 857 | if (s->session->ciphers != NULL) |
| 717 | sk_free(s->session->ciphers); | 858 | sk_SSL_CIPHER_free(s->session->ciphers); |
| 718 | s->session->ciphers=ciphers; | 859 | s->session->ciphers=ciphers; |
| 719 | if (ciphers == NULL) | 860 | if (ciphers == NULL) |
| 720 | { | 861 | { |
| @@ -724,7 +865,7 @@ SSL *s; | |||
| 724 | } | 865 | } |
| 725 | ciphers=NULL; | 866 | ciphers=NULL; |
| 726 | c=ssl3_choose_cipher(s,s->session->ciphers, | 867 | c=ssl3_choose_cipher(s,s->session->ciphers, |
| 727 | ssl_get_ciphers_by_id(s)); | 868 | SSL_get_ciphers(s)); |
| 728 | 869 | ||
| 729 | if (c == NULL) | 870 | if (c == NULL) |
| 730 | { | 871 | { |
| @@ -738,19 +879,19 @@ SSL *s; | |||
| 738 | { | 879 | { |
| 739 | /* Session-id reuse */ | 880 | /* Session-id reuse */ |
| 740 | #ifdef REUSE_CIPHER_BUG | 881 | #ifdef REUSE_CIPHER_BUG |
| 741 | STACK *sk; | 882 | STACK_OF(SSL_CIPHER) *sk; |
| 742 | SSL_CIPHER *nc=NULL; | 883 | SSL_CIPHER *nc=NULL; |
| 743 | SSL_CIPHER *ec=NULL; | 884 | SSL_CIPHER *ec=NULL; |
| 744 | 885 | ||
| 745 | if (s->options & SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG) | 886 | if (s->options & SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG) |
| 746 | { | 887 | { |
| 747 | sk=s->session->ciphers; | 888 | sk=s->session->ciphers; |
| 748 | for (i=0; i<sk_num(sk); i++) | 889 | for (i=0; i<sk_SSL_CIPHER_num(sk); i++) |
| 749 | { | 890 | { |
| 750 | c=(SSL_CIPHER *)sk_value(sk,i); | 891 | c=sk_SSL_CIPHER_value(sk,i); |
| 751 | if (c->algorithms & SSL_eNULL) | 892 | if (c->algorithms & SSL_eNULL) |
| 752 | nc=c; | 893 | nc=c; |
| 753 | if (c->algorithms & SSL_EXP) | 894 | if (SSL_C_IS_EXPORT(c)) |
| 754 | ec=c; | 895 | ec=c; |
| 755 | } | 896 | } |
| 756 | if (nc != NULL) | 897 | if (nc != NULL) |
| @@ -772,7 +913,7 @@ SSL *s; | |||
| 772 | * compression - basically ignored right now | 913 | * compression - basically ignored right now |
| 773 | * ssl version is set - sslv3 | 914 | * ssl version is set - sslv3 |
| 774 | * s->session - The ssl session has been setup. | 915 | * s->session - The ssl session has been setup. |
| 775 | * s->hit - sesson reuse flag | 916 | * s->hit - session reuse flag |
| 776 | * s->tmp.new_cipher - the new cipher to use. | 917 | * s->tmp.new_cipher - the new cipher to use. |
| 777 | */ | 918 | */ |
| 778 | 919 | ||
| @@ -783,12 +924,11 @@ f_err: | |||
| 783 | ssl3_send_alert(s,SSL3_AL_FATAL,al); | 924 | ssl3_send_alert(s,SSL3_AL_FATAL,al); |
| 784 | } | 925 | } |
| 785 | err: | 926 | err: |
| 786 | if (ciphers != NULL) sk_free(ciphers); | 927 | if (ciphers != NULL) sk_SSL_CIPHER_free(ciphers); |
| 787 | return(ret); | 928 | return(ret); |
| 788 | } | 929 | } |
| 789 | 930 | ||
| 790 | static int ssl3_send_server_hello(s) | 931 | static int ssl3_send_server_hello(SSL *s) |
| 791 | SSL *s; | ||
| 792 | { | 932 | { |
| 793 | unsigned char *buf; | 933 | unsigned char *buf; |
| 794 | unsigned char *p,*d; | 934 | unsigned char *p,*d; |
| @@ -801,7 +941,7 @@ SSL *s; | |||
| 801 | p=s->s3->server_random; | 941 | p=s->s3->server_random; |
| 802 | Time=time(NULL); /* Time */ | 942 | Time=time(NULL); /* Time */ |
| 803 | l2n(Time,p); | 943 | l2n(Time,p); |
| 804 | RAND_bytes(p,SSL3_RANDOM_SIZE-sizeof(Time)); | 944 | RAND_pseudo_bytes(p,SSL3_RANDOM_SIZE-sizeof(Time)); |
| 805 | /* Do the message type and length last */ | 945 | /* Do the message type and length last */ |
| 806 | d=p= &(buf[4]); | 946 | d=p= &(buf[4]); |
| 807 | 947 | ||
| @@ -833,7 +973,10 @@ SSL *s; | |||
| 833 | p+=i; | 973 | p+=i; |
| 834 | 974 | ||
| 835 | /* put the compression method */ | 975 | /* put the compression method */ |
| 836 | *(p++)=0; | 976 | if (s->s3->tmp.new_compression == NULL) |
| 977 | *(p++)=0; | ||
| 978 | else | ||
| 979 | *(p++)=s->s3->tmp.new_compression->id; | ||
| 837 | 980 | ||
| 838 | /* do the header */ | 981 | /* do the header */ |
| 839 | l=(p-d); | 982 | l=(p-d); |
| @@ -851,8 +994,7 @@ SSL *s; | |||
| 851 | return(ssl3_do_write(s,SSL3_RT_HANDSHAKE)); | 994 | return(ssl3_do_write(s,SSL3_RT_HANDSHAKE)); |
| 852 | } | 995 | } |
| 853 | 996 | ||
| 854 | static int ssl3_send_server_done(s) | 997 | static int ssl3_send_server_done(SSL *s) |
| 855 | SSL *s; | ||
| 856 | { | 998 | { |
| 857 | unsigned char *p; | 999 | unsigned char *p; |
| 858 | 1000 | ||
| @@ -876,17 +1018,17 @@ SSL *s; | |||
| 876 | return(ssl3_do_write(s,SSL3_RT_HANDSHAKE)); | 1018 | return(ssl3_do_write(s,SSL3_RT_HANDSHAKE)); |
| 877 | } | 1019 | } |
| 878 | 1020 | ||
| 879 | static int ssl3_send_server_key_exchange(s) | 1021 | static int ssl3_send_server_key_exchange(SSL *s) |
| 880 | SSL *s; | ||
| 881 | { | 1022 | { |
| 882 | #ifndef NO_RSA | 1023 | #ifndef OPENSSL_NO_RSA |
| 883 | unsigned char *q; | 1024 | unsigned char *q; |
| 884 | int j,num; | 1025 | int j,num; |
| 885 | RSA *rsa; | 1026 | RSA *rsa; |
| 886 | unsigned char md_buf[MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH]; | 1027 | unsigned char md_buf[MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH]; |
| 1028 | unsigned int u; | ||
| 887 | #endif | 1029 | #endif |
| 888 | #ifndef NO_DH | 1030 | #ifndef OPENSSL_NO_DH |
| 889 | DH *dh,*dhp; | 1031 | DH *dh=NULL,*dhp; |
| 890 | #endif | 1032 | #endif |
| 891 | EVP_PKEY *pkey; | 1033 | EVP_PKEY *pkey; |
| 892 | unsigned char *p,*d; | 1034 | unsigned char *p,*d; |
| @@ -899,25 +1041,32 @@ SSL *s; | |||
| 899 | BUF_MEM *buf; | 1041 | BUF_MEM *buf; |
| 900 | EVP_MD_CTX md_ctx; | 1042 | EVP_MD_CTX md_ctx; |
| 901 | 1043 | ||
| 1044 | EVP_MD_CTX_init(&md_ctx); | ||
| 902 | if (s->state == SSL3_ST_SW_KEY_EXCH_A) | 1045 | if (s->state == SSL3_ST_SW_KEY_EXCH_A) |
| 903 | { | 1046 | { |
| 904 | type=s->s3->tmp.new_cipher->algorithms & SSL_MKEY_MASK; | 1047 | type=s->s3->tmp.new_cipher->algorithms & SSL_MKEY_MASK; |
| 905 | cert=s->session->cert; | 1048 | cert=s->cert; |
| 906 | 1049 | ||
| 907 | buf=s->init_buf; | 1050 | buf=s->init_buf; |
| 908 | 1051 | ||
| 909 | r[0]=r[1]=r[2]=r[3]=NULL; | 1052 | r[0]=r[1]=r[2]=r[3]=NULL; |
| 910 | n=0; | 1053 | n=0; |
| 911 | #ifndef NO_RSA | 1054 | #ifndef OPENSSL_NO_RSA |
| 912 | if (type & SSL_kRSA) | 1055 | if (type & SSL_kRSA) |
| 913 | { | 1056 | { |
| 914 | rsa=cert->rsa_tmp; | 1057 | rsa=cert->rsa_tmp; |
| 915 | if ((rsa == NULL) && (s->ctx->default_cert->rsa_tmp_cb != NULL)) | 1058 | if ((rsa == NULL) && (s->cert->rsa_tmp_cb != NULL)) |
| 1059 | { | ||
| 1060 | rsa=s->cert->rsa_tmp_cb(s, | ||
| 1061 | SSL_C_IS_EXPORT(s->s3->tmp.new_cipher), | ||
| 1062 | SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)); | ||
| 1063 | if(rsa == NULL) | ||
| 916 | { | 1064 | { |
| 917 | rsa=s->ctx->default_cert->rsa_tmp_cb(s, | 1065 | al=SSL_AD_HANDSHAKE_FAILURE; |
| 918 | (s->s3->tmp.new_cipher->algorithms| | 1066 | SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,SSL_R_ERROR_GENERATING_TMP_RSA_KEY); |
| 919 | SSL_NOT_EXP)?0:1); | 1067 | goto f_err; |
| 920 | CRYPTO_add(&rsa->references,1,CRYPTO_LOCK_RSA); | 1068 | } |
| 1069 | RSA_up_ref(rsa); | ||
| 921 | cert->rsa_tmp=rsa; | 1070 | cert->rsa_tmp=rsa; |
| 922 | } | 1071 | } |
| 923 | if (rsa == NULL) | 1072 | if (rsa == NULL) |
| @@ -932,20 +1081,28 @@ SSL *s; | |||
| 932 | } | 1081 | } |
| 933 | else | 1082 | else |
| 934 | #endif | 1083 | #endif |
| 935 | #ifndef NO_DH | 1084 | #ifndef OPENSSL_NO_DH |
| 936 | if (type & SSL_kEDH) | 1085 | if (type & SSL_kEDH) |
| 937 | { | 1086 | { |
| 938 | dhp=cert->dh_tmp; | 1087 | dhp=cert->dh_tmp; |
| 939 | if ((dhp == NULL) && (cert->dh_tmp_cb != NULL)) | 1088 | if ((dhp == NULL) && (s->cert->dh_tmp_cb != NULL)) |
| 940 | dhp=cert->dh_tmp_cb(s, | 1089 | dhp=s->cert->dh_tmp_cb(s, |
| 941 | (s->s3->tmp.new_cipher->algorithms| | 1090 | SSL_C_IS_EXPORT(s->s3->tmp.new_cipher), |
| 942 | SSL_NOT_EXP)?0:1); | 1091 | SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)); |
| 943 | if (dhp == NULL) | 1092 | if (dhp == NULL) |
| 944 | { | 1093 | { |
| 945 | al=SSL_AD_HANDSHAKE_FAILURE; | 1094 | al=SSL_AD_HANDSHAKE_FAILURE; |
| 946 | SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,SSL_R_MISSING_TMP_DH_KEY); | 1095 | SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,SSL_R_MISSING_TMP_DH_KEY); |
| 947 | goto f_err; | 1096 | goto f_err; |
| 948 | } | 1097 | } |
| 1098 | |||
| 1099 | if (s->s3->tmp.dh != NULL) | ||
| 1100 | { | ||
| 1101 | DH_free(dh); | ||
| 1102 | SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); | ||
| 1103 | goto err; | ||
| 1104 | } | ||
| 1105 | |||
| 949 | if ((dh=DHparams_dup(dhp)) == NULL) | 1106 | if ((dh=DHparams_dup(dhp)) == NULL) |
| 950 | { | 1107 | { |
| 951 | SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,ERR_R_DH_LIB); | 1108 | SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,ERR_R_DH_LIB); |
| @@ -953,13 +1110,16 @@ SSL *s; | |||
| 953 | } | 1110 | } |
| 954 | 1111 | ||
| 955 | s->s3->tmp.dh=dh; | 1112 | s->s3->tmp.dh=dh; |
| 956 | if (((dhp->pub_key == NULL) || | 1113 | if ((dhp->pub_key == NULL || |
| 957 | (dhp->priv_key == NULL) || | 1114 | dhp->priv_key == NULL || |
| 958 | (s->options & SSL_OP_SINGLE_DH_USE)) && | 1115 | (s->options & SSL_OP_SINGLE_DH_USE))) |
| 959 | (!DH_generate_key(dh))) | ||
| 960 | { | 1116 | { |
| 961 | SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,ERR_R_DH_LIB); | 1117 | if(!DH_generate_key(dh)) |
| 962 | goto err; | 1118 | { |
| 1119 | SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, | ||
| 1120 | ERR_R_DH_LIB); | ||
| 1121 | goto err; | ||
| 1122 | } | ||
| 963 | } | 1123 | } |
| 964 | else | 1124 | else |
| 965 | { | 1125 | { |
| @@ -1025,40 +1185,39 @@ SSL *s; | |||
| 1025 | { | 1185 | { |
| 1026 | /* n is the length of the params, they start at &(d[4]) | 1186 | /* n is the length of the params, they start at &(d[4]) |
| 1027 | * and p points to the space at the end. */ | 1187 | * and p points to the space at the end. */ |
| 1028 | #ifndef NO_RSA | 1188 | #ifndef OPENSSL_NO_RSA |
| 1029 | if (pkey->type == EVP_PKEY_RSA) | 1189 | if (pkey->type == EVP_PKEY_RSA) |
| 1030 | { | 1190 | { |
| 1031 | q=md_buf; | 1191 | q=md_buf; |
| 1032 | j=0; | 1192 | j=0; |
| 1033 | for (num=2; num > 0; num--) | 1193 | for (num=2; num > 0; num--) |
| 1034 | { | 1194 | { |
| 1035 | EVP_DigestInit(&md_ctx,(num == 2) | 1195 | EVP_DigestInit_ex(&md_ctx,(num == 2) |
| 1036 | ?s->ctx->md5:s->ctx->sha1); | 1196 | ?s->ctx->md5:s->ctx->sha1, NULL); |
| 1037 | EVP_DigestUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE); | 1197 | EVP_DigestUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE); |
| 1038 | EVP_DigestUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE); | 1198 | EVP_DigestUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE); |
| 1039 | EVP_DigestUpdate(&md_ctx,&(d[4]),n); | 1199 | EVP_DigestUpdate(&md_ctx,&(d[4]),n); |
| 1040 | EVP_DigestFinal(&md_ctx,q, | 1200 | EVP_DigestFinal_ex(&md_ctx,q, |
| 1041 | (unsigned int *)&i); | 1201 | (unsigned int *)&i); |
| 1042 | q+=i; | 1202 | q+=i; |
| 1043 | j+=i; | 1203 | j+=i; |
| 1044 | } | 1204 | } |
| 1045 | i=RSA_private_encrypt(j,md_buf,&(p[2]), | 1205 | if (RSA_sign(NID_md5_sha1, md_buf, j, |
| 1046 | pkey->pkey.rsa,RSA_PKCS1_PADDING); | 1206 | &(p[2]), &u, pkey->pkey.rsa) <= 0) |
| 1047 | if (i <= 0) | ||
| 1048 | { | 1207 | { |
| 1049 | SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,ERR_LIB_RSA); | 1208 | SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,ERR_LIB_RSA); |
| 1050 | goto err; | 1209 | goto err; |
| 1051 | } | 1210 | } |
| 1052 | s2n(i,p); | 1211 | s2n(u,p); |
| 1053 | n+=i+2; | 1212 | n+=u+2; |
| 1054 | } | 1213 | } |
| 1055 | else | 1214 | else |
| 1056 | #endif | 1215 | #endif |
| 1057 | #if !defined(NO_DSA) | 1216 | #if !defined(OPENSSL_NO_DSA) |
| 1058 | if (pkey->type == EVP_PKEY_DSA) | 1217 | if (pkey->type == EVP_PKEY_DSA) |
| 1059 | { | 1218 | { |
| 1060 | /* lets do DSS */ | 1219 | /* lets do DSS */ |
| 1061 | EVP_SignInit(&md_ctx,EVP_dss1()); | 1220 | EVP_SignInit_ex(&md_ctx,EVP_dss1(), NULL); |
| 1062 | EVP_SignUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE); | 1221 | EVP_SignUpdate(&md_ctx,&(s->s3->client_random[0]),SSL3_RANDOM_SIZE); |
| 1063 | EVP_SignUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE); | 1222 | EVP_SignUpdate(&md_ctx,&(s->s3->server_random[0]),SSL3_RANDOM_SIZE); |
| 1064 | EVP_SignUpdate(&md_ctx,&(d[4]),n); | 1223 | EVP_SignUpdate(&md_ctx,&(d[4]),n); |
| @@ -1090,20 +1249,21 @@ SSL *s; | |||
| 1090 | s->init_off=0; | 1249 | s->init_off=0; |
| 1091 | } | 1250 | } |
| 1092 | 1251 | ||
| 1093 | /* SSL3_ST_SW_KEY_EXCH_B */ | 1252 | s->state = SSL3_ST_SW_KEY_EXCH_B; |
| 1253 | EVP_MD_CTX_cleanup(&md_ctx); | ||
| 1094 | return(ssl3_do_write(s,SSL3_RT_HANDSHAKE)); | 1254 | return(ssl3_do_write(s,SSL3_RT_HANDSHAKE)); |
| 1095 | f_err: | 1255 | f_err: |
| 1096 | ssl3_send_alert(s,SSL3_AL_FATAL,al); | 1256 | ssl3_send_alert(s,SSL3_AL_FATAL,al); |
| 1097 | err: | 1257 | err: |
| 1258 | EVP_MD_CTX_cleanup(&md_ctx); | ||
| 1098 | return(-1); | 1259 | return(-1); |
| 1099 | } | 1260 | } |
| 1100 | 1261 | ||
| 1101 | static int ssl3_send_certificate_request(s) | 1262 | static int ssl3_send_certificate_request(SSL *s) |
| 1102 | SSL *s; | ||
| 1103 | { | 1263 | { |
| 1104 | unsigned char *p,*d; | 1264 | unsigned char *p,*d; |
| 1105 | int i,j,nl,off,n; | 1265 | int i,j,nl,off,n; |
| 1106 | STACK *sk=NULL; | 1266 | STACK_OF(X509_NAME) *sk=NULL; |
| 1107 | X509_NAME *name; | 1267 | X509_NAME *name; |
| 1108 | BUF_MEM *buf; | 1268 | BUF_MEM *buf; |
| 1109 | 1269 | ||
| @@ -1128,9 +1288,9 @@ SSL *s; | |||
| 1128 | nl=0; | 1288 | nl=0; |
| 1129 | if (sk != NULL) | 1289 | if (sk != NULL) |
| 1130 | { | 1290 | { |
| 1131 | for (i=0; i<sk_num(sk); i++) | 1291 | for (i=0; i<sk_X509_NAME_num(sk); i++) |
| 1132 | { | 1292 | { |
| 1133 | name=(X509_NAME *)sk_value(sk,i); | 1293 | name=sk_X509_NAME_value(sk,i); |
| 1134 | j=i2d_X509_NAME(name,NULL); | 1294 | j=i2d_X509_NAME(name,NULL); |
| 1135 | if (!BUF_MEM_grow(buf,4+n+j+2)) | 1295 | if (!BUF_MEM_grow(buf,4+n+j+2)) |
| 1136 | { | 1296 | { |
| @@ -1168,6 +1328,17 @@ SSL *s; | |||
| 1168 | 1328 | ||
| 1169 | s->init_num=n+4; | 1329 | s->init_num=n+4; |
| 1170 | s->init_off=0; | 1330 | s->init_off=0; |
| 1331 | #ifdef NETSCAPE_HANG_BUG | ||
| 1332 | p=(unsigned char *)s->init_buf->data + s->init_num; | ||
| 1333 | |||
| 1334 | /* do the header */ | ||
| 1335 | *(p++)=SSL3_MT_SERVER_DONE; | ||
| 1336 | *(p++)=0; | ||
| 1337 | *(p++)=0; | ||
| 1338 | *(p++)=0; | ||
| 1339 | s->init_num += 4; | ||
| 1340 | #endif | ||
| 1341 | |||
| 1171 | } | 1342 | } |
| 1172 | 1343 | ||
| 1173 | /* SSL3_ST_SW_CERT_REQ_B */ | 1344 | /* SSL3_ST_SW_CERT_REQ_B */ |
| @@ -1176,44 +1347,44 @@ err: | |||
| 1176 | return(-1); | 1347 | return(-1); |
| 1177 | } | 1348 | } |
| 1178 | 1349 | ||
| 1179 | static int ssl3_get_client_key_exchange(s) | 1350 | static int ssl3_get_client_key_exchange(SSL *s) |
| 1180 | SSL *s; | ||
| 1181 | { | 1351 | { |
| 1182 | int i,al,ok; | 1352 | int i,al,ok; |
| 1183 | long n; | 1353 | long n; |
| 1184 | unsigned long l; | 1354 | unsigned long l; |
| 1185 | unsigned char *p; | 1355 | unsigned char *p; |
| 1356 | #ifndef OPENSSL_NO_RSA | ||
| 1186 | RSA *rsa=NULL; | 1357 | RSA *rsa=NULL; |
| 1187 | EVP_PKEY *pkey=NULL; | 1358 | EVP_PKEY *pkey=NULL; |
| 1188 | #ifndef NO_DH | 1359 | #endif |
| 1360 | #ifndef OPENSSL_NO_DH | ||
| 1189 | BIGNUM *pub=NULL; | 1361 | BIGNUM *pub=NULL; |
| 1190 | DH *dh_srvr; | 1362 | DH *dh_srvr; |
| 1191 | #endif | 1363 | #endif |
| 1364 | #ifndef OPENSSL_NO_KRB5 | ||
| 1365 | KSSL_ERR kssl_err; | ||
| 1366 | #endif /* OPENSSL_NO_KRB5 */ | ||
| 1192 | 1367 | ||
| 1193 | n=ssl3_get_message(s, | 1368 | n=ssl3_get_message(s, |
| 1194 | SSL3_ST_SR_KEY_EXCH_A, | 1369 | SSL3_ST_SR_KEY_EXCH_A, |
| 1195 | SSL3_ST_SR_KEY_EXCH_B, | 1370 | SSL3_ST_SR_KEY_EXCH_B, |
| 1196 | SSL3_MT_CLIENT_KEY_EXCHANGE, | 1371 | SSL3_MT_CLIENT_KEY_EXCHANGE, |
| 1197 | 400, /* ???? */ | 1372 | 2048, /* ??? */ |
| 1198 | &ok); | 1373 | &ok); |
| 1199 | 1374 | ||
| 1200 | if (!ok) return((int)n); | 1375 | if (!ok) return((int)n); |
| 1201 | p=(unsigned char *)s->init_buf->data; | 1376 | p=(unsigned char *)s->init_msg; |
| 1202 | 1377 | ||
| 1203 | l=s->s3->tmp.new_cipher->algorithms; | 1378 | l=s->s3->tmp.new_cipher->algorithms; |
| 1204 | 1379 | ||
| 1205 | #ifndef NO_RSA | 1380 | #ifndef OPENSSL_NO_RSA |
| 1206 | if (l & SSL_kRSA) | 1381 | if (l & SSL_kRSA) |
| 1207 | { | 1382 | { |
| 1208 | /* FIX THIS UP EAY EAY EAY EAY */ | 1383 | /* FIX THIS UP EAY EAY EAY EAY */ |
| 1209 | if (s->s3->tmp.use_rsa_tmp) | 1384 | if (s->s3->tmp.use_rsa_tmp) |
| 1210 | { | 1385 | { |
| 1211 | if ((s->session->cert != NULL) && | 1386 | if ((s->cert != NULL) && (s->cert->rsa_tmp != NULL)) |
| 1212 | (s->session->cert->rsa_tmp != NULL)) | 1387 | rsa=s->cert->rsa_tmp; |
| 1213 | rsa=s->session->cert->rsa_tmp; | ||
| 1214 | else if ((s->ctx->default_cert != NULL) && | ||
| 1215 | (s->ctx->default_cert->rsa_tmp != NULL)) | ||
| 1216 | rsa=s->ctx->default_cert->rsa_tmp; | ||
| 1217 | /* Don't do a callback because rsa_tmp should | 1388 | /* Don't do a callback because rsa_tmp should |
| 1218 | * be sent already */ | 1389 | * be sent already */ |
| 1219 | if (rsa == NULL) | 1390 | if (rsa == NULL) |
| @@ -1258,33 +1429,53 @@ SSL *s; | |||
| 1258 | 1429 | ||
| 1259 | i=RSA_private_decrypt((int)n,p,p,rsa,RSA_PKCS1_PADDING); | 1430 | i=RSA_private_decrypt((int)n,p,p,rsa,RSA_PKCS1_PADDING); |
| 1260 | 1431 | ||
| 1261 | #if 1 | 1432 | al = -1; |
| 1262 | /* If a bad decrypt, use a dud master key */ | 1433 | |
| 1263 | if ((i != SSL_MAX_MASTER_KEY_LENGTH) || | ||
| 1264 | ((p[0] != (s->version>>8)) || | ||
| 1265 | (p[1] != (s->version & 0xff)))) | ||
| 1266 | { | ||
| 1267 | p[0]=(s->version>>8); | ||
| 1268 | p[1]=(s->version & 0xff); | ||
| 1269 | RAND_bytes(&(p[2]),SSL_MAX_MASTER_KEY_LENGTH-2); | ||
| 1270 | i=SSL_MAX_MASTER_KEY_LENGTH; | ||
| 1271 | } | ||
| 1272 | #else | ||
| 1273 | if (i != SSL_MAX_MASTER_KEY_LENGTH) | 1434 | if (i != SSL_MAX_MASTER_KEY_LENGTH) |
| 1274 | { | 1435 | { |
| 1275 | al=SSL_AD_DECODE_ERROR; | 1436 | al=SSL_AD_DECODE_ERROR; |
| 1276 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_BAD_RSA_DECRYPT); | 1437 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_BAD_RSA_DECRYPT); |
| 1277 | goto f_err; | ||
| 1278 | } | 1438 | } |
| 1279 | 1439 | ||
| 1280 | if ((p[0] != (s->version>>8)) || (p[1] != (s->version & 0xff))) | 1440 | if ((al == -1) && !((p[0] == (s->client_version>>8)) && (p[1] == (s->client_version & 0xff)))) |
| 1281 | { | 1441 | { |
| 1282 | al=SSL_AD_DECODE_ERROR; | 1442 | /* The premaster secret must contain the same version number as the |
| 1283 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_BAD_PROTOCOL_VERSION_NUMBER); | 1443 | * ClientHello to detect version rollback attacks (strangely, the |
| 1284 | goto f_err; | 1444 | * protocol does not offer such protection for DH ciphersuites). |
| 1445 | * However, buggy clients exist that send the negotiated protocol | ||
| 1446 | * version instead if the server does not support the requested | ||
| 1447 | * protocol version. | ||
| 1448 | * If SSL_OP_TLS_ROLLBACK_BUG is set, tolerate such clients. */ | ||
| 1449 | if (!((s->options & SSL_OP_TLS_ROLLBACK_BUG) && | ||
| 1450 | (p[0] == (s->version>>8)) && (p[1] == (s->version & 0xff)))) | ||
| 1451 | { | ||
| 1452 | al=SSL_AD_DECODE_ERROR; | ||
| 1453 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_BAD_PROTOCOL_VERSION_NUMBER); | ||
| 1454 | goto f_err; | ||
| 1455 | } | ||
| 1285 | } | 1456 | } |
| 1286 | #endif | ||
| 1287 | 1457 | ||
| 1458 | if (al != -1) | ||
| 1459 | { | ||
| 1460 | #if 0 | ||
| 1461 | goto f_err; | ||
| 1462 | #else | ||
| 1463 | /* Some decryption failure -- use random value instead as countermeasure | ||
| 1464 | * against Bleichenbacher's attack on PKCS #1 v1.5 RSA padding | ||
| 1465 | * (see RFC 2246, section 7.4.7.1). | ||
| 1466 | * But note that due to length and protocol version checking, the | ||
| 1467 | * attack is impractical anyway (see section 5 in D. Bleichenbacher: | ||
| 1468 | * "Chosen Ciphertext Attacks Against Protocols Based on the RSA | ||
| 1469 | * Encryption Standard PKCS #1", CRYPTO '98, LNCS 1462, pp. 1-12). | ||
| 1470 | */ | ||
| 1471 | ERR_clear_error(); | ||
| 1472 | i = SSL_MAX_MASTER_KEY_LENGTH; | ||
| 1473 | p[0] = s->client_version >> 8; | ||
| 1474 | p[1] = s->client_version & 0xff; | ||
| 1475 | RAND_pseudo_bytes(p+2, i-2); /* should be RAND_bytes, but we cannot work around a failure */ | ||
| 1476 | #endif | ||
| 1477 | } | ||
| 1478 | |||
| 1288 | s->session->master_key_length= | 1479 | s->session->master_key_length= |
| 1289 | s->method->ssl3_enc->generate_master_secret(s, | 1480 | s->method->ssl3_enc->generate_master_secret(s, |
| 1290 | s->session->master_key, | 1481 | s->session->master_key, |
| @@ -1293,7 +1484,7 @@ SSL *s; | |||
| 1293 | } | 1484 | } |
| 1294 | else | 1485 | else |
| 1295 | #endif | 1486 | #endif |
| 1296 | #ifndef NO_DH | 1487 | #ifndef OPENSSL_NO_DH |
| 1297 | if (l & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) | 1488 | if (l & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) |
| 1298 | { | 1489 | { |
| 1299 | n2s(p,i); | 1490 | n2s(p,i); |
| @@ -1352,26 +1543,175 @@ SSL *s; | |||
| 1352 | s->session->master_key_length= | 1543 | s->session->master_key_length= |
| 1353 | s->method->ssl3_enc->generate_master_secret(s, | 1544 | s->method->ssl3_enc->generate_master_secret(s, |
| 1354 | s->session->master_key,p,i); | 1545 | s->session->master_key,p,i); |
| 1546 | memset(p,0,i); | ||
| 1355 | } | 1547 | } |
| 1356 | else | 1548 | else |
| 1357 | #endif | 1549 | #endif |
| 1550 | #ifndef OPENSSL_NO_KRB5 | ||
| 1551 | if (l & SSL_kKRB5) | ||
| 1552 | { | ||
| 1553 | krb5_error_code krb5rc; | ||
| 1554 | krb5_data enc_ticket; | ||
| 1555 | krb5_data authenticator; | ||
| 1556 | krb5_data enc_pms; | ||
| 1557 | KSSL_CTX *kssl_ctx = s->kssl_ctx; | ||
| 1558 | EVP_CIPHER_CTX ciph_ctx; | ||
| 1559 | EVP_CIPHER *enc = NULL; | ||
| 1560 | unsigned char iv[EVP_MAX_IV_LENGTH]; | ||
| 1561 | unsigned char pms[SSL_MAX_MASTER_KEY_LENGTH | ||
| 1562 | + EVP_MAX_IV_LENGTH + 1]; | ||
| 1563 | int padl, outl = sizeof(pms); | ||
| 1564 | krb5_timestamp authtime = 0; | ||
| 1565 | krb5_ticket_times ttimes; | ||
| 1566 | |||
| 1567 | EVP_CIPHER_CTX_init(&ciph_ctx); | ||
| 1568 | |||
| 1569 | if (!kssl_ctx) kssl_ctx = kssl_ctx_new(); | ||
| 1570 | |||
| 1571 | n2s(p,i); | ||
| 1572 | enc_ticket.length = i; | ||
| 1573 | enc_ticket.data = (char *)p; | ||
| 1574 | p+=enc_ticket.length; | ||
| 1575 | |||
| 1576 | n2s(p,i); | ||
| 1577 | authenticator.length = i; | ||
| 1578 | authenticator.data = (char *)p; | ||
| 1579 | p+=authenticator.length; | ||
| 1580 | |||
| 1581 | n2s(p,i); | ||
| 1582 | enc_pms.length = i; | ||
| 1583 | enc_pms.data = (char *)p; | ||
| 1584 | p+=enc_pms.length; | ||
| 1585 | |||
| 1586 | if (n != enc_ticket.length + authenticator.length + | ||
| 1587 | enc_pms.length + 6) | ||
| 1588 | { | ||
| 1589 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, | ||
| 1590 | SSL_R_DATA_LENGTH_TOO_LONG); | ||
| 1591 | goto err; | ||
| 1592 | } | ||
| 1593 | |||
| 1594 | if ((krb5rc = kssl_sget_tkt(kssl_ctx, &enc_ticket, &ttimes, | ||
| 1595 | &kssl_err)) != 0) | ||
| 1596 | { | ||
| 1597 | #ifdef KSSL_DEBUG | ||
| 1598 | printf("kssl_sget_tkt rtn %d [%d]\n", | ||
| 1599 | krb5rc, kssl_err.reason); | ||
| 1600 | if (kssl_err.text) | ||
| 1601 | printf("kssl_err text= %s\n", kssl_err.text); | ||
| 1602 | #endif /* KSSL_DEBUG */ | ||
| 1603 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, | ||
| 1604 | kssl_err.reason); | ||
| 1605 | goto err; | ||
| 1606 | } | ||
| 1607 | |||
| 1608 | /* Note: no authenticator is not considered an error, | ||
| 1609 | ** but will return authtime == 0. | ||
| 1610 | */ | ||
| 1611 | if ((krb5rc = kssl_check_authent(kssl_ctx, &authenticator, | ||
| 1612 | &authtime, &kssl_err)) != 0) | ||
| 1613 | { | ||
| 1614 | #ifdef KSSL_DEBUG | ||
| 1615 | printf("kssl_check_authent rtn %d [%d]\n", | ||
| 1616 | krb5rc, kssl_err.reason); | ||
| 1617 | if (kssl_err.text) | ||
| 1618 | printf("kssl_err text= %s\n", kssl_err.text); | ||
| 1619 | #endif /* KSSL_DEBUG */ | ||
| 1620 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, | ||
| 1621 | kssl_err.reason); | ||
| 1622 | goto err; | ||
| 1623 | } | ||
| 1624 | |||
| 1625 | if ((krb5rc = kssl_validate_times(authtime, &ttimes)) != 0) | ||
| 1626 | { | ||
| 1627 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, krb5rc); | ||
| 1628 | goto err; | ||
| 1629 | } | ||
| 1630 | |||
| 1631 | #ifdef KSSL_DEBUG | ||
| 1632 | kssl_ctx_show(kssl_ctx); | ||
| 1633 | #endif /* KSSL_DEBUG */ | ||
| 1634 | |||
| 1635 | enc = kssl_map_enc(kssl_ctx->enctype); | ||
| 1636 | if (enc == NULL) | ||
| 1637 | goto err; | ||
| 1638 | |||
| 1639 | memset(iv, 0, EVP_MAX_IV_LENGTH); /* per RFC 1510 */ | ||
| 1640 | |||
| 1641 | if (!EVP_DecryptInit_ex(&ciph_ctx,enc,NULL,kssl_ctx->key,iv)) | ||
| 1642 | { | ||
| 1643 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, | ||
| 1644 | SSL_R_DECRYPTION_FAILED); | ||
| 1645 | goto err; | ||
| 1646 | } | ||
| 1647 | if (!EVP_DecryptUpdate(&ciph_ctx, pms,&outl, | ||
| 1648 | (unsigned char *)enc_pms.data, enc_pms.length)) | ||
| 1649 | { | ||
| 1650 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, | ||
| 1651 | SSL_R_DECRYPTION_FAILED); | ||
| 1652 | goto err; | ||
| 1653 | } | ||
| 1654 | if (outl > SSL_MAX_MASTER_KEY_LENGTH) | ||
| 1655 | { | ||
| 1656 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, | ||
| 1657 | SSL_R_DATA_LENGTH_TOO_LONG); | ||
| 1658 | goto err; | ||
| 1659 | } | ||
| 1660 | if (!EVP_DecryptFinal_ex(&ciph_ctx,&(pms[outl]),&padl)) | ||
| 1661 | { | ||
| 1662 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, | ||
| 1663 | SSL_R_DECRYPTION_FAILED); | ||
| 1664 | goto err; | ||
| 1665 | } | ||
| 1666 | outl += padl; | ||
| 1667 | if (outl > SSL_MAX_MASTER_KEY_LENGTH) | ||
| 1668 | { | ||
| 1669 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, | ||
| 1670 | SSL_R_DATA_LENGTH_TOO_LONG); | ||
| 1671 | goto err; | ||
| 1672 | } | ||
| 1673 | EVP_CIPHER_CTX_cleanup(&ciph_ctx); | ||
| 1674 | |||
| 1675 | s->session->master_key_length= | ||
| 1676 | s->method->ssl3_enc->generate_master_secret(s, | ||
| 1677 | s->session->master_key, pms, outl); | ||
| 1678 | |||
| 1679 | if (kssl_ctx->client_princ) | ||
| 1680 | { | ||
| 1681 | int len = strlen(kssl_ctx->client_princ); | ||
| 1682 | if ( len < SSL_MAX_KRB5_PRINCIPAL_LENGTH ) | ||
| 1683 | { | ||
| 1684 | s->session->krb5_client_princ_len = len; | ||
| 1685 | memcpy(s->session->krb5_client_princ,kssl_ctx->client_princ,len); | ||
| 1686 | } | ||
| 1687 | } | ||
| 1688 | |||
| 1689 | |||
| 1690 | /* Was doing kssl_ctx_free() here, | ||
| 1691 | ** but it caused problems for apache. | ||
| 1692 | ** kssl_ctx = kssl_ctx_free(kssl_ctx); | ||
| 1693 | ** if (s->kssl_ctx) s->kssl_ctx = NULL; | ||
| 1694 | */ | ||
| 1695 | } | ||
| 1696 | else | ||
| 1697 | #endif /* OPENSSL_NO_KRB5 */ | ||
| 1358 | { | 1698 | { |
| 1359 | al=SSL_AD_HANDSHAKE_FAILURE; | 1699 | al=SSL_AD_HANDSHAKE_FAILURE; |
| 1360 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,SSL_R_UNKNOWN_CIPHER_TYPE); | 1700 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, |
| 1701 | SSL_R_UNKNOWN_CIPHER_TYPE); | ||
| 1361 | goto f_err; | 1702 | goto f_err; |
| 1362 | } | 1703 | } |
| 1363 | 1704 | ||
| 1364 | return(1); | 1705 | return(1); |
| 1365 | f_err: | 1706 | f_err: |
| 1366 | ssl3_send_alert(s,SSL3_AL_FATAL,al); | 1707 | ssl3_send_alert(s,SSL3_AL_FATAL,al); |
| 1367 | #if !defined(NO_DH) || !defined(NO_RSA) | 1708 | #if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_RSA) |
| 1368 | err: | 1709 | err: |
| 1369 | #endif | 1710 | #endif |
| 1370 | return(-1); | 1711 | return(-1); |
| 1371 | } | 1712 | } |
| 1372 | 1713 | ||
| 1373 | static int ssl3_get_cert_verify(s) | 1714 | static int ssl3_get_cert_verify(SSL *s) |
| 1374 | SSL *s; | ||
| 1375 | { | 1715 | { |
| 1376 | EVP_PKEY *pkey=NULL; | 1716 | EVP_PKEY *pkey=NULL; |
| 1377 | unsigned char *p; | 1717 | unsigned char *p; |
| @@ -1436,7 +1776,7 @@ SSL *s; | |||
| 1436 | } | 1776 | } |
| 1437 | 1777 | ||
| 1438 | /* we now have a signature that we need to verify */ | 1778 | /* we now have a signature that we need to verify */ |
| 1439 | p=(unsigned char *)s->init_buf->data; | 1779 | p=(unsigned char *)s->init_msg; |
| 1440 | n2s(p,i); | 1780 | n2s(p,i); |
| 1441 | n-=2; | 1781 | n-=2; |
| 1442 | if (i > n) | 1782 | if (i > n) |
| @@ -1454,19 +1794,19 @@ SSL *s; | |||
| 1454 | goto f_err; | 1794 | goto f_err; |
| 1455 | } | 1795 | } |
| 1456 | 1796 | ||
| 1457 | #ifndef NO_RSA | 1797 | #ifndef OPENSSL_NO_RSA |
| 1458 | if (pkey->type == EVP_PKEY_RSA) | 1798 | if (pkey->type == EVP_PKEY_RSA) |
| 1459 | { | 1799 | { |
| 1460 | i=RSA_public_decrypt(i,p,p,pkey->pkey.rsa,RSA_PKCS1_PADDING); | 1800 | i=RSA_verify(NID_md5_sha1, s->s3->tmp.cert_verify_md, |
| 1801 | MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH, p, i, | ||
| 1802 | pkey->pkey.rsa); | ||
| 1461 | if (i < 0) | 1803 | if (i < 0) |
| 1462 | { | 1804 | { |
| 1463 | al=SSL_AD_DECRYPT_ERROR; | 1805 | al=SSL_AD_DECRYPT_ERROR; |
| 1464 | SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_BAD_RSA_DECRYPT); | 1806 | SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_BAD_RSA_DECRYPT); |
| 1465 | goto f_err; | 1807 | goto f_err; |
| 1466 | } | 1808 | } |
| 1467 | if ((i != (MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH)) || | 1809 | if (i == 0) |
| 1468 | memcmp(&(s->s3->tmp.finish_md[0]),p, | ||
| 1469 | MD5_DIGEST_LENGTH+SHA_DIGEST_LENGTH)) | ||
| 1470 | { | 1810 | { |
| 1471 | al=SSL_AD_DECRYPT_ERROR; | 1811 | al=SSL_AD_DECRYPT_ERROR; |
| 1472 | SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_BAD_RSA_SIGNATURE); | 1812 | SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_BAD_RSA_SIGNATURE); |
| @@ -1475,11 +1815,11 @@ SSL *s; | |||
| 1475 | } | 1815 | } |
| 1476 | else | 1816 | else |
| 1477 | #endif | 1817 | #endif |
| 1478 | #ifndef NO_DSA | 1818 | #ifndef OPENSSL_NO_DSA |
| 1479 | if (pkey->type == EVP_PKEY_DSA) | 1819 | if (pkey->type == EVP_PKEY_DSA) |
| 1480 | { | 1820 | { |
| 1481 | j=DSA_verify(pkey->save_type, | 1821 | j=DSA_verify(pkey->save_type, |
| 1482 | &(s->s3->tmp.finish_md[MD5_DIGEST_LENGTH]), | 1822 | &(s->s3->tmp.cert_verify_md[MD5_DIGEST_LENGTH]), |
| 1483 | SHA_DIGEST_LENGTH,p,i,pkey->pkey.dsa); | 1823 | SHA_DIGEST_LENGTH,p,i,pkey->pkey.dsa); |
| 1484 | if (j <= 0) | 1824 | if (j <= 0) |
| 1485 | { | 1825 | { |
| @@ -1492,7 +1832,7 @@ SSL *s; | |||
| 1492 | else | 1832 | else |
| 1493 | #endif | 1833 | #endif |
| 1494 | { | 1834 | { |
| 1495 | SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,SSL_R_INTERNAL_ERROR); | 1835 | SSLerr(SSL_F_SSL3_GET_CERT_VERIFY,ERR_R_INTERNAL_ERROR); |
| 1496 | al=SSL_AD_UNSUPPORTED_CERTIFICATE; | 1836 | al=SSL_AD_UNSUPPORTED_CERTIFICATE; |
| 1497 | goto f_err; | 1837 | goto f_err; |
| 1498 | } | 1838 | } |
| @@ -1505,27 +1845,23 @@ f_err: | |||
| 1505 | ssl3_send_alert(s,SSL3_AL_FATAL,al); | 1845 | ssl3_send_alert(s,SSL3_AL_FATAL,al); |
| 1506 | } | 1846 | } |
| 1507 | end: | 1847 | end: |
| 1848 | EVP_PKEY_free(pkey); | ||
| 1508 | return(ret); | 1849 | return(ret); |
| 1509 | } | 1850 | } |
| 1510 | 1851 | ||
| 1511 | static int ssl3_get_client_certificate(s) | 1852 | static int ssl3_get_client_certificate(SSL *s) |
| 1512 | SSL *s; | ||
| 1513 | { | 1853 | { |
| 1514 | int i,ok,al,ret= -1; | 1854 | int i,ok,al,ret= -1; |
| 1515 | X509 *x=NULL; | 1855 | X509 *x=NULL; |
| 1516 | unsigned long l,nc,llen,n; | 1856 | unsigned long l,nc,llen,n; |
| 1517 | unsigned char *p,*d,*q; | 1857 | unsigned char *p,*d,*q; |
| 1518 | STACK *sk=NULL; | 1858 | STACK_OF(X509) *sk=NULL; |
| 1519 | 1859 | ||
| 1520 | n=ssl3_get_message(s, | 1860 | n=ssl3_get_message(s, |
| 1521 | SSL3_ST_SR_CERT_A, | 1861 | SSL3_ST_SR_CERT_A, |
| 1522 | SSL3_ST_SR_CERT_B, | 1862 | SSL3_ST_SR_CERT_B, |
| 1523 | -1, | 1863 | -1, |
| 1524 | #if defined(MSDOS) && !defined(WIN32) | 1864 | s->max_cert_list, |
| 1525 | 1024*30, /* 30k max cert list :-) */ | ||
| 1526 | #else | ||
| 1527 | 1024*100, /* 100k max cert list :-) */ | ||
| 1528 | #endif | ||
| 1529 | &ok); | 1865 | &ok); |
| 1530 | 1866 | ||
| 1531 | if (!ok) return((int)n); | 1867 | if (!ok) return((int)n); |
| @@ -1539,7 +1875,7 @@ SSL *s; | |||
| 1539 | al=SSL_AD_HANDSHAKE_FAILURE; | 1875 | al=SSL_AD_HANDSHAKE_FAILURE; |
| 1540 | goto f_err; | 1876 | goto f_err; |
| 1541 | } | 1877 | } |
| 1542 | /* If tls asked for a client cert we must return a 0 list */ | 1878 | /* If tls asked for a client cert, the client must return a 0 list */ |
| 1543 | if ((s->version > SSL3_VERSION) && s->s3->tmp.cert_request) | 1879 | if ((s->version > SSL3_VERSION) && s->s3->tmp.cert_request) |
| 1544 | { | 1880 | { |
| 1545 | SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST); | 1881 | SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST); |
| @@ -1556,9 +1892,9 @@ SSL *s; | |||
| 1556 | SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,SSL_R_WRONG_MESSAGE_TYPE); | 1892 | SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,SSL_R_WRONG_MESSAGE_TYPE); |
| 1557 | goto f_err; | 1893 | goto f_err; |
| 1558 | } | 1894 | } |
| 1559 | d=p=(unsigned char *)s->init_buf->data; | 1895 | d=p=(unsigned char *)s->init_msg; |
| 1560 | 1896 | ||
| 1561 | if ((sk=sk_new_null()) == NULL) | 1897 | if ((sk=sk_X509_new_null()) == NULL) |
| 1562 | { | 1898 | { |
| 1563 | SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,ERR_R_MALLOC_FAILURE); | 1899 | SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,ERR_R_MALLOC_FAILURE); |
| 1564 | goto err; | 1900 | goto err; |
| @@ -1594,7 +1930,7 @@ SSL *s; | |||
| 1594 | SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,SSL_R_CERT_LENGTH_MISMATCH); | 1930 | SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,SSL_R_CERT_LENGTH_MISMATCH); |
| 1595 | goto f_err; | 1931 | goto f_err; |
| 1596 | } | 1932 | } |
| 1597 | if (!sk_push(sk,(char *)x)) | 1933 | if (!sk_X509_push(sk,x)) |
| 1598 | { | 1934 | { |
| 1599 | SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,ERR_R_MALLOC_FAILURE); | 1935 | SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,ERR_R_MALLOC_FAILURE); |
| 1600 | goto err; | 1936 | goto err; |
| @@ -1603,7 +1939,7 @@ SSL *s; | |||
| 1603 | nc+=l+3; | 1939 | nc+=l+3; |
| 1604 | } | 1940 | } |
| 1605 | 1941 | ||
| 1606 | if (sk_num(sk) <= 0) | 1942 | if (sk_X509_num(sk) <= 0) |
| 1607 | { | 1943 | { |
| 1608 | /* TLS does not mind 0 certs returned */ | 1944 | /* TLS does not mind 0 certs returned */ |
| 1609 | if (s->version == SSL3_VERSION) | 1945 | if (s->version == SSL3_VERSION) |
| @@ -1632,10 +1968,29 @@ SSL *s; | |||
| 1632 | } | 1968 | } |
| 1633 | } | 1969 | } |
| 1634 | 1970 | ||
| 1635 | /* This should not be needed */ | 1971 | if (s->session->peer != NULL) /* This should not be needed */ |
| 1636 | if (s->session->peer != NULL) | ||
| 1637 | X509_free(s->session->peer); | 1972 | X509_free(s->session->peer); |
| 1638 | s->session->peer=(X509 *)sk_shift(sk); | 1973 | s->session->peer=sk_X509_shift(sk); |
| 1974 | s->session->verify_result = s->verify_result; | ||
| 1975 | |||
| 1976 | /* With the current implementation, sess_cert will always be NULL | ||
| 1977 | * when we arrive here. */ | ||
| 1978 | if (s->session->sess_cert == NULL) | ||
| 1979 | { | ||
| 1980 | s->session->sess_cert = ssl_sess_cert_new(); | ||
| 1981 | if (s->session->sess_cert == NULL) | ||
| 1982 | { | ||
| 1983 | SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, ERR_R_MALLOC_FAILURE); | ||
| 1984 | goto err; | ||
| 1985 | } | ||
| 1986 | } | ||
| 1987 | if (s->session->sess_cert->cert_chain != NULL) | ||
| 1988 | sk_X509_pop_free(s->session->sess_cert->cert_chain, X509_free); | ||
| 1989 | s->session->sess_cert->cert_chain=sk; | ||
| 1990 | /* Inconsistency alert: cert_chain does *not* include the | ||
| 1991 | * peer's own certificate, while we do include it in s3_clnt.c */ | ||
| 1992 | |||
| 1993 | sk=NULL; | ||
| 1639 | 1994 | ||
| 1640 | ret=1; | 1995 | ret=1; |
| 1641 | if (0) | 1996 | if (0) |
| @@ -1645,12 +2000,11 @@ f_err: | |||
| 1645 | } | 2000 | } |
| 1646 | err: | 2001 | err: |
| 1647 | if (x != NULL) X509_free(x); | 2002 | if (x != NULL) X509_free(x); |
| 1648 | if (sk != NULL) sk_pop_free(sk,X509_free); | 2003 | if (sk != NULL) sk_X509_pop_free(sk,X509_free); |
| 1649 | return(ret); | 2004 | return(ret); |
| 1650 | } | 2005 | } |
| 1651 | 2006 | ||
| 1652 | int ssl3_send_server_certificate(s) | 2007 | int ssl3_send_server_certificate(SSL *s) |
| 1653 | SSL *s; | ||
| 1654 | { | 2008 | { |
| 1655 | unsigned long l; | 2009 | unsigned long l; |
| 1656 | X509 *x; | 2010 | X509 *x; |
| @@ -1658,9 +2012,13 @@ SSL *s; | |||
| 1658 | if (s->state == SSL3_ST_SW_CERT_A) | 2012 | if (s->state == SSL3_ST_SW_CERT_A) |
| 1659 | { | 2013 | { |
| 1660 | x=ssl_get_server_send_cert(s); | 2014 | x=ssl_get_server_send_cert(s); |
| 1661 | if (x == NULL) | 2015 | if (x == NULL && |
| 2016 | /* VRS: allow null cert if auth == KRB5 */ | ||
| 2017 | (s->s3->tmp.new_cipher->algorithms | ||
| 2018 | & (SSL_MKEY_MASK|SSL_AUTH_MASK)) | ||
| 2019 | != (SSL_aKRB5|SSL_kKRB5)) | ||
| 1662 | { | 2020 | { |
| 1663 | SSLerr(SSL_F_SSL3_SEND_SERVER_CERTIFICATE,SSL_R_INTERNAL_ERROR); | 2021 | SSLerr(SSL_F_SSL3_SEND_SERVER_CERTIFICATE,ERR_R_INTERNAL_ERROR); |
| 1664 | return(0); | 2022 | return(0); |
| 1665 | } | 2023 | } |
| 1666 | 2024 | ||
diff --git a/src/lib/libssl/ssl.h b/src/lib/libssl/ssl.h index cf8f9651b2..833f761690 100644 --- a/src/lib/libssl/ssl.h +++ b/src/lib/libssl/ssl.h | |||
| @@ -55,10 +55,131 @@ | |||
| 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-2001 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 | * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. | ||
| 113 | * | ||
| 114 | * Redistribution and use in source and binary forms, with or without | ||
| 115 | * modification, are permitted provided that the following conditions | ||
| 116 | * are met: | ||
| 117 | * | ||
| 118 | * 1. Redistributions of source code must retain the above copyright | ||
| 119 | * notice, this list of conditions and the following disclaimer. | ||
| 120 | * | ||
| 121 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 122 | * notice, this list of conditions and the following disclaimer in | ||
| 123 | * the documentation and/or other materials provided with the | ||
| 124 | * distribution. | ||
| 125 | * | ||
| 126 | * 3. All advertising materials mentioning features or use of this | ||
| 127 | * software must display the following acknowledgment: | ||
| 128 | * "This product includes software developed by the OpenSSL Project | ||
| 129 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | ||
| 130 | * | ||
| 131 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 132 | * endorse or promote products derived from this software without | ||
| 133 | * prior written permission. For written permission, please contact | ||
| 134 | * openssl-core@openssl.org. | ||
| 135 | * | ||
| 136 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 137 | * nor may "OpenSSL" appear in their names without prior written | ||
| 138 | * permission of the OpenSSL Project. | ||
| 139 | * | ||
| 140 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 141 | * acknowledgment: | ||
| 142 | * "This product includes software developed by the OpenSSL Project | ||
| 143 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
| 144 | * | ||
| 145 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 146 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 147 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 148 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 149 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 150 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 151 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 152 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 153 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 154 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 155 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 156 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 157 | * ==================================================================== | ||
| 158 | * | ||
| 159 | * This product includes cryptographic software written by Eric Young | ||
| 160 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 161 | * Hudson (tjh@cryptsoft.com). | ||
| 162 | * | ||
| 163 | */ | ||
| 58 | 164 | ||
| 59 | #ifndef HEADER_SSL_H | 165 | #ifndef HEADER_SSL_H |
| 60 | #define HEADER_SSL_H | 166 | #define HEADER_SSL_H |
| 61 | 167 | ||
| 168 | #include <openssl/e_os2.h> | ||
| 169 | |||
| 170 | #ifndef OPENSSL_NO_COMP | ||
| 171 | #include <openssl/comp.h> | ||
| 172 | #endif | ||
| 173 | #ifndef OPENSSL_NO_BIO | ||
| 174 | #include <openssl/bio.h> | ||
| 175 | #endif | ||
| 176 | #ifndef OPENSSL_NO_X509 | ||
| 177 | #include <openssl/x509.h> | ||
| 178 | #endif | ||
| 179 | #include <openssl/kssl.h> | ||
| 180 | #include <openssl/safestack.h> | ||
| 181 | #include <openssl/symhacks.h> | ||
| 182 | |||
| 62 | #ifdef __cplusplus | 183 | #ifdef __cplusplus |
| 63 | extern "C" { | 184 | extern "C" { |
| 64 | #endif | 185 | #endif |
| @@ -81,7 +202,18 @@ extern "C" { | |||
| 81 | #define SSL_TXT_DES_192_EDE3_CBC_WITH_MD5 SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5 | 202 | #define SSL_TXT_DES_192_EDE3_CBC_WITH_MD5 SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5 |
| 82 | #define SSL_TXT_DES_192_EDE3_CBC_WITH_SHA SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA | 203 | #define SSL_TXT_DES_192_EDE3_CBC_WITH_SHA SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA |
| 83 | 204 | ||
| 205 | /* VRS Additional Kerberos5 entries | ||
| 206 | */ | ||
| 207 | #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 | ||
| 209 | #define SSL_TXT_KRB5_DES_64_CBC_SHA SSL3_TXT_KRB5_DES_64_CBC_SHA | ||
| 210 | #define SSL_TXT_KRB5_DES_64_CBC_MD5 SSL3_TXT_KRB5_DES_64_CBC_MD5 | ||
| 211 | #define SSL_TXT_KRB5_DES_192_CBC3_SHA SSL3_TXT_KRB5_DES_192_CBC3_SHA | ||
| 212 | #define SSL_TXT_KRB5_DES_192_CBC3_MD5 SSL3_TXT_KRB5_DES_192_CBC3_MD5 | ||
| 213 | #define SSL_MAX_KRB5_PRINCIPAL_LENGTH 256 | ||
| 214 | |||
| 84 | #define SSL_MAX_SSL_SESSION_ID_LENGTH 32 | 215 | #define SSL_MAX_SSL_SESSION_ID_LENGTH 32 |
| 216 | #define SSL_MAX_SID_CTX_LENGTH 32 | ||
| 85 | 217 | ||
| 86 | #define SSL_MIN_RSA_MODULUS_LENGTH_IN_BYTES (512/8) | 218 | #define SSL_MIN_RSA_MODULUS_LENGTH_IN_BYTES (512/8) |
| 87 | #define SSL_MAX_KEY_ARG_LENGTH 8 | 219 | #define SSL_MAX_KEY_ARG_LENGTH 8 |
| @@ -100,6 +232,10 @@ extern "C" { | |||
| 100 | #define SSL_TXT_eNULL "eNULL" | 232 | #define SSL_TXT_eNULL "eNULL" |
| 101 | #define SSL_TXT_NULL "NULL" | 233 | #define SSL_TXT_NULL "NULL" |
| 102 | 234 | ||
| 235 | #define SSL_TXT_kKRB5 "kKRB5" | ||
| 236 | #define SSL_TXT_aKRB5 "aKRB5" | ||
| 237 | #define SSL_TXT_KRB5 "KRB5" | ||
| 238 | |||
| 103 | #define SSL_TXT_kRSA "kRSA" | 239 | #define SSL_TXT_kRSA "kRSA" |
| 104 | #define SSL_TXT_kDHr "kDHr" | 240 | #define SSL_TXT_kDHr "kDHr" |
| 105 | #define SSL_TXT_kDHd "kDHd" | 241 | #define SSL_TXT_kDHd "kDHd" |
| @@ -117,33 +253,46 @@ extern "C" { | |||
| 117 | #define SSL_TXT_RC4 "RC4" | 253 | #define SSL_TXT_RC4 "RC4" |
| 118 | #define SSL_TXT_RC2 "RC2" | 254 | #define SSL_TXT_RC2 "RC2" |
| 119 | #define SSL_TXT_IDEA "IDEA" | 255 | #define SSL_TXT_IDEA "IDEA" |
| 256 | #define SSL_TXT_AES "AESdraft" /* AES ciphersuites are not yet official (thus excluded from 'ALL') */ | ||
| 120 | #define SSL_TXT_MD5 "MD5" | 257 | #define SSL_TXT_MD5 "MD5" |
| 121 | #define SSL_TXT_SHA1 "SHA1" | 258 | #define SSL_TXT_SHA1 "SHA1" |
| 122 | #define SSL_TXT_SHA "SHA" | 259 | #define SSL_TXT_SHA "SHA" |
| 123 | #define SSL_TXT_EXP "EXP" | 260 | #define SSL_TXT_EXP "EXP" |
| 124 | #define SSL_TXT_EXPORT "EXPORT" | 261 | #define SSL_TXT_EXPORT "EXPORT" |
| 262 | #define SSL_TXT_EXP40 "EXPORT40" | ||
| 263 | #define SSL_TXT_EXP56 "EXPORT56" | ||
| 125 | #define SSL_TXT_SSLV2 "SSLv2" | 264 | #define SSL_TXT_SSLV2 "SSLv2" |
| 126 | #define SSL_TXT_SSLV3 "SSLv3" | 265 | #define SSL_TXT_SSLV3 "SSLv3" |
| 266 | #define SSL_TXT_TLSV1 "TLSv1" | ||
| 127 | #define SSL_TXT_ALL "ALL" | 267 | #define SSL_TXT_ALL "ALL" |
| 128 | 268 | ||
| 129 | /* 'DEFAULT' at the start of the cipher list insert the following string | 269 | /* The following cipher list is used by default. |
| 130 | * in addition to this being the default cipher string */ | 270 | * It also is substituted when an application-defined cipher list string |
| 131 | #ifndef NO_RSA | 271 | * starts with 'DEFAULT'. */ |
| 132 | #define SSL_DEFAULT_CIPHER_LIST "ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP" | 272 | #define SSL_DEFAULT_CIPHER_LIST "ALL:!ADH:+RC4:@STRENGTH" /* low priority for RC4 */ |
| 133 | #else | ||
| 134 | #define SSL_ALLOW_ADH | ||
| 135 | #define SSL_DEFAULT_CIPHER_LIST "HIGH:MEDIUM:LOW:ADH+3DES:ADH+RC4:ADH+DES:+EXP" | ||
| 136 | #endif | ||
| 137 | 273 | ||
| 138 | /* Used in SSL_set_shutdown()/SSL_get_shutdown(); */ | 274 | /* Used in SSL_set_shutdown()/SSL_get_shutdown(); */ |
| 139 | #define SSL_SENT_SHUTDOWN 1 | 275 | #define SSL_SENT_SHUTDOWN 1 |
| 140 | #define SSL_RECEIVED_SHUTDOWN 2 | 276 | #define SSL_RECEIVED_SHUTDOWN 2 |
| 141 | 277 | ||
| 142 | #include "crypto.h" | 278 | #ifdef __cplusplus |
| 143 | #include "lhash.h" | 279 | } |
| 144 | #include "buffer.h" | 280 | #endif |
| 145 | #include "bio.h" | 281 | |
| 146 | #include "x509.h" | 282 | #include <openssl/crypto.h> |
| 283 | #include <openssl/lhash.h> | ||
| 284 | #include <openssl/buffer.h> | ||
| 285 | #include <openssl/bio.h> | ||
| 286 | #include <openssl/pem.h> | ||
| 287 | #include <openssl/x509.h> | ||
| 288 | |||
| 289 | #ifdef __cplusplus | ||
| 290 | extern "C" { | ||
| 291 | #endif | ||
| 292 | |||
| 293 | #if (defined(OPENSSL_NO_RSA) || defined(OPENSSL_NO_MD5)) && !defined(OPENSSL_NO_SSL2) | ||
| 294 | #define OPENSSL_NO_SSL2 | ||
| 295 | #endif | ||
| 147 | 296 | ||
| 148 | #define SSL_FILETYPE_ASN1 X509_FILETYPE_ASN1 | 297 | #define SSL_FILETYPE_ASN1 X509_FILETYPE_ASN1 |
| 149 | #define SSL_FILETYPE_PEM X509_FILETYPE_PEM | 298 | #define SSL_FILETYPE_PEM X509_FILETYPE_PEM |
| @@ -157,44 +306,52 @@ typedef struct ssl_st *ssl_crock_st; | |||
| 157 | typedef struct ssl_cipher_st | 306 | typedef struct ssl_cipher_st |
| 158 | { | 307 | { |
| 159 | int valid; | 308 | int valid; |
| 160 | char *name; /* text name */ | 309 | const char *name; /* text name */ |
| 161 | unsigned long id; /* id, 4 bytes, first is version */ | 310 | unsigned long id; /* id, 4 bytes, first is version */ |
| 162 | unsigned long algorithms; /* what ciphers are used */ | 311 | unsigned long algorithms; /* what ciphers are used */ |
| 312 | unsigned long algo_strength; /* strength and export flags */ | ||
| 163 | unsigned long algorithm2; /* Extra flags */ | 313 | unsigned long algorithm2; /* Extra flags */ |
| 314 | int strength_bits; /* Number of bits really used */ | ||
| 315 | int alg_bits; /* Number of bits for algorithm */ | ||
| 164 | unsigned long mask; /* used for matching */ | 316 | unsigned long mask; /* used for matching */ |
| 317 | unsigned long mask_strength; /* also used for matching */ | ||
| 165 | } SSL_CIPHER; | 318 | } SSL_CIPHER; |
| 166 | 319 | ||
| 320 | DECLARE_STACK_OF(SSL_CIPHER) | ||
| 321 | |||
| 322 | typedef struct ssl_st SSL; | ||
| 323 | typedef struct ssl_ctx_st SSL_CTX; | ||
| 324 | |||
| 167 | /* Used to hold functions for SSLv2 or SSLv3/TLSv1 functions */ | 325 | /* Used to hold functions for SSLv2 or SSLv3/TLSv1 functions */ |
| 168 | typedef struct ssl_method_st | 326 | typedef struct ssl_method_st |
| 169 | { | 327 | { |
| 170 | int version; | 328 | int version; |
| 171 | int (*ssl_new)(); | 329 | int (*ssl_new)(SSL *s); |
| 172 | void (*ssl_clear)(); | 330 | void (*ssl_clear)(SSL *s); |
| 173 | void (*ssl_free)(); | 331 | void (*ssl_free)(SSL *s); |
| 174 | int (*ssl_accept)(); | 332 | int (*ssl_accept)(SSL *s); |
| 175 | int (*ssl_connect)(); | 333 | int (*ssl_connect)(SSL *s); |
| 176 | int (*ssl_read)(); | 334 | int (*ssl_read)(SSL *s,void *buf,int len); |
| 177 | int (*ssl_peek)(); | 335 | int (*ssl_peek)(SSL *s,void *buf,int len); |
| 178 | int (*ssl_write)(); | 336 | int (*ssl_write)(SSL *s,const void *buf,int len); |
| 179 | int (*ssl_shutdown)(); | 337 | int (*ssl_shutdown)(SSL *s); |
| 180 | int (*ssl_renegotiate)(); | 338 | int (*ssl_renegotiate)(SSL *s); |
| 181 | long (*ssl_ctrl)(); | 339 | int (*ssl_renegotiate_check)(SSL *s); |
| 182 | long (*ssl_ctx_ctrl)(); | 340 | long (*ssl_ctrl)(SSL *s,int cmd,long larg,void *parg); |
| 183 | SSL_CIPHER *(*get_cipher_by_char)(); | 341 | long (*ssl_ctx_ctrl)(SSL_CTX *ctx,int cmd,long larg,void *parg); |
| 184 | int (*put_cipher_by_char)(); | 342 | SSL_CIPHER *(*get_cipher_by_char)(const unsigned char *ptr); |
| 185 | int (*ssl_pending)(); | 343 | int (*put_cipher_by_char)(const SSL_CIPHER *cipher,unsigned char *ptr); |
| 186 | int (*num_ciphers)(); | 344 | int (*ssl_pending)(SSL *s); |
| 187 | SSL_CIPHER *(*get_cipher)(); | 345 | int (*num_ciphers)(void); |
| 188 | struct ssl_method_st *(*get_ssl_method)(); | 346 | SSL_CIPHER *(*get_cipher)(unsigned ncipher); |
| 189 | long (*get_timeout)(); | 347 | struct ssl_method_st *(*get_ssl_method)(int version); |
| 348 | long (*get_timeout)(void); | ||
| 190 | struct ssl3_enc_method *ssl3_enc; /* Extra SSLv3/TLS stuff */ | 349 | struct ssl3_enc_method *ssl3_enc; /* Extra SSLv3/TLS stuff */ |
| 350 | int (*ssl_version)(); | ||
| 351 | long (*ssl_callback_ctrl)(SSL *s, int cb_id, void (*fp)()); | ||
| 352 | long (*ssl_ctx_callback_ctrl)(SSL_CTX *s, int cb_id, void (*fp)()); | ||
| 191 | } SSL_METHOD; | 353 | } SSL_METHOD; |
| 192 | 354 | ||
| 193 | typedef struct ssl_compression_st | ||
| 194 | { | ||
| 195 | char *stuff; | ||
| 196 | } SSL_COMPRESSION; | ||
| 197 | |||
| 198 | /* Lets make this into an ASN.1 type structure as follows | 355 | /* Lets make this into an ASN.1 type structure as follows |
| 199 | * SSL_SESSION_ID ::= SEQUENCE { | 356 | * SSL_SESSION_ID ::= SEQUENCE { |
| 200 | * version INTEGER, -- structure version number | 357 | * version INTEGER, -- structure version number |
| @@ -202,10 +359,14 @@ typedef struct ssl_compression_st | |||
| 202 | * Cipher OCTET_STRING, -- the 3 byte cipher ID | 359 | * Cipher OCTET_STRING, -- the 3 byte cipher ID |
| 203 | * Session_ID OCTET_STRING, -- the Session ID | 360 | * Session_ID OCTET_STRING, -- the Session ID |
| 204 | * Master_key OCTET_STRING, -- the master key | 361 | * Master_key OCTET_STRING, -- the master key |
| 362 | * KRB5_principal OCTET_STRING -- optional Kerberos principal | ||
| 205 | * Key_Arg [ 0 ] IMPLICIT OCTET_STRING, -- the optional Key argument | 363 | * Key_Arg [ 0 ] IMPLICIT OCTET_STRING, -- the optional Key argument |
| 206 | * Time [ 1 ] EXPLICIT INTEGER, -- optional Start Time | 364 | * Time [ 1 ] EXPLICIT INTEGER, -- optional Start Time |
| 207 | * Timeout [ 2 ] EXPLICIT INTEGER, -- optional Timeout ins seconds | 365 | * Timeout [ 2 ] EXPLICIT INTEGER, -- optional Timeout ins seconds |
| 208 | * Peer [ 3 ] EXPLICIT X509, -- optional Peer Certificate | 366 | * Peer [ 3 ] EXPLICIT X509, -- optional Peer Certificate |
| 367 | * Session_ID_context [ 4 ] EXPLICIT OCTET_STRING, -- the Session ID context | ||
| 368 | * Verify_result [ 5 ] EXPLICIT INTEGER -- X509_V_... code for `Peer' | ||
| 369 | * Compression [6] IMPLICIT ASN1_OBJECT -- compression OID XXXXX | ||
| 209 | * } | 370 | * } |
| 210 | * Look in ssl/ssl_asn1.c for more details | 371 | * Look in ssl/ssl_asn1.c for more details |
| 211 | * I'm using EXPLICIT tags so I can read the damn things using asn1parse :-). | 372 | * I'm using EXPLICIT tags so I can read the damn things using asn1parse :-). |
| @@ -223,29 +384,43 @@ typedef struct ssl_session_st | |||
| 223 | /* session_id - valid? */ | 384 | /* session_id - valid? */ |
| 224 | unsigned int session_id_length; | 385 | unsigned int session_id_length; |
| 225 | unsigned char session_id[SSL_MAX_SSL_SESSION_ID_LENGTH]; | 386 | unsigned char session_id[SSL_MAX_SSL_SESSION_ID_LENGTH]; |
| 387 | /* this is used to determine whether the session is being reused in | ||
| 388 | * the appropriate context. It is up to the application to set this, | ||
| 389 | * via SSL_new */ | ||
| 390 | unsigned int sid_ctx_length; | ||
| 391 | unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; | ||
| 392 | |||
| 393 | #ifndef OPENSSL_NO_KRB5 | ||
| 394 | unsigned int krb5_client_princ_len; | ||
| 395 | unsigned char krb5_client_princ[SSL_MAX_KRB5_PRINCIPAL_LENGTH]; | ||
| 396 | #endif /* OPENSSL_NO_KRB5 */ | ||
| 226 | 397 | ||
| 227 | int not_resumable; | 398 | int not_resumable; |
| 228 | 399 | ||
| 229 | /* The cert is the certificate used to establish this connection */ | 400 | /* The cert is the certificate used to establish this connection */ |
| 230 | struct cert_st /* CERT */ *cert; | 401 | struct sess_cert_st /* SESS_CERT */ *sess_cert; |
| 231 | 402 | ||
| 232 | /* This is the cert for the other end. On servers, it will be | 403 | /* This is the cert for the other end. |
| 233 | * the same as cert->x509 */ | 404 | * On clients, it will be the same as sess_cert->peer_key->x509 |
| 405 | * (the latter is not enough as sess_cert is not retained | ||
| 406 | * in the external representation of sessions, see ssl_asn1.c). */ | ||
| 234 | X509 *peer; | 407 | X509 *peer; |
| 408 | /* when app_verify_callback accepts a session where the peer's certificate | ||
| 409 | * is not ok, we must remember the error for session reuse: */ | ||
| 410 | long verify_result; /* only for servers */ | ||
| 235 | 411 | ||
| 236 | int references; | 412 | int references; |
| 237 | long timeout; | 413 | long timeout; |
| 238 | long time; | 414 | long time; |
| 239 | 415 | ||
| 240 | SSL_COMPRESSION *read_compression; | 416 | int compress_meth; /* Need to lookup the method */ |
| 241 | SSL_COMPRESSION *write_compression; | ||
| 242 | 417 | ||
| 243 | SSL_CIPHER *cipher; | 418 | SSL_CIPHER *cipher; |
| 244 | unsigned long cipher_id; /* when ASN.1 loaded, this | 419 | unsigned long cipher_id; /* when ASN.1 loaded, this |
| 245 | * needs to be used to load | 420 | * needs to be used to load |
| 246 | * the 'cipher' structure */ | 421 | * the 'cipher' structure */ |
| 247 | 422 | ||
| 248 | STACK /* SSL_CIPHER */ *ciphers; /* shared ciphers? */ | 423 | STACK_OF(SSL_CIPHER) *ciphers; /* shared ciphers? */ |
| 249 | 424 | ||
| 250 | CRYPTO_EX_DATA ex_data; /* application specific data */ | 425 | CRYPTO_EX_DATA ex_data; /* application specific data */ |
| 251 | 426 | ||
| @@ -262,47 +437,126 @@ typedef struct ssl_session_st | |||
| 262 | #define SSL_OP_MSIE_SSLV2_RSA_PADDING 0x00000040L | 437 | #define SSL_OP_MSIE_SSLV2_RSA_PADDING 0x00000040L |
| 263 | #define SSL_OP_SSLEAY_080_CLIENT_DH_BUG 0x00000080L | 438 | #define SSL_OP_SSLEAY_080_CLIENT_DH_BUG 0x00000080L |
| 264 | #define SSL_OP_TLS_D5_BUG 0x00000100L | 439 | #define SSL_OP_TLS_D5_BUG 0x00000100L |
| 265 | #define SSL_OP_TLS_BLOCK_PADDING_BUG 0x00000200L | 440 | #define SSL_OP_TLS_BLOCK_PADDING_BUG 0x00000200L |
| 266 | 441 | ||
| 267 | /* If set, only use tmp_dh parameters once */ | 442 | /* If set, always create a new key when using tmp_dh parameters */ |
| 268 | #define SSL_OP_SINGLE_DH_USE 0x00100000L | 443 | #define SSL_OP_SINGLE_DH_USE 0x00100000L |
| 269 | /* Set to also use the tmp_rsa key when doing RSA operations. */ | 444 | /* Set to always use the tmp_rsa key when doing RSA operations, |
| 445 | * even when this violates protocol specs */ | ||
| 270 | #define SSL_OP_EPHEMERAL_RSA 0x00200000L | 446 | #define SSL_OP_EPHEMERAL_RSA 0x00200000L |
| 271 | 447 | /* Set on servers to choose the cipher according to the server's | |
| 448 | * preferences */ | ||
| 449 | #define SSL_OP_CIPHER_SERVER_PREFERENCE 0x00400000L | ||
| 450 | /* If set, a server will allow a client to issue a SSLv3.0 version number | ||
| 451 | * as latest version supported in the premaster secret, even when TLSv1.0 | ||
| 452 | * (version 3.1) was announced in the client hello. Normally this is | ||
| 453 | * forbidden to prevent version rollback attacks. */ | ||
| 454 | #define SSL_OP_TLS_ROLLBACK_BUG 0x00800000L | ||
| 455 | /* As server, disallow session resumption on renegotiation */ | ||
| 456 | #define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION 0x01000000L | ||
| 457 | |||
| 458 | /* The next flag deliberately changes the ciphertest, this is a check | ||
| 459 | * for the PKCS#1 attack */ | ||
| 460 | #define SSL_OP_PKCS1_CHECK_1 0x08000000L | ||
| 461 | #define SSL_OP_PKCS1_CHECK_2 0x10000000L | ||
| 272 | #define SSL_OP_NETSCAPE_CA_DN_BUG 0x20000000L | 462 | #define SSL_OP_NETSCAPE_CA_DN_BUG 0x20000000L |
| 273 | #define SSL_OP_NON_EXPORT_FIRST 0x40000000L | 463 | #define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG 0x40000000L |
| 274 | #define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG 0x80000000L | ||
| 275 | #define SSL_OP_ALL 0x000FFFFFL | 464 | #define SSL_OP_ALL 0x000FFFFFL |
| 276 | 465 | ||
| 277 | #define SSL_CTX_set_options(ctx,op) ((ctx)->options|=(op)) | ||
| 278 | #define SSL_set_options(ssl,op) ((ssl)->options|=(op)) | ||
| 279 | |||
| 280 | #define SSL_OP_NO_SSLv2 0x01000000L | 466 | #define SSL_OP_NO_SSLv2 0x01000000L |
| 281 | #define SSL_OP_NO_SSLv3 0x02000000L | 467 | #define SSL_OP_NO_SSLv3 0x02000000L |
| 282 | #define SSL_OP_NO_TLSv1 0x04000000L | 468 | #define SSL_OP_NO_TLSv1 0x04000000L |
| 283 | 469 | ||
| 284 | /* Normally you will only use these if your application wants to use | 470 | /* Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success |
| 285 | * the certificate store in other places, perhaps PKCS7 */ | 471 | * when just a single record has been written): */ |
| 286 | #define SSL_CTX_get_cert_store(ctx) ((ctx)->cert_store) | 472 | #define SSL_MODE_ENABLE_PARTIAL_WRITE 0x00000001L |
| 287 | #define SSL_CTX_set_cert_store(ctx,cs) \ | 473 | /* Make it possible to retry SSL_write() with changed buffer location |
| 288 | (X509_STORE_free((ctx)->cert_store),(ctx)->cert_store=(cs)) | 474 | * (buffer contents must stay the same!); this is not the default to avoid |
| 289 | 475 | * the misconception that non-blocking SSL_write() behaves like | |
| 476 | * non-blocking write(): */ | ||
| 477 | #define SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 0x00000002L | ||
| 478 | /* Never bother the application with retries if the transport | ||
| 479 | * is blocking: */ | ||
| 480 | #define SSL_MODE_AUTO_RETRY 0x00000004L | ||
| 481 | |||
| 482 | /* Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value, | ||
| 483 | * they cannot be used to clear bits. */ | ||
| 484 | |||
| 485 | #define SSL_CTX_set_options(ctx,op) \ | ||
| 486 | SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,(op),NULL) | ||
| 487 | #define SSL_CTX_get_options(ctx) \ | ||
| 488 | SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,0,NULL) | ||
| 489 | #define SSL_set_options(ssl,op) \ | ||
| 490 | SSL_ctrl((ssl),SSL_CTRL_OPTIONS,(op),NULL) | ||
| 491 | #define SSL_get_options(ssl) \ | ||
| 492 | SSL_ctrl((ssl),SSL_CTRL_OPTIONS,0,NULL) | ||
| 493 | |||
| 494 | #define SSL_CTX_set_mode(ctx,op) \ | ||
| 495 | SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL) | ||
| 496 | #define SSL_CTX_get_mode(ctx) \ | ||
| 497 | SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,0,NULL) | ||
| 498 | #define SSL_set_mode(ssl,op) \ | ||
| 499 | SSL_ctrl((ssl),SSL_CTRL_MODE,(op),NULL) | ||
| 500 | #define SSL_get_mode(ssl) \ | ||
| 501 | SSL_ctrl((ssl),SSL_CTRL_MODE,0,NULL) | ||
| 502 | |||
| 503 | |||
| 504 | void SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)); | ||
| 505 | void SSL_set_msg_callback(SSL *ssl, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)); | ||
| 506 | #define SSL_CTX_set_msg_callback_arg(ctx, arg) SSL_CTX_ctrl((ctx), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) | ||
| 507 | #define SSL_set_msg_callback_arg(ssl, arg) SSL_ctrl((ssl), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) | ||
| 508 | |||
| 509 | |||
| 510 | |||
| 511 | #if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32) | ||
| 512 | #define SSL_MAX_CERT_LIST_DEFAULT 1024*30 /* 30k max cert list :-) */ | ||
| 513 | #else | ||
| 514 | #define SSL_MAX_CERT_LIST_DEFAULT 1024*100 /* 100k max cert list :-) */ | ||
| 515 | #endif | ||
| 290 | 516 | ||
| 291 | #define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT (1024*20) | 517 | #define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT (1024*20) |
| 292 | 518 | ||
| 293 | typedef struct ssl_ctx_st | 519 | /* This callback type is used inside SSL_CTX, SSL, and in the functions that set |
| 520 | * them. It is used to override the generation of SSL/TLS session IDs in a | ||
| 521 | * server. Return value should be zero on an error, non-zero to proceed. Also, | ||
| 522 | * callbacks should themselves check if the id they generate is unique otherwise | ||
| 523 | * the SSL handshake will fail with an error - callbacks can do this using the | ||
| 524 | * 'ssl' value they're passed by; | ||
| 525 | * SSL_has_matching_session_id(ssl, id, *id_len) | ||
| 526 | * The length value passed in is set at the maximum size the session ID can be. | ||
| 527 | * In SSLv2 this is 16 bytes, whereas SSLv3/TLSv1 it is 32 bytes. The callback | ||
| 528 | * can alter this length to be less if desired, but under SSLv2 session IDs are | ||
| 529 | * supposed to be fixed at 16 bytes so the id will be padded after the callback | ||
| 530 | * returns in this case. It is also an error for the callback to set the size to | ||
| 531 | * zero. */ | ||
| 532 | typedef int (*GEN_SESSION_CB)(const SSL *ssl, unsigned char *id, | ||
| 533 | unsigned int *id_len); | ||
| 534 | |||
| 535 | typedef struct ssl_comp_st | ||
| 536 | { | ||
| 537 | int id; | ||
| 538 | char *name; | ||
| 539 | #ifndef OPENSSL_NO_COMP | ||
| 540 | COMP_METHOD *method; | ||
| 541 | #else | ||
| 542 | char *method; | ||
| 543 | #endif | ||
| 544 | } SSL_COMP; | ||
| 545 | |||
| 546 | DECLARE_STACK_OF(SSL_COMP) | ||
| 547 | |||
| 548 | struct ssl_ctx_st | ||
| 294 | { | 549 | { |
| 295 | SSL_METHOD *method; | 550 | SSL_METHOD *method; |
| 296 | unsigned long options; | ||
| 297 | 551 | ||
| 298 | STACK /* SSL_CIPHER */ *cipher_list; | 552 | STACK_OF(SSL_CIPHER) *cipher_list; |
| 299 | /* same as above but sorted for lookup */ | 553 | /* same as above but sorted for lookup */ |
| 300 | STACK /* SSL_CIPHER */ *cipher_list_by_id; | 554 | STACK_OF(SSL_CIPHER) *cipher_list_by_id; |
| 301 | 555 | ||
| 302 | struct x509_store_st /* X509_STORE */ *cert_store; | 556 | struct x509_store_st /* X509_STORE */ *cert_store; |
| 303 | struct lhash_st /* LHASH */ *sessions; /* a set of SSL_SESSION's */ | 557 | struct lhash_st /* LHASH */ *sessions; /* a set of SSL_SESSIONs */ |
| 304 | /* Most session-ids that will be cached, default is | 558 | /* Most session-ids that will be cached, default is |
| 305 | * SSL_SESSION_CACHE_SIZE_DEFAULT. 0 is unlimited. */ | 559 | * SSL_SESSION_CACHE_MAX_SIZE_DEFAULT. 0 is unlimited. */ |
| 306 | unsigned long session_cache_size; | 560 | unsigned long session_cache_size; |
| 307 | struct ssl_session_st *session_cache_head; | 561 | struct ssl_session_st *session_cache_head; |
| 308 | struct ssl_session_st *session_cache_tail; | 562 | struct ssl_session_st *session_cache_tail; |
| @@ -325,67 +579,95 @@ typedef struct ssl_ctx_st | |||
| 325 | * SSL_SESSION_free() when it has finished using it. Otherwise, | 579 | * SSL_SESSION_free() when it has finished using it. Otherwise, |
| 326 | * on 0, it means the callback has finished with it. | 580 | * on 0, it means the callback has finished with it. |
| 327 | * If remove_session_cb is not null, it will be called when | 581 | * If remove_session_cb is not null, it will be called when |
| 328 | * a session-id is removed from the cache. Again, a return | 582 | * a session-id is removed from the cache. After the call, |
| 329 | * of 0 mens that SSLeay should not SSL_SESSION_free() since | 583 | * OpenSSL will SSL_SESSION_free() it. */ |
| 330 | * the application is doing something with it. */ | ||
| 331 | #ifndef NOPROTO | ||
| 332 | int (*new_session_cb)(struct ssl_st *ssl,SSL_SESSION *sess); | 584 | int (*new_session_cb)(struct ssl_st *ssl,SSL_SESSION *sess); |
| 333 | void (*remove_session_cb)(struct ssl_ctx_st *ctx,SSL_SESSION *sess); | 585 | void (*remove_session_cb)(struct ssl_ctx_st *ctx,SSL_SESSION *sess); |
| 334 | SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl, | 586 | SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl, |
| 335 | unsigned char *data,int len,int *copy); | 587 | unsigned char *data,int len,int *copy); |
| 336 | #else | ||
| 337 | int (*new_session_cb)(); | ||
| 338 | void (*remove_session_cb)(); | ||
| 339 | SSL_SESSION *(*get_session_cb)(); | ||
| 340 | #endif | ||
| 341 | 588 | ||
| 342 | int sess_connect; /* SSL new connection - started */ | 589 | struct |
| 343 | int sess_connect_renegotiate;/* SSL renegotiatene - requested */ | 590 | { |
| 344 | int sess_connect_good; /* SSL new connection/renegotiate - finished */ | 591 | int sess_connect; /* SSL new conn - started */ |
| 345 | int sess_accept; /* SSL new accept - started */ | 592 | int sess_connect_renegotiate;/* SSL reneg - requested */ |
| 346 | int sess_accept_renegotiate;/* SSL renegotiatene - requested */ | 593 | int sess_connect_good; /* SSL new conne/reneg - finished */ |
| 347 | int sess_accept_good; /* SSL accept/renegotiate - finished */ | 594 | int sess_accept; /* SSL new accept - started */ |
| 348 | int sess_miss; /* session lookup misses */ | 595 | int sess_accept_renegotiate;/* SSL reneg - requested */ |
| 349 | int sess_timeout; /* session reuse attempt on timeouted session */ | 596 | int sess_accept_good; /* SSL accept/reneg - finished */ |
| 350 | int sess_cache_full; /* session removed due to full cache */ | 597 | int sess_miss; /* session lookup misses */ |
| 351 | int sess_hit; /* session reuse actually done */ | 598 | int sess_timeout; /* reuse attempt on timeouted session */ |
| 352 | int sess_cb_hit; /* session-id that was not in the cache was | 599 | int sess_cache_full; /* session removed due to full cache */ |
| 353 | * passed back via the callback. This | 600 | int sess_hit; /* session reuse actually done */ |
| 354 | * indicates that the application is supplying | 601 | int sess_cb_hit; /* session-id that was not |
| 355 | * session-id's from other processes - | 602 | * in the cache was |
| 356 | * spooky :-) */ | 603 | * passed back via the callback. This |
| 604 | * indicates that the application is | ||
| 605 | * supplying session-id's from other | ||
| 606 | * processes - spooky :-) */ | ||
| 607 | } stats; | ||
| 357 | 608 | ||
| 358 | int references; | 609 | int references; |
| 359 | 610 | ||
| 360 | void (*info_callback)(); | ||
| 361 | |||
| 362 | /* if defined, these override the X509_verify_cert() calls */ | 611 | /* if defined, these override the X509_verify_cert() calls */ |
| 363 | int (*app_verify_callback)(); | 612 | int (*app_verify_callback)(X509_STORE_CTX *, void *); |
| 364 | char *app_verify_arg; | 613 | void *app_verify_arg; |
| 365 | 614 | /* before OpenSSL 0.9.7, 'app_verify_arg' was ignored | |
| 366 | /* default values to use in SSL structures */ | 615 | * ('app_verify_callback' was called with just one argument) */ |
| 367 | struct cert_st /* CERT */ *default_cert; | ||
| 368 | int default_read_ahead; | ||
| 369 | int default_verify_mode; | ||
| 370 | int (*default_verify_callback)(); | ||
| 371 | 616 | ||
| 372 | /* Default password callback. */ | 617 | /* Default password callback. */ |
| 373 | int (*default_passwd_callback)(); | 618 | pem_password_cb *default_passwd_callback; |
| 619 | |||
| 620 | /* Default password callback user data. */ | ||
| 621 | void *default_passwd_callback_userdata; | ||
| 374 | 622 | ||
| 375 | /* get client cert callback */ | 623 | /* get client cert callback */ |
| 376 | int (*client_cert_cb)(/* SSL *ssl, X509 **x509, EVP_PKEY **pkey */); | 624 | int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey); |
| 377 | 625 | ||
| 378 | /* what we put in client requests */ | 626 | CRYPTO_EX_DATA ex_data; |
| 379 | STACK *client_CA; | ||
| 380 | 627 | ||
| 381 | int quiet_shutdown; | 628 | const EVP_MD *rsa_md5;/* For SSLv2 - name is 'ssl2-md5' */ |
| 629 | const EVP_MD *md5; /* For SSLv3/TLSv1 'ssl3-md5' */ | ||
| 630 | const EVP_MD *sha1; /* For SSLv3/TLSv1 'ssl3->sha1' */ | ||
| 382 | 631 | ||
| 383 | CRYPTO_EX_DATA ex_data; | 632 | STACK_OF(X509) *extra_certs; |
| 633 | STACK_OF(SSL_COMP) *comp_methods; /* stack of SSL_COMP, SSLv3/TLSv1 */ | ||
| 634 | |||
| 635 | |||
| 636 | /* Default values used when no per-SSL value is defined follow */ | ||
| 637 | |||
| 638 | void (*info_callback)(const SSL *ssl,int type,int val); /* used if SSL's info_callback is NULL */ | ||
| 639 | |||
| 640 | /* what we put in client cert requests */ | ||
| 641 | STACK_OF(X509_NAME) *client_CA; | ||
| 384 | 642 | ||
| 385 | EVP_MD *rsa_md5;/* For SSLv2 - name is 'ssl2-md5' */ | 643 | |
| 386 | EVP_MD *md5; /* For SSLv3/TLSv1 'ssl3-md5' */ | 644 | /* Default values to use in SSL structures follow (these are copied by SSL_new) */ |
| 387 | EVP_MD *sha1; /* For SSLv3/TLSv1 'ssl3->sha1' */ | 645 | |
| 388 | } SSL_CTX; | 646 | unsigned long options; |
| 647 | unsigned long mode; | ||
| 648 | long max_cert_list; | ||
| 649 | |||
| 650 | struct cert_st /* CERT */ *cert; | ||
| 651 | int read_ahead; | ||
| 652 | |||
| 653 | /* callback that allows applications to peek at protocol messages */ | ||
| 654 | void (*msg_callback)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg); | ||
| 655 | void *msg_callback_arg; | ||
| 656 | |||
| 657 | int verify_mode; | ||
| 658 | int verify_depth; | ||
| 659 | unsigned int sid_ctx_length; | ||
| 660 | unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; | ||
| 661 | int (*default_verify_callback)(int ok,X509_STORE_CTX *ctx); /* called 'verify_callback' in the SSL */ | ||
| 662 | |||
| 663 | /* Default generate session ID callback. */ | ||
| 664 | GEN_SESSION_CB generate_session_id; | ||
| 665 | |||
| 666 | int purpose; /* Purpose setting */ | ||
| 667 | int trust; /* Trust setting */ | ||
| 668 | |||
| 669 | int quiet_shutdown; | ||
| 670 | }; | ||
| 389 | 671 | ||
| 390 | #define SSL_SESS_CACHE_OFF 0x0000 | 672 | #define SSL_SESS_CACHE_OFF 0x0000 |
| 391 | #define SSL_SESS_CACHE_CLIENT 0x0001 | 673 | #define SSL_SESS_CACHE_CLIENT 0x0001 |
| @@ -397,23 +679,31 @@ typedef struct ssl_ctx_st | |||
| 397 | * defined, this will still get called. */ | 679 | * defined, this will still get called. */ |
| 398 | #define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP 0x0100 | 680 | #define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP 0x0100 |
| 399 | 681 | ||
| 400 | #define SSL_CTX_sessions(ctx) ((ctx)->sessions) | 682 | struct lhash_st *SSL_CTX_sessions(SSL_CTX *ctx); |
| 401 | /* You will need to include lhash.h to access the following #define */ | 683 | #define SSL_CTX_sess_number(ctx) \ |
| 402 | #define SSL_CTX_sess_number(ctx) ((ctx)->sessions->num_items) | 684 | SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_NUMBER,0,NULL) |
| 403 | #define SSL_CTX_sess_connect(ctx) ((ctx)->sess_connect) | 685 | #define SSL_CTX_sess_connect(ctx) \ |
| 404 | #define SSL_CTX_sess_connect_good(ctx) ((ctx)->sess_connect_good) | 686 | SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT,0,NULL) |
| 405 | #define SSL_CTX_sess_accept(ctx) ((ctx)->sess_accept) | 687 | #define SSL_CTX_sess_connect_good(ctx) \ |
| 406 | #define SSL_CTX_sess_accept_renegotiate(ctx) ((ctx)->sess_accept_renegotiate) | 688 | SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_GOOD,0,NULL) |
| 407 | #define SSL_CTX_sess_connect_renegotiate(ctx) ((ctx)->sess_connect_renegotiate) | 689 | #define SSL_CTX_sess_connect_renegotiate(ctx) \ |
| 408 | #define SSL_CTX_sess_accept_good(ctx) ((ctx)->sess_accept_good) | 690 | SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_RENEGOTIATE,0,NULL) |
| 409 | #define SSL_CTX_sess_hits(ctx) ((ctx)->sess_hit) | 691 | #define SSL_CTX_sess_accept(ctx) \ |
| 410 | #define SSL_CTX_sess_cb_hits(ctx) ((ctx)->sess_cb_hit) | 692 | SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT,0,NULL) |
| 411 | #define SSL_CTX_sess_misses(ctx) ((ctx)->sess_miss) | 693 | #define SSL_CTX_sess_accept_renegotiate(ctx) \ |
| 412 | #define SSL_CTX_sess_timeouts(ctx) ((ctx)->sess_timeout) | 694 | SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_RENEGOTIATE,0,NULL) |
| 413 | #define SSL_CTX_sess_cache_full(ctx) ((ctx)->sess_cache_full) | 695 | #define SSL_CTX_sess_accept_good(ctx) \ |
| 414 | 696 | SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_GOOD,0,NULL) | |
| 415 | #define SSL_CTX_sess_set_cache_size(ctx,t) ((ctx)->session_cache_size=(t)) | 697 | #define SSL_CTX_sess_hits(ctx) \ |
| 416 | #define SSL_CTX_sess_get_cache_size(ctx) ((ctx)->session_cache_size) | 698 | SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_HIT,0,NULL) |
| 699 | #define SSL_CTX_sess_cb_hits(ctx) \ | ||
| 700 | SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CB_HIT,0,NULL) | ||
| 701 | #define SSL_CTX_sess_misses(ctx) \ | ||
| 702 | SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_MISSES,0,NULL) | ||
| 703 | #define SSL_CTX_sess_timeouts(ctx) \ | ||
| 704 | SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_TIMEOUTS,0,NULL) | ||
| 705 | #define SSL_CTX_sess_cache_full(ctx) \ | ||
| 706 | SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CACHE_FULL,0,NULL) | ||
| 417 | 707 | ||
| 418 | #define SSL_CTX_sess_set_new_cb(ctx,cb) ((ctx)->new_session_cb=(cb)) | 708 | #define SSL_CTX_sess_set_new_cb(ctx,cb) ((ctx)->new_session_cb=(cb)) |
| 419 | #define SSL_CTX_sess_get_new_cb(ctx) ((ctx)->new_session_cb) | 709 | #define SSL_CTX_sess_get_new_cb(ctx) ((ctx)->new_session_cb) |
| @@ -421,15 +711,8 @@ typedef struct ssl_ctx_st | |||
| 421 | #define SSL_CTX_sess_get_remove_cb(ctx) ((ctx)->remove_session_cb) | 711 | #define SSL_CTX_sess_get_remove_cb(ctx) ((ctx)->remove_session_cb) |
| 422 | #define SSL_CTX_sess_set_get_cb(ctx,cb) ((ctx)->get_session_cb=(cb)) | 712 | #define SSL_CTX_sess_set_get_cb(ctx,cb) ((ctx)->get_session_cb=(cb)) |
| 423 | #define SSL_CTX_sess_get_get_cb(ctx) ((ctx)->get_session_cb) | 713 | #define SSL_CTX_sess_get_get_cb(ctx) ((ctx)->get_session_cb) |
| 424 | #define SSL_CTX_set_session_cache_mode(ctx,m) ((ctx)->session_cache_mode=(m)) | ||
| 425 | #define SSL_CTX_get_session_cache_mode(ctx) ((ctx)->session_cache_mode) | ||
| 426 | #define SSL_CTX_set_timeout(ctx,t) ((ctx)->session_timeout=(t)) | ||
| 427 | #define SSL_CTX_get_timeout(ctx) ((ctx)->session_timeout) | ||
| 428 | |||
| 429 | #define SSL_CTX_set_info_callback(ctx,cb) ((ctx)->info_callback=(cb)) | 714 | #define SSL_CTX_set_info_callback(ctx,cb) ((ctx)->info_callback=(cb)) |
| 430 | #define SSL_CTX_get_info_callback(ctx) ((ctx)->info_callback) | 715 | #define SSL_CTX_get_info_callback(ctx) ((ctx)->info_callback) |
| 431 | #define SSL_CTX_set_default_read_ahead(ctx,m) (((ctx)->default_read_ahead)=(m)) | ||
| 432 | |||
| 433 | #define SSL_CTX_set_client_cert_cb(ctx,cb) ((ctx)->client_cert_cb=(cb)) | 716 | #define SSL_CTX_set_client_cert_cb(ctx,cb) ((ctx)->client_cert_cb=(cb)) |
| 434 | #define SSL_CTX_get_client_cert_cb(ctx) ((ctx)->client_cert_cb) | 717 | #define SSL_CTX_get_client_cert_cb(ctx) ((ctx)->client_cert_cb) |
| 435 | 718 | ||
| @@ -439,18 +722,16 @@ typedef struct ssl_ctx_st | |||
| 439 | #define SSL_X509_LOOKUP 4 | 722 | #define SSL_X509_LOOKUP 4 |
| 440 | 723 | ||
| 441 | /* These will only be used when doing non-blocking IO */ | 724 | /* These will only be used when doing non-blocking IO */ |
| 442 | #define SSL_want(s) ((s)->rwstate) | 725 | #define SSL_want_nothing(s) (SSL_want(s) == SSL_NOTHING) |
| 443 | #define SSL_want_nothing(s) ((s)->rwstate == SSL_NOTHING) | 726 | #define SSL_want_read(s) (SSL_want(s) == SSL_READING) |
| 444 | #define SSL_want_read(s) ((s)->rwstate == SSL_READING) | 727 | #define SSL_want_write(s) (SSL_want(s) == SSL_WRITING) |
| 445 | #define SSL_want_write(s) ((s)->rwstate == SSL_WRITING) | 728 | #define SSL_want_x509_lookup(s) (SSL_want(s) == SSL_X509_LOOKUP) |
| 446 | #define SSL_want_x509_lookup(s) ((s)->rwstate == SSL_X509_LOOKUP) | ||
| 447 | 729 | ||
| 448 | typedef struct ssl_st | 730 | struct ssl_st |
| 449 | { | 731 | { |
| 450 | /* procol version | 732 | /* protocol version |
| 451 | * 2 for SSLv2 | 733 | * (one of SSL2_VERSION, SSL3_VERSION, TLS1_VERSION) |
| 452 | * 3 for SSLv3 | 734 | */ |
| 453 | * -3 for SSLv3 but accept SSLv2 */ | ||
| 454 | int version; | 735 | int version; |
| 455 | int type; /* SSL_ST_CONNECT or SSL_ST_ACCEPT */ | 736 | int type; /* SSL_ST_CONNECT or SSL_ST_ACCEPT */ |
| 456 | 737 | ||
| @@ -460,10 +741,10 @@ typedef struct ssl_st | |||
| 460 | * same. This is so data can be read and written to different | 741 | * same. This is so data can be read and written to different |
| 461 | * handlers */ | 742 | * handlers */ |
| 462 | 743 | ||
| 463 | #ifdef HEADER_BIO_H | 744 | #ifndef OPENSSL_NO_BIO |
| 464 | BIO *rbio; /* used by SSL_read */ | 745 | BIO *rbio; /* used by SSL_read */ |
| 465 | BIO *wbio; /* used by SSL_write */ | 746 | BIO *wbio; /* used by SSL_write */ |
| 466 | BIO *bbio; /* used during session-id reuse to concatinate | 747 | BIO *bbio; /* used during session-id reuse to concatenate |
| 467 | * messages */ | 748 | * messages */ |
| 468 | #else | 749 | #else |
| 469 | char *rbio; /* used by SSL_read */ | 750 | char *rbio; /* used by SSL_read */ |
| @@ -480,9 +761,22 @@ typedef struct ssl_st | |||
| 480 | int in_handshake; | 761 | int in_handshake; |
| 481 | int (*handshake_func)(); | 762 | int (*handshake_func)(); |
| 482 | 763 | ||
| 483 | /* int server;*/ /* are we the server side? */ | 764 | /* Imagine that here's a boolean member "init" that is |
| 484 | 765 | * switched as soon as SSL_set_{accept/connect}_state | |
| 485 | int new_session;/* 1 if we are to use a new session */ | 766 | * is called for the first time, so that "state" and |
| 767 | * "handshake_func" are properly initialized. But as | ||
| 768 | * handshake_func is == 0 until then, we use this | ||
| 769 | * test instead of an "init" member. | ||
| 770 | */ | ||
| 771 | |||
| 772 | int server; /* are we the server side? - mostly used by SSL_clear*/ | ||
| 773 | |||
| 774 | int new_session;/* 1 if we are to use a new session. | ||
| 775 | * 2 if we are a server and are inside a handshake | ||
| 776 | * (i.e. not just sending a HelloRequest) | ||
| 777 | * NB: For servers, the 'new' session may actually be a previously | ||
| 778 | * cached session or even the previous session unless | ||
| 779 | * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is set */ | ||
| 486 | int quiet_shutdown;/* don't send shutdown packets */ | 780 | int quiet_shutdown;/* don't send shutdown packets */ |
| 487 | int shutdown; /* we have shut things down, 0x01 sent, 0x02 | 781 | int shutdown; /* we have shut things down, 0x01 sent, 0x02 |
| 488 | * for received */ | 782 | * for received */ |
| @@ -490,6 +784,7 @@ typedef struct ssl_st | |||
| 490 | int rstate; /* where we are when reading */ | 784 | int rstate; /* where we are when reading */ |
| 491 | 785 | ||
| 492 | BUF_MEM *init_buf; /* buffer used during init */ | 786 | BUF_MEM *init_buf; /* buffer used during init */ |
| 787 | void *init_msg; /* pointer to handshake message body, set by ssl3_get_message() */ | ||
| 493 | int init_num; /* amount read/written */ | 788 | int init_num; /* amount read/written */ |
| 494 | int init_off; /* amount read/written */ | 789 | int init_off; /* amount read/written */ |
| 495 | 790 | ||
| @@ -497,26 +792,43 @@ typedef struct ssl_st | |||
| 497 | unsigned char *packet; | 792 | unsigned char *packet; |
| 498 | unsigned int packet_length; | 793 | unsigned int packet_length; |
| 499 | 794 | ||
| 500 | struct ssl2_ctx_st *s2; /* SSLv2 variables */ | 795 | struct ssl2_state_st *s2; /* SSLv2 variables */ |
| 501 | struct ssl3_ctx_st *s3; /* SSLv3 variables */ | 796 | struct ssl3_state_st *s3; /* SSLv3 variables */ |
| 797 | |||
| 798 | int read_ahead; /* Read as many input bytes as possible | ||
| 799 | * (for non-blocking reads) */ | ||
| 800 | |||
| 801 | /* callback that allows applications to peek at protocol messages */ | ||
| 802 | void (*msg_callback)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg); | ||
| 803 | void *msg_callback_arg; | ||
| 502 | 804 | ||
| 503 | int read_ahead; /* Read as many input bytes as possible */ | ||
| 504 | int hit; /* reusing a previous session */ | 805 | int hit; /* reusing a previous session */ |
| 505 | 806 | ||
| 807 | int purpose; /* Purpose setting */ | ||
| 808 | int trust; /* Trust setting */ | ||
| 809 | |||
| 506 | /* crypto */ | 810 | /* crypto */ |
| 507 | STACK /* SSL_CIPHER */ *cipher_list; | 811 | STACK_OF(SSL_CIPHER) *cipher_list; |
| 508 | STACK /* SSL_CIPHER */ *cipher_list_by_id; | 812 | STACK_OF(SSL_CIPHER) *cipher_list_by_id; |
| 509 | 813 | ||
| 510 | /* These are the ones being used, the ones is SSL_SESSION are | 814 | /* These are the ones being used, the ones in SSL_SESSION are |
| 511 | * the ones to be 'copied' into these ones */ | 815 | * the ones to be 'copied' into these ones */ |
| 512 | 816 | ||
| 513 | EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */ | 817 | EVP_CIPHER_CTX *enc_read_ctx; /* cryptographic state */ |
| 514 | EVP_MD *read_hash; /* used for mac generation */ | 818 | const EVP_MD *read_hash; /* used for mac generation */ |
| 515 | SSL_COMPRESSION *read_compression; /* compression */ | 819 | #ifndef OPENSSL_NO_COMP |
| 820 | COMP_CTX *expand; /* uncompress */ | ||
| 821 | #else | ||
| 822 | char *expand; | ||
| 823 | #endif | ||
| 516 | 824 | ||
| 517 | EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */ | 825 | EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */ |
| 518 | EVP_MD *write_hash; /* used for mac generation */ | 826 | const EVP_MD *write_hash; /* used for mac generation */ |
| 519 | SSL_COMPRESSION *write_compression; /* compression */ | 827 | #ifndef OPENSSL_NO_COMP |
| 828 | COMP_CTX *compress; /* compression */ | ||
| 829 | #else | ||
| 830 | char *compress; | ||
| 831 | #endif | ||
| 520 | 832 | ||
| 521 | /* session info */ | 833 | /* session info */ |
| 522 | 834 | ||
| @@ -524,18 +836,32 @@ typedef struct ssl_st | |||
| 524 | /* This is used to hold the server certificate used */ | 836 | /* This is used to hold the server certificate used */ |
| 525 | struct cert_st /* CERT */ *cert; | 837 | struct cert_st /* CERT */ *cert; |
| 526 | 838 | ||
| 839 | /* the session_id_context is used to ensure sessions are only reused | ||
| 840 | * in the appropriate context */ | ||
| 841 | unsigned int sid_ctx_length; | ||
| 842 | unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; | ||
| 843 | |||
| 527 | /* This can also be in the session once a session is established */ | 844 | /* This can also be in the session once a session is established */ |
| 528 | SSL_SESSION *session; | 845 | SSL_SESSION *session; |
| 529 | 846 | ||
| 847 | /* Default generate session ID callback. */ | ||
| 848 | GEN_SESSION_CB generate_session_id; | ||
| 849 | |||
| 530 | /* Used in SSL2 and SSL3 */ | 850 | /* Used in SSL2 and SSL3 */ |
| 531 | int verify_mode; /* 0 don't care about verify failure. | 851 | int verify_mode; /* 0 don't care about verify failure. |
| 532 | * 1 fail if verify fails */ | 852 | * 1 fail if verify fails */ |
| 533 | int (*verify_callback)(); /* fail if callback returns 0 */ | 853 | int verify_depth; |
| 534 | void (*info_callback)(); /* optional informational callback */ | 854 | int (*verify_callback)(int ok,X509_STORE_CTX *ctx); /* fail if callback returns 0 */ |
| 855 | |||
| 856 | void (*info_callback)(const SSL *ssl,int type,int val); /* optional informational callback */ | ||
| 535 | 857 | ||
| 536 | int error; /* error bytes to be written */ | 858 | int error; /* error bytes to be written */ |
| 537 | int error_code; /* actual code */ | 859 | int error_code; /* actual code */ |
| 538 | 860 | ||
| 861 | #ifndef OPENSSL_NO_KRB5 | ||
| 862 | KSSL_CTX *kssl_ctx; /* Kerberos 5 context */ | ||
| 863 | #endif /* OPENSSL_NO_KRB5 */ | ||
| 864 | |||
| 539 | SSL_CTX *ctx; | 865 | SSL_CTX *ctx; |
| 540 | /* set this flag to 1 and a sleep(1) is put into all SSL_read() | 866 | /* set this flag to 1 and a sleep(1) is put into all SSL_read() |
| 541 | * and SSL_write() calls, good for nbio debuging :-) */ | 867 | * and SSL_write() calls, good for nbio debuging :-) */ |
| @@ -546,19 +872,31 @@ typedef struct ssl_st | |||
| 546 | CRYPTO_EX_DATA ex_data; | 872 | CRYPTO_EX_DATA ex_data; |
| 547 | 873 | ||
| 548 | /* for server side, keep the list of CA_dn we can use */ | 874 | /* for server side, keep the list of CA_dn we can use */ |
| 549 | STACK /* X509_NAME */ *client_CA; | 875 | STACK_OF(X509_NAME) *client_CA; |
| 550 | 876 | ||
| 551 | int references; | 877 | int references; |
| 552 | unsigned long options; | 878 | unsigned long options; /* protocol behaviour */ |
| 879 | unsigned long mode; /* API behaviour */ | ||
| 880 | long max_cert_list; | ||
| 553 | int first_packet; | 881 | int first_packet; |
| 554 | } SSL; | 882 | int client_version; /* what was passed, used for |
| 883 | * SSLv3/TLS rollback check */ | ||
| 884 | }; | ||
| 555 | 885 | ||
| 556 | #include "ssl2.h" | 886 | #ifdef __cplusplus |
| 557 | #include "ssl3.h" | 887 | } |
| 558 | #include "tls1.h" /* This is mostly sslv3 with a few tweaks */ | 888 | #endif |
| 559 | #include "ssl23.h" | ||
| 560 | 889 | ||
| 561 | /* compatablity */ | 890 | #include <openssl/ssl2.h> |
| 891 | #include <openssl/ssl3.h> | ||
| 892 | #include <openssl/tls1.h> /* This is mostly sslv3 with a few tweaks */ | ||
| 893 | #include <openssl/ssl23.h> | ||
| 894 | |||
| 895 | #ifdef __cplusplus | ||
| 896 | extern "C" { | ||
| 897 | #endif | ||
| 898 | |||
| 899 | /* compatibility */ | ||
| 562 | #define SSL_set_app_data(s,arg) (SSL_set_ex_data(s,0,(char *)arg)) | 900 | #define SSL_set_app_data(s,arg) (SSL_set_ex_data(s,0,(char *)arg)) |
| 563 | #define SSL_get_app_data(s) (SSL_get_ex_data(s,0)) | 901 | #define SSL_get_app_data(s) (SSL_get_ex_data(s,0)) |
| 564 | #define SSL_SESSION_set_app_data(s,a) (SSL_SESSION_set_ex_data(s,0,(char *)a)) | 902 | #define SSL_SESSION_set_app_data(s,a) (SSL_SESSION_set_ex_data(s,0,(char *)a)) |
| @@ -567,7 +905,7 @@ typedef struct ssl_st | |||
| 567 | #define SSL_CTX_set_app_data(ctx,arg) (SSL_CTX_set_ex_data(ctx,0,(char *)arg)) | 905 | #define SSL_CTX_set_app_data(ctx,arg) (SSL_CTX_set_ex_data(ctx,0,(char *)arg)) |
| 568 | 906 | ||
| 569 | /* The following are the possible values for ssl->state are are | 907 | /* The following are the possible values for ssl->state are are |
| 570 | * used to indicate where we are upto in the SSL connection establishment. | 908 | * used to indicate where we are up to in the SSL connection establishment. |
| 571 | * The macros that follow are about the only things you should need to use | 909 | * The macros that follow are about the only things you should need to use |
| 572 | * and even then, only when using non-blocking IO. | 910 | * and even then, only when using non-blocking IO. |
| 573 | * It can also be useful to work out where you were when the connection | 911 | * It can also be useful to work out where you were when the connection |
| @@ -609,6 +947,13 @@ typedef struct ssl_st | |||
| 609 | #define SSL_ST_READ_BODY 0xF1 | 947 | #define SSL_ST_READ_BODY 0xF1 |
| 610 | #define SSL_ST_READ_DONE 0xF2 | 948 | #define SSL_ST_READ_DONE 0xF2 |
| 611 | 949 | ||
| 950 | /* Obtain latest Finished message | ||
| 951 | * -- that we sent (SSL_get_finished) | ||
| 952 | * -- that we expected from peer (SSL_get_peer_finished). | ||
| 953 | * Returns length (0 == no Finished so far), copies up to 'count' bytes. */ | ||
| 954 | size_t SSL_get_finished(SSL *s, void *buf, size_t count); | ||
| 955 | size_t SSL_get_peer_finished(SSL *s, void *buf, size_t count); | ||
| 956 | |||
| 612 | /* use either SSL_VERIFY_NONE or SSL_VERIFY_PEER, the last 2 options | 957 | /* use either SSL_VERIFY_NONE or SSL_VERIFY_PEER, the last 2 options |
| 613 | * are 'ored' with SSL_VERIFY_PEER if they are desired */ | 958 | * are 'ored' with SSL_VERIFY_PEER if they are desired */ |
| 614 | #define SSL_VERIFY_NONE 0x00 | 959 | #define SSL_VERIFY_NONE 0x00 |
| @@ -616,7 +961,10 @@ typedef struct ssl_st | |||
| 616 | #define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02 | 961 | #define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02 |
| 617 | #define SSL_VERIFY_CLIENT_ONCE 0x04 | 962 | #define SSL_VERIFY_CLIENT_ONCE 0x04 |
| 618 | 963 | ||
| 619 | /* this is for backward compatablility */ | 964 | #define OpenSSL_add_ssl_algorithms() SSL_library_init() |
| 965 | #define SSLeay_add_ssl_algorithms() SSL_library_init() | ||
| 966 | |||
| 967 | /* this is for backward compatibility */ | ||
| 620 | #if 0 /* NEW_SSLEAY */ | 968 | #if 0 /* NEW_SSLEAY */ |
| 621 | #define SSL_CTX_set_default_verify(a,b,c) SSL_CTX_set_verify(a,b,c) | 969 | #define SSL_CTX_set_default_verify(a,b,c) SSL_CTX_set_verify(a,b,c) |
| 622 | #define SSL_set_pref_cipher(c,n) SSL_set_cipher_list(c,n) | 970 | #define SSL_set_pref_cipher(c,n) SSL_set_cipher_list(c,n) |
| @@ -624,7 +972,7 @@ typedef struct ssl_st | |||
| 624 | #define SSL_remove_session(a,b) SSL_CTX_remove_session((a),(b)) | 972 | #define SSL_remove_session(a,b) SSL_CTX_remove_session((a),(b)) |
| 625 | #define SSL_flush_sessions(a,b) SSL_CTX_flush_sessions((a),(b)) | 973 | #define SSL_flush_sessions(a,b) SSL_CTX_flush_sessions((a),(b)) |
| 626 | #endif | 974 | #endif |
| 627 | /* More backward compatablity */ | 975 | /* More backward compatibility */ |
| 628 | #define SSL_get_cipher(s) \ | 976 | #define SSL_get_cipher(s) \ |
| 629 | SSL_CIPHER_get_name(SSL_get_current_cipher(s)) | 977 | SSL_CIPHER_get_name(SSL_get_current_cipher(s)) |
| 630 | #define SSL_get_cipher_bits(s,np) \ | 978 | #define SSL_get_cipher_bits(s,np) \ |
| @@ -638,28 +986,25 @@ typedef struct ssl_st | |||
| 638 | #define SSL_get_timeout(a) SSL_SESSION_get_timeout(a) | 986 | #define SSL_get_timeout(a) SSL_SESSION_get_timeout(a) |
| 639 | #define SSL_set_timeout(a,b) SSL_SESSION_set_timeout((a),(b)) | 987 | #define SSL_set_timeout(a,b) SSL_SESSION_set_timeout((a),(b)) |
| 640 | 988 | ||
| 641 | /* VMS linker has a 31 char name limit */ | ||
| 642 | #define SSL_CTX_set_cert_verify_callback(a,b,c) \ | ||
| 643 | SSL_CTX_set_cert_verify_cb((a),(b),(c)) | ||
| 644 | |||
| 645 | #if 1 /*SSLEAY_MACROS*/ | 989 | #if 1 /*SSLEAY_MACROS*/ |
| 646 | #define d2i_SSL_SESSION_bio(bp,s_id) (SSL_SESSION *)ASN1_d2i_bio( \ | 990 | #define d2i_SSL_SESSION_bio(bp,s_id) (SSL_SESSION *)ASN1_d2i_bio( \ |
| 647 | (char *(*)())SSL_SESSION_new,(char *(*)())d2i_SSL_SESSION, \ | 991 | (char *(*)())SSL_SESSION_new,(char *(*)())d2i_SSL_SESSION, \ |
| 648 | (bp),(unsigned char **)(s_id)) | 992 | (bp),(unsigned char **)(s_id)) |
| 649 | #define i2d_SSL_SESSION_bio(bp,s_id) ASN1_i2d_bio(i2d_SSL_SESSION, \ | 993 | #define i2d_SSL_SESSION_bio(bp,s_id) ASN1_i2d_bio(i2d_SSL_SESSION, \ |
| 650 | bp,(unsigned char *)s_id) | 994 | bp,(unsigned char *)s_id) |
| 651 | #define PEM_read_SSL_SESSION(fp,x,cb) (SSL_SESSION *)PEM_ASN1_read( \ | 995 | #define PEM_read_SSL_SESSION(fp,x,cb,u) (SSL_SESSION *)PEM_ASN1_read( \ |
| 652 | (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb) | 996 | (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb,u) |
| 653 | #define PEM_read_bio_SSL_SESSION(bp,x,cb) (SSL_SESSION *)PEM_ASN1_read_bio( \ | 997 | #define PEM_read_bio_SSL_SESSION(bp,x,cb,u) (SSL_SESSION *)PEM_ASN1_read_bio( \ |
| 654 | (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,bp,(char **)x,cb) | 998 | (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,bp,(char **)x,cb,u) |
| 655 | #define PEM_write_SSL_SESSION(fp,x) \ | 999 | #define PEM_write_SSL_SESSION(fp,x) \ |
| 656 | PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \ | 1000 | PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \ |
| 657 | PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL) | 1001 | PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL,NULL) |
| 658 | #define PEM_write_bio_SSL_SESSION(bp,x) \ | 1002 | #define PEM_write_bio_SSL_SESSION(bp,x) \ |
| 659 | PEM_ASN1_write_bio((int (*)())i2d_SSL_SESSION, \ | 1003 | PEM_ASN1_write_bio((int (*)())i2d_SSL_SESSION, \ |
| 660 | PEM_STRING_SSL_SESSION,bp, (char *)x, NULL,NULL,0,NULL) | 1004 | PEM_STRING_SSL_SESSION,bp, (char *)x, NULL,NULL,0,NULL,NULL) |
| 661 | #endif | 1005 | #endif |
| 662 | 1006 | ||
| 1007 | #define SSL_AD_REASON_OFFSET 1000 | ||
| 663 | /* These alert types are for SSLv3 and TLSv1 */ | 1008 | /* These alert types are for SSLv3 and TLSv1 */ |
| 664 | #define SSL_AD_CLOSE_NOTIFY SSL3_AD_CLOSE_NOTIFY | 1009 | #define SSL_AD_CLOSE_NOTIFY SSL3_AD_CLOSE_NOTIFY |
| 665 | #define SSL_AD_UNEXPECTED_MESSAGE SSL3_AD_UNEXPECTED_MESSAGE /* fatal */ | 1010 | #define SSL_AD_UNEXPECTED_MESSAGE SSL3_AD_UNEXPECTED_MESSAGE /* fatal */ |
| @@ -679,11 +1024,11 @@ typedef struct ssl_st | |||
| 679 | #define SSL_AD_ACCESS_DENIED TLS1_AD_ACCESS_DENIED /* fatal */ | 1024 | #define SSL_AD_ACCESS_DENIED TLS1_AD_ACCESS_DENIED /* fatal */ |
| 680 | #define SSL_AD_DECODE_ERROR TLS1_AD_DECODE_ERROR /* fatal */ | 1025 | #define SSL_AD_DECODE_ERROR TLS1_AD_DECODE_ERROR /* fatal */ |
| 681 | #define SSL_AD_DECRYPT_ERROR TLS1_AD_DECRYPT_ERROR | 1026 | #define SSL_AD_DECRYPT_ERROR TLS1_AD_DECRYPT_ERROR |
| 682 | #define SSL_AD_EXPORT_RESTRICION TLS1_AD_EXPORT_RESTRICION/* fatal */ | 1027 | #define SSL_AD_EXPORT_RESTRICTION TLS1_AD_EXPORT_RESTRICTION/* fatal */ |
| 683 | #define SSL_AD_PROTOCOL_VERSION TLS1_AD_PROTOCOL_VERSION /* fatal */ | 1028 | #define SSL_AD_PROTOCOL_VERSION TLS1_AD_PROTOCOL_VERSION /* fatal */ |
| 684 | #define SSL_AD_INSUFFICIENT_SECURITY TLS1_AD_INSUFFICIENT_SECURITY/* fatal */ | 1029 | #define SSL_AD_INSUFFICIENT_SECURITY TLS1_AD_INSUFFICIENT_SECURITY/* fatal */ |
| 685 | #define SSL_AD_INTERNAL_ERROR TLS1_AD_INTERNAL_ERROR /* fatal */ | 1030 | #define SSL_AD_INTERNAL_ERROR TLS1_AD_INTERNAL_ERROR /* fatal */ |
| 686 | #define SSL_AD_USER_CANCLED TLS1_AD_USER_CANCLED | 1031 | #define SSL_AD_USER_CANCELLED TLS1_AD_USER_CANCELLED |
| 687 | #define SSL_AD_NO_RENEGOTIATION TLS1_AD_NO_RENEGOTIATION | 1032 | #define SSL_AD_NO_RENEGOTIATION TLS1_AD_NO_RENEGOTIATION |
| 688 | 1033 | ||
| 689 | #define SSL_ERROR_NONE 0 | 1034 | #define SSL_ERROR_NONE 0 |
| @@ -691,21 +1036,53 @@ typedef struct ssl_st | |||
| 691 | #define SSL_ERROR_WANT_READ 2 | 1036 | #define SSL_ERROR_WANT_READ 2 |
| 692 | #define SSL_ERROR_WANT_WRITE 3 | 1037 | #define SSL_ERROR_WANT_WRITE 3 |
| 693 | #define SSL_ERROR_WANT_X509_LOOKUP 4 | 1038 | #define SSL_ERROR_WANT_X509_LOOKUP 4 |
| 694 | #define SSL_ERROR_SYSCALL 5 /* look at errno */ | 1039 | #define SSL_ERROR_SYSCALL 5 /* look at error stack/return value/errno */ |
| 695 | #define SSL_ERROR_ZERO_RETURN 6 | 1040 | #define SSL_ERROR_ZERO_RETURN 6 |
| 696 | #define SSL_ERROR_WANT_CONNECT 7 | 1041 | #define SSL_ERROR_WANT_CONNECT 7 |
| 1042 | #define SSL_ERROR_WANT_ACCEPT 8 | ||
| 697 | 1043 | ||
| 698 | #define SSL_CTRL_NEED_TMP_RSA 1 | 1044 | #define SSL_CTRL_NEED_TMP_RSA 1 |
| 699 | #define SSL_CTRL_SET_TMP_RSA 2 | 1045 | #define SSL_CTRL_SET_TMP_RSA 2 |
| 700 | #define SSL_CTRL_SET_TMP_DH 3 | 1046 | #define SSL_CTRL_SET_TMP_DH 3 |
| 701 | #define SSL_CTRL_SET_TMP_RSA_CB 4 | 1047 | #define SSL_CTRL_SET_TMP_RSA_CB 4 |
| 702 | #define SSL_CTRL_SET_TMP_DH_CB 5 | 1048 | #define SSL_CTRL_SET_TMP_DH_CB 5 |
| 703 | /* Add these ones */ | 1049 | |
| 704 | #define SSL_CTRL_GET_SESSION_REUSED 6 | 1050 | #define SSL_CTRL_GET_SESSION_REUSED 6 |
| 705 | #define SSL_CTRL_GET_CLIENT_CERT_REQUEST 7 | 1051 | #define SSL_CTRL_GET_CLIENT_CERT_REQUEST 7 |
| 706 | #define SSL_CTRL_GET_NUM_RENEGOTIATIONS 8 | 1052 | #define SSL_CTRL_GET_NUM_RENEGOTIATIONS 8 |
| 707 | #define SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS 9 | 1053 | #define SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS 9 |
| 708 | #define SSL_CTRL_GET_TOTAL_RENEGOTIATIONS 10 | 1054 | #define SSL_CTRL_GET_TOTAL_RENEGOTIATIONS 10 |
| 1055 | #define SSL_CTRL_GET_FLAGS 11 | ||
| 1056 | #define SSL_CTRL_EXTRA_CHAIN_CERT 12 | ||
| 1057 | |||
| 1058 | #define SSL_CTRL_SET_MSG_CALLBACK 13 | ||
| 1059 | #define SSL_CTRL_SET_MSG_CALLBACK_ARG 14 | ||
| 1060 | |||
| 1061 | /* Stats */ | ||
| 1062 | #define SSL_CTRL_SESS_NUMBER 20 | ||
| 1063 | #define SSL_CTRL_SESS_CONNECT 21 | ||
| 1064 | #define SSL_CTRL_SESS_CONNECT_GOOD 22 | ||
| 1065 | #define SSL_CTRL_SESS_CONNECT_RENEGOTIATE 23 | ||
| 1066 | #define SSL_CTRL_SESS_ACCEPT 24 | ||
| 1067 | #define SSL_CTRL_SESS_ACCEPT_GOOD 25 | ||
| 1068 | #define SSL_CTRL_SESS_ACCEPT_RENEGOTIATE 26 | ||
| 1069 | #define SSL_CTRL_SESS_HIT 27 | ||
| 1070 | #define SSL_CTRL_SESS_CB_HIT 28 | ||
| 1071 | #define SSL_CTRL_SESS_MISSES 29 | ||
| 1072 | #define SSL_CTRL_SESS_TIMEOUTS 30 | ||
| 1073 | #define SSL_CTRL_SESS_CACHE_FULL 31 | ||
| 1074 | #define SSL_CTRL_OPTIONS 32 | ||
| 1075 | #define SSL_CTRL_MODE 33 | ||
| 1076 | |||
| 1077 | #define SSL_CTRL_GET_READ_AHEAD 40 | ||
| 1078 | #define SSL_CTRL_SET_READ_AHEAD 41 | ||
| 1079 | #define SSL_CTRL_SET_SESS_CACHE_SIZE 42 | ||
| 1080 | #define SSL_CTRL_GET_SESS_CACHE_SIZE 43 | ||
| 1081 | #define SSL_CTRL_SET_SESS_CACHE_MODE 44 | ||
| 1082 | #define SSL_CTRL_GET_SESS_CACHE_MODE 45 | ||
| 1083 | |||
| 1084 | #define SSL_CTRL_GET_MAX_CERT_LIST 50 | ||
| 1085 | #define SSL_CTRL_SET_MAX_CERT_LIST 51 | ||
| 709 | 1086 | ||
| 710 | #define SSL_session_reused(ssl) \ | 1087 | #define SSL_session_reused(ssl) \ |
| 711 | SSL_ctrl((ssl),SSL_CTRL_GET_SESSION_REUSED,0,NULL) | 1088 | SSL_ctrl((ssl),SSL_CTRL_GET_SESSION_REUSED,0,NULL) |
| @@ -723,18 +1100,17 @@ typedef struct ssl_st | |||
| 723 | #define SSL_CTX_set_tmp_dh(ctx,dh) \ | 1100 | #define SSL_CTX_set_tmp_dh(ctx,dh) \ |
| 724 | SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_DH,0,(char *)dh) | 1101 | SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_DH,0,(char *)dh) |
| 725 | 1102 | ||
| 726 | /* For the next 2, the callbacks are | 1103 | #define SSL_need_tmp_RSA(ssl) \ |
| 727 | * RSA *tmp_rsa_cb(int export) | 1104 | SSL_ctrl(ssl,SSL_CTRL_NEED_TMP_RSA,0,NULL) |
| 728 | * DH *tmp_dh_cb(int export) | 1105 | #define SSL_set_tmp_rsa(ssl,rsa) \ |
| 729 | */ | 1106 | SSL_ctrl(ssl,SSL_CTRL_SET_TMP_RSA,0,(char *)rsa) |
| 730 | #define SSL_CTX_set_tmp_rsa_callback(ctx,cb) \ | 1107 | #define SSL_set_tmp_dh(ssl,dh) \ |
| 731 | SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_RSA_CB,0,(char *)cb) | 1108 | SSL_ctrl(ssl,SSL_CTRL_SET_TMP_DH,0,(char *)dh) |
| 732 | #define SSL_CTX_set_tmp_dh_callback(ctx,dh) \ | ||
| 733 | SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_DH_CB,0,(char *)dh) | ||
| 734 | 1109 | ||
| 735 | #ifndef NOPROTO | 1110 | #define SSL_CTX_add_extra_chain_cert(ctx,x509) \ |
| 1111 | SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)x509) | ||
| 736 | 1112 | ||
| 737 | #ifdef HEADER_BIO_H | 1113 | #ifndef OPENSSL_NO_BIO |
| 738 | BIO_METHOD *BIO_f_ssl(void); | 1114 | BIO_METHOD *BIO_f_ssl(void); |
| 739 | BIO *BIO_new_ssl(SSL_CTX *ctx,int client); | 1115 | BIO *BIO_new_ssl(SSL_CTX *ctx,int client); |
| 740 | BIO *BIO_new_ssl_connect(SSL_CTX *ctx); | 1116 | BIO *BIO_new_ssl_connect(SSL_CTX *ctx); |
| @@ -744,60 +1120,84 @@ void BIO_ssl_shutdown(BIO *ssl_bio); | |||
| 744 | 1120 | ||
| 745 | #endif | 1121 | #endif |
| 746 | 1122 | ||
| 747 | int SSL_CTX_set_cipher_list(SSL_CTX *,char *str); | 1123 | int SSL_CTX_set_cipher_list(SSL_CTX *,const char *str); |
| 748 | SSL_CTX *SSL_CTX_new(SSL_METHOD *meth); | 1124 | SSL_CTX *SSL_CTX_new(SSL_METHOD *meth); |
| 749 | void SSL_CTX_free(SSL_CTX *); | 1125 | void SSL_CTX_free(SSL_CTX *); |
| 750 | void SSL_clear(SSL *s); | 1126 | long SSL_CTX_set_timeout(SSL_CTX *ctx,long t); |
| 1127 | long SSL_CTX_get_timeout(SSL_CTX *ctx); | ||
| 1128 | X509_STORE *SSL_CTX_get_cert_store(SSL_CTX *); | ||
| 1129 | void SSL_CTX_set_cert_store(SSL_CTX *,X509_STORE *); | ||
| 1130 | int SSL_want(SSL *s); | ||
| 1131 | int SSL_clear(SSL *s); | ||
| 1132 | |||
| 751 | void SSL_CTX_flush_sessions(SSL_CTX *ctx,long tm); | 1133 | void SSL_CTX_flush_sessions(SSL_CTX *ctx,long tm); |
| 752 | 1134 | ||
| 753 | SSL_CIPHER *SSL_get_current_cipher(SSL *s); | 1135 | SSL_CIPHER *SSL_get_current_cipher(SSL *s); |
| 754 | int SSL_CIPHER_get_bits(SSL_CIPHER *c,int *alg_bits); | 1136 | int SSL_CIPHER_get_bits(SSL_CIPHER *c,int *alg_bits); |
| 755 | char * SSL_CIPHER_get_version(SSL_CIPHER *c); | 1137 | char * SSL_CIPHER_get_version(SSL_CIPHER *c); |
| 756 | char * SSL_CIPHER_get_name(SSL_CIPHER *c); | 1138 | const char * SSL_CIPHER_get_name(SSL_CIPHER *c); |
| 757 | 1139 | ||
| 758 | int SSL_get_fd(SSL *s); | 1140 | int SSL_get_fd(SSL *s); |
| 759 | char * SSL_get_cipher_list(SSL *s,int n); | 1141 | int SSL_get_rfd(SSL *s); |
| 1142 | int SSL_get_wfd(SSL *s); | ||
| 1143 | const char * SSL_get_cipher_list(SSL *s,int n); | ||
| 760 | char * SSL_get_shared_ciphers(SSL *s, char *buf, int len); | 1144 | char * SSL_get_shared_ciphers(SSL *s, char *buf, int len); |
| 761 | int SSL_get_read_ahead(SSL * s); | 1145 | int SSL_get_read_ahead(SSL * s); |
| 762 | int SSL_pending(SSL *s); | 1146 | int SSL_pending(SSL *s); |
| 763 | #ifndef NO_SOCK | 1147 | #ifndef OPENSSL_NO_SOCK |
| 764 | int SSL_set_fd(SSL *s, int fd); | 1148 | int SSL_set_fd(SSL *s, int fd); |
| 765 | int SSL_set_rfd(SSL *s, int fd); | 1149 | int SSL_set_rfd(SSL *s, int fd); |
| 766 | int SSL_set_wfd(SSL *s, int fd); | 1150 | int SSL_set_wfd(SSL *s, int fd); |
| 767 | #endif | 1151 | #endif |
| 768 | #ifdef HEADER_BIO_H | 1152 | #ifndef OPENSSL_NO_BIO |
| 769 | void SSL_set_bio(SSL *s, BIO *rbio,BIO *wbio); | 1153 | void SSL_set_bio(SSL *s, BIO *rbio,BIO *wbio); |
| 770 | BIO * SSL_get_rbio(SSL *s); | 1154 | BIO * SSL_get_rbio(SSL *s); |
| 771 | BIO * SSL_get_wbio(SSL *s); | 1155 | BIO * SSL_get_wbio(SSL *s); |
| 772 | #endif | 1156 | #endif |
| 773 | int SSL_set_cipher_list(SSL *s, char *str); | 1157 | int SSL_set_cipher_list(SSL *s, const char *str); |
| 774 | void SSL_set_read_ahead(SSL *s, int yes); | 1158 | void SSL_set_read_ahead(SSL *s, int yes); |
| 775 | int SSL_get_verify_mode(SSL *s); | 1159 | int SSL_get_verify_mode(SSL *s); |
| 776 | int (*SSL_get_verify_callback(SSL *s))(); | 1160 | int SSL_get_verify_depth(SSL *s); |
| 777 | void SSL_set_verify(SSL *s, int mode, int (*callback) ()); | 1161 | int (*SSL_get_verify_callback(SSL *s))(int,X509_STORE_CTX *); |
| 1162 | void SSL_set_verify(SSL *s, int mode, | ||
| 1163 | int (*callback)(int ok,X509_STORE_CTX *ctx)); | ||
| 1164 | void SSL_set_verify_depth(SSL *s, int depth); | ||
| 1165 | #ifndef OPENSSL_NO_RSA | ||
| 778 | int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa); | 1166 | int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa); |
| 1167 | #endif | ||
| 779 | int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len); | 1168 | int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len); |
| 780 | int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey); | 1169 | int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey); |
| 781 | int SSL_use_PrivateKey_ASN1(int pk,SSL *ssl, unsigned char *d, long len); | 1170 | int SSL_use_PrivateKey_ASN1(int pk,SSL *ssl, unsigned char *d, long len); |
| 782 | int SSL_use_certificate(SSL *ssl, X509 *x); | 1171 | int SSL_use_certificate(SSL *ssl, X509 *x); |
| 783 | int SSL_use_certificate_ASN1(SSL *ssl, int len, unsigned char *d); | 1172 | int SSL_use_certificate_ASN1(SSL *ssl, unsigned char *d, int len); |
| 784 | 1173 | ||
| 785 | #ifndef NO_STDIO | 1174 | #ifndef OPENSSL_NO_STDIO |
| 786 | int SSL_use_RSAPrivateKey_file(SSL *ssl, char *file, int type); | 1175 | int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type); |
| 787 | int SSL_use_PrivateKey_file(SSL *ssl, char *file, int type); | 1176 | int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type); |
| 788 | int SSL_use_certificate_file(SSL *ssl, char *file, int type); | 1177 | int SSL_use_certificate_file(SSL *ssl, const char *file, int type); |
| 789 | int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, char *file, int type); | 1178 | int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type); |
| 790 | int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, char *file, int type); | 1179 | int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type); |
| 791 | int SSL_CTX_use_certificate_file(SSL_CTX *ctx, char *file, int type); | 1180 | int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type); |
| 792 | STACK * SSL_load_client_CA_file(char *file); | 1181 | int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file); /* PEM type */ |
| 1182 | STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file); | ||
| 1183 | int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, | ||
| 1184 | const char *file); | ||
| 1185 | #ifndef OPENSSL_SYS_WIN32 | ||
| 1186 | #ifndef OPENSSL_SYS_VMS | ||
| 1187 | #ifndef OPENSSL_SYS_MACINTOSH_CLASSIC /* XXXXX: Better scheme needed! [was: #ifndef MAC_OS_pre_X] */ | ||
| 1188 | int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, | ||
| 1189 | const char *dir); | ||
| 1190 | #endif | ||
| 1191 | #endif | ||
| 1192 | #endif | ||
| 1193 | |||
| 793 | #endif | 1194 | #endif |
| 794 | 1195 | ||
| 795 | void ERR_load_SSL_strings(void ); | ||
| 796 | void SSL_load_error_strings(void ); | 1196 | void SSL_load_error_strings(void ); |
| 797 | char * SSL_state_string(SSL *s); | 1197 | const char *SSL_state_string(const SSL *s); |
| 798 | char * SSL_rstate_string(SSL *s); | 1198 | const char *SSL_rstate_string(const SSL *s); |
| 799 | char * SSL_state_string_long(SSL *s); | 1199 | const char *SSL_state_string_long(const SSL *s); |
| 800 | char * SSL_rstate_string_long(SSL *s); | 1200 | const char *SSL_rstate_string_long(const SSL *s); |
| 801 | long SSL_SESSION_get_time(SSL_SESSION *s); | 1201 | long SSL_SESSION_get_time(SSL_SESSION *s); |
| 802 | long SSL_SESSION_set_time(SSL_SESSION *s, long t); | 1202 | long SSL_SESSION_set_time(SSL_SESSION *s, long t); |
| 803 | long SSL_SESSION_get_timeout(SSL_SESSION *s); | 1203 | long SSL_SESSION_get_timeout(SSL_SESSION *s); |
| @@ -807,10 +1207,10 @@ void SSL_copy_session_id(SSL *to,SSL *from); | |||
| 807 | SSL_SESSION *SSL_SESSION_new(void); | 1207 | SSL_SESSION *SSL_SESSION_new(void); |
| 808 | unsigned long SSL_SESSION_hash(SSL_SESSION *a); | 1208 | unsigned long SSL_SESSION_hash(SSL_SESSION *a); |
| 809 | int SSL_SESSION_cmp(SSL_SESSION *a,SSL_SESSION *b); | 1209 | int SSL_SESSION_cmp(SSL_SESSION *a,SSL_SESSION *b); |
| 810 | #ifndef NO_FP_API | 1210 | #ifndef OPENSSL_NO_FP_API |
| 811 | int SSL_SESSION_print_fp(FILE *fp,SSL_SESSION *ses); | 1211 | int SSL_SESSION_print_fp(FILE *fp,SSL_SESSION *ses); |
| 812 | #endif | 1212 | #endif |
| 813 | #ifdef HEADER_BIO_H | 1213 | #ifndef OPENSSL_NO_BIO |
| 814 | int SSL_SESSION_print(BIO *fp,SSL_SESSION *ses); | 1214 | int SSL_SESSION_print(BIO *fp,SSL_SESSION *ses); |
| 815 | #endif | 1215 | #endif |
| 816 | void SSL_SESSION_free(SSL_SESSION *ses); | 1216 | void SSL_SESSION_free(SSL_SESSION *ses); |
| @@ -818,19 +1218,28 @@ int i2d_SSL_SESSION(SSL_SESSION *in,unsigned char **pp); | |||
| 818 | int SSL_set_session(SSL *to, SSL_SESSION *session); | 1218 | int SSL_set_session(SSL *to, SSL_SESSION *session); |
| 819 | int SSL_CTX_add_session(SSL_CTX *s, SSL_SESSION *c); | 1219 | int SSL_CTX_add_session(SSL_CTX *s, SSL_SESSION *c); |
| 820 | int SSL_CTX_remove_session(SSL_CTX *,SSL_SESSION *c); | 1220 | int SSL_CTX_remove_session(SSL_CTX *,SSL_SESSION *c); |
| 1221 | int SSL_CTX_set_generate_session_id(SSL_CTX *, GEN_SESSION_CB); | ||
| 1222 | int SSL_set_generate_session_id(SSL *, GEN_SESSION_CB); | ||
| 1223 | int SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id, | ||
| 1224 | unsigned int id_len); | ||
| 821 | SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a,unsigned char **pp,long length); | 1225 | SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a,unsigned char **pp,long length); |
| 822 | 1226 | ||
| 823 | #ifdef HEADER_X509_H | 1227 | #ifdef HEADER_X509_H |
| 824 | X509 * SSL_get_peer_certificate(SSL *s); | 1228 | X509 * SSL_get_peer_certificate(SSL *s); |
| 825 | #endif | 1229 | #endif |
| 826 | 1230 | ||
| 827 | STACK * SSL_get_peer_cert_chain(SSL *s); | 1231 | STACK_OF(X509) *SSL_get_peer_cert_chain(SSL *s); |
| 828 | 1232 | ||
| 829 | int SSL_CTX_get_verify_mode(SSL_CTX *ctx); | 1233 | int SSL_CTX_get_verify_mode(SSL_CTX *ctx); |
| 830 | int (*SSL_CTX_get_verify_callback(SSL_CTX *ctx))(); | 1234 | int SSL_CTX_get_verify_depth(SSL_CTX *ctx); |
| 831 | void SSL_CTX_set_verify(SSL_CTX *ctx,int mode,int (*callback)()); | 1235 | int (*SSL_CTX_get_verify_callback(SSL_CTX *ctx))(int,X509_STORE_CTX *); |
| 832 | void SSL_CTX_set_cert_verify_cb(SSL_CTX *ctx, int (*cb)(),char *arg); | 1236 | void SSL_CTX_set_verify(SSL_CTX *ctx,int mode, |
| 1237 | int (*callback)(int, X509_STORE_CTX *)); | ||
| 1238 | void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth); | ||
| 1239 | void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, int (*cb)(X509_STORE_CTX *,void *), void *arg); | ||
| 1240 | #ifndef OPENSSL_NO_RSA | ||
| 833 | int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa); | 1241 | int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa); |
| 1242 | #endif | ||
| 834 | int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, unsigned char *d, long len); | 1243 | int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, unsigned char *d, long len); |
| 835 | int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey); | 1244 | int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey); |
| 836 | int SSL_CTX_use_PrivateKey_ASN1(int pk,SSL_CTX *ctx, | 1245 | int SSL_CTX_use_PrivateKey_ASN1(int pk,SSL_CTX *ctx, |
| @@ -838,24 +1247,37 @@ int SSL_CTX_use_PrivateKey_ASN1(int pk,SSL_CTX *ctx, | |||
| 838 | int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x); | 1247 | int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x); |
| 839 | int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, unsigned char *d); | 1248 | int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, unsigned char *d); |
| 840 | 1249 | ||
| 841 | void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx,int (*cb)()); | 1250 | void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb); |
| 1251 | void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u); | ||
| 842 | 1252 | ||
| 843 | int SSL_CTX_check_private_key(SSL_CTX *ctx); | 1253 | int SSL_CTX_check_private_key(SSL_CTX *ctx); |
| 844 | int SSL_check_private_key(SSL *ctx); | 1254 | int SSL_check_private_key(SSL *ctx); |
| 845 | 1255 | ||
| 1256 | int SSL_CTX_set_session_id_context(SSL_CTX *ctx,const unsigned char *sid_ctx, | ||
| 1257 | unsigned int sid_ctx_len); | ||
| 1258 | |||
| 846 | SSL * SSL_new(SSL_CTX *ctx); | 1259 | SSL * SSL_new(SSL_CTX *ctx); |
| 847 | void SSL_clear(SSL *s); | 1260 | int SSL_set_session_id_context(SSL *ssl,const unsigned char *sid_ctx, |
| 1261 | unsigned int sid_ctx_len); | ||
| 1262 | |||
| 1263 | int SSL_CTX_set_purpose(SSL_CTX *s, int purpose); | ||
| 1264 | int SSL_set_purpose(SSL *s, int purpose); | ||
| 1265 | int SSL_CTX_set_trust(SSL_CTX *s, int trust); | ||
| 1266 | int SSL_set_trust(SSL *s, int trust); | ||
| 1267 | |||
| 848 | void SSL_free(SSL *ssl); | 1268 | void SSL_free(SSL *ssl); |
| 849 | int SSL_accept(SSL *ssl); | 1269 | int SSL_accept(SSL *ssl); |
| 850 | int SSL_connect(SSL *ssl); | 1270 | int SSL_connect(SSL *ssl); |
| 851 | int SSL_read(SSL *ssl,char *buf,int num); | 1271 | int SSL_read(SSL *ssl,void *buf,int num); |
| 852 | int SSL_peek(SSL *ssl,char *buf,int num); | 1272 | int SSL_peek(SSL *ssl,void *buf,int num); |
| 853 | int SSL_write(SSL *ssl,char *buf,int num); | 1273 | int SSL_write(SSL *ssl,const void *buf,int num); |
| 854 | long SSL_ctrl(SSL *ssl,int cmd, long larg, char *parg); | 1274 | long SSL_ctrl(SSL *ssl,int cmd, long larg, void *parg); |
| 855 | long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd, long larg, char *parg); | 1275 | long SSL_callback_ctrl(SSL *, int, void (*)()); |
| 1276 | long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd, long larg, void *parg); | ||
| 1277 | long SSL_CTX_callback_ctrl(SSL_CTX *, int, void (*)()); | ||
| 856 | 1278 | ||
| 857 | int SSL_get_error(SSL *s,int ret_code); | 1279 | int SSL_get_error(SSL *s,int ret_code); |
| 858 | char * SSL_get_version(SSL *s); | 1280 | const char *SSL_get_version(SSL *s); |
| 859 | 1281 | ||
| 860 | /* This sets the 'default' SSL version that SSL_new() will create */ | 1282 | /* This sets the 'default' SSL version that SSL_new() will create */ |
| 861 | int SSL_CTX_set_ssl_version(SSL_CTX *ctx,SSL_METHOD *meth); | 1283 | int SSL_CTX_set_ssl_version(SSL_CTX *ctx,SSL_METHOD *meth); |
| @@ -876,23 +1298,24 @@ SSL_METHOD *TLSv1_method(void); /* TLSv1.0 */ | |||
| 876 | SSL_METHOD *TLSv1_server_method(void); /* TLSv1.0 */ | 1298 | SSL_METHOD *TLSv1_server_method(void); /* TLSv1.0 */ |
| 877 | SSL_METHOD *TLSv1_client_method(void); /* TLSv1.0 */ | 1299 | SSL_METHOD *TLSv1_client_method(void); /* TLSv1.0 */ |
| 878 | 1300 | ||
| 879 | STACK *SSL_get_ciphers(SSL *s); | 1301 | STACK_OF(SSL_CIPHER) *SSL_get_ciphers(SSL *s); |
| 880 | 1302 | ||
| 881 | int SSL_do_handshake(SSL *s); | 1303 | int SSL_do_handshake(SSL *s); |
| 882 | int SSL_renegotiate(SSL *s); | 1304 | int SSL_renegotiate(SSL *s); |
| 1305 | int SSL_renegotiate_pending(SSL *s); | ||
| 883 | int SSL_shutdown(SSL *s); | 1306 | int SSL_shutdown(SSL *s); |
| 884 | 1307 | ||
| 885 | SSL_METHOD *SSL_get_ssl_method(SSL *s); | 1308 | SSL_METHOD *SSL_get_ssl_method(SSL *s); |
| 886 | int SSL_set_ssl_method(SSL *s,SSL_METHOD *method); | 1309 | int SSL_set_ssl_method(SSL *s,SSL_METHOD *method); |
| 887 | char *SSL_alert_type_string_long(int value); | 1310 | const char *SSL_alert_type_string_long(int value); |
| 888 | char *SSL_alert_type_string(int value); | 1311 | const char *SSL_alert_type_string(int value); |
| 889 | char *SSL_alert_desc_string_long(int value); | 1312 | const char *SSL_alert_desc_string_long(int value); |
| 890 | char *SSL_alert_desc_string(int value); | 1313 | const char *SSL_alert_desc_string(int value); |
| 891 | 1314 | ||
| 892 | void SSL_set_client_CA_list(SSL *s, STACK *list); | 1315 | void SSL_set_client_CA_list(SSL *s, STACK_OF(X509_NAME) *list); |
| 893 | void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK *list); | 1316 | void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *list); |
| 894 | STACK *SSL_get_client_CA_list(SSL *s); | 1317 | STACK_OF(X509_NAME) *SSL_get_client_CA_list(SSL *s); |
| 895 | STACK *SSL_CTX_get_client_CA_list(SSL_CTX *s); | 1318 | STACK_OF(X509_NAME) *SSL_CTX_get_client_CA_list(SSL_CTX *s); |
| 896 | int SSL_add_client_CA(SSL *ssl,X509 *x); | 1319 | int SSL_add_client_CA(SSL *ssl,X509 *x); |
| 897 | int SSL_CTX_add_client_CA(SSL_CTX *ctx,X509 *x); | 1320 | int SSL_CTX_add_client_CA(SSL_CTX *ctx,X509 *x); |
| 898 | 1321 | ||
| @@ -901,10 +1324,10 @@ void SSL_set_accept_state(SSL *s); | |||
| 901 | 1324 | ||
| 902 | long SSL_get_default_timeout(SSL *s); | 1325 | long SSL_get_default_timeout(SSL *s); |
| 903 | 1326 | ||
| 904 | void SSLeay_add_ssl_algorithms(void ); | 1327 | int SSL_library_init(void ); |
| 905 | 1328 | ||
| 906 | char *SSL_CIPHER_description(SSL_CIPHER *,char *buf,int size); | 1329 | char *SSL_CIPHER_description(SSL_CIPHER *,char *buf,int size); |
| 907 | STACK *SSL_dup_CA_list(STACK *sk); | 1330 | STACK_OF(X509_NAME) *SSL_dup_CA_list(STACK_OF(X509_NAME) *sk); |
| 908 | 1331 | ||
| 909 | SSL *SSL_dup(SSL *ssl); | 1332 | SSL *SSL_dup(SSL *ssl); |
| 910 | 1333 | ||
| @@ -919,242 +1342,92 @@ void SSL_set_shutdown(SSL *ssl,int mode); | |||
| 919 | int SSL_get_shutdown(SSL *ssl); | 1342 | int SSL_get_shutdown(SSL *ssl); |
| 920 | int SSL_version(SSL *ssl); | 1343 | int SSL_version(SSL *ssl); |
| 921 | int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx); | 1344 | int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx); |
| 922 | int SSL_CTX_load_verify_locations(SSL_CTX *ctx,char *CAfile,char *CApath); | 1345 | int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, |
| 1346 | const char *CApath); | ||
| 1347 | #define SSL_get0_session SSL_get_session /* just peek at pointer */ | ||
| 923 | SSL_SESSION *SSL_get_session(SSL *ssl); | 1348 | SSL_SESSION *SSL_get_session(SSL *ssl); |
| 1349 | SSL_SESSION *SSL_get1_session(SSL *ssl); /* obtain a reference count */ | ||
| 924 | SSL_CTX *SSL_get_SSL_CTX(SSL *ssl); | 1350 | SSL_CTX *SSL_get_SSL_CTX(SSL *ssl); |
| 925 | void SSL_set_info_callback(SSL *ssl,void (*cb)()); | 1351 | void SSL_set_info_callback(SSL *ssl, |
| 926 | void (*SSL_get_info_callback(SSL *ssl))(); | 1352 | void (*cb)(const SSL *ssl,int type,int val)); |
| 1353 | void (*SSL_get_info_callback(SSL *ssl))(const SSL *ssl,int type,int val); | ||
| 927 | int SSL_state(SSL *ssl); | 1354 | int SSL_state(SSL *ssl); |
| 928 | 1355 | ||
| 929 | void SSL_set_verify_result(SSL *ssl,long v); | 1356 | void SSL_set_verify_result(SSL *ssl,long v); |
| 930 | long SSL_get_verify_result(SSL *ssl); | 1357 | long SSL_get_verify_result(SSL *ssl); |
| 931 | 1358 | ||
| 932 | int SSL_set_ex_data(SSL *ssl,int idx,char *data); | 1359 | int SSL_set_ex_data(SSL *ssl,int idx,void *data); |
| 933 | char *SSL_get_ex_data(SSL *ssl,int idx); | 1360 | void *SSL_get_ex_data(SSL *ssl,int idx); |
| 934 | int SSL_get_ex_new_index(long argl, char *argp, int (*new_func)(), | 1361 | int SSL_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, |
| 935 | int (*dup_func)(), void (*free_func)()); | 1362 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); |
| 936 | 1363 | ||
| 937 | int SSL_SESSION_set_ex_data(SSL_SESSION *ss,int idx,char *data); | 1364 | int SSL_SESSION_set_ex_data(SSL_SESSION *ss,int idx,void *data); |
| 938 | char *SSL_SESSION_get_ex_data(SSL_SESSION *ss,int idx); | 1365 | void *SSL_SESSION_get_ex_data(SSL_SESSION *ss,int idx); |
| 939 | int SSL_SESSION_get_ex_new_index(long argl, char *argp, int (*new_func)(), | 1366 | int SSL_SESSION_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, |
| 940 | int (*dup_func)(), void (*free_func)()); | 1367 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); |
| 941 | 1368 | ||
| 942 | int SSL_CTX_set_ex_data(SSL_CTX *ssl,int idx,char *data); | 1369 | int SSL_CTX_set_ex_data(SSL_CTX *ssl,int idx,void *data); |
| 943 | char *SSL_CTX_get_ex_data(SSL_CTX *ssl,int idx); | 1370 | void *SSL_CTX_get_ex_data(SSL_CTX *ssl,int idx); |
| 944 | int SSL_CTX_get_ex_new_index(long argl, char *argp, int (*new_func)(), | 1371 | int SSL_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, |
| 945 | int (*dup_func)(), void (*free_func)()); | 1372 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); |
| 946 | 1373 | ||
| 947 | #else | 1374 | int SSL_get_ex_data_X509_STORE_CTX_idx(void ); |
| 948 | 1375 | ||
| 949 | BIO_METHOD *BIO_f_ssl(); | 1376 | #define SSL_CTX_sess_set_cache_size(ctx,t) \ |
| 950 | BIO *BIO_new_ssl(); | 1377 | SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_SIZE,t,NULL) |
| 951 | BIO *BIO_new_ssl_connect(); | 1378 | #define SSL_CTX_sess_get_cache_size(ctx) \ |
| 952 | BIO *BIO_new_buffer_ssl_connect(); | 1379 | SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_SIZE,0,NULL) |
| 953 | int BIO_ssl_copy_session_id(); | 1380 | #define SSL_CTX_set_session_cache_mode(ctx,m) \ |
| 954 | void BIO_ssl_shutdown(); | 1381 | SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_MODE,m,NULL) |
| 955 | 1382 | #define SSL_CTX_get_session_cache_mode(ctx) \ | |
| 956 | int SSL_CTX_set_cipher_list(); | 1383 | SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_MODE,0,NULL) |
| 957 | SSL_CTX *SSL_CTX_new(); | 1384 | |
| 958 | void SSL_CTX_free(); | 1385 | #define SSL_CTX_get_default_read_ahead(ctx) SSL_CTX_get_read_ahead(ctx) |
| 959 | void SSL_clear(); | 1386 | #define SSL_CTX_set_default_read_ahead(ctx,m) SSL_CTX_set_read_ahead(ctx,m) |
| 960 | void SSL_CTX_flush_sessions(); | 1387 | #define SSL_CTX_get_read_ahead(ctx) \ |
| 961 | 1388 | SSL_CTX_ctrl(ctx,SSL_CTRL_GET_READ_AHEAD,0,NULL) | |
| 962 | SSL_CIPHER *SSL_get_current_cipher(); | 1389 | #define SSL_CTX_set_read_ahead(ctx,m) \ |
| 963 | int SSL_CIPHER_get_bits(); | 1390 | SSL_CTX_ctrl(ctx,SSL_CTRL_SET_READ_AHEAD,m,NULL) |
| 964 | char * SSL_CIPHER_get_version(); | 1391 | #define SSL_CTX_get_max_cert_list(ctx) \ |
| 965 | char * SSL_CIPHER_get_name(); | 1392 | SSL_CTX_ctrl(ctx,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL) |
| 966 | 1393 | #define SSL_CTX_set_max_cert_list(ctx,m) \ | |
| 967 | int SSL_get_fd(); | 1394 | SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL) |
| 968 | char * SSL_get_cipher_list(); | 1395 | #define SSL_get_max_cert_list(ssl) \ |
| 969 | char * SSL_get_shared_ciphers(); | 1396 | SSL_ctrl(ssl,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL) |
| 970 | int SSL_get_read_ahead(); | 1397 | #define SSL_set_max_cert_list(ssl,m) \ |
| 971 | int SSL_pending(); | 1398 | SSL_ctrl(ssl,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL) |
| 972 | #ifndef NO_SOCK | 1399 | |
| 973 | int SSL_set_fd(); | 1400 | /* NB: the keylength is only applicable when is_export is true */ |
| 974 | int SSL_set_rfd(); | 1401 | #ifndef OPENSSL_NO_RSA |
| 975 | int SSL_set_wfd(); | 1402 | void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx, |
| 976 | #endif | 1403 | RSA *(*cb)(SSL *ssl,int is_export, |
| 977 | #ifdef HEADER_BIO_H | 1404 | int keylength)); |
| 978 | void SSL_set_bio(); | 1405 | |
| 979 | BIO * SSL_get_rbio(); | 1406 | void SSL_set_tmp_rsa_callback(SSL *ssl, |
| 980 | BIO * SSL_get_wbio(); | 1407 | RSA *(*cb)(SSL *ssl,int is_export, |
| 981 | #endif | 1408 | int keylength)); |
| 982 | int SSL_set_cipher_list(); | ||
| 983 | void SSL_set_read_ahead(); | ||
| 984 | int SSL_get_verify_mode(); | ||
| 985 | |||
| 986 | void SSL_set_verify(); | ||
| 987 | int SSL_use_RSAPrivateKey(); | ||
| 988 | int SSL_use_RSAPrivateKey_ASN1(); | ||
| 989 | int SSL_use_PrivateKey(); | ||
| 990 | int SSL_use_PrivateKey_ASN1(); | ||
| 991 | int SSL_use_certificate(); | ||
| 992 | int SSL_use_certificate_ASN1(); | ||
| 993 | |||
| 994 | #ifndef NO_STDIO | ||
| 995 | int SSL_use_RSAPrivateKey_file(); | ||
| 996 | int SSL_use_PrivateKey_file(); | ||
| 997 | int SSL_use_certificate_file(); | ||
| 998 | int SSL_CTX_use_RSAPrivateKey_file(); | ||
| 999 | int SSL_CTX_use_PrivateKey_file(); | ||
| 1000 | int SSL_CTX_use_certificate_file(); | ||
| 1001 | STACK * SSL_load_client_CA_file(); | ||
| 1002 | #endif | ||
| 1003 | |||
| 1004 | void ERR_load_SSL_strings(); | ||
| 1005 | void SSL_load_error_strings(); | ||
| 1006 | char * SSL_state_string(); | ||
| 1007 | char * SSL_rstate_string(); | ||
| 1008 | char * SSL_state_string_long(); | ||
| 1009 | char * SSL_rstate_string_long(); | ||
| 1010 | long SSL_SESSION_get_time(); | ||
| 1011 | long SSL_SESSION_set_time(); | ||
| 1012 | long SSL_SESSION_get_timeout(); | ||
| 1013 | long SSL_SESSION_set_timeout(); | ||
| 1014 | void SSL_copy_session_id(); | ||
| 1015 | |||
| 1016 | SSL_SESSION *SSL_SESSION_new(); | ||
| 1017 | unsigned long SSL_SESSION_hash(); | ||
| 1018 | int SSL_SESSION_cmp(); | ||
| 1019 | #ifndef NO_FP_API | ||
| 1020 | int SSL_SESSION_print_fp(); | ||
| 1021 | #endif | ||
| 1022 | #ifdef HEADER_BIO_H | ||
| 1023 | int SSL_SESSION_print(); | ||
| 1024 | #endif | ||
| 1025 | void SSL_SESSION_free(); | ||
| 1026 | int i2d_SSL_SESSION(); | ||
| 1027 | int SSL_set_session(); | ||
| 1028 | int SSL_CTX_add_session(); | ||
| 1029 | int SSL_CTX_remove_session(); | ||
| 1030 | SSL_SESSION *d2i_SSL_SESSION(); | ||
| 1031 | |||
| 1032 | #ifdef HEADER_X509_H | ||
| 1033 | X509 * SSL_get_peer_certificate(); | ||
| 1034 | #endif | 1409 | #endif |
| 1035 | 1410 | #ifndef OPENSSL_NO_DH | |
| 1036 | STACK * SSL_get_peer_cert_chain(); | 1411 | void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx, |
| 1037 | 1412 | DH *(*dh)(SSL *ssl,int is_export, | |
| 1038 | int SSL_CTX_get_verify_mode(); | 1413 | int keylength)); |
| 1039 | int (*SSL_CTX_get_verify_callback())(); | 1414 | void SSL_set_tmp_dh_callback(SSL *ssl, |
| 1040 | void SSL_CTX_set_verify(); | 1415 | DH *(*dh)(SSL *ssl,int is_export, |
| 1041 | void SSL_CTX_set_cert_verify_cb(); | 1416 | int keylength)); |
| 1042 | int SSL_CTX_use_RSAPrivateKey(); | ||
| 1043 | int SSL_CTX_use_RSAPrivateKey_ASN1(); | ||
| 1044 | int SSL_CTX_use_PrivateKey(); | ||
| 1045 | int SSL_CTX_use_PrivateKey_ASN1(); | ||
| 1046 | int SSL_CTX_use_certificate(); | ||
| 1047 | int SSL_CTX_use_certificate_ASN1(); | ||
| 1048 | |||
| 1049 | void SSL_CTX_set_default_passwd_cb(); | ||
| 1050 | |||
| 1051 | int SSL_CTX_check_private_key(); | ||
| 1052 | int SSL_check_private_key(); | ||
| 1053 | |||
| 1054 | SSL * SSL_new(); | ||
| 1055 | void SSL_clear(); | ||
| 1056 | void SSL_free(); | ||
| 1057 | int SSL_accept(); | ||
| 1058 | int SSL_connect(); | ||
| 1059 | int SSL_read(); | ||
| 1060 | int SSL_peek(); | ||
| 1061 | int SSL_write(); | ||
| 1062 | long SSL_ctrl(); | ||
| 1063 | long SSL_CTX_ctrl(); | ||
| 1064 | |||
| 1065 | int SSL_get_error(); | ||
| 1066 | char * SSL_get_version(); | ||
| 1067 | |||
| 1068 | int SSL_CTX_set_ssl_version(); | ||
| 1069 | |||
| 1070 | SSL_METHOD *SSLv2_method(); | ||
| 1071 | SSL_METHOD *SSLv2_server_method(); | ||
| 1072 | SSL_METHOD *SSLv2_client_method(); | ||
| 1073 | |||
| 1074 | SSL_METHOD *SSLv3_method(); | ||
| 1075 | SSL_METHOD *SSLv3_server_method(); | ||
| 1076 | SSL_METHOD *SSLv3_client_method(); | ||
| 1077 | |||
| 1078 | SSL_METHOD *SSLv23_method(); | ||
| 1079 | SSL_METHOD *SSLv23_server_method(); | ||
| 1080 | SSL_METHOD *SSLv23_client_method(); | ||
| 1081 | |||
| 1082 | SSL_METHOD *TLSv1_method(); | ||
| 1083 | SSL_METHOD *TLSv1_server_method(); | ||
| 1084 | SSL_METHOD *TLSv1_client_method(); | ||
| 1085 | |||
| 1086 | STACK *SSL_get_ciphers(); | ||
| 1087 | |||
| 1088 | int SSL_do_handshake(); | ||
| 1089 | int SSL_renegotiate(); | ||
| 1090 | int SSL_shutdown(); | ||
| 1091 | |||
| 1092 | SSL_METHOD *SSL_get_ssl_method(); | ||
| 1093 | int SSL_set_ssl_method(); | ||
| 1094 | char *SSL_alert_type_string_long(); | ||
| 1095 | char *SSL_alert_type_string(); | ||
| 1096 | char *SSL_alert_desc_string_long(); | ||
| 1097 | char *SSL_alert_desc_string(); | ||
| 1098 | |||
| 1099 | void SSL_set_client_CA_list(); | ||
| 1100 | void SSL_CTX_set_client_CA_list(); | ||
| 1101 | STACK *SSL_get_client_CA_list(); | ||
| 1102 | STACK *SSL_CTX_get_client_CA_list(); | ||
| 1103 | int SSL_add_client_CA(); | ||
| 1104 | int SSL_CTX_add_client_CA(); | ||
| 1105 | |||
| 1106 | void SSL_set_connect_state(); | ||
| 1107 | void SSL_set_accept_state(); | ||
| 1108 | |||
| 1109 | long SSL_get_default_timeout(); | ||
| 1110 | |||
| 1111 | void SSLeay_add_ssl_algorithms(); | ||
| 1112 | |||
| 1113 | char *SSL_CIPHER_description(); | ||
| 1114 | STACK *SSL_dup_CA_list(); | ||
| 1115 | |||
| 1116 | SSL *SSL_dup(); | ||
| 1117 | |||
| 1118 | X509 *SSL_get_certificate(); | ||
| 1119 | /* EVP * */ struct evp_pkey_st *SSL_get_privatekey(); | ||
| 1120 | |||
| 1121 | #ifdef this_is_for_mk1mf_pl | ||
| 1122 | EVP *SSL_get_privatekey(); | ||
| 1123 | |||
| 1124 | void SSL_CTX_set_quiet_shutdown(); | ||
| 1125 | int SSL_CTX_get_quiet_shutdown(); | ||
| 1126 | void SSL_set_quiet_shutdown(); | ||
| 1127 | int SSL_get_quiet_shutdown(); | ||
| 1128 | void SSL_set_shutdown(); | ||
| 1129 | int SSL_get_shutdown(); | ||
| 1130 | int SSL_version(); | ||
| 1131 | int SSL_CTX_set_default_verify_paths(); | ||
| 1132 | int SSL_CTX_load_verify_locations(); | ||
| 1133 | SSL_SESSION *SSL_get_session(); | ||
| 1134 | SSL_CTX *SSL_get_SSL_CTX(); | ||
| 1135 | void SSL_set_info_callback(); | ||
| 1136 | int (*SSL_get_info_callback())(); | ||
| 1137 | int SSL_state(); | ||
| 1138 | void SSL_set_verify_result(); | ||
| 1139 | long SSL_get_verify_result(); | ||
| 1140 | |||
| 1141 | int SSL_set_ex_data(); | ||
| 1142 | char *SSL_get_ex_data(); | ||
| 1143 | int SSL_get_ex_new_index(); | ||
| 1144 | |||
| 1145 | int SSL_SESSION_set_ex_data(); | ||
| 1146 | char *SSL_SESSION_get_ex_data(); | ||
| 1147 | int SSL_SESSION_get_ex_new_index(); | ||
| 1148 | |||
| 1149 | int SSL_CTX_set_ex_data(); | ||
| 1150 | char *SSL_CTX_get_ex_data(); | ||
| 1151 | int SSL_CTX_get_ex_new_index(); | ||
| 1152 | |||
| 1153 | #endif | 1417 | #endif |
| 1154 | 1418 | ||
| 1419 | #ifndef OPENSSL_NO_COMP | ||
| 1420 | int SSL_COMP_add_compression_method(int id,COMP_METHOD *cm); | ||
| 1421 | #else | ||
| 1422 | int SSL_COMP_add_compression_method(int id,char *cm); | ||
| 1155 | #endif | 1423 | #endif |
| 1156 | 1424 | ||
| 1157 | /* BEGIN ERROR CODES */ | 1425 | /* BEGIN ERROR CODES */ |
| 1426 | /* The following lines are auto generated by the script mkerr.pl. Any changes | ||
| 1427 | * made after this point may be overwritten when the script is next run. | ||
| 1428 | */ | ||
| 1429 | void ERR_load_SSL_strings(void); | ||
| 1430 | |||
| 1158 | /* Error codes for the SSL functions. */ | 1431 | /* Error codes for the SSL functions. */ |
| 1159 | 1432 | ||
| 1160 | /* Function codes. */ | 1433 | /* Function codes. */ |
| @@ -1178,21 +1451,27 @@ int SSL_CTX_get_ex_new_index(); | |||
| 1178 | #define SSL_F_SSL23_CONNECT 117 | 1451 | #define SSL_F_SSL23_CONNECT 117 |
| 1179 | #define SSL_F_SSL23_GET_CLIENT_HELLO 118 | 1452 | #define SSL_F_SSL23_GET_CLIENT_HELLO 118 |
| 1180 | #define SSL_F_SSL23_GET_SERVER_HELLO 119 | 1453 | #define SSL_F_SSL23_GET_SERVER_HELLO 119 |
| 1454 | #define SSL_F_SSL23_PEEK 237 | ||
| 1181 | #define SSL_F_SSL23_READ 120 | 1455 | #define SSL_F_SSL23_READ 120 |
| 1182 | #define SSL_F_SSL23_WRITE 121 | 1456 | #define SSL_F_SSL23_WRITE 121 |
| 1183 | #define SSL_F_SSL2_ACCEPT 122 | 1457 | #define SSL_F_SSL2_ACCEPT 122 |
| 1184 | #define SSL_F_SSL2_CONNECT 123 | 1458 | #define SSL_F_SSL2_CONNECT 123 |
| 1185 | #define SSL_F_SSL2_ENC_INIT 124 | 1459 | #define SSL_F_SSL2_ENC_INIT 124 |
| 1460 | #define SSL_F_SSL2_PEEK 234 | ||
| 1186 | #define SSL_F_SSL2_READ 125 | 1461 | #define SSL_F_SSL2_READ 125 |
| 1462 | #define SSL_F_SSL2_READ_INTERNAL 236 | ||
| 1187 | #define SSL_F_SSL2_SET_CERTIFICATE 126 | 1463 | #define SSL_F_SSL2_SET_CERTIFICATE 126 |
| 1188 | #define SSL_F_SSL2_WRITE 127 | 1464 | #define SSL_F_SSL2_WRITE 127 |
| 1189 | #define SSL_F_SSL3_ACCEPT 128 | 1465 | #define SSL_F_SSL3_ACCEPT 128 |
| 1466 | #define SSL_F_SSL3_CALLBACK_CTRL 233 | ||
| 1190 | #define SSL_F_SSL3_CHANGE_CIPHER_STATE 129 | 1467 | #define SSL_F_SSL3_CHANGE_CIPHER_STATE 129 |
| 1191 | #define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM 130 | 1468 | #define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM 130 |
| 1192 | #define SSL_F_SSL3_CLIENT_HELLO 131 | 1469 | #define SSL_F_SSL3_CLIENT_HELLO 131 |
| 1193 | #define SSL_F_SSL3_CONNECT 132 | 1470 | #define SSL_F_SSL3_CONNECT 132 |
| 1471 | #define SSL_F_SSL3_CTRL 213 | ||
| 1194 | #define SSL_F_SSL3_CTX_CTRL 133 | 1472 | #define SSL_F_SSL3_CTX_CTRL 133 |
| 1195 | #define SSL_F_SSL3_ENC 134 | 1473 | #define SSL_F_SSL3_ENC 134 |
| 1474 | #define SSL_F_SSL3_GENERATE_KEY_BLOCK 238 | ||
| 1196 | #define SSL_F_SSL3_GET_CERTIFICATE_REQUEST 135 | 1475 | #define SSL_F_SSL3_GET_CERTIFICATE_REQUEST 135 |
| 1197 | #define SSL_F_SSL3_GET_CERT_VERIFY 136 | 1476 | #define SSL_F_SSL3_GET_CERT_VERIFY 136 |
| 1198 | #define SSL_F_SSL3_GET_CLIENT_CERTIFICATE 137 | 1477 | #define SSL_F_SSL3_GET_CLIENT_CERTIFICATE 137 |
| @@ -1206,6 +1485,7 @@ int SSL_CTX_get_ex_new_index(); | |||
| 1206 | #define SSL_F_SSL3_GET_SERVER_DONE 145 | 1485 | #define SSL_F_SSL3_GET_SERVER_DONE 145 |
| 1207 | #define SSL_F_SSL3_GET_SERVER_HELLO 146 | 1486 | #define SSL_F_SSL3_GET_SERVER_HELLO 146 |
| 1208 | #define SSL_F_SSL3_OUTPUT_CERT_CHAIN 147 | 1487 | #define SSL_F_SSL3_OUTPUT_CERT_CHAIN 147 |
| 1488 | #define SSL_F_SSL3_PEEK 235 | ||
| 1209 | #define SSL_F_SSL3_READ_BYTES 148 | 1489 | #define SSL_F_SSL3_READ_BYTES 148 |
| 1210 | #define SSL_F_SSL3_READ_N 149 | 1490 | #define SSL_F_SSL3_READ_N 149 |
| 1211 | #define SSL_F_SSL3_SEND_CERTIFICATE_REQUEST 150 | 1491 | #define SSL_F_SSL3_SEND_CERTIFICATE_REQUEST 150 |
| @@ -1218,63 +1498,85 @@ int SSL_CTX_get_ex_new_index(); | |||
| 1218 | #define SSL_F_SSL3_SETUP_KEY_BLOCK 157 | 1498 | #define SSL_F_SSL3_SETUP_KEY_BLOCK 157 |
| 1219 | #define SSL_F_SSL3_WRITE_BYTES 158 | 1499 | #define SSL_F_SSL3_WRITE_BYTES 158 |
| 1220 | #define SSL_F_SSL3_WRITE_PENDING 159 | 1500 | #define SSL_F_SSL3_WRITE_PENDING 159 |
| 1501 | #define SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK 215 | ||
| 1502 | #define SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK 216 | ||
| 1221 | #define SSL_F_SSL_BAD_METHOD 160 | 1503 | #define SSL_F_SSL_BAD_METHOD 160 |
| 1222 | #define SSL_F_SSL_BYTES_TO_CIPHER_LIST 161 | 1504 | #define SSL_F_SSL_BYTES_TO_CIPHER_LIST 161 |
| 1505 | #define SSL_F_SSL_CERT_DUP 221 | ||
| 1506 | #define SSL_F_SSL_CERT_INST 222 | ||
| 1507 | #define SSL_F_SSL_CERT_INSTANTIATE 214 | ||
| 1223 | #define SSL_F_SSL_CERT_NEW 162 | 1508 | #define SSL_F_SSL_CERT_NEW 162 |
| 1224 | #define SSL_F_SSL_CHECK_PRIVATE_KEY 163 | 1509 | #define SSL_F_SSL_CHECK_PRIVATE_KEY 163 |
| 1225 | #define SSL_F_SSL_CREATE_CIPHER_LIST 164 | 1510 | #define SSL_F_SSL_CIPHER_PROCESS_RULESTR 230 |
| 1226 | #define SSL_F_SSL_CTX_CHECK_PRIVATE_KEY 165 | 1511 | #define SSL_F_SSL_CIPHER_STRENGTH_SORT 231 |
| 1227 | #define SSL_F_SSL_CTX_NEW 166 | 1512 | #define SSL_F_SSL_CLEAR 164 |
| 1228 | #define SSL_F_SSL_CTX_SET_SSL_VERSION 167 | 1513 | #define SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD 165 |
| 1229 | #define SSL_F_SSL_CTX_USE_CERTIFICATE 168 | 1514 | #define SSL_F_SSL_CREATE_CIPHER_LIST 166 |
| 1230 | #define SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1 169 | 1515 | #define SSL_F_SSL_CTRL 232 |
| 1231 | #define SSL_F_SSL_CTX_USE_CERTIFICATE_FILE 170 | 1516 | #define SSL_F_SSL_CTX_CHECK_PRIVATE_KEY 168 |
| 1232 | #define SSL_F_SSL_CTX_USE_PRIVATEKEY 171 | 1517 | #define SSL_F_SSL_CTX_NEW 169 |
| 1233 | #define SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1 172 | 1518 | #define SSL_F_SSL_CTX_SET_PURPOSE 226 |
| 1234 | #define SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE 173 | 1519 | #define SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT 219 |
| 1235 | #define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY 174 | 1520 | #define SSL_F_SSL_CTX_SET_SSL_VERSION 170 |
| 1236 | #define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_ASN1 175 | 1521 | #define SSL_F_SSL_CTX_SET_TRUST 229 |
| 1237 | #define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE 176 | 1522 | #define SSL_F_SSL_CTX_USE_CERTIFICATE 171 |
| 1238 | #define SSL_F_SSL_DO_HANDSHAKE 177 | 1523 | #define SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1 172 |
| 1239 | #define SSL_F_SSL_GET_NEW_SESSION 178 | 1524 | #define SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE 220 |
| 1240 | #define SSL_F_SSL_GET_SERVER_SEND_CERT 179 | 1525 | #define SSL_F_SSL_CTX_USE_CERTIFICATE_FILE 173 |
| 1241 | #define SSL_F_SSL_GET_SIGN_PKEY 180 | 1526 | #define SSL_F_SSL_CTX_USE_PRIVATEKEY 174 |
| 1242 | #define SSL_F_SSL_INIT_WBIO_BUFFER 181 | 1527 | #define SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1 175 |
| 1243 | #define SSL_F_SSL_LOAD_CLIENT_CA_FILE 182 | 1528 | #define SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE 176 |
| 1244 | #define SSL_F_SSL_NEW 183 | 1529 | #define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY 177 |
| 1245 | #define SSL_F_SSL_RSA_PRIVATE_DECRYPT 184 | 1530 | #define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_ASN1 178 |
| 1246 | #define SSL_F_SSL_RSA_PUBLIC_ENCRYPT 185 | 1531 | #define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE 179 |
| 1247 | #define SSL_F_SSL_SESSION_NEW 186 | 1532 | #define SSL_F_SSL_DO_HANDSHAKE 180 |
| 1248 | #define SSL_F_SSL_SESSION_PRINT_FP 187 | 1533 | #define SSL_F_SSL_GET_NEW_SESSION 181 |
| 1249 | #define SSL_F_SSL_SET_CERT 188 | 1534 | #define SSL_F_SSL_GET_PREV_SESSION 217 |
| 1250 | #define SSL_F_SSL_SET_FD 189 | 1535 | #define SSL_F_SSL_GET_SERVER_SEND_CERT 182 |
| 1251 | #define SSL_F_SSL_SET_PKEY 190 | 1536 | #define SSL_F_SSL_GET_SIGN_PKEY 183 |
| 1252 | #define SSL_F_SSL_SET_RFD 191 | 1537 | #define SSL_F_SSL_INIT_WBIO_BUFFER 184 |
| 1253 | #define SSL_F_SSL_SET_SESSION 192 | 1538 | #define SSL_F_SSL_LOAD_CLIENT_CA_FILE 185 |
| 1254 | #define SSL_F_SSL_SET_WFD 193 | 1539 | #define SSL_F_SSL_NEW 186 |
| 1255 | #define SSL_F_SSL_UNDEFINED_FUNCTION 194 | 1540 | #define SSL_F_SSL_READ 223 |
| 1256 | #define SSL_F_SSL_USE_CERTIFICATE 195 | 1541 | #define SSL_F_SSL_RSA_PRIVATE_DECRYPT 187 |
| 1257 | #define SSL_F_SSL_USE_CERTIFICATE_ASN1 196 | 1542 | #define SSL_F_SSL_RSA_PUBLIC_ENCRYPT 188 |
| 1258 | #define SSL_F_SSL_USE_CERTIFICATE_FILE 197 | 1543 | #define SSL_F_SSL_SESSION_NEW 189 |
| 1259 | #define SSL_F_SSL_USE_PRIVATEKEY 198 | 1544 | #define SSL_F_SSL_SESSION_PRINT_FP 190 |
| 1260 | #define SSL_F_SSL_USE_PRIVATEKEY_ASN1 199 | 1545 | #define SSL_F_SSL_SESS_CERT_NEW 225 |
| 1261 | #define SSL_F_SSL_USE_PRIVATEKEY_FILE 200 | 1546 | #define SSL_F_SSL_SET_CERT 191 |
| 1262 | #define SSL_F_SSL_USE_RSAPRIVATEKEY 201 | 1547 | #define SSL_F_SSL_SET_FD 192 |
| 1263 | #define SSL_F_SSL_USE_RSAPRIVATEKEY_ASN1 202 | 1548 | #define SSL_F_SSL_SET_PKEY 193 |
| 1264 | #define SSL_F_SSL_USE_RSAPRIVATEKEY_FILE 203 | 1549 | #define SSL_F_SSL_SET_PURPOSE 227 |
| 1265 | #define SSL_F_SSL_WRITE 204 | 1550 | #define SSL_F_SSL_SET_RFD 194 |
| 1266 | #define SSL_F_TLS1_CHANGE_CIPHER_STATE 205 | 1551 | #define SSL_F_SSL_SET_SESSION 195 |
| 1267 | #define SSL_F_TLS1_ENC 206 | 1552 | #define SSL_F_SSL_SET_SESSION_ID_CONTEXT 218 |
| 1268 | #define SSL_F_TLS1_SETUP_KEY_BLOCK 207 | 1553 | #define SSL_F_SSL_SET_TRUST 228 |
| 1269 | #define SSL_F_WRITE_PENDING 208 | 1554 | #define SSL_F_SSL_SET_WFD 196 |
| 1555 | #define SSL_F_SSL_SHUTDOWN 224 | ||
| 1556 | #define SSL_F_SSL_UNDEFINED_FUNCTION 197 | ||
| 1557 | #define SSL_F_SSL_USE_CERTIFICATE 198 | ||
| 1558 | #define SSL_F_SSL_USE_CERTIFICATE_ASN1 199 | ||
| 1559 | #define SSL_F_SSL_USE_CERTIFICATE_FILE 200 | ||
| 1560 | #define SSL_F_SSL_USE_PRIVATEKEY 201 | ||
| 1561 | #define SSL_F_SSL_USE_PRIVATEKEY_ASN1 202 | ||
| 1562 | #define SSL_F_SSL_USE_PRIVATEKEY_FILE 203 | ||
| 1563 | #define SSL_F_SSL_USE_RSAPRIVATEKEY 204 | ||
| 1564 | #define SSL_F_SSL_USE_RSAPRIVATEKEY_ASN1 205 | ||
| 1565 | #define SSL_F_SSL_USE_RSAPRIVATEKEY_FILE 206 | ||
| 1566 | #define SSL_F_SSL_VERIFY_CERT_CHAIN 207 | ||
| 1567 | #define SSL_F_SSL_WRITE 208 | ||
| 1568 | #define SSL_F_TLS1_CHANGE_CIPHER_STATE 209 | ||
| 1569 | #define SSL_F_TLS1_ENC 210 | ||
| 1570 | #define SSL_F_TLS1_SETUP_KEY_BLOCK 211 | ||
| 1571 | #define SSL_F_WRITE_PENDING 212 | ||
| 1270 | 1572 | ||
| 1271 | /* Reason codes. */ | 1573 | /* Reason codes. */ |
| 1272 | #define SSL_R_APP_DATA_IN_HANDSHAKE 100 | 1574 | #define SSL_R_APP_DATA_IN_HANDSHAKE 100 |
| 1575 | #define SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT 272 | ||
| 1273 | #define SSL_R_BAD_ALERT_RECORD 101 | 1576 | #define SSL_R_BAD_ALERT_RECORD 101 |
| 1274 | #define SSL_R_BAD_AUTHENTICATION_TYPE 102 | 1577 | #define SSL_R_BAD_AUTHENTICATION_TYPE 102 |
| 1275 | #define SSL_R_BAD_CHANGE_CIPHER_SPEC 103 | 1578 | #define SSL_R_BAD_CHANGE_CIPHER_SPEC 103 |
| 1276 | #define SSL_R_BAD_CHECKSUM 104 | 1579 | #define SSL_R_BAD_CHECKSUM 104 |
| 1277 | #define SSL_R_BAD_CLIENT_REQUEST 105 | ||
| 1278 | #define SSL_R_BAD_DATA_RETURNED_BY_CALLBACK 106 | 1580 | #define SSL_R_BAD_DATA_RETURNED_BY_CALLBACK 106 |
| 1279 | #define SSL_R_BAD_DECOMPRESSION 107 | 1581 | #define SSL_R_BAD_DECOMPRESSION 107 |
| 1280 | #define SSL_R_BAD_DH_G_LENGTH 108 | 1582 | #define SSL_R_BAD_DH_G_LENGTH 108 |
| @@ -1282,6 +1584,8 @@ int SSL_CTX_get_ex_new_index(); | |||
| 1282 | #define SSL_R_BAD_DH_P_LENGTH 110 | 1584 | #define SSL_R_BAD_DH_P_LENGTH 110 |
| 1283 | #define SSL_R_BAD_DIGEST_LENGTH 111 | 1585 | #define SSL_R_BAD_DIGEST_LENGTH 111 |
| 1284 | #define SSL_R_BAD_DSA_SIGNATURE 112 | 1586 | #define SSL_R_BAD_DSA_SIGNATURE 112 |
| 1587 | #define SSL_R_BAD_HELLO_REQUEST 105 | ||
| 1588 | #define SSL_R_BAD_LENGTH 271 | ||
| 1285 | #define SSL_R_BAD_MAC_DECODE 113 | 1589 | #define SSL_R_BAD_MAC_DECODE 113 |
| 1286 | #define SSL_R_BAD_MESSAGE_TYPE 114 | 1590 | #define SSL_R_BAD_MESSAGE_TYPE 114 |
| 1287 | #define SSL_R_BAD_PACKET_LENGTH 115 | 1591 | #define SSL_R_BAD_PACKET_LENGTH 115 |
| @@ -1311,83 +1615,108 @@ int SSL_CTX_get_ex_new_index(); | |||
| 1311 | #define SSL_R_CIPHER_TABLE_SRC_ERROR 139 | 1615 | #define SSL_R_CIPHER_TABLE_SRC_ERROR 139 |
| 1312 | #define SSL_R_COMPRESSED_LENGTH_TOO_LONG 140 | 1616 | #define SSL_R_COMPRESSED_LENGTH_TOO_LONG 140 |
| 1313 | #define SSL_R_COMPRESSION_FAILURE 141 | 1617 | #define SSL_R_COMPRESSION_FAILURE 141 |
| 1314 | #define SSL_R_CONNECTION_ID_IS_DIFFERENT 142 | 1618 | #define SSL_R_COMPRESSION_LIBRARY_ERROR 142 |
| 1315 | #define SSL_R_CONNECTION_TYPE_NOT_SET 143 | 1619 | #define SSL_R_CONNECTION_ID_IS_DIFFERENT 143 |
| 1316 | #define SSL_R_DATA_BETWEEN_CCS_AND_FINISHED 144 | 1620 | #define SSL_R_CONNECTION_TYPE_NOT_SET 144 |
| 1317 | #define SSL_R_DATA_LENGTH_TOO_LONG 145 | 1621 | #define SSL_R_DATA_BETWEEN_CCS_AND_FINISHED 145 |
| 1318 | #define SSL_R_DECRYPTION_FAILED 146 | 1622 | #define SSL_R_DATA_LENGTH_TOO_LONG 146 |
| 1319 | #define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG 147 | 1623 | #define SSL_R_DECRYPTION_FAILED 147 |
| 1320 | #define SSL_R_DIGEST_CHECK_FAILED 148 | 1624 | #define SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC 1109 |
| 1321 | #define SSL_R_ENCRYPTED_LENGTH_TOO_LONG 149 | 1625 | #define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG 148 |
| 1322 | #define SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST 150 | 1626 | #define SSL_R_DIGEST_CHECK_FAILED 149 |
| 1323 | #define SSL_R_EXCESSIVE_MESSAGE_SIZE 151 | 1627 | #define SSL_R_ENCRYPTED_LENGTH_TOO_LONG 150 |
| 1324 | #define SSL_R_EXTRA_DATA_IN_MESSAGE 152 | 1628 | #define SSL_R_ERROR_GENERATING_TMP_RSA_KEY 1092 |
| 1325 | #define SSL_R_GOT_A_FIN_BEFORE_A_CCS 153 | 1629 | #define SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST 151 |
| 1326 | #define SSL_R_HTTPS_PROXY_REQUEST 154 | 1630 | #define SSL_R_EXCESSIVE_MESSAGE_SIZE 152 |
| 1327 | #define SSL_R_HTTP_REQUEST 155 | 1631 | #define SSL_R_EXTRA_DATA_IN_MESSAGE 153 |
| 1328 | #define SSL_R_INTERNAL_ERROR 156 | 1632 | #define SSL_R_GOT_A_FIN_BEFORE_A_CCS 154 |
| 1329 | #define SSL_R_INVALID_CHALLENGE_LENGTH 157 | 1633 | #define SSL_R_HTTPS_PROXY_REQUEST 155 |
| 1330 | #define SSL_R_LENGTH_MISMATCH 158 | 1634 | #define SSL_R_HTTP_REQUEST 156 |
| 1331 | #define SSL_R_LENGTH_TOO_SHORT 159 | 1635 | #define SSL_R_ILLEGAL_PADDING 1110 |
| 1332 | #define SSL_R_LIBRARY_HAS_NO_CIPHERS 160 | 1636 | #define SSL_R_INVALID_CHALLENGE_LENGTH 158 |
| 1333 | #define SSL_R_MISSING_DH_DSA_CERT 161 | 1637 | #define SSL_R_INVALID_COMMAND 280 |
| 1334 | #define SSL_R_MISSING_DH_KEY 162 | 1638 | #define SSL_R_INVALID_PURPOSE 278 |
| 1335 | #define SSL_R_MISSING_DH_RSA_CERT 163 | 1639 | #define SSL_R_INVALID_TRUST 279 |
| 1336 | #define SSL_R_MISSING_DSA_SIGNING_CERT 164 | 1640 | #define SSL_R_KRB5 1104 |
| 1337 | #define SSL_R_MISSING_EXPORT_TMP_DH_KEY 165 | 1641 | #define SSL_R_KRB5_C_CC_PRINC 1094 |
| 1338 | #define SSL_R_MISSING_EXPORT_TMP_RSA_KEY 166 | 1642 | #define SSL_R_KRB5_C_GET_CRED 1095 |
| 1339 | #define SSL_R_MISSING_RSA_CERTIFICATE 167 | 1643 | #define SSL_R_KRB5_C_INIT 1096 |
| 1340 | #define SSL_R_MISSING_RSA_ENCRYPTING_CERT 168 | 1644 | #define SSL_R_KRB5_C_MK_REQ 1097 |
| 1341 | #define SSL_R_MISSING_RSA_SIGNING_CERT 169 | 1645 | #define SSL_R_KRB5_S_BAD_TICKET 1098 |
| 1342 | #define SSL_R_MISSING_TMP_DH_KEY 170 | 1646 | #define SSL_R_KRB5_S_INIT 1099 |
| 1343 | #define SSL_R_MISSING_TMP_RSA_KEY 171 | 1647 | #define SSL_R_KRB5_S_RD_REQ 1108 |
| 1344 | #define SSL_R_MISSING_TMP_RSA_PKEY 172 | 1648 | #define SSL_R_KRB5_S_TKT_EXPIRED 1105 |
| 1345 | #define SSL_R_MISSING_VERIFY_MESSAGE 173 | 1649 | #define SSL_R_KRB5_S_TKT_NYV 1106 |
| 1346 | #define SSL_R_NON_SSLV2_INITIAL_PACKET 174 | 1650 | #define SSL_R_KRB5_S_TKT_SKEW 1107 |
| 1347 | #define SSL_R_NO_CERTIFICATES_RETURNED 175 | 1651 | #define SSL_R_LENGTH_MISMATCH 159 |
| 1348 | #define SSL_R_NO_CERTIFICATE_ASSIGNED 176 | 1652 | #define SSL_R_LENGTH_TOO_SHORT 160 |
| 1349 | #define SSL_R_NO_CERTIFICATE_RETURNED 177 | 1653 | #define SSL_R_LIBRARY_BUG 274 |
| 1350 | #define SSL_R_NO_CERTIFICATE_SET 178 | 1654 | #define SSL_R_LIBRARY_HAS_NO_CIPHERS 161 |
| 1351 | #define SSL_R_NO_CERTIFICATE_SPECIFIED 179 | 1655 | #define SSL_R_MESSAGE_TOO_LONG 1111 |
| 1352 | #define SSL_R_NO_CIPHERS_AVAILABLE 180 | 1656 | #define SSL_R_MISSING_DH_DSA_CERT 162 |
| 1353 | #define SSL_R_NO_CIPHERS_PASSED 181 | 1657 | #define SSL_R_MISSING_DH_KEY 163 |
| 1354 | #define SSL_R_NO_CIPHERS_SPECIFIED 182 | 1658 | #define SSL_R_MISSING_DH_RSA_CERT 164 |
| 1355 | #define SSL_R_NO_CIPHER_LIST 183 | 1659 | #define SSL_R_MISSING_DSA_SIGNING_CERT 165 |
| 1356 | #define SSL_R_NO_CIPHER_MATCH 184 | 1660 | #define SSL_R_MISSING_EXPORT_TMP_DH_KEY 166 |
| 1357 | #define SSL_R_NO_CLIENT_CERT_RECEIVED 185 | 1661 | #define SSL_R_MISSING_EXPORT_TMP_RSA_KEY 167 |
| 1358 | #define SSL_R_NO_COMPRESSION_SPECIFIED 186 | 1662 | #define SSL_R_MISSING_RSA_CERTIFICATE 168 |
| 1359 | #define SSL_R_NO_PRIVATEKEY 187 | 1663 | #define SSL_R_MISSING_RSA_ENCRYPTING_CERT 169 |
| 1360 | #define SSL_R_NO_PRIVATE_KEY_ASSIGNED 188 | 1664 | #define SSL_R_MISSING_RSA_SIGNING_CERT 170 |
| 1361 | #define SSL_R_NO_PROTOCOLS_AVAILABLE 189 | 1665 | #define SSL_R_MISSING_TMP_DH_KEY 171 |
| 1362 | #define SSL_R_NO_PUBLICKEY 190 | 1666 | #define SSL_R_MISSING_TMP_RSA_KEY 172 |
| 1363 | #define SSL_R_NO_SHARED_CIPHER 191 | 1667 | #define SSL_R_MISSING_TMP_RSA_PKEY 173 |
| 1364 | #define SSL_R_NULL_SSL_CTX 192 | 1668 | #define SSL_R_MISSING_VERIFY_MESSAGE 174 |
| 1365 | #define SSL_R_NULL_SSL_METHOD_PASSED 193 | 1669 | #define SSL_R_NON_SSLV2_INITIAL_PACKET 175 |
| 1366 | #define SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED 194 | 1670 | #define SSL_R_NO_CERTIFICATES_RETURNED 176 |
| 1367 | #define SSL_R_PACKET_LENGTH_TOO_LONG 195 | 1671 | #define SSL_R_NO_CERTIFICATE_ASSIGNED 177 |
| 1368 | #define SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE 196 | 1672 | #define SSL_R_NO_CERTIFICATE_RETURNED 178 |
| 1369 | #define SSL_R_PEER_ERROR 197 | 1673 | #define SSL_R_NO_CERTIFICATE_SET 179 |
| 1370 | #define SSL_R_PEER_ERROR_CERTIFICATE 198 | 1674 | #define SSL_R_NO_CERTIFICATE_SPECIFIED 180 |
| 1371 | #define SSL_R_PEER_ERROR_NO_CERTIFICATE 199 | 1675 | #define SSL_R_NO_CIPHERS_AVAILABLE 181 |
| 1372 | #define SSL_R_PEER_ERROR_NO_CIPHER 200 | 1676 | #define SSL_R_NO_CIPHERS_PASSED 182 |
| 1373 | #define SSL_R_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE 201 | 1677 | #define SSL_R_NO_CIPHERS_SPECIFIED 183 |
| 1374 | #define SSL_R_PRE_MAC_LENGTH_TOO_LONG 202 | 1678 | #define SSL_R_NO_CIPHER_LIST 184 |
| 1375 | #define SSL_R_PROBLEMS_MAPPING_CIPHER_FUNCTIONS 203 | 1679 | #define SSL_R_NO_CIPHER_MATCH 185 |
| 1376 | #define SSL_R_PROTOCOL_IS_SHUTDOWN 204 | 1680 | #define SSL_R_NO_CLIENT_CERT_RECEIVED 186 |
| 1377 | #define SSL_R_PUBLIC_KEY_ENCRYPT_ERROR 205 | 1681 | #define SSL_R_NO_COMPRESSION_SPECIFIED 187 |
| 1378 | #define SSL_R_PUBLIC_KEY_IS_NOT_RSA 206 | 1682 | #define SSL_R_NO_METHOD_SPECIFIED 188 |
| 1379 | #define SSL_R_PUBLIC_KEY_NOT_RSA 207 | 1683 | #define SSL_R_NO_PRIVATEKEY 189 |
| 1380 | #define SSL_R_READ_BIO_NOT_SET 208 | 1684 | #define SSL_R_NO_PRIVATE_KEY_ASSIGNED 190 |
| 1381 | #define SSL_R_READ_WRONG_PACKET_TYPE 209 | 1685 | #define SSL_R_NO_PROTOCOLS_AVAILABLE 191 |
| 1382 | #define SSL_R_RECORD_LENGTH_MISMATCH 210 | 1686 | #define SSL_R_NO_PUBLICKEY 192 |
| 1383 | #define SSL_R_RECORD_TOO_LARGE 211 | 1687 | #define SSL_R_NO_SHARED_CIPHER 193 |
| 1384 | #define SSL_R_REQUIRED_CIPHER_MISSING 212 | 1688 | #define SSL_R_NO_VERIFY_CALLBACK 194 |
| 1385 | #define SSL_R_REUSE_CERT_LENGTH_NOT_ZERO 213 | 1689 | #define SSL_R_NULL_SSL_CTX 195 |
| 1386 | #define SSL_R_REUSE_CERT_TYPE_NOT_ZERO 214 | 1690 | #define SSL_R_NULL_SSL_METHOD_PASSED 196 |
| 1387 | #define SSL_R_REUSE_CIPHER_LIST_NOT_ZERO 215 | 1691 | #define SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED 197 |
| 1388 | #define SSL_R_SHORT_READ 216 | 1692 | #define SSL_R_PACKET_LENGTH_TOO_LONG 198 |
| 1389 | #define SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE 217 | 1693 | #define SSL_R_PATH_TOO_LONG 270 |
| 1390 | #define SSL_R_SSL3_SESSION_ID_TOO_SHORT 218 | 1694 | #define SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE 199 |
| 1695 | #define SSL_R_PEER_ERROR 200 | ||
| 1696 | #define SSL_R_PEER_ERROR_CERTIFICATE 201 | ||
| 1697 | #define SSL_R_PEER_ERROR_NO_CERTIFICATE 202 | ||
| 1698 | #define SSL_R_PEER_ERROR_NO_CIPHER 203 | ||
| 1699 | #define SSL_R_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE 204 | ||
| 1700 | #define SSL_R_PRE_MAC_LENGTH_TOO_LONG 205 | ||
| 1701 | #define SSL_R_PROBLEMS_MAPPING_CIPHER_FUNCTIONS 206 | ||
| 1702 | #define SSL_R_PROTOCOL_IS_SHUTDOWN 207 | ||
| 1703 | #define SSL_R_PUBLIC_KEY_ENCRYPT_ERROR 208 | ||
| 1704 | #define SSL_R_PUBLIC_KEY_IS_NOT_RSA 209 | ||
| 1705 | #define SSL_R_PUBLIC_KEY_NOT_RSA 210 | ||
| 1706 | #define SSL_R_READ_BIO_NOT_SET 211 | ||
| 1707 | #define SSL_R_READ_WRONG_PACKET_TYPE 212 | ||
| 1708 | #define SSL_R_RECORD_LENGTH_MISMATCH 213 | ||
| 1709 | #define SSL_R_RECORD_TOO_LARGE 214 | ||
| 1710 | #define SSL_R_RECORD_TOO_SMALL 1093 | ||
| 1711 | #define SSL_R_REQUIRED_CIPHER_MISSING 215 | ||
| 1712 | #define SSL_R_REUSE_CERT_LENGTH_NOT_ZERO 216 | ||
| 1713 | #define SSL_R_REUSE_CERT_TYPE_NOT_ZERO 217 | ||
| 1714 | #define SSL_R_REUSE_CIPHER_LIST_NOT_ZERO 218 | ||
| 1715 | #define SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED 277 | ||
| 1716 | #define SSL_R_SHORT_READ 219 | ||
| 1717 | #define SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE 220 | ||
| 1718 | #define SSL_R_SSL23_DOING_SESSION_ID_REUSE 221 | ||
| 1719 | #define SSL_R_SSL3_SESSION_ID_TOO_SHORT 222 | ||
| 1391 | #define SSL_R_SSLV3_ALERT_BAD_CERTIFICATE 1042 | 1720 | #define SSL_R_SSLV3_ALERT_BAD_CERTIFICATE 1042 |
| 1392 | #define SSL_R_SSLV3_ALERT_BAD_RECORD_MAC 1020 | 1721 | #define SSL_R_SSLV3_ALERT_BAD_RECORD_MAC 1020 |
| 1393 | #define SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED 1045 | 1722 | #define SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED 1045 |
| @@ -1397,57 +1726,75 @@ int SSL_CTX_get_ex_new_index(); | |||
| 1397 | #define SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE 1040 | 1726 | #define SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE 1040 |
| 1398 | #define SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER 1047 | 1727 | #define SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER 1047 |
| 1399 | #define SSL_R_SSLV3_ALERT_NO_CERTIFICATE 1041 | 1728 | #define SSL_R_SSLV3_ALERT_NO_CERTIFICATE 1041 |
| 1400 | #define SSL_R_SSLV3_ALERT_PEER_ERROR_CERTIFICATE 219 | 1729 | #define SSL_R_SSLV3_ALERT_PEER_ERROR_CERTIFICATE 223 |
| 1401 | #define SSL_R_SSLV3_ALERT_PEER_ERROR_NO_CERTIFICATE 220 | 1730 | #define SSL_R_SSLV3_ALERT_PEER_ERROR_NO_CERTIFICATE 224 |
| 1402 | #define SSL_R_SSLV3_ALERT_PEER_ERROR_NO_CIPHER 221 | 1731 | #define SSL_R_SSLV3_ALERT_PEER_ERROR_NO_CIPHER 225 |
| 1403 | #define SSL_R_SSLV3_ALERT_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE 222 | 1732 | #define SSL_R_SSLV3_ALERT_PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE 226 |
| 1404 | #define SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE 1010 | 1733 | #define SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE 1010 |
| 1405 | #define SSL_R_SSLV3_ALERT_UNKNOWN_REMOTE_ERROR_TYPE 223 | 1734 | #define SSL_R_SSLV3_ALERT_UNKNOWN_REMOTE_ERROR_TYPE 227 |
| 1406 | #define SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE 1043 | 1735 | #define SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE 1043 |
| 1407 | #define SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION 224 | 1736 | #define SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION 228 |
| 1408 | #define SSL_R_SSL_HANDSHAKE_FAILURE 225 | 1737 | #define SSL_R_SSL_HANDSHAKE_FAILURE 229 |
| 1409 | #define SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS 226 | 1738 | #define SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS 230 |
| 1410 | #define SSL_R_SSL_SESSION_ID_IS_DIFFERENT 227 | 1739 | #define SSL_R_SSL_SESSION_ID_CALLBACK_FAILED 1102 |
| 1411 | #define SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER 228 | 1740 | #define SSL_R_SSL_SESSION_ID_CONFLICT 1103 |
| 1412 | #define SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST 229 | 1741 | #define SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG 273 |
| 1413 | #define SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG 230 | 1742 | #define SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH 1101 |
| 1414 | #define SSL_R_TRIED_TO_USE_UNSUPPORTED_CIPHER 231 | 1743 | #define SSL_R_SSL_SESSION_ID_IS_DIFFERENT 231 |
| 1415 | #define SSL_R_UNABLE_TO_DECODE_DH_CERTS 232 | 1744 | #define SSL_R_TLSV1_ALERT_ACCESS_DENIED 1049 |
| 1416 | #define SSL_R_UNABLE_TO_EXTRACT_PUBLIC_KEY 233 | 1745 | #define SSL_R_TLSV1_ALERT_DECODE_ERROR 1050 |
| 1417 | #define SSL_R_UNABLE_TO_FIND_DH_PARAMETERS 234 | 1746 | #define SSL_R_TLSV1_ALERT_DECRYPTION_FAILED 1021 |
| 1418 | #define SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS 235 | 1747 | #define SSL_R_TLSV1_ALERT_DECRYPT_ERROR 1051 |
| 1419 | #define SSL_R_UNABLE_TO_FIND_SSL_METHOD 236 | 1748 | #define SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION 1060 |
| 1420 | #define SSL_R_UNABLE_TO_LOAD_SSL2_MD5_ROUTINES 237 | 1749 | #define SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071 |
| 1421 | #define SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES 238 | 1750 | #define SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080 |
| 1422 | #define SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES 239 | 1751 | #define SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100 |
| 1423 | #define SSL_R_UNEXPECTED_MESSAGE 240 | 1752 | #define SSL_R_TLSV1_ALERT_PROTOCOL_VERSION 1070 |
| 1424 | #define SSL_R_UNEXPECTED_RECORD 241 | 1753 | #define SSL_R_TLSV1_ALERT_RECORD_OVERFLOW 1022 |
| 1425 | #define SSL_R_UNKNOWN_ALERT_TYPE 242 | 1754 | #define SSL_R_TLSV1_ALERT_UNKNOWN_CA 1048 |
| 1426 | #define SSL_R_UNKNOWN_CERTIFICATE_TYPE 243 | 1755 | #define SSL_R_TLSV1_ALERT_USER_CANCELLED 1090 |
| 1427 | #define SSL_R_UNKNOWN_CIPHER_RETURNED 244 | 1756 | #define SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER 232 |
| 1428 | #define SSL_R_UNKNOWN_CIPHER_TYPE 245 | 1757 | #define SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST 233 |
| 1429 | #define SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE 246 | 1758 | #define SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG 234 |
| 1430 | #define SSL_R_UNKNOWN_PKEY_TYPE 247 | 1759 | #define SSL_R_TRIED_TO_USE_UNSUPPORTED_CIPHER 235 |
| 1431 | #define SSL_R_UNKNOWN_PROTOCOL 248 | 1760 | #define SSL_R_UNABLE_TO_DECODE_DH_CERTS 236 |
| 1432 | #define SSL_R_UNKNOWN_REMOTE_ERROR_TYPE 249 | 1761 | #define SSL_R_UNABLE_TO_EXTRACT_PUBLIC_KEY 237 |
| 1433 | #define SSL_R_UNKNOWN_SSL_VERSION 250 | 1762 | #define SSL_R_UNABLE_TO_FIND_DH_PARAMETERS 238 |
| 1434 | #define SSL_R_UNKNOWN_STATE 251 | 1763 | #define SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS 239 |
| 1435 | #define SSL_R_UNSUPPORTED_CIPHER 252 | 1764 | #define SSL_R_UNABLE_TO_FIND_SSL_METHOD 240 |
| 1436 | #define SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM 253 | 1765 | #define SSL_R_UNABLE_TO_LOAD_SSL2_MD5_ROUTINES 241 |
| 1437 | #define SSL_R_UNSUPPORTED_PROTOCOL 254 | 1766 | #define SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES 242 |
| 1438 | #define SSL_R_UNSUPPORTED_SSL_VERSION 255 | 1767 | #define SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES 243 |
| 1439 | #define SSL_R_WRITE_BIO_NOT_SET 256 | 1768 | #define SSL_R_UNEXPECTED_MESSAGE 244 |
| 1440 | #define SSL_R_WRONG_CIPHER_RETURNED 257 | 1769 | #define SSL_R_UNEXPECTED_RECORD 245 |
| 1441 | #define SSL_R_WRONG_MESSAGE_TYPE 258 | 1770 | #define SSL_R_UNINITIALIZED 276 |
| 1442 | #define SSL_R_WRONG_NUMBER_OF_KEY_BITS 259 | 1771 | #define SSL_R_UNKNOWN_ALERT_TYPE 246 |
| 1443 | #define SSL_R_WRONG_SIGNATURE_LENGTH 260 | 1772 | #define SSL_R_UNKNOWN_CERTIFICATE_TYPE 247 |
| 1444 | #define SSL_R_WRONG_SIGNATURE_SIZE 261 | 1773 | #define SSL_R_UNKNOWN_CIPHER_RETURNED 248 |
| 1445 | #define SSL_R_WRONG_SSL_VERSION 262 | 1774 | #define SSL_R_UNKNOWN_CIPHER_TYPE 249 |
| 1446 | #define SSL_R_WRONG_VERSION_NUMBER 263 | 1775 | #define SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE 250 |
| 1447 | #define SSL_R_X509_LIB 264 | 1776 | #define SSL_R_UNKNOWN_PKEY_TYPE 251 |
| 1448 | 1777 | #define SSL_R_UNKNOWN_PROTOCOL 252 | |
| 1778 | #define SSL_R_UNKNOWN_REMOTE_ERROR_TYPE 253 | ||
| 1779 | #define SSL_R_UNKNOWN_SSL_VERSION 254 | ||
| 1780 | #define SSL_R_UNKNOWN_STATE 255 | ||
| 1781 | #define SSL_R_UNSUPPORTED_CIPHER 256 | ||
| 1782 | #define SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM 257 | ||
| 1783 | #define SSL_R_UNSUPPORTED_OPTION 1091 | ||
| 1784 | #define SSL_R_UNSUPPORTED_PROTOCOL 258 | ||
| 1785 | #define SSL_R_UNSUPPORTED_SSL_VERSION 259 | ||
| 1786 | #define SSL_R_WRITE_BIO_NOT_SET 260 | ||
| 1787 | #define SSL_R_WRONG_CIPHER_RETURNED 261 | ||
| 1788 | #define SSL_R_WRONG_MESSAGE_TYPE 262 | ||
| 1789 | #define SSL_R_WRONG_NUMBER_OF_KEY_BITS 263 | ||
| 1790 | #define SSL_R_WRONG_SIGNATURE_LENGTH 264 | ||
| 1791 | #define SSL_R_WRONG_SIGNATURE_SIZE 265 | ||
| 1792 | #define SSL_R_WRONG_SSL_VERSION 266 | ||
| 1793 | #define SSL_R_WRONG_VERSION_NUMBER 267 | ||
| 1794 | #define SSL_R_X509_LIB 268 | ||
| 1795 | #define SSL_R_X509_VERIFICATION_SETUP_PROBLEMS 269 | ||
| 1796 | |||
| 1449 | #ifdef __cplusplus | 1797 | #ifdef __cplusplus |
| 1450 | } | 1798 | } |
| 1451 | #endif | 1799 | #endif |
| 1452 | #endif | 1800 | #endif |
| 1453 | |||
diff --git a/src/lib/libssl/ssl2.h b/src/lib/libssl/ssl2.h index 3dc94e520b..99a52ea0dd 100644 --- a/src/lib/libssl/ssl2.h +++ b/src/lib/libssl/ssl2.h | |||
| @@ -67,8 +67,8 @@ extern "C" { | |||
| 67 | #define SSL2_VERSION 0x0002 | 67 | #define SSL2_VERSION 0x0002 |
| 68 | #define SSL2_VERSION_MAJOR 0x00 | 68 | #define SSL2_VERSION_MAJOR 0x00 |
| 69 | #define SSL2_VERSION_MINOR 0x02 | 69 | #define SSL2_VERSION_MINOR 0x02 |
| 70 | #define SSL2_CLIENT_VERSION 0x0002 | 70 | /* #define SSL2_CLIENT_VERSION 0x0002 */ |
| 71 | #define SSL2_SERVER_VERSION 0x0002 | 71 | /* #define SSL2_SERVER_VERSION 0x0002 */ |
| 72 | 72 | ||
| 73 | /* Protocol Message Codes */ | 73 | /* Protocol Message Codes */ |
| 74 | #define SSL2_MT_ERROR 0 | 74 | #define SSL2_MT_ERROR 0 |
| @@ -133,8 +133,12 @@ extern "C" { | |||
| 133 | 133 | ||
| 134 | /* Upper/Lower Bounds */ | 134 | /* Upper/Lower Bounds */ |
| 135 | #define SSL2_MAX_MASTER_KEY_LENGTH_IN_BITS 256 | 135 | #define SSL2_MAX_MASTER_KEY_LENGTH_IN_BITS 256 |
| 136 | #define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER (unsigned int)32767 | 136 | #ifdef OPENSSL_SYS_MPE |
| 137 | #define SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER 16383 /**/ | 137 | #define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER 29998u |
| 138 | #else | ||
| 139 | #define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER 32767u /* 2^15-1 */ | ||
| 140 | #endif | ||
| 141 | #define SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER 16383 /* 2^14-1 */ | ||
| 138 | 142 | ||
| 139 | #define SSL2_CHALLENGE_LENGTH 16 | 143 | #define SSL2_CHALLENGE_LENGTH 16 |
| 140 | /*#define SSL2_CHALLENGE_LENGTH 32 */ | 144 | /*#define SSL2_CHALLENGE_LENGTH 32 */ |
| @@ -151,7 +155,7 @@ extern "C" { | |||
| 151 | #define CERT char | 155 | #define CERT char |
| 152 | #endif | 156 | #endif |
| 153 | 157 | ||
| 154 | typedef struct ssl2_ctx_st | 158 | typedef struct ssl2_state_st |
| 155 | { | 159 | { |
| 156 | int three_byte_header; | 160 | int three_byte_header; |
| 157 | int clear_text; /* clear text */ | 161 | int clear_text; /* clear text */ |
| @@ -162,7 +166,7 @@ typedef struct ssl2_ctx_st | |||
| 162 | * args were passwd */ | 166 | * args were passwd */ |
| 163 | unsigned int wnum; /* number of bytes sent so far */ | 167 | unsigned int wnum; /* number of bytes sent so far */ |
| 164 | int wpend_tot; | 168 | int wpend_tot; |
| 165 | char *wpend_buf; | 169 | const unsigned char *wpend_buf; |
| 166 | 170 | ||
| 167 | int wpend_off; /* offset to data to write */ | 171 | int wpend_off; /* offset to data to write */ |
| 168 | int wpend_len; /* number of bytes passwd to write */ | 172 | int wpend_len; /* number of bytes passwd to write */ |
| @@ -185,7 +189,6 @@ typedef struct ssl2_ctx_st | |||
| 185 | unsigned char *ract_data; | 189 | unsigned char *ract_data; |
| 186 | unsigned char *wact_data; | 190 | unsigned char *wact_data; |
| 187 | unsigned char *mac_data; | 191 | unsigned char *mac_data; |
| 188 | unsigned char *pad_data; | ||
| 189 | 192 | ||
| 190 | unsigned char *read_key; | 193 | unsigned char *read_key; |
| 191 | unsigned char *write_key; | 194 | unsigned char *write_key; |
| @@ -205,16 +208,16 @@ typedef struct ssl2_ctx_st | |||
| 205 | unsigned int conn_id_length; | 208 | unsigned int conn_id_length; |
| 206 | unsigned int cert_type; | 209 | unsigned int cert_type; |
| 207 | unsigned int cert_length; | 210 | unsigned int cert_length; |
| 208 | int csl; | 211 | unsigned int csl; |
| 209 | int clear; | 212 | unsigned int clear; |
| 210 | unsigned int enc; | 213 | unsigned int enc; |
| 211 | unsigned char ccl[SSL2_MAX_CERT_CHALLENGE_LENGTH]; | 214 | unsigned char ccl[SSL2_MAX_CERT_CHALLENGE_LENGTH]; |
| 212 | int cipher_spec_length; | 215 | unsigned int cipher_spec_length; |
| 213 | unsigned int session_id_length; | 216 | unsigned int session_id_length; |
| 214 | unsigned int clen; | 217 | unsigned int clen; |
| 215 | unsigned int rlen; | 218 | unsigned int rlen; |
| 216 | } tmp; | 219 | } tmp; |
| 217 | } SSL2_CTX; | 220 | } SSL2_STATE; |
| 218 | 221 | ||
| 219 | /* SSLv2 */ | 222 | /* SSLv2 */ |
| 220 | /* client */ | 223 | /* client */ |
diff --git a/src/lib/libssl/ssl3.h b/src/lib/libssl/ssl3.h index 95772eef60..8fd6951d77 100644 --- a/src/lib/libssl/ssl3.h +++ b/src/lib/libssl/ssl3.h | |||
| @@ -55,11 +55,69 @@ | |||
| 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 | ||
| 59 | #ifndef HEADER_SSL3_H | 112 | #ifndef HEADER_SSL3_H |
| 60 | #define HEADER_SSL3_H | 113 | #define HEADER_SSL3_H |
| 61 | 114 | ||
| 62 | #include "buffer.h" | 115 | #ifndef OPENSSL_NO_COMP |
| 116 | #include <openssl/comp.h> | ||
| 117 | #endif | ||
| 118 | #include <openssl/buffer.h> | ||
| 119 | #include <openssl/evp.h> | ||
| 120 | #include <openssl/ssl.h> | ||
| 63 | 121 | ||
| 64 | #ifdef __cplusplus | 122 | #ifdef __cplusplus |
| 65 | extern "C" { | 123 | extern "C" { |
| @@ -100,6 +158,22 @@ extern "C" { | |||
| 100 | #define SSL3_CK_FZA_DMS_FZA_SHA 0x0300001D | 158 | #define SSL3_CK_FZA_DMS_FZA_SHA 0x0300001D |
| 101 | #define SSL3_CK_FZA_DMS_RC4_SHA 0x0300001E | 159 | #define SSL3_CK_FZA_DMS_RC4_SHA 0x0300001E |
| 102 | 160 | ||
| 161 | /* VRS Additional Kerberos5 entries | ||
| 162 | */ | ||
| 163 | #define SSL3_CK_KRB5_DES_40_CBC_SHA 0x03000021 | ||
| 164 | #define SSL3_CK_KRB5_DES_40_CBC_MD5 0x03000022 | ||
| 165 | #define SSL3_CK_KRB5_DES_64_CBC_SHA 0x03000023 | ||
| 166 | #define SSL3_CK_KRB5_DES_64_CBC_MD5 0x03000024 | ||
| 167 | #define SSL3_CK_KRB5_DES_192_CBC3_SHA 0x03000025 | ||
| 168 | #define SSL3_CK_KRB5_DES_192_CBC3_MD5 0x03000026 | ||
| 169 | |||
| 170 | #define SSL3_TXT_KRB5_DES_40_CBC_SHA "EXP-KRB5-DES-CBC-SHA" | ||
| 171 | #define SSL3_TXT_KRB5_DES_40_CBC_MD5 "EXP-KRB5-DES-CBC-MD5" | ||
| 172 | #define SSL3_TXT_KRB5_DES_64_CBC_SHA "KRB5-DES-CBC-SHA" | ||
| 173 | #define SSL3_TXT_KRB5_DES_64_CBC_MD5 "KRB5-DES-CBC-MD5" | ||
| 174 | #define SSL3_TXT_KRB5_DES_192_CBC3_SHA "KRB5-DES-CBC3-SHA" | ||
| 175 | #define SSL3_TXT_KRB5_DES_192_CBC3_MD5 "KRB5-DES-CBC3-MD5" | ||
| 176 | |||
| 103 | #define SSL3_TXT_RSA_NULL_MD5 "NULL-MD5" | 177 | #define SSL3_TXT_RSA_NULL_MD5 "NULL-MD5" |
| 104 | #define SSL3_TXT_RSA_NULL_SHA "NULL-SHA" | 178 | #define SSL3_TXT_RSA_NULL_SHA "NULL-SHA" |
| 105 | #define SSL3_TXT_RSA_RC4_40_MD5 "EXP-RC4-MD5" | 179 | #define SSL3_TXT_RSA_RC4_40_MD5 "EXP-RC4-MD5" |
| @@ -144,7 +218,8 @@ extern "C" { | |||
| 144 | #define SSL3_RT_HEADER_LENGTH 5 | 218 | #define SSL3_RT_HEADER_LENGTH 5 |
| 145 | 219 | ||
| 146 | /* Due to MS stuffing up, this can change.... */ | 220 | /* Due to MS stuffing up, this can change.... */ |
| 147 | #if defined(WIN16) || (defined(MSDOS) && !defined(WIN32)) | 221 | #if defined(OPENSSL_SYS_WIN16) || \ |
| 222 | (defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32)) | ||
| 148 | #define SSL3_RT_MAX_EXTRA (14000) | 223 | #define SSL3_RT_MAX_EXTRA (14000) |
| 149 | #else | 224 | #else |
| 150 | #define SSL3_RT_MAX_EXTRA (16384) | 225 | #define SSL3_RT_MAX_EXTRA (16384) |
| @@ -156,24 +231,8 @@ extern "C" { | |||
| 156 | #define SSL3_RT_MAX_PACKET_SIZE (SSL3_RT_MAX_ENCRYPTED_LENGTH+SSL3_RT_HEADER_LENGTH) | 231 | #define SSL3_RT_MAX_PACKET_SIZE (SSL3_RT_MAX_ENCRYPTED_LENGTH+SSL3_RT_HEADER_LENGTH) |
| 157 | #define SSL3_RT_MAX_DATA_SIZE (1024*1024) | 232 | #define SSL3_RT_MAX_DATA_SIZE (1024*1024) |
| 158 | 233 | ||
| 159 | /* the states that a SSL3_RECORD can be in | 234 | #define SSL3_MD_CLIENT_FINISHED_CONST "\x43\x4C\x4E\x54" |
| 160 | * For SSL_read it goes | 235 | #define SSL3_MD_SERVER_FINISHED_CONST "\x53\x52\x56\x52" |
| 161 | * rbuf->ENCODED -> read | ||
| 162 | * ENCODED -> we need to decode everything - call decode_record | ||
| 163 | */ | ||
| 164 | |||
| 165 | #define SSL3_RS_BLANK 1 | ||
| 166 | #define SSL3_RS_DATA | ||
| 167 | |||
| 168 | #define SSL3_RS_ENCODED 2 | ||
| 169 | #define SSL3_RS_READ_MORE 3 | ||
| 170 | #define SSL3_RS_WRITE_MORE | ||
| 171 | #define SSL3_RS_PLAIN 3 | ||
| 172 | #define SSL3_RS_PART_READ 4 | ||
| 173 | #define SSL3_RS_PART_WRITE 5 | ||
| 174 | |||
| 175 | #define SSL3_MD_CLIENT_FINISHED_CONST {0x43,0x4C,0x4E,0x54} | ||
| 176 | #define SSL3_MD_SERVER_FINISHED_CONST {0x53,0x52,0x56,0x52} | ||
| 177 | 236 | ||
| 178 | #define SSL3_VERSION 0x0300 | 237 | #define SSL3_VERSION 0x0300 |
| 179 | #define SSL3_VERSION_MAJOR 0x03 | 238 | #define SSL3_VERSION_MAJOR 0x03 |
| @@ -202,28 +261,23 @@ extern "C" { | |||
| 202 | 261 | ||
| 203 | typedef struct ssl3_record_st | 262 | typedef struct ssl3_record_st |
| 204 | { | 263 | { |
| 205 | /*r */ int type; /* type of record */ | 264 | /*r */ int type; /* type of record */ |
| 206 | /* */ /*int state;*/ /* any data in it? */ | 265 | /*rw*/ unsigned int length; /* How many bytes available */ |
| 207 | /*rw*/ unsigned int length; /* How many bytes available */ | 266 | /*r */ unsigned int off; /* read/write offset into 'buf' */ |
| 208 | /*r */ unsigned int off; /* read/write offset into 'buf' */ | 267 | /*rw*/ unsigned char *data; /* pointer to the record data */ |
| 209 | /*rw*/ unsigned char *data; /* pointer to the record data */ | 268 | /*rw*/ unsigned char *input; /* where the decode bytes are */ |
| 210 | /*rw*/ unsigned char *input; /* where the decode bytes are */ | 269 | /*r */ unsigned char *comp; /* only used with decompression - malloc()ed */ |
| 211 | /*rw*/ unsigned char *comp; /* only used with decompression */ | ||
| 212 | } SSL3_RECORD; | 270 | } SSL3_RECORD; |
| 213 | 271 | ||
| 214 | typedef struct ssl3_buffer_st | 272 | typedef struct ssl3_buffer_st |
| 215 | { | 273 | { |
| 216 | /*r */ int total; /* used in non-blocking writes */ | 274 | unsigned char *buf; /* at least SSL3_RT_MAX_PACKET_SIZE bytes, |
| 217 | /*r */ int wanted; /* how many more bytes we need */ | 275 | * see ssl3_setup_buffers() */ |
| 218 | /*rw*/ int left; /* how many bytes left */ | 276 | size_t len; /* buffer size */ |
| 219 | /*rw*/ int offset; /* where to 'copy from' */ | 277 | int offset; /* where to 'copy from' */ |
| 220 | /*rw*/ unsigned char *buf; /* SSL3_RT_MAX_PACKET_SIZE bytes */ | 278 | int left; /* how many bytes left */ |
| 221 | } SSL3_BUFFER; | 279 | } SSL3_BUFFER; |
| 222 | 280 | ||
| 223 | typedef struct ssl3_compression_st { | ||
| 224 | int nothing; | ||
| 225 | } SSL3_COMPRESSION; | ||
| 226 | |||
| 227 | #define SSL3_CT_RSA_SIGN 1 | 281 | #define SSL3_CT_RSA_SIGN 1 |
| 228 | #define SSL3_CT_DSS_SIGN 2 | 282 | #define SSL3_CT_DSS_SIGN 2 |
| 229 | #define SSL3_CT_RSA_FIXED_DH 3 | 283 | #define SSL3_CT_RSA_FIXED_DH 3 |
| @@ -236,36 +290,9 @@ typedef struct ssl3_compression_st { | |||
| 236 | #define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS 0x0001 | 290 | #define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS 0x0001 |
| 237 | #define SSL3_FLAGS_DELAY_CLIENT_FINISHED 0x0002 | 291 | #define SSL3_FLAGS_DELAY_CLIENT_FINISHED 0x0002 |
| 238 | #define SSL3_FLAGS_POP_BUFFER 0x0004 | 292 | #define SSL3_FLAGS_POP_BUFFER 0x0004 |
| 239 | #define TLS1_FLAGS_TLS_PADDING_BUG 0x0008 | 293 | #define TLS1_FLAGS_TLS_PADDING_BUG 0x0008 |
| 240 | |||
| 241 | #if 0 | ||
| 242 | #define AD_CLOSE_NOTIFY 0 | ||
| 243 | #define AD_UNEXPECTED_MESSAGE 1 | ||
| 244 | #define AD_BAD_RECORD_MAC 2 | ||
| 245 | #define AD_DECRYPTION_FAILED 3 | ||
| 246 | #define AD_RECORD_OVERFLOW 4 | ||
| 247 | #define AD_DECOMPRESSION_FAILURE 5 /* fatal */ | ||
| 248 | #define AD_HANDSHAKE_FAILURE 6 /* fatal */ | ||
| 249 | #define AD_NO_CERTIFICATE 7 /* Not under TLS */ | ||
| 250 | #define AD_BAD_CERTIFICATE 8 | ||
| 251 | #define AD_UNSUPPORTED_CERTIFICATE 9 | ||
| 252 | #define AD_CERTIFICATE_REVOKED 10 | ||
| 253 | #define AD_CERTIFICATE_EXPIRED 11 | ||
| 254 | #define AD_CERTIFICATE_UNKNOWN 12 | ||
| 255 | #define AD_ILLEGAL_PARAMETER 13 /* fatal */ | ||
| 256 | #define AD_UNKNOWN_CA 14 /* fatal */ | ||
| 257 | #define AD_ACCESS_DENIED 15 /* fatal */ | ||
| 258 | #define AD_DECODE_ERROR 16 /* fatal */ | ||
| 259 | #define AD_DECRYPT_ERROR 17 | ||
| 260 | #define AD_EXPORT_RESTRICION 18 /* fatal */ | ||
| 261 | #define AD_PROTOCOL_VERSION 19 /* fatal */ | ||
| 262 | #define AD_INSUFFICIENT_SECURITY 20 /* fatal */ | ||
| 263 | #define AD_INTERNAL_ERROR 21 /* fatal */ | ||
| 264 | #define AD_USER_CANCLED 22 | ||
| 265 | #define AD_NO_RENEGOTIATION 23 | ||
| 266 | #endif | ||
| 267 | 294 | ||
| 268 | typedef struct ssl3_ctx_st | 295 | typedef struct ssl3_state_st |
| 269 | { | 296 | { |
| 270 | long flags; | 297 | long flags; |
| 271 | int delay_buf_pop_ret; | 298 | int delay_buf_pop_ret; |
| @@ -278,19 +305,29 @@ typedef struct ssl3_ctx_st | |||
| 278 | unsigned char server_random[SSL3_RANDOM_SIZE]; | 305 | unsigned char server_random[SSL3_RANDOM_SIZE]; |
| 279 | unsigned char client_random[SSL3_RANDOM_SIZE]; | 306 | unsigned char client_random[SSL3_RANDOM_SIZE]; |
| 280 | 307 | ||
| 308 | /* flags for countermeasure against known-IV weakness */ | ||
| 309 | int need_empty_fragments; | ||
| 310 | int empty_fragment_done; | ||
| 311 | |||
| 281 | SSL3_BUFFER rbuf; /* read IO goes into here */ | 312 | SSL3_BUFFER rbuf; /* read IO goes into here */ |
| 282 | SSL3_BUFFER wbuf; /* write IO goes into here */ | 313 | SSL3_BUFFER wbuf; /* write IO goes into here */ |
| 314 | |||
| 283 | SSL3_RECORD rrec; /* each decoded record goes in here */ | 315 | SSL3_RECORD rrec; /* each decoded record goes in here */ |
| 284 | SSL3_RECORD wrec; /* goes out from here */ | 316 | SSL3_RECORD wrec; /* goes out from here */ |
| 285 | /* Used by ssl3_read_n to point | 317 | |
| 286 | * to input data packet */ | 318 | /* storage for Alert/Handshake protocol data received but not |
| 319 | * yet processed by ssl3_read_bytes: */ | ||
| 320 | unsigned char alert_fragment[2]; | ||
| 321 | unsigned int alert_fragment_len; | ||
| 322 | unsigned char handshake_fragment[4]; | ||
| 323 | unsigned int handshake_fragment_len; | ||
| 287 | 324 | ||
| 288 | /* partial write - check the numbers match */ | 325 | /* partial write - check the numbers match */ |
| 289 | unsigned int wnum; /* number of bytes sent so far */ | 326 | unsigned int wnum; /* number of bytes sent so far */ |
| 290 | int wpend_tot; /* number bytes written */ | 327 | int wpend_tot; /* number bytes written */ |
| 291 | int wpend_type; | 328 | int wpend_type; |
| 292 | int wpend_ret; /* number of bytes submitted */ | 329 | int wpend_ret; /* number of bytes submitted */ |
| 293 | char *wpend_buf; | 330 | const unsigned char *wpend_buf; |
| 294 | 331 | ||
| 295 | /* used during startup, digest all incoming/outgoing packets */ | 332 | /* used during startup, digest all incoming/outgoing packets */ |
| 296 | EVP_MD_CTX finish_dgst1; | 333 | EVP_MD_CTX finish_dgst1; |
| @@ -302,10 +339,10 @@ typedef struct ssl3_ctx_st | |||
| 302 | 339 | ||
| 303 | int warn_alert; | 340 | int warn_alert; |
| 304 | int fatal_alert; | 341 | int fatal_alert; |
| 305 | /* we alow one fatal and one warning alert to be outstanding, | 342 | /* we allow one fatal and one warning alert to be outstanding, |
| 306 | * send close alert via the warning alert */ | 343 | * send close alert via the warning alert */ |
| 307 | int alert_dispatch; | 344 | int alert_dispatch; |
| 308 | char send_alert[2]; | 345 | unsigned char send_alert[2]; |
| 309 | 346 | ||
| 310 | /* This flag is set when we should renegotiate ASAP, basically when | 347 | /* This flag is set when we should renegotiate ASAP, basically when |
| 311 | * there is no more data in the read or write buffers */ | 348 | * there is no more data in the read or write buffers */ |
| @@ -316,16 +353,23 @@ typedef struct ssl3_ctx_st | |||
| 316 | int in_read_app_data; | 353 | int in_read_app_data; |
| 317 | 354 | ||
| 318 | struct { | 355 | struct { |
| 319 | /* Actually only needs to be 16+20 for SSLv3 and 12 for TLS */ | 356 | /* actually only needs to be 16+20 */ |
| 357 | unsigned char cert_verify_md[EVP_MAX_MD_SIZE*2]; | ||
| 358 | |||
| 359 | /* actually only need to be 16+20 for SSLv3 and 12 for TLS */ | ||
| 320 | unsigned char finish_md[EVP_MAX_MD_SIZE*2]; | 360 | unsigned char finish_md[EVP_MAX_MD_SIZE*2]; |
| 361 | int finish_md_len; | ||
| 362 | unsigned char peer_finish_md[EVP_MAX_MD_SIZE*2]; | ||
| 363 | int peer_finish_md_len; | ||
| 321 | 364 | ||
| 322 | unsigned long message_size; | 365 | unsigned long message_size; |
| 323 | int message_type; | 366 | int message_type; |
| 324 | 367 | ||
| 325 | /* used to hold the new cipher we are going to use */ | 368 | /* used to hold the new cipher we are going to use */ |
| 326 | SSL_CIPHER *new_cipher; | 369 | SSL_CIPHER *new_cipher; |
| 370 | #ifndef OPENSSL_NO_DH | ||
| 327 | DH *dh; | 371 | DH *dh; |
| 328 | 372 | #endif | |
| 329 | /* used when SSL_ST_FLUSH_DATA is entered */ | 373 | /* used when SSL_ST_FLUSH_DATA is entered */ |
| 330 | int next_state; | 374 | int next_state; |
| 331 | 375 | ||
| @@ -335,19 +379,24 @@ typedef struct ssl3_ctx_st | |||
| 335 | int cert_req; | 379 | int cert_req; |
| 336 | int ctype_num; | 380 | int ctype_num; |
| 337 | char ctype[SSL3_CT_NUMBER]; | 381 | char ctype[SSL3_CT_NUMBER]; |
| 338 | STACK *ca_names; | 382 | STACK_OF(X509_NAME) *ca_names; |
| 339 | 383 | ||
| 340 | int use_rsa_tmp; | 384 | int use_rsa_tmp; |
| 341 | 385 | ||
| 342 | int key_block_length; | 386 | int key_block_length; |
| 343 | unsigned char *key_block; | 387 | unsigned char *key_block; |
| 344 | 388 | ||
| 345 | EVP_CIPHER *new_sym_enc; | 389 | const EVP_CIPHER *new_sym_enc; |
| 346 | EVP_MD *new_hash; | 390 | const EVP_MD *new_hash; |
| 347 | SSL_COMPRESSION *new_compression; | 391 | #ifndef OPENSSL_NO_COMP |
| 392 | const SSL_COMP *new_compression; | ||
| 393 | #else | ||
| 394 | char *new_compression; | ||
| 395 | #endif | ||
| 348 | int cert_request; | 396 | int cert_request; |
| 349 | } tmp; | 397 | } tmp; |
| 350 | } SSL3_CTX; | 398 | |
| 399 | } SSL3_STATE; | ||
| 351 | 400 | ||
| 352 | /* SSLv3 */ | 401 | /* SSLv3 */ |
| 353 | /*client */ | 402 | /*client */ |
| @@ -425,7 +474,7 @@ typedef struct ssl3_ctx_st | |||
| 425 | #define SSL3_ST_SW_FINISHED_A (0x1E0|SSL_ST_ACCEPT) | 474 | #define SSL3_ST_SW_FINISHED_A (0x1E0|SSL_ST_ACCEPT) |
| 426 | #define SSL3_ST_SW_FINISHED_B (0x1E1|SSL_ST_ACCEPT) | 475 | #define SSL3_ST_SW_FINISHED_B (0x1E1|SSL_ST_ACCEPT) |
| 427 | 476 | ||
| 428 | #define SSL3_MT_CLIENT_REQUEST 0 | 477 | #define SSL3_MT_HELLO_REQUEST 0 |
| 429 | #define SSL3_MT_CLIENT_HELLO 1 | 478 | #define SSL3_MT_CLIENT_HELLO 1 |
| 430 | #define SSL3_MT_SERVER_HELLO 2 | 479 | #define SSL3_MT_SERVER_HELLO 2 |
| 431 | #define SSL3_MT_CERTIFICATE 11 | 480 | #define SSL3_MT_CERTIFICATE 11 |
diff --git a/src/lib/libssl/ssl_algs.c b/src/lib/libssl/ssl_algs.c index 65f3a59386..3d1299ee7b 100644 --- a/src/lib/libssl/ssl_algs.c +++ b/src/lib/libssl/ssl_algs.c | |||
| @@ -57,46 +57,55 @@ | |||
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include "objects.h" | 60 | #include <openssl/objects.h> |
| 61 | #include "lhash.h" | 61 | #include <openssl/lhash.h> |
| 62 | #include "ssl_locl.h" | 62 | #include "ssl_locl.h" |
| 63 | 63 | ||
| 64 | void SSLeay_add_ssl_algorithms() | 64 | int SSL_library_init(void) |
| 65 | { | 65 | { |
| 66 | #ifndef NO_DES | 66 | |
| 67 | #ifndef OPENSSL_NO_DES | ||
| 67 | EVP_add_cipher(EVP_des_cbc()); | 68 | EVP_add_cipher(EVP_des_cbc()); |
| 68 | EVP_add_cipher(EVP_des_ede3_cbc()); | 69 | EVP_add_cipher(EVP_des_ede3_cbc()); |
| 69 | #endif | 70 | #endif |
| 70 | #ifndef NO_IDEA | 71 | #ifndef OPENSSL_NO_IDEA |
| 71 | EVP_add_cipher(EVP_idea_cbc()); | 72 | EVP_add_cipher(EVP_idea_cbc()); |
| 72 | #endif | 73 | #endif |
| 73 | #ifndef NO_RC4 | 74 | #ifndef OPENSSL_NO_RC4 |
| 74 | EVP_add_cipher(EVP_rc4()); | 75 | EVP_add_cipher(EVP_rc4()); |
| 75 | #endif | ||
| 76 | #ifndef NO_RC2 | ||
| 77 | EVP_add_cipher(EVP_rc2_cbc()); | ||
| 78 | #endif | 76 | #endif |
| 79 | 77 | #ifndef OPENSSL_NO_RC2 | |
| 80 | #ifndef NO_MD2 | 78 | EVP_add_cipher(EVP_rc2_cbc()); |
| 81 | EVP_add_digest(EVP_md2()); | ||
| 82 | #endif | 79 | #endif |
| 83 | #ifndef NO_MD5 | 80 | #ifndef OPENSSL_NO_AES |
| 81 | EVP_add_cipher(EVP_aes_128_cbc()); | ||
| 82 | EVP_add_cipher(EVP_aes_192_cbc()); | ||
| 83 | EVP_add_cipher(EVP_aes_256_cbc()); | ||
| 84 | #endif | ||
| 85 | #ifndef OPENSSL_NO_MD2 | ||
| 86 | EVP_add_digest(EVP_md2()); | ||
| 87 | #endif | ||
| 88 | #ifndef OPENSSL_NO_MD5 | ||
| 84 | EVP_add_digest(EVP_md5()); | 89 | EVP_add_digest(EVP_md5()); |
| 85 | EVP_add_alias(SN_md5,"ssl2-md5"); | 90 | EVP_add_digest_alias(SN_md5,"ssl2-md5"); |
| 86 | EVP_add_alias(SN_md5,"ssl3-md5"); | 91 | EVP_add_digest_alias(SN_md5,"ssl3-md5"); |
| 87 | #endif | 92 | #endif |
| 88 | #ifndef NO_SHA1 | 93 | #ifndef OPENSSL_NO_SHA |
| 89 | EVP_add_digest(EVP_sha1()); /* RSA with sha1 */ | 94 | EVP_add_digest(EVP_sha1()); /* RSA with sha1 */ |
| 90 | EVP_add_alias(SN_sha1,"ssl3-sha1"); | 95 | EVP_add_digest_alias(SN_sha1,"ssl3-sha1"); |
| 96 | EVP_add_digest_alias(SN_sha1WithRSAEncryption,SN_sha1WithRSA); | ||
| 91 | #endif | 97 | #endif |
| 92 | #if !defined(NO_SHA1) && !defined(NO_DSA) | 98 | #if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_DSA) |
| 93 | EVP_add_digest(EVP_dss1()); /* DSA with sha1 */ | 99 | EVP_add_digest(EVP_dss1()); /* DSA with sha1 */ |
| 100 | EVP_add_digest_alias(SN_dsaWithSHA1,SN_dsaWithSHA1_2); | ||
| 101 | EVP_add_digest_alias(SN_dsaWithSHA1,"DSS1"); | ||
| 102 | EVP_add_digest_alias(SN_dsaWithSHA1,"dss1"); | ||
| 94 | #endif | 103 | #endif |
| 95 | |||
| 96 | /* If you want support for phased out ciphers, add the following */ | 104 | /* If you want support for phased out ciphers, add the following */ |
| 97 | #if 0 | 105 | #if 0 |
| 98 | EVP_add_digest(EVP_sha()); | 106 | EVP_add_digest(EVP_sha()); |
| 99 | EVP_add_digest(EVP_dss()); | 107 | EVP_add_digest(EVP_dss()); |
| 100 | #endif | 108 | #endif |
| 109 | return(1); | ||
| 101 | } | 110 | } |
| 102 | 111 | ||
diff --git a/src/lib/libssl/ssl_asn1.c b/src/lib/libssl/ssl_asn1.c index 116a83de64..c5eeeb6bc5 100644 --- a/src/lib/libssl/ssl_asn1.c +++ b/src/lib/libssl/ssl_asn1.c | |||
| @@ -58,8 +58,9 @@ | |||
| 58 | 58 | ||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include <stdlib.h> | 60 | #include <stdlib.h> |
| 61 | #include "asn1_mac.h" | 61 | #include <openssl/asn1_mac.h> |
| 62 | #include "objects.h" | 62 | #include <openssl/objects.h> |
| 63 | #include <openssl/x509.h> | ||
| 63 | #include "ssl_locl.h" | 64 | #include "ssl_locl.h" |
| 64 | 65 | ||
| 65 | typedef struct ssl_session_asn1_st | 66 | typedef struct ssl_session_asn1_st |
| @@ -69,24 +70,22 @@ typedef struct ssl_session_asn1_st | |||
| 69 | ASN1_OCTET_STRING cipher; | 70 | ASN1_OCTET_STRING cipher; |
| 70 | ASN1_OCTET_STRING master_key; | 71 | ASN1_OCTET_STRING master_key; |
| 71 | ASN1_OCTET_STRING session_id; | 72 | ASN1_OCTET_STRING session_id; |
| 73 | ASN1_OCTET_STRING session_id_context; | ||
| 72 | ASN1_OCTET_STRING key_arg; | 74 | ASN1_OCTET_STRING key_arg; |
| 75 | #ifndef OPENSSL_NO_KRB5 | ||
| 76 | ASN1_OCTET_STRING krb5_princ; | ||
| 77 | #endif /* OPENSSL_NO_KRB5 */ | ||
| 73 | ASN1_INTEGER time; | 78 | ASN1_INTEGER time; |
| 74 | ASN1_INTEGER timeout; | 79 | ASN1_INTEGER timeout; |
| 80 | ASN1_INTEGER verify_result; | ||
| 75 | } SSL_SESSION_ASN1; | 81 | } SSL_SESSION_ASN1; |
| 76 | 82 | ||
| 77 | /* | 83 | int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp) |
| 78 | * SSLerr(SSL_F_I2D_SSL_SESSION,SSL_R_CIPHER_CODE_WRONG_LENGTH); | ||
| 79 | * SSLerr(SSL_F_D2I_SSL_SESSION,SSL_R_UNSUPPORTED_CIPHER); | ||
| 80 | */ | ||
| 81 | |||
| 82 | int i2d_SSL_SESSION(in,pp) | ||
| 83 | SSL_SESSION *in; | ||
| 84 | unsigned char **pp; | ||
| 85 | { | 84 | { |
| 86 | #define LSIZE2 (sizeof(long)*2) | 85 | #define LSIZE2 (sizeof(long)*2) |
| 87 | int v1=0,v2=0,v3=0; | 86 | int v1=0,v2=0,v3=0,v4=0,v5=0; |
| 88 | unsigned char buf[4],ibuf1[LSIZE2],ibuf2[LSIZE2]; | 87 | unsigned char buf[4],ibuf1[LSIZE2],ibuf2[LSIZE2]; |
| 89 | unsigned char ibuf3[LSIZE2],ibuf4[LSIZE2]; | 88 | unsigned char ibuf3[LSIZE2],ibuf4[LSIZE2],ibuf5[LSIZE2]; |
| 90 | long l; | 89 | long l; |
| 91 | SSL_SESSION_ASN1 a; | 90 | SSL_SESSION_ASN1 a; |
| 92 | M_ASN1_I2D_vars(in); | 91 | M_ASN1_I2D_vars(in); |
| @@ -95,8 +94,8 @@ unsigned char **pp; | |||
| 95 | return(0); | 94 | return(0); |
| 96 | 95 | ||
| 97 | /* Note that I cheat in the following 2 assignments. I know | 96 | /* Note that I cheat in the following 2 assignments. I know |
| 98 | * that if the ASN1_INTERGER passed to ASN1_INTEGER_set | 97 | * that if the ASN1_INTEGER passed to ASN1_INTEGER_set |
| 99 | * is > sizeof(long)+1, the buffer will not be re-Malloc()ed. | 98 | * is > sizeof(long)+1, the buffer will not be re-OPENSSL_malloc()ed. |
| 100 | * This is a bit evil but makes things simple, no dynamic allocation | 99 | * This is a bit evil but makes things simple, no dynamic allocation |
| 101 | * to clean up :-) */ | 100 | * to clean up :-) */ |
| 102 | a.version.length=LSIZE2; | 101 | a.version.length=LSIZE2; |
| @@ -138,10 +137,23 @@ unsigned char **pp; | |||
| 138 | a.session_id.type=V_ASN1_OCTET_STRING; | 137 | a.session_id.type=V_ASN1_OCTET_STRING; |
| 139 | a.session_id.data=in->session_id; | 138 | a.session_id.data=in->session_id; |
| 140 | 139 | ||
| 140 | a.session_id_context.length=in->sid_ctx_length; | ||
| 141 | a.session_id_context.type=V_ASN1_OCTET_STRING; | ||
| 142 | a.session_id_context.data=in->sid_ctx; | ||
| 143 | |||
| 141 | a.key_arg.length=in->key_arg_length; | 144 | a.key_arg.length=in->key_arg_length; |
| 142 | a.key_arg.type=V_ASN1_OCTET_STRING; | 145 | a.key_arg.type=V_ASN1_OCTET_STRING; |
| 143 | a.key_arg.data=in->key_arg; | 146 | a.key_arg.data=in->key_arg; |
| 144 | 147 | ||
| 148 | #ifndef OPENSSL_NO_KRB5 | ||
| 149 | if (in->krb5_client_princ_len) | ||
| 150 | { | ||
| 151 | a.krb5_princ.length=in->krb5_client_princ_len; | ||
| 152 | a.krb5_princ.type=V_ASN1_OCTET_STRING; | ||
| 153 | a.krb5_princ.data=in->krb5_client_princ; | ||
| 154 | } | ||
| 155 | #endif /* OPENSSL_NO_KRB5 */ | ||
| 156 | |||
| 145 | if (in->time != 0L) | 157 | if (in->time != 0L) |
| 146 | { | 158 | { |
| 147 | a.time.length=LSIZE2; | 159 | a.time.length=LSIZE2; |
| @@ -158,11 +170,24 @@ unsigned char **pp; | |||
| 158 | ASN1_INTEGER_set(&(a.timeout),in->timeout); | 170 | ASN1_INTEGER_set(&(a.timeout),in->timeout); |
| 159 | } | 171 | } |
| 160 | 172 | ||
| 173 | if (in->verify_result != X509_V_OK) | ||
| 174 | { | ||
| 175 | a.verify_result.length=LSIZE2; | ||
| 176 | a.verify_result.type=V_ASN1_INTEGER; | ||
| 177 | a.verify_result.data=ibuf5; | ||
| 178 | ASN1_INTEGER_set(&a.verify_result,in->verify_result); | ||
| 179 | } | ||
| 180 | |||
| 181 | |||
| 161 | M_ASN1_I2D_len(&(a.version), i2d_ASN1_INTEGER); | 182 | M_ASN1_I2D_len(&(a.version), i2d_ASN1_INTEGER); |
| 162 | M_ASN1_I2D_len(&(a.ssl_version), i2d_ASN1_INTEGER); | 183 | M_ASN1_I2D_len(&(a.ssl_version), i2d_ASN1_INTEGER); |
| 163 | M_ASN1_I2D_len(&(a.cipher), i2d_ASN1_OCTET_STRING); | 184 | M_ASN1_I2D_len(&(a.cipher), i2d_ASN1_OCTET_STRING); |
| 164 | M_ASN1_I2D_len(&(a.session_id), i2d_ASN1_OCTET_STRING); | 185 | M_ASN1_I2D_len(&(a.session_id), i2d_ASN1_OCTET_STRING); |
| 165 | M_ASN1_I2D_len(&(a.master_key), i2d_ASN1_OCTET_STRING); | 186 | M_ASN1_I2D_len(&(a.master_key), i2d_ASN1_OCTET_STRING); |
| 187 | #ifndef OPENSSL_NO_KRB5 | ||
| 188 | if (in->krb5_client_princ_len) | ||
| 189 | M_ASN1_I2D_len(&(a.krb5_princ), i2d_ASN1_OCTET_STRING); | ||
| 190 | #endif /* OPENSSL_NO_KRB5 */ | ||
| 166 | if (in->key_arg_length > 0) | 191 | if (in->key_arg_length > 0) |
| 167 | M_ASN1_I2D_len_IMP_opt(&(a.key_arg),i2d_ASN1_OCTET_STRING); | 192 | M_ASN1_I2D_len_IMP_opt(&(a.key_arg),i2d_ASN1_OCTET_STRING); |
| 168 | if (in->time != 0L) | 193 | if (in->time != 0L) |
| @@ -171,6 +196,9 @@ unsigned char **pp; | |||
| 171 | M_ASN1_I2D_len_EXP_opt(&(a.timeout),i2d_ASN1_INTEGER,2,v2); | 196 | M_ASN1_I2D_len_EXP_opt(&(a.timeout),i2d_ASN1_INTEGER,2,v2); |
| 172 | if (in->peer != NULL) | 197 | if (in->peer != NULL) |
| 173 | M_ASN1_I2D_len_EXP_opt(in->peer,i2d_X509,3,v3); | 198 | M_ASN1_I2D_len_EXP_opt(in->peer,i2d_X509,3,v3); |
| 199 | M_ASN1_I2D_len_EXP_opt(&a.session_id_context,i2d_ASN1_OCTET_STRING,4,v4); | ||
| 200 | if (in->verify_result != X509_V_OK) | ||
| 201 | M_ASN1_I2D_len_EXP_opt(&(a.verify_result),i2d_ASN1_INTEGER,5,v5); | ||
| 174 | 202 | ||
| 175 | M_ASN1_I2D_seq_total(); | 203 | M_ASN1_I2D_seq_total(); |
| 176 | 204 | ||
| @@ -179,6 +207,10 @@ unsigned char **pp; | |||
| 179 | M_ASN1_I2D_put(&(a.cipher), i2d_ASN1_OCTET_STRING); | 207 | M_ASN1_I2D_put(&(a.cipher), i2d_ASN1_OCTET_STRING); |
| 180 | M_ASN1_I2D_put(&(a.session_id), i2d_ASN1_OCTET_STRING); | 208 | M_ASN1_I2D_put(&(a.session_id), i2d_ASN1_OCTET_STRING); |
| 181 | M_ASN1_I2D_put(&(a.master_key), i2d_ASN1_OCTET_STRING); | 209 | M_ASN1_I2D_put(&(a.master_key), i2d_ASN1_OCTET_STRING); |
| 210 | #ifndef OPENSSL_NO_KRB5 | ||
| 211 | if (in->krb5_client_princ_len) | ||
| 212 | M_ASN1_I2D_put(&(a.krb5_princ), i2d_ASN1_OCTET_STRING); | ||
| 213 | #endif /* OPENSSL_NO_KRB5 */ | ||
| 182 | if (in->key_arg_length > 0) | 214 | if (in->key_arg_length > 0) |
| 183 | M_ASN1_I2D_put_IMP_opt(&(a.key_arg),i2d_ASN1_OCTET_STRING,0); | 215 | M_ASN1_I2D_put_IMP_opt(&(a.key_arg),i2d_ASN1_OCTET_STRING,0); |
| 184 | if (in->time != 0L) | 216 | if (in->time != 0L) |
| @@ -187,14 +219,15 @@ unsigned char **pp; | |||
| 187 | M_ASN1_I2D_put_EXP_opt(&(a.timeout),i2d_ASN1_INTEGER,2,v2); | 219 | M_ASN1_I2D_put_EXP_opt(&(a.timeout),i2d_ASN1_INTEGER,2,v2); |
| 188 | if (in->peer != NULL) | 220 | if (in->peer != NULL) |
| 189 | M_ASN1_I2D_put_EXP_opt(in->peer,i2d_X509,3,v3); | 221 | M_ASN1_I2D_put_EXP_opt(in->peer,i2d_X509,3,v3); |
| 190 | 222 | M_ASN1_I2D_put_EXP_opt(&a.session_id_context,i2d_ASN1_OCTET_STRING,4, | |
| 223 | v4); | ||
| 224 | if (in->verify_result != X509_V_OK) | ||
| 225 | M_ASN1_I2D_put_EXP_opt(&a.verify_result,i2d_ASN1_INTEGER,5,v5); | ||
| 191 | M_ASN1_I2D_finish(); | 226 | M_ASN1_I2D_finish(); |
| 192 | } | 227 | } |
| 193 | 228 | ||
| 194 | SSL_SESSION *d2i_SSL_SESSION(a,pp,length) | 229 | SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, unsigned char **pp, |
| 195 | SSL_SESSION **a; | 230 | long length) |
| 196 | unsigned char **pp; | ||
| 197 | long length; | ||
| 198 | { | 231 | { |
| 199 | int version,ssl_version=0,i; | 232 | int version,ssl_version=0,i; |
| 200 | long id; | 233 | long id; |
| @@ -211,13 +244,13 @@ long length; | |||
| 211 | ai.data=NULL; ai.length=0; | 244 | ai.data=NULL; ai.length=0; |
| 212 | M_ASN1_D2I_get(aip,d2i_ASN1_INTEGER); | 245 | M_ASN1_D2I_get(aip,d2i_ASN1_INTEGER); |
| 213 | version=(int)ASN1_INTEGER_get(aip); | 246 | version=(int)ASN1_INTEGER_get(aip); |
| 214 | if (ai.data != NULL) { Free(ai.data); ai.data=NULL; ai.length=0; } | 247 | if (ai.data != NULL) { OPENSSL_free(ai.data); ai.data=NULL; ai.length=0; } |
| 215 | 248 | ||
| 216 | /* we don't care about the version right now :-) */ | 249 | /* we don't care about the version right now :-) */ |
| 217 | M_ASN1_D2I_get(aip,d2i_ASN1_INTEGER); | 250 | M_ASN1_D2I_get(aip,d2i_ASN1_INTEGER); |
| 218 | ssl_version=(int)ASN1_INTEGER_get(aip); | 251 | ssl_version=(int)ASN1_INTEGER_get(aip); |
| 219 | ret->ssl_version=ssl_version; | 252 | ret->ssl_version=ssl_version; |
| 220 | if (ai.data != NULL) { Free(ai.data); ai.data=NULL; ai.length=0; } | 253 | if (ai.data != NULL) { OPENSSL_free(ai.data); ai.data=NULL; ai.length=0; } |
| 221 | 254 | ||
| 222 | os.data=NULL; os.length=0; | 255 | os.data=NULL; os.length=0; |
| 223 | M_ASN1_D2I_get(osp,d2i_ASN1_OCTET_STRING); | 256 | M_ASN1_D2I_get(osp,d2i_ASN1_OCTET_STRING); |
| @@ -273,20 +306,39 @@ long length; | |||
| 273 | memcpy(ret->master_key,os.data,ret->master_key_length); | 306 | memcpy(ret->master_key,os.data,ret->master_key_length); |
| 274 | 307 | ||
| 275 | os.length=0; | 308 | os.length=0; |
| 309 | |||
| 310 | #ifndef OPENSSL_NO_KRB5 | ||
| 311 | os.length=0; | ||
| 312 | M_ASN1_D2I_get_opt(osp,d2i_ASN1_OCTET_STRING,V_ASN1_OCTET_STRING); | ||
| 313 | if (os.data) | ||
| 314 | { | ||
| 315 | if (os.length > SSL_MAX_KRB5_PRINCIPAL_LENGTH) | ||
| 316 | ret->krb5_client_princ_len=0; | ||
| 317 | else | ||
| 318 | ret->krb5_client_princ_len=os.length; | ||
| 319 | memcpy(ret->krb5_client_princ,os.data,ret->krb5_client_princ_len); | ||
| 320 | OPENSSL_free(os.data); | ||
| 321 | os.data = NULL; | ||
| 322 | os.length = 0; | ||
| 323 | } | ||
| 324 | else | ||
| 325 | ret->krb5_client_princ_len=0; | ||
| 326 | #endif /* OPENSSL_NO_KRB5 */ | ||
| 327 | |||
| 276 | M_ASN1_D2I_get_IMP_opt(osp,d2i_ASN1_OCTET_STRING,0,V_ASN1_OCTET_STRING); | 328 | M_ASN1_D2I_get_IMP_opt(osp,d2i_ASN1_OCTET_STRING,0,V_ASN1_OCTET_STRING); |
| 277 | if (os.length > SSL_MAX_KEY_ARG_LENGTH) | 329 | if (os.length > SSL_MAX_KEY_ARG_LENGTH) |
| 278 | ret->key_arg_length=SSL_MAX_KEY_ARG_LENGTH; | 330 | ret->key_arg_length=SSL_MAX_KEY_ARG_LENGTH; |
| 279 | else | 331 | else |
| 280 | ret->key_arg_length=os.length; | 332 | ret->key_arg_length=os.length; |
| 281 | memcpy(ret->key_arg,os.data,ret->key_arg_length); | 333 | memcpy(ret->key_arg,os.data,ret->key_arg_length); |
| 282 | if (os.data != NULL) Free(os.data); | 334 | if (os.data != NULL) OPENSSL_free(os.data); |
| 283 | 335 | ||
| 284 | ai.length=0; | 336 | ai.length=0; |
| 285 | M_ASN1_D2I_get_EXP_opt(aip,d2i_ASN1_INTEGER,1); | 337 | M_ASN1_D2I_get_EXP_opt(aip,d2i_ASN1_INTEGER,1); |
| 286 | if (ai.data != NULL) | 338 | if (ai.data != NULL) |
| 287 | { | 339 | { |
| 288 | ret->time=ASN1_INTEGER_get(aip); | 340 | ret->time=ASN1_INTEGER_get(aip); |
| 289 | Free(ai.data); ai.data=NULL; ai.length=0; | 341 | OPENSSL_free(ai.data); ai.data=NULL; ai.length=0; |
| 290 | } | 342 | } |
| 291 | else | 343 | else |
| 292 | ret->time=time(NULL); | 344 | ret->time=time(NULL); |
| @@ -296,7 +348,7 @@ long length; | |||
| 296 | if (ai.data != NULL) | 348 | if (ai.data != NULL) |
| 297 | { | 349 | { |
| 298 | ret->timeout=ASN1_INTEGER_get(aip); | 350 | ret->timeout=ASN1_INTEGER_get(aip); |
| 299 | Free(ai.data); ai.data=NULL; ai.length=0; | 351 | OPENSSL_free(ai.data); ai.data=NULL; ai.length=0; |
| 300 | } | 352 | } |
| 301 | else | 353 | else |
| 302 | ret->timeout=3; | 354 | ret->timeout=3; |
| @@ -308,6 +360,30 @@ long length; | |||
| 308 | } | 360 | } |
| 309 | M_ASN1_D2I_get_EXP_opt(ret->peer,d2i_X509,3); | 361 | M_ASN1_D2I_get_EXP_opt(ret->peer,d2i_X509,3); |
| 310 | 362 | ||
| 363 | os.length=0; | ||
| 364 | os.data=NULL; | ||
| 365 | M_ASN1_D2I_get_EXP_opt(osp,d2i_ASN1_OCTET_STRING,4); | ||
| 366 | |||
| 367 | if(os.data != NULL) | ||
| 368 | { | ||
| 369 | if (os.length > SSL_MAX_SID_CTX_LENGTH) | ||
| 370 | SSLerr(SSL_F_D2I_SSL_SESSION,SSL_R_BAD_LENGTH); | ||
| 371 | ret->sid_ctx_length=os.length; | ||
| 372 | memcpy(ret->sid_ctx,os.data,os.length); | ||
| 373 | OPENSSL_free(os.data); os.data=NULL; os.length=0; | ||
| 374 | } | ||
| 375 | else | ||
| 376 | ret->sid_ctx_length=0; | ||
| 377 | |||
| 378 | ai.length=0; | ||
| 379 | M_ASN1_D2I_get_EXP_opt(aip,d2i_ASN1_INTEGER,5); | ||
| 380 | if (ai.data != NULL) | ||
| 381 | { | ||
| 382 | ret->verify_result=ASN1_INTEGER_get(aip); | ||
| 383 | OPENSSL_free(ai.data); ai.data=NULL; ai.length=0; | ||
| 384 | } | ||
| 385 | else | ||
| 386 | ret->verify_result=X509_V_OK; | ||
| 387 | |||
| 311 | M_ASN1_D2I_Finish(a,SSL_SESSION_free,SSL_F_D2I_SSL_SESSION); | 388 | M_ASN1_D2I_Finish(a,SSL_SESSION_free,SSL_F_D2I_SSL_SESSION); |
| 312 | } | 389 | } |
| 313 | |||
diff --git a/src/lib/libssl/ssl_cert.c b/src/lib/libssl/ssl_cert.c index c1cb86e1b7..3d31bbf05f 100644 --- a/src/lib/libssl/ssl_cert.c +++ b/src/lib/libssl/ssl_cert.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* ssl/ssl_cert.c */ | 1 | /*! \file ssl/ssl_cert.c */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -55,32 +55,113 @@ | |||
| 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) 1999 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 | */ | ||
| 58 | 106 | ||
| 59 | #include <stdio.h> | 107 | #include <stdio.h> |
| 60 | #include "objects.h" | 108 | |
| 61 | #include "bio.h" | 109 | #include "e_os.h" |
| 62 | #include "pem.h" | 110 | #ifndef NO_SYS_TYPES_H |
| 111 | # include <sys/types.h> | ||
| 112 | #endif | ||
| 113 | |||
| 114 | #if !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_VMS) && !defined(NeXT) && !defined(MAC_OS_pre_X) | ||
| 115 | #include <dirent.h> | ||
| 116 | #endif | ||
| 117 | |||
| 118 | #if defined(WIN32) | ||
| 119 | #include <windows.h> | ||
| 120 | #endif | ||
| 121 | |||
| 122 | #ifdef NeXT | ||
| 123 | #include <sys/dir.h> | ||
| 124 | #define dirent direct | ||
| 125 | #endif | ||
| 126 | |||
| 127 | #include <openssl/objects.h> | ||
| 128 | #include <openssl/bio.h> | ||
| 129 | #include <openssl/pem.h> | ||
| 130 | #include <openssl/x509v3.h> | ||
| 63 | #include "ssl_locl.h" | 131 | #include "ssl_locl.h" |
| 64 | 132 | ||
| 65 | CERT *ssl_cert_new() | 133 | int SSL_get_ex_data_X509_STORE_CTX_idx(void) |
| 134 | { | ||
| 135 | static volatile int ssl_x509_store_ctx_idx= -1; | ||
| 136 | |||
| 137 | if (ssl_x509_store_ctx_idx < 0) | ||
| 138 | { | ||
| 139 | /* any write lock will do; usually this branch | ||
| 140 | * will only be taken once anyway */ | ||
| 141 | CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); | ||
| 142 | |||
| 143 | if (ssl_x509_store_ctx_idx < 0) | ||
| 144 | { | ||
| 145 | ssl_x509_store_ctx_idx=X509_STORE_CTX_get_ex_new_index( | ||
| 146 | 0,"SSL for verify callback",NULL,NULL,NULL); | ||
| 147 | } | ||
| 148 | |||
| 149 | CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX); | ||
| 150 | } | ||
| 151 | return ssl_x509_store_ctx_idx; | ||
| 152 | } | ||
| 153 | |||
| 154 | CERT *ssl_cert_new(void) | ||
| 66 | { | 155 | { |
| 67 | CERT *ret; | 156 | CERT *ret; |
| 68 | 157 | ||
| 69 | ret=(CERT *)Malloc(sizeof(CERT)); | 158 | ret=(CERT *)OPENSSL_malloc(sizeof(CERT)); |
| 70 | if (ret == NULL) | 159 | if (ret == NULL) |
| 71 | { | 160 | { |
| 72 | SSLerr(SSL_F_SSL_CERT_NEW,ERR_R_MALLOC_FAILURE); | 161 | SSLerr(SSL_F_SSL_CERT_NEW,ERR_R_MALLOC_FAILURE); |
| 73 | return(NULL); | 162 | return(NULL); |
| 74 | } | 163 | } |
| 75 | memset(ret,0,sizeof(CERT)); | 164 | memset(ret,0,sizeof(CERT)); |
| 76 | /* | ||
| 77 | ret->valid=0; | ||
| 78 | ret->mask=0; | ||
| 79 | ret->export_mask=0; | ||
| 80 | ret->cert_type=0; | ||
| 81 | ret->key->x509=NULL; | ||
| 82 | ret->key->publickey=NULL; | ||
| 83 | ret->key->privatekey=NULL; */ | ||
| 84 | 165 | ||
| 85 | ret->key= &(ret->pkeys[SSL_PKEY_RSA_ENC]); | 166 | ret->key= &(ret->pkeys[SSL_PKEY_RSA_ENC]); |
| 86 | ret->references=1; | 167 | ret->references=1; |
| @@ -88,11 +169,151 @@ CERT *ssl_cert_new() | |||
| 88 | return(ret); | 169 | return(ret); |
| 89 | } | 170 | } |
| 90 | 171 | ||
| 91 | void ssl_cert_free(c) | 172 | CERT *ssl_cert_dup(CERT *cert) |
| 92 | CERT *c; | ||
| 93 | { | 173 | { |
| 174 | CERT *ret; | ||
| 94 | int i; | 175 | int i; |
| 95 | 176 | ||
| 177 | ret = (CERT *)OPENSSL_malloc(sizeof(CERT)); | ||
| 178 | if (ret == NULL) | ||
| 179 | { | ||
| 180 | SSLerr(SSL_F_SSL_CERT_DUP, ERR_R_MALLOC_FAILURE); | ||
| 181 | return(NULL); | ||
| 182 | } | ||
| 183 | |||
| 184 | memset(ret, 0, sizeof(CERT)); | ||
| 185 | |||
| 186 | ret->key = &ret->pkeys[cert->key - &cert->pkeys[0]]; | ||
| 187 | /* or ret->key = ret->pkeys + (cert->key - cert->pkeys), | ||
| 188 | * if you find that more readable */ | ||
| 189 | |||
| 190 | ret->valid = cert->valid; | ||
| 191 | ret->mask = cert->mask; | ||
| 192 | ret->export_mask = cert->export_mask; | ||
| 193 | |||
| 194 | #ifndef OPENSSL_NO_RSA | ||
| 195 | if (cert->rsa_tmp != NULL) | ||
| 196 | { | ||
| 197 | RSA_up_ref(cert->rsa_tmp); | ||
| 198 | ret->rsa_tmp = cert->rsa_tmp; | ||
| 199 | } | ||
| 200 | ret->rsa_tmp_cb = cert->rsa_tmp_cb; | ||
| 201 | #endif | ||
| 202 | |||
| 203 | #ifndef OPENSSL_NO_DH | ||
| 204 | if (cert->dh_tmp != NULL) | ||
| 205 | { | ||
| 206 | /* DH parameters don't have a reference count */ | ||
| 207 | ret->dh_tmp = DHparams_dup(cert->dh_tmp); | ||
| 208 | if (ret->dh_tmp == NULL) | ||
| 209 | { | ||
| 210 | SSLerr(SSL_F_SSL_CERT_DUP, ERR_R_DH_LIB); | ||
| 211 | goto err; | ||
| 212 | } | ||
| 213 | if (cert->dh_tmp->priv_key) | ||
| 214 | { | ||
| 215 | BIGNUM *b = BN_dup(cert->dh_tmp->priv_key); | ||
| 216 | if (!b) | ||
| 217 | { | ||
| 218 | SSLerr(SSL_F_SSL_CERT_DUP, ERR_R_BN_LIB); | ||
| 219 | goto err; | ||
| 220 | } | ||
| 221 | ret->dh_tmp->priv_key = b; | ||
| 222 | } | ||
| 223 | if (cert->dh_tmp->pub_key) | ||
| 224 | { | ||
| 225 | BIGNUM *b = BN_dup(cert->dh_tmp->pub_key); | ||
| 226 | if (!b) | ||
| 227 | { | ||
| 228 | SSLerr(SSL_F_SSL_CERT_DUP, ERR_R_BN_LIB); | ||
| 229 | goto err; | ||
| 230 | } | ||
| 231 | ret->dh_tmp->pub_key = b; | ||
| 232 | } | ||
| 233 | } | ||
| 234 | ret->dh_tmp_cb = cert->dh_tmp_cb; | ||
| 235 | #endif | ||
| 236 | |||
| 237 | for (i = 0; i < SSL_PKEY_NUM; i++) | ||
| 238 | { | ||
| 239 | if (cert->pkeys[i].x509 != NULL) | ||
| 240 | { | ||
| 241 | ret->pkeys[i].x509 = cert->pkeys[i].x509; | ||
| 242 | CRYPTO_add(&ret->pkeys[i].x509->references, 1, | ||
| 243 | CRYPTO_LOCK_X509); | ||
| 244 | } | ||
| 245 | |||
| 246 | if (cert->pkeys[i].privatekey != NULL) | ||
| 247 | { | ||
| 248 | ret->pkeys[i].privatekey = cert->pkeys[i].privatekey; | ||
| 249 | CRYPTO_add(&ret->pkeys[i].privatekey->references, 1, | ||
| 250 | CRYPTO_LOCK_EVP_PKEY); | ||
| 251 | |||
| 252 | switch(i) | ||
| 253 | { | ||
| 254 | /* If there was anything special to do for | ||
| 255 | * certain types of keys, we'd do it here. | ||
| 256 | * (Nothing at the moment, I think.) */ | ||
| 257 | |||
| 258 | case SSL_PKEY_RSA_ENC: | ||
| 259 | case SSL_PKEY_RSA_SIGN: | ||
| 260 | /* We have an RSA key. */ | ||
| 261 | break; | ||
| 262 | |||
| 263 | case SSL_PKEY_DSA_SIGN: | ||
| 264 | /* We have a DSA key. */ | ||
| 265 | break; | ||
| 266 | |||
| 267 | case SSL_PKEY_DH_RSA: | ||
| 268 | case SSL_PKEY_DH_DSA: | ||
| 269 | /* We have a DH key. */ | ||
| 270 | break; | ||
| 271 | |||
| 272 | default: | ||
| 273 | /* Can't happen. */ | ||
| 274 | SSLerr(SSL_F_SSL_CERT_DUP, SSL_R_LIBRARY_BUG); | ||
| 275 | } | ||
| 276 | } | ||
| 277 | } | ||
| 278 | |||
| 279 | /* ret->extra_certs *should* exist, but currently the own certificate | ||
| 280 | * chain is held inside SSL_CTX */ | ||
| 281 | |||
| 282 | ret->references=1; | ||
| 283 | |||
| 284 | return(ret); | ||
| 285 | |||
| 286 | #ifndef OPENSSL_NO_DH /* avoid 'unreferenced label' warning if OPENSSL_NO_DH is defined */ | ||
| 287 | err: | ||
| 288 | #endif | ||
| 289 | #ifndef OPENSSL_NO_RSA | ||
| 290 | if (ret->rsa_tmp != NULL) | ||
| 291 | RSA_free(ret->rsa_tmp); | ||
| 292 | #endif | ||
| 293 | #ifndef OPENSSL_NO_DH | ||
| 294 | if (ret->dh_tmp != NULL) | ||
| 295 | DH_free(ret->dh_tmp); | ||
| 296 | #endif | ||
| 297 | |||
| 298 | for (i = 0; i < SSL_PKEY_NUM; i++) | ||
| 299 | { | ||
| 300 | if (ret->pkeys[i].x509 != NULL) | ||
| 301 | X509_free(ret->pkeys[i].x509); | ||
| 302 | if (ret->pkeys[i].privatekey != NULL) | ||
| 303 | EVP_PKEY_free(ret->pkeys[i].privatekey); | ||
| 304 | } | ||
| 305 | |||
| 306 | return NULL; | ||
| 307 | } | ||
| 308 | |||
| 309 | |||
| 310 | void ssl_cert_free(CERT *c) | ||
| 311 | { | ||
| 312 | int i; | ||
| 313 | |||
| 314 | if(c == NULL) | ||
| 315 | return; | ||
| 316 | |||
| 96 | i=CRYPTO_add(&c->references,-1,CRYPTO_LOCK_SSL_CERT); | 317 | i=CRYPTO_add(&c->references,-1,CRYPTO_LOCK_SSL_CERT); |
| 97 | #ifdef REF_PRINT | 318 | #ifdef REF_PRINT |
| 98 | REF_PRINT("CERT",c); | 319 | REF_PRINT("CERT",c); |
| @@ -106,10 +327,10 @@ CERT *c; | |||
| 106 | } | 327 | } |
| 107 | #endif | 328 | #endif |
| 108 | 329 | ||
| 109 | #ifndef NO_RSA | 330 | #ifndef OPENSSL_NO_RSA |
| 110 | if (c->rsa_tmp) RSA_free(c->rsa_tmp); | 331 | if (c->rsa_tmp) RSA_free(c->rsa_tmp); |
| 111 | #endif | 332 | #endif |
| 112 | #ifndef NO_DH | 333 | #ifndef OPENSSL_NO_DH |
| 113 | if (c->dh_tmp) DH_free(c->dh_tmp); | 334 | if (c->dh_tmp) DH_free(c->dh_tmp); |
| 114 | #endif | 335 | #endif |
| 115 | 336 | ||
| @@ -124,97 +345,209 @@ CERT *c; | |||
| 124 | EVP_PKEY_free(c->pkeys[i].publickey); | 345 | EVP_PKEY_free(c->pkeys[i].publickey); |
| 125 | #endif | 346 | #endif |
| 126 | } | 347 | } |
| 127 | if (c->cert_chain != NULL) | 348 | OPENSSL_free(c); |
| 128 | sk_pop_free(c->cert_chain,X509_free); | ||
| 129 | Free(c); | ||
| 130 | } | 349 | } |
| 131 | 350 | ||
| 132 | int ssl_set_cert_type(c, type) | 351 | int ssl_cert_inst(CERT **o) |
| 133 | CERT *c; | ||
| 134 | int type; | ||
| 135 | { | 352 | { |
| 136 | c->cert_type=type; | 353 | /* Create a CERT if there isn't already one |
| 354 | * (which cannot really happen, as it is initially created in | ||
| 355 | * SSL_CTX_new; but the earlier code usually allows for that one | ||
| 356 | * being non-existant, so we follow that behaviour, as it might | ||
| 357 | * turn out that there actually is a reason for it -- but I'm | ||
| 358 | * not sure that *all* of the existing code could cope with | ||
| 359 | * s->cert being NULL, otherwise we could do without the | ||
| 360 | * initialization in SSL_CTX_new). | ||
| 361 | */ | ||
| 362 | |||
| 363 | if (o == NULL) | ||
| 364 | { | ||
| 365 | SSLerr(SSL_F_SSL_CERT_INST, ERR_R_PASSED_NULL_PARAMETER); | ||
| 366 | return(0); | ||
| 367 | } | ||
| 368 | if (*o == NULL) | ||
| 369 | { | ||
| 370 | if ((*o = ssl_cert_new()) == NULL) | ||
| 371 | { | ||
| 372 | SSLerr(SSL_F_SSL_CERT_INST, ERR_R_MALLOC_FAILURE); | ||
| 373 | return(0); | ||
| 374 | } | ||
| 375 | } | ||
| 137 | return(1); | 376 | return(1); |
| 138 | } | 377 | } |
| 139 | 378 | ||
| 140 | int ssl_verify_cert_chain(s,sk) | 379 | |
| 141 | SSL *s; | 380 | SESS_CERT *ssl_sess_cert_new(void) |
| 142 | STACK *sk; | 381 | { |
| 382 | SESS_CERT *ret; | ||
| 383 | |||
| 384 | ret = OPENSSL_malloc(sizeof *ret); | ||
| 385 | if (ret == NULL) | ||
| 386 | { | ||
| 387 | SSLerr(SSL_F_SSL_SESS_CERT_NEW, ERR_R_MALLOC_FAILURE); | ||
| 388 | return NULL; | ||
| 389 | } | ||
| 390 | |||
| 391 | memset(ret, 0 ,sizeof *ret); | ||
| 392 | ret->peer_key = &(ret->peer_pkeys[SSL_PKEY_RSA_ENC]); | ||
| 393 | ret->references = 1; | ||
| 394 | |||
| 395 | return ret; | ||
| 396 | } | ||
| 397 | |||
| 398 | void ssl_sess_cert_free(SESS_CERT *sc) | ||
| 399 | { | ||
| 400 | int i; | ||
| 401 | |||
| 402 | if (sc == NULL) | ||
| 403 | return; | ||
| 404 | |||
| 405 | i = CRYPTO_add(&sc->references, -1, CRYPTO_LOCK_SSL_SESS_CERT); | ||
| 406 | #ifdef REF_PRINT | ||
| 407 | REF_PRINT("SESS_CERT", sc); | ||
| 408 | #endif | ||
| 409 | if (i > 0) | ||
| 410 | return; | ||
| 411 | #ifdef REF_CHECK | ||
| 412 | if (i < 0) | ||
| 413 | { | ||
| 414 | fprintf(stderr,"ssl_sess_cert_free, bad reference count\n"); | ||
| 415 | abort(); /* ok */ | ||
| 416 | } | ||
| 417 | #endif | ||
| 418 | |||
| 419 | /* i == 0 */ | ||
| 420 | if (sc->cert_chain != NULL) | ||
| 421 | sk_X509_pop_free(sc->cert_chain, X509_free); | ||
| 422 | for (i = 0; i < SSL_PKEY_NUM; i++) | ||
| 423 | { | ||
| 424 | if (sc->peer_pkeys[i].x509 != NULL) | ||
| 425 | X509_free(sc->peer_pkeys[i].x509); | ||
| 426 | #if 0 /* We don't have the peer's private key. These lines are just | ||
| 427 | * here as a reminder that we're still using a not-quite-appropriate | ||
| 428 | * data structure. */ | ||
| 429 | if (sc->peer_pkeys[i].privatekey != NULL) | ||
| 430 | EVP_PKEY_free(sc->peer_pkeys[i].privatekey); | ||
| 431 | #endif | ||
| 432 | } | ||
| 433 | |||
| 434 | #ifndef OPENSSL_NO_RSA | ||
| 435 | if (sc->peer_rsa_tmp != NULL) | ||
| 436 | RSA_free(sc->peer_rsa_tmp); | ||
| 437 | #endif | ||
| 438 | #ifndef OPENSSL_NO_DH | ||
| 439 | if (sc->peer_dh_tmp != NULL) | ||
| 440 | DH_free(sc->peer_dh_tmp); | ||
| 441 | #endif | ||
| 442 | |||
| 443 | OPENSSL_free(sc); | ||
| 444 | } | ||
| 445 | |||
| 446 | int ssl_set_peer_cert_type(SESS_CERT *sc,int type) | ||
| 447 | { | ||
| 448 | sc->peer_cert_type = type; | ||
| 449 | return(1); | ||
| 450 | } | ||
| 451 | |||
| 452 | int ssl_verify_cert_chain(SSL *s,STACK_OF(X509) *sk) | ||
| 143 | { | 453 | { |
| 144 | X509 *x; | 454 | X509 *x; |
| 145 | int i; | 455 | int i; |
| 146 | X509_STORE_CTX ctx; | 456 | X509_STORE_CTX ctx; |
| 147 | 457 | ||
| 148 | if ((sk == NULL) || (sk_num(sk) == 0)) | 458 | if ((sk == NULL) || (sk_X509_num(sk) == 0)) |
| 149 | return(0); | 459 | return(0); |
| 150 | 460 | ||
| 151 | x=(X509 *)sk_value(sk,0); | 461 | x=sk_X509_value(sk,0); |
| 152 | X509_STORE_CTX_init(&ctx,s->ctx->cert_store,x,sk); | 462 | if(!X509_STORE_CTX_init(&ctx,s->ctx->cert_store,x,sk)) |
| 153 | X509_STORE_CTX_set_app_data(&ctx,(char *)s); | 463 | { |
| 464 | SSLerr(SSL_F_SSL_VERIFY_CERT_CHAIN,ERR_R_X509_LIB); | ||
| 465 | return(0); | ||
| 466 | } | ||
| 467 | if (SSL_get_verify_depth(s) >= 0) | ||
| 468 | X509_STORE_CTX_set_depth(&ctx, SSL_get_verify_depth(s)); | ||
| 469 | X509_STORE_CTX_set_ex_data(&ctx,SSL_get_ex_data_X509_STORE_CTX_idx(),s); | ||
| 470 | |||
| 471 | /* We need to set the verify purpose. The purpose can be determined by | ||
| 472 | * the context: if its a server it will verify SSL client certificates | ||
| 473 | * or vice versa. | ||
| 474 | */ | ||
| 475 | if (s->server) | ||
| 476 | i = X509_PURPOSE_SSL_CLIENT; | ||
| 477 | else | ||
| 478 | i = X509_PURPOSE_SSL_SERVER; | ||
| 479 | |||
| 480 | X509_STORE_CTX_purpose_inherit(&ctx, i, s->purpose, s->trust); | ||
| 481 | |||
| 482 | if (s->verify_callback) | ||
| 483 | X509_STORE_CTX_set_verify_cb(&ctx, s->verify_callback); | ||
| 154 | 484 | ||
| 155 | if (s->ctx->app_verify_callback != NULL) | 485 | if (s->ctx->app_verify_callback != NULL) |
| 156 | i=s->ctx->app_verify_callback(&ctx); | 486 | #if 1 /* new with OpenSSL 0.9.7 */ |
| 487 | i=s->ctx->app_verify_callback(&ctx, s->ctx->app_verify_arg); | ||
| 488 | #else | ||
| 489 | i=s->ctx->app_verify_callback(&ctx); /* should pass app_verify_arg */ | ||
| 490 | #endif | ||
| 157 | else | 491 | else |
| 492 | { | ||
| 493 | #ifndef OPENSSL_NO_X509_VERIFY | ||
| 158 | i=X509_verify_cert(&ctx); | 494 | i=X509_verify_cert(&ctx); |
| 495 | #else | ||
| 496 | i=0; | ||
| 497 | ctx.error=X509_V_ERR_APPLICATION_VERIFICATION; | ||
| 498 | SSLerr(SSL_F_SSL_VERIFY_CERT_CHAIN,SSL_R_NO_VERIFY_CALLBACK); | ||
| 499 | #endif | ||
| 500 | } | ||
| 159 | 501 | ||
| 160 | X509_STORE_CTX_cleanup(&ctx); | ||
| 161 | s->verify_result=ctx.error; | 502 | s->verify_result=ctx.error; |
| 503 | X509_STORE_CTX_cleanup(&ctx); | ||
| 162 | 504 | ||
| 163 | return(i); | 505 | return(i); |
| 164 | } | 506 | } |
| 165 | 507 | ||
| 166 | static void set_client_CA_list(ca_list,list) | 508 | static void set_client_CA_list(STACK_OF(X509_NAME) **ca_list,STACK_OF(X509_NAME) *list) |
| 167 | STACK **ca_list; | ||
| 168 | STACK *list; | ||
| 169 | { | 509 | { |
| 170 | if (*ca_list != NULL) | 510 | if (*ca_list != NULL) |
| 171 | sk_pop_free(*ca_list,X509_NAME_free); | 511 | sk_X509_NAME_pop_free(*ca_list,X509_NAME_free); |
| 172 | 512 | ||
| 173 | *ca_list=list; | 513 | *ca_list=list; |
| 174 | } | 514 | } |
| 175 | 515 | ||
| 176 | STACK *SSL_dup_CA_list(sk) | 516 | STACK_OF(X509_NAME) *SSL_dup_CA_list(STACK_OF(X509_NAME) *sk) |
| 177 | STACK *sk; | ||
| 178 | { | 517 | { |
| 179 | int i; | 518 | int i; |
| 180 | STACK *ret; | 519 | STACK_OF(X509_NAME) *ret; |
| 181 | X509_NAME *name; | 520 | X509_NAME *name; |
| 182 | 521 | ||
| 183 | ret=sk_new_null(); | 522 | ret=sk_X509_NAME_new_null(); |
| 184 | for (i=0; i<sk_num(sk); i++) | 523 | for (i=0; i<sk_X509_NAME_num(sk); i++) |
| 185 | { | 524 | { |
| 186 | name=X509_NAME_dup((X509_NAME *)sk_value(sk,i)); | 525 | name=X509_NAME_dup(sk_X509_NAME_value(sk,i)); |
| 187 | if ((name == NULL) || !sk_push(ret,(char *)name)) | 526 | if ((name == NULL) || !sk_X509_NAME_push(ret,name)) |
| 188 | { | 527 | { |
| 189 | sk_pop_free(ret,X509_NAME_free); | 528 | sk_X509_NAME_pop_free(ret,X509_NAME_free); |
| 190 | return(NULL); | 529 | return(NULL); |
| 191 | } | 530 | } |
| 192 | } | 531 | } |
| 193 | return(ret); | 532 | return(ret); |
| 194 | } | 533 | } |
| 195 | 534 | ||
| 196 | void SSL_set_client_CA_list(s,list) | 535 | void SSL_set_client_CA_list(SSL *s,STACK_OF(X509_NAME) *list) |
| 197 | SSL *s; | ||
| 198 | STACK *list; | ||
| 199 | { | 536 | { |
| 200 | set_client_CA_list(&(s->client_CA),list); | 537 | set_client_CA_list(&(s->client_CA),list); |
| 201 | } | 538 | } |
| 202 | 539 | ||
| 203 | void SSL_CTX_set_client_CA_list(ctx,list) | 540 | void SSL_CTX_set_client_CA_list(SSL_CTX *ctx,STACK_OF(X509_NAME) *list) |
| 204 | SSL_CTX *ctx; | ||
| 205 | STACK *list; | ||
| 206 | { | 541 | { |
| 207 | set_client_CA_list(&(ctx->client_CA),list); | 542 | set_client_CA_list(&(ctx->client_CA),list); |
| 208 | } | 543 | } |
| 209 | 544 | ||
| 210 | STACK *SSL_CTX_get_client_CA_list(ctx) | 545 | STACK_OF(X509_NAME) *SSL_CTX_get_client_CA_list(SSL_CTX *ctx) |
| 211 | SSL_CTX *ctx; | ||
| 212 | { | 546 | { |
| 213 | return(ctx->client_CA); | 547 | return(ctx->client_CA); |
| 214 | } | 548 | } |
| 215 | 549 | ||
| 216 | STACK *SSL_get_client_CA_list(s) | 550 | STACK_OF(X509_NAME) *SSL_get_client_CA_list(SSL *s) |
| 217 | SSL *s; | ||
| 218 | { | 551 | { |
| 219 | if (s->type == SSL_ST_CONNECT) | 552 | if (s->type == SSL_ST_CONNECT) |
| 220 | { /* we are in the client */ | 553 | { /* we are in the client */ |
| @@ -233,20 +566,18 @@ SSL *s; | |||
| 233 | } | 566 | } |
| 234 | } | 567 | } |
| 235 | 568 | ||
| 236 | static int add_client_CA(sk,x) | 569 | static int add_client_CA(STACK_OF(X509_NAME) **sk,X509 *x) |
| 237 | STACK **sk; | ||
| 238 | X509 *x; | ||
| 239 | { | 570 | { |
| 240 | X509_NAME *name; | 571 | X509_NAME *name; |
| 241 | 572 | ||
| 242 | if (x == NULL) return(0); | 573 | if (x == NULL) return(0); |
| 243 | if ((*sk == NULL) && ((*sk=sk_new_null()) == NULL)) | 574 | if ((*sk == NULL) && ((*sk=sk_X509_NAME_new_null()) == NULL)) |
| 244 | return(0); | 575 | return(0); |
| 245 | 576 | ||
| 246 | if ((name=X509_NAME_dup(X509_get_subject_name(x))) == NULL) | 577 | if ((name=X509_NAME_dup(X509_get_subject_name(x))) == NULL) |
| 247 | return(0); | 578 | return(0); |
| 248 | 579 | ||
| 249 | if (!sk_push(*sk,(char *)name)) | 580 | if (!sk_X509_NAME_push(*sk,name)) |
| 250 | { | 581 | { |
| 251 | X509_NAME_free(name); | 582 | X509_NAME_free(name); |
| 252 | return(0); | 583 | return(0); |
| @@ -254,37 +585,39 @@ X509 *x; | |||
| 254 | return(1); | 585 | return(1); |
| 255 | } | 586 | } |
| 256 | 587 | ||
| 257 | int SSL_add_client_CA(ssl,x) | 588 | int SSL_add_client_CA(SSL *ssl,X509 *x) |
| 258 | SSL *ssl; | ||
| 259 | X509 *x; | ||
| 260 | { | 589 | { |
| 261 | return(add_client_CA(&(ssl->client_CA),x)); | 590 | return(add_client_CA(&(ssl->client_CA),x)); |
| 262 | } | 591 | } |
| 263 | 592 | ||
| 264 | int SSL_CTX_add_client_CA(ctx,x) | 593 | int SSL_CTX_add_client_CA(SSL_CTX *ctx,X509 *x) |
| 265 | SSL_CTX *ctx; | ||
| 266 | X509 *x; | ||
| 267 | { | 594 | { |
| 268 | return(add_client_CA(&(ctx->client_CA),x)); | 595 | return(add_client_CA(&(ctx->client_CA),x)); |
| 269 | } | 596 | } |
| 270 | 597 | ||
| 271 | static int name_cmp(a,b) | 598 | static int xname_cmp(const X509_NAME * const *a, const X509_NAME * const *b) |
| 272 | X509_NAME **a,**b; | ||
| 273 | { | 599 | { |
| 274 | return(X509_NAME_cmp(*a,*b)); | 600 | return(X509_NAME_cmp(*a,*b)); |
| 275 | } | 601 | } |
| 276 | 602 | ||
| 277 | #ifndef NO_STDIO | 603 | #ifndef OPENSSL_NO_STDIO |
| 278 | STACK *SSL_load_client_CA_file(file) | 604 | /*! |
| 279 | char *file; | 605 | * Load CA certs from a file into a ::STACK. Note that it is somewhat misnamed; |
| 606 | * it doesn't really have anything to do with clients (except that a common use | ||
| 607 | * for a stack of CAs is to send it to the client). Actually, it doesn't have | ||
| 608 | * much to do with CAs, either, since it will load any old cert. | ||
| 609 | * \param file the file containing one or more certs. | ||
| 610 | * \return a ::STACK containing the certs. | ||
| 611 | */ | ||
| 612 | STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file) | ||
| 280 | { | 613 | { |
| 281 | BIO *in; | 614 | BIO *in; |
| 282 | X509 *x=NULL; | 615 | X509 *x=NULL; |
| 283 | X509_NAME *xn=NULL; | 616 | X509_NAME *xn=NULL; |
| 284 | STACK *ret,*sk; | 617 | STACK_OF(X509_NAME) *ret,*sk; |
| 285 | 618 | ||
| 286 | ret=sk_new(NULL); | 619 | ret=sk_X509_NAME_new_null(); |
| 287 | sk=sk_new(name_cmp); | 620 | sk=sk_X509_NAME_new(xname_cmp); |
| 288 | 621 | ||
| 289 | in=BIO_new(BIO_s_file_internal()); | 622 | in=BIO_new(BIO_s_file_internal()); |
| 290 | 623 | ||
| @@ -299,31 +632,201 @@ char *file; | |||
| 299 | 632 | ||
| 300 | for (;;) | 633 | for (;;) |
| 301 | { | 634 | { |
| 302 | if (PEM_read_bio_X509(in,&x,NULL) == NULL) | 635 | if (PEM_read_bio_X509(in,&x,NULL,NULL) == NULL) |
| 303 | break; | 636 | break; |
| 304 | if ((xn=X509_get_subject_name(x)) == NULL) goto err; | 637 | if ((xn=X509_get_subject_name(x)) == NULL) goto err; |
| 305 | /* check for duplicates */ | 638 | /* check for duplicates */ |
| 306 | xn=X509_NAME_dup(xn); | 639 | xn=X509_NAME_dup(xn); |
| 307 | if (xn == NULL) goto err; | 640 | if (xn == NULL) goto err; |
| 308 | if (sk_find(sk,(char *)xn) >= 0) | 641 | if (sk_X509_NAME_find(sk,xn) >= 0) |
| 309 | X509_NAME_free(xn); | 642 | X509_NAME_free(xn); |
| 310 | else | 643 | else |
| 311 | { | 644 | { |
| 312 | sk_push(sk,(char *)xn); | 645 | sk_X509_NAME_push(sk,xn); |
| 313 | sk_push(ret,(char *)xn); | 646 | sk_X509_NAME_push(ret,xn); |
| 314 | } | 647 | } |
| 315 | } | 648 | } |
| 316 | 649 | ||
| 317 | if (0) | 650 | if (0) |
| 318 | { | 651 | { |
| 319 | err: | 652 | err: |
| 320 | if (ret != NULL) sk_pop_free(ret,X509_NAME_free); | 653 | if (ret != NULL) sk_X509_NAME_pop_free(ret,X509_NAME_free); |
| 321 | ret=NULL; | 654 | ret=NULL; |
| 322 | } | 655 | } |
| 323 | if (sk != NULL) sk_free(sk); | 656 | if (sk != NULL) sk_X509_NAME_free(sk); |
| 324 | if (in != NULL) BIO_free(in); | 657 | if (in != NULL) BIO_free(in); |
| 325 | if (x != NULL) X509_free(x); | 658 | if (x != NULL) X509_free(x); |
| 326 | return(ret); | 659 | return(ret); |
| 327 | } | 660 | } |
| 328 | #endif | 661 | #endif |
| 329 | 662 | ||
| 663 | /*! | ||
| 664 | * Add a file of certs to a stack. | ||
| 665 | * \param stack the stack to add to. | ||
| 666 | * \param file the file to add from. All certs in this file that are not | ||
| 667 | * already in the stack will be added. | ||
| 668 | * \return 1 for success, 0 for failure. Note that in the case of failure some | ||
| 669 | * certs may have been added to \c stack. | ||
| 670 | */ | ||
| 671 | |||
| 672 | int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, | ||
| 673 | const char *file) | ||
| 674 | { | ||
| 675 | BIO *in; | ||
| 676 | X509 *x=NULL; | ||
| 677 | X509_NAME *xn=NULL; | ||
| 678 | int ret=1; | ||
| 679 | int (*oldcmp)(const X509_NAME * const *a, const X509_NAME * const *b); | ||
| 680 | |||
| 681 | oldcmp=sk_X509_NAME_set_cmp_func(stack,xname_cmp); | ||
| 682 | |||
| 683 | in=BIO_new(BIO_s_file_internal()); | ||
| 684 | |||
| 685 | if (in == NULL) | ||
| 686 | { | ||
| 687 | SSLerr(SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK,ERR_R_MALLOC_FAILURE); | ||
| 688 | goto err; | ||
| 689 | } | ||
| 690 | |||
| 691 | if (!BIO_read_filename(in,file)) | ||
| 692 | goto err; | ||
| 693 | |||
| 694 | for (;;) | ||
| 695 | { | ||
| 696 | if (PEM_read_bio_X509(in,&x,NULL,NULL) == NULL) | ||
| 697 | break; | ||
| 698 | if ((xn=X509_get_subject_name(x)) == NULL) goto err; | ||
| 699 | xn=X509_NAME_dup(xn); | ||
| 700 | if (xn == NULL) goto err; | ||
| 701 | if (sk_X509_NAME_find(stack,xn) >= 0) | ||
| 702 | X509_NAME_free(xn); | ||
| 703 | else | ||
| 704 | sk_X509_NAME_push(stack,xn); | ||
| 705 | } | ||
| 706 | |||
| 707 | if (0) | ||
| 708 | { | ||
| 709 | err: | ||
| 710 | ret=0; | ||
| 711 | } | ||
| 712 | if(in != NULL) | ||
| 713 | BIO_free(in); | ||
| 714 | if(x != NULL) | ||
| 715 | X509_free(x); | ||
| 716 | |||
| 717 | sk_X509_NAME_set_cmp_func(stack,oldcmp); | ||
| 718 | |||
| 719 | return ret; | ||
| 720 | } | ||
| 721 | |||
| 722 | /*! | ||
| 723 | * Add a directory of certs to a stack. | ||
| 724 | * \param stack the stack to append to. | ||
| 725 | * \param dir the directory to append from. All files in this directory will be | ||
| 726 | * examined as potential certs. Any that are acceptable to | ||
| 727 | * SSL_add_dir_cert_subjects_to_stack() that are not already in the stack will be | ||
| 728 | * included. | ||
| 729 | * \return 1 for success, 0 for failure. Note that in the case of failure some | ||
| 730 | * certs may have been added to \c stack. | ||
| 731 | */ | ||
| 732 | |||
| 733 | #ifndef OPENSSL_SYS_WIN32 | ||
| 734 | #ifndef OPENSSL_SYS_VMS /* XXXX This may be fixed in the future */ | ||
| 735 | #ifndef OPENSSL_SYS_MACINTOSH_CLASSIC /* XXXXX: Better scheme needed! */ | ||
| 736 | |||
| 737 | int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, | ||
| 738 | const char *dir) | ||
| 739 | { | ||
| 740 | DIR *d; | ||
| 741 | struct dirent *dstruct; | ||
| 742 | int ret = 0; | ||
| 743 | |||
| 744 | CRYPTO_w_lock(CRYPTO_LOCK_READDIR); | ||
| 745 | d = opendir(dir); | ||
| 746 | |||
| 747 | /* Note that a side effect is that the CAs will be sorted by name */ | ||
| 748 | if(!d) | ||
| 749 | { | ||
| 750 | SYSerr(SYS_F_OPENDIR, get_last_sys_error()); | ||
| 751 | ERR_add_error_data(3, "opendir('", dir, "')"); | ||
| 752 | SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK, ERR_R_SYS_LIB); | ||
| 753 | goto err; | ||
| 754 | } | ||
| 755 | |||
| 756 | while((dstruct=readdir(d))) | ||
| 757 | { | ||
| 758 | char buf[1024]; | ||
| 759 | int r; | ||
| 760 | |||
| 761 | if(strlen(dir)+strlen(dstruct->d_name)+2 > sizeof buf) | ||
| 762 | { | ||
| 763 | SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK,SSL_R_PATH_TOO_LONG); | ||
| 764 | goto err; | ||
| 765 | } | ||
| 766 | |||
| 767 | r = BIO_snprintf(buf,sizeof buf,"%s/%s",dir,dstruct->d_name); | ||
| 768 | if (r <= 0 || r >= sizeof buf) | ||
| 769 | goto err; | ||
| 770 | if(!SSL_add_file_cert_subjects_to_stack(stack,buf)) | ||
| 771 | goto err; | ||
| 772 | } | ||
| 773 | ret = 1; | ||
| 774 | |||
| 775 | err: | ||
| 776 | if (d) closedir(d); | ||
| 777 | CRYPTO_w_unlock(CRYPTO_LOCK_READDIR); | ||
| 778 | return ret; | ||
| 779 | } | ||
| 780 | |||
| 781 | #endif | ||
| 782 | #endif | ||
| 783 | |||
| 784 | #else | ||
| 785 | |||
| 786 | int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack, | ||
| 787 | const char *dir) | ||
| 788 | { | ||
| 789 | WIN32_FIND_DATA FindFileData; | ||
| 790 | HANDLE hFind; | ||
| 791 | int ret = 0; | ||
| 792 | |||
| 793 | CRYPTO_w_lock(CRYPTO_LOCK_READDIR); | ||
| 794 | |||
| 795 | hFind = FindFirstFile(dir, &FindFileData); | ||
| 796 | /* Note that a side effect is that the CAs will be sorted by name */ | ||
| 797 | if(hFind == INVALID_HANDLE_VALUE) | ||
| 798 | { | ||
| 799 | SYSerr(SYS_F_OPENDIR, get_last_sys_error()); | ||
| 800 | ERR_add_error_data(3, "opendir('", dir, "')"); | ||
| 801 | SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK, ERR_R_SYS_LIB); | ||
| 802 | goto err_noclose; | ||
| 803 | } | ||
| 804 | |||
| 805 | do | ||
| 806 | { | ||
| 807 | char buf[1024]; | ||
| 808 | int r; | ||
| 809 | |||
| 810 | if(strlen(dir)+strlen(FindFileData.cFileName)+2 > sizeof buf) | ||
| 811 | { | ||
| 812 | SSLerr(SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK,SSL_R_PATH_TOO_LONG); | ||
| 813 | goto err; | ||
| 814 | } | ||
| 815 | |||
| 816 | r = BIO_snprintf(buf,sizeof buf,"%s/%s",dir,FindFileData.cFileName); | ||
| 817 | if (r <= 0 || r >= sizeof buf) | ||
| 818 | goto err; | ||
| 819 | if(!SSL_add_file_cert_subjects_to_stack(stack,buf)) | ||
| 820 | goto err; | ||
| 821 | } | ||
| 822 | while (FindNextFile(hFind, &FindFileData) != FALSE); | ||
| 823 | ret = 1; | ||
| 824 | |||
| 825 | err: | ||
| 826 | FindClose(hFind); | ||
| 827 | err_noclose: | ||
| 828 | CRYPTO_w_unlock(CRYPTO_LOCK_READDIR); | ||
| 829 | return ret; | ||
| 830 | } | ||
| 831 | |||
| 832 | #endif | ||
diff --git a/src/lib/libssl/ssl_ciph.c b/src/lib/libssl/ssl_ciph.c index 820994408b..cdd8dde128 100644 --- a/src/lib/libssl/ssl_ciph.c +++ b/src/lib/libssl/ssl_ciph.c | |||
| @@ -57,7 +57,8 @@ | |||
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include "objects.h" | 60 | #include <openssl/objects.h> |
| 61 | #include <openssl/comp.h> | ||
| 61 | #include "ssl_locl.h" | 62 | #include "ssl_locl.h" |
| 62 | 63 | ||
| 63 | #define SSL_ENC_DES_IDX 0 | 64 | #define SSL_ENC_DES_IDX 0 |
| @@ -67,37 +68,28 @@ | |||
| 67 | #define SSL_ENC_IDEA_IDX 4 | 68 | #define SSL_ENC_IDEA_IDX 4 |
| 68 | #define SSL_ENC_eFZA_IDX 5 | 69 | #define SSL_ENC_eFZA_IDX 5 |
| 69 | #define SSL_ENC_NULL_IDX 6 | 70 | #define SSL_ENC_NULL_IDX 6 |
| 70 | #define SSL_ENC_NUM_IDX 7 | 71 | #define SSL_ENC_AES128_IDX 7 |
| 72 | #define SSL_ENC_AES256_IDX 8 | ||
| 73 | #define SSL_ENC_NUM_IDX 9 | ||
| 71 | 74 | ||
| 72 | static EVP_CIPHER *ssl_cipher_methods[SSL_ENC_NUM_IDX]={ | 75 | static const EVP_CIPHER *ssl_cipher_methods[SSL_ENC_NUM_IDX]={ |
| 73 | NULL,NULL,NULL,NULL,NULL,NULL, | 76 | NULL,NULL,NULL,NULL,NULL,NULL, |
| 74 | }; | 77 | }; |
| 75 | 78 | ||
| 79 | static STACK_OF(SSL_COMP) *ssl_comp_methods=NULL; | ||
| 80 | |||
| 76 | #define SSL_MD_MD5_IDX 0 | 81 | #define SSL_MD_MD5_IDX 0 |
| 77 | #define SSL_MD_SHA1_IDX 1 | 82 | #define SSL_MD_SHA1_IDX 1 |
| 78 | #define SSL_MD_NUM_IDX 2 | 83 | #define SSL_MD_NUM_IDX 2 |
| 79 | static EVP_MD *ssl_digest_methods[SSL_MD_NUM_IDX]={ | 84 | static const EVP_MD *ssl_digest_methods[SSL_MD_NUM_IDX]={ |
| 80 | NULL,NULL, | 85 | NULL,NULL, |
| 81 | }; | 86 | }; |
| 82 | 87 | ||
| 83 | typedef struct cipher_sort_st | ||
| 84 | { | ||
| 85 | SSL_CIPHER *cipher; | ||
| 86 | int pref; | ||
| 87 | } CIPHER_SORT; | ||
| 88 | |||
| 89 | #define CIPHER_ADD 1 | 88 | #define CIPHER_ADD 1 |
| 90 | #define CIPHER_KILL 2 | 89 | #define CIPHER_KILL 2 |
| 91 | #define CIPHER_DEL 3 | 90 | #define CIPHER_DEL 3 |
| 92 | #define CIPHER_ORD 4 | 91 | #define CIPHER_ORD 4 |
| 93 | 92 | #define CIPHER_SPECIAL 5 | |
| 94 | typedef struct cipher_choice_st | ||
| 95 | { | ||
| 96 | int type; | ||
| 97 | unsigned long algorithms; | ||
| 98 | unsigned long mask; | ||
| 99 | long top; | ||
| 100 | } CIPHER_CHOICE; | ||
| 101 | 93 | ||
| 102 | typedef struct cipher_order_st | 94 | typedef struct cipher_order_st |
| 103 | { | 95 | { |
| @@ -107,59 +99,62 @@ typedef struct cipher_order_st | |||
| 107 | struct cipher_order_st *next,*prev; | 99 | struct cipher_order_st *next,*prev; |
| 108 | } CIPHER_ORDER; | 100 | } CIPHER_ORDER; |
| 109 | 101 | ||
| 110 | static SSL_CIPHER cipher_aliases[]={ | 102 | static const SSL_CIPHER cipher_aliases[]={ |
| 111 | {0,SSL_TXT_ALL, 0,SSL_ALL, 0,SSL_ALL}, /* must be first */ | 103 | /* Don't include eNULL unless specifically enabled. |
| 112 | {0,SSL_TXT_kRSA,0,SSL_kRSA, 0,SSL_MKEY_MASK}, | 104 | * Similarly, don't include AES in ALL because these ciphers are not yet official. */ |
| 113 | {0,SSL_TXT_kDHr,0,SSL_kDHr, 0,SSL_MKEY_MASK}, | 105 | {0,SSL_TXT_ALL, 0,SSL_ALL & ~SSL_eNULL & ~SSL_AES, SSL_ALL ,0,0,0,SSL_ALL,SSL_ALL}, /* must be first */ |
| 114 | {0,SSL_TXT_kDHd,0,SSL_kDHd, 0,SSL_MKEY_MASK}, | 106 | {0,SSL_TXT_kKRB5,0,SSL_kKRB5,0,0,0,0,SSL_MKEY_MASK,0}, /* VRS Kerberos5 */ |
| 115 | {0,SSL_TXT_kEDH,0,SSL_kEDH, 0,SSL_MKEY_MASK}, | 107 | {0,SSL_TXT_kRSA,0,SSL_kRSA, 0,0,0,0,SSL_MKEY_MASK,0}, |
| 116 | {0,SSL_TXT_kFZA,0,SSL_kFZA, 0,SSL_MKEY_MASK}, | 108 | {0,SSL_TXT_kDHr,0,SSL_kDHr, 0,0,0,0,SSL_MKEY_MASK,0}, |
| 117 | {0,SSL_TXT_DH, 0,SSL_DH, 0,SSL_MKEY_MASK}, | 109 | {0,SSL_TXT_kDHd,0,SSL_kDHd, 0,0,0,0,SSL_MKEY_MASK,0}, |
| 118 | {0,SSL_TXT_EDH, 0,SSL_EDH, 0,SSL_MKEY_MASK|SSL_AUTH_MASK}, | 110 | {0,SSL_TXT_kEDH,0,SSL_kEDH, 0,0,0,0,SSL_MKEY_MASK,0}, |
| 119 | 111 | {0,SSL_TXT_kFZA,0,SSL_kFZA, 0,0,0,0,SSL_MKEY_MASK,0}, | |
| 120 | {0,SSL_TXT_aRSA,0,SSL_aRSA, 0,SSL_AUTH_MASK}, | 112 | {0,SSL_TXT_DH, 0,SSL_DH, 0,0,0,0,SSL_MKEY_MASK,0}, |
| 121 | {0,SSL_TXT_aDSS,0,SSL_aDSS, 0,SSL_AUTH_MASK}, | 113 | {0,SSL_TXT_EDH, 0,SSL_EDH, 0,0,0,0,SSL_MKEY_MASK|SSL_AUTH_MASK,0}, |
| 122 | {0,SSL_TXT_aFZA,0,SSL_aFZA, 0,SSL_AUTH_MASK}, | 114 | |
| 123 | {0,SSL_TXT_aNULL,0,SSL_aNULL,0,SSL_AUTH_MASK}, | 115 | {0,SSL_TXT_aKRB5,0,SSL_aKRB5,0,0,0,0,SSL_AUTH_MASK,0}, /* VRS Kerberos5 */ |
| 124 | {0,SSL_TXT_aDH, 0,SSL_aDH, 0,SSL_AUTH_MASK}, | 116 | {0,SSL_TXT_aRSA,0,SSL_aRSA, 0,0,0,0,SSL_AUTH_MASK,0}, |
| 125 | {0,SSL_TXT_DSS, 0,SSL_DSS, 0,SSL_AUTH_MASK}, | 117 | {0,SSL_TXT_aDSS,0,SSL_aDSS, 0,0,0,0,SSL_AUTH_MASK,0}, |
| 126 | 118 | {0,SSL_TXT_aFZA,0,SSL_aFZA, 0,0,0,0,SSL_AUTH_MASK,0}, | |
| 127 | {0,SSL_TXT_DES, 0,SSL_DES, 0,SSL_ENC_MASK}, | 119 | {0,SSL_TXT_aNULL,0,SSL_aNULL,0,0,0,0,SSL_AUTH_MASK,0}, |
| 128 | {0,SSL_TXT_3DES,0,SSL_3DES, 0,SSL_ENC_MASK}, | 120 | {0,SSL_TXT_aDH, 0,SSL_aDH, 0,0,0,0,SSL_AUTH_MASK,0}, |
| 129 | {0,SSL_TXT_RC4, 0,SSL_RC4, 0,SSL_ENC_MASK}, | 121 | {0,SSL_TXT_DSS, 0,SSL_DSS, 0,0,0,0,SSL_AUTH_MASK,0}, |
| 130 | {0,SSL_TXT_RC2, 0,SSL_RC2, 0,SSL_ENC_MASK}, | 122 | |
| 131 | {0,SSL_TXT_IDEA,0,SSL_IDEA, 0,SSL_ENC_MASK}, | 123 | {0,SSL_TXT_DES, 0,SSL_DES, 0,0,0,0,SSL_ENC_MASK,0}, |
| 132 | {0,SSL_TXT_eNULL,0,SSL_eNULL,0,SSL_ENC_MASK}, | 124 | {0,SSL_TXT_3DES,0,SSL_3DES, 0,0,0,0,SSL_ENC_MASK,0}, |
| 133 | {0,SSL_TXT_eFZA,0,SSL_eFZA, 0,SSL_ENC_MASK}, | 125 | {0,SSL_TXT_RC4, 0,SSL_RC4, 0,0,0,0,SSL_ENC_MASK,0}, |
| 134 | 126 | {0,SSL_TXT_RC2, 0,SSL_RC2, 0,0,0,0,SSL_ENC_MASK,0}, | |
| 135 | {0,SSL_TXT_MD5, 0,SSL_MD5, 0,SSL_MAC_MASK}, | 127 | {0,SSL_TXT_IDEA,0,SSL_IDEA, 0,0,0,0,SSL_ENC_MASK,0}, |
| 136 | {0,SSL_TXT_SHA1,0,SSL_SHA1, 0,SSL_MAC_MASK}, | 128 | {0,SSL_TXT_eNULL,0,SSL_eNULL,0,0,0,0,SSL_ENC_MASK,0}, |
| 137 | {0,SSL_TXT_SHA, 0,SSL_SHA, 0,SSL_MAC_MASK}, | 129 | {0,SSL_TXT_eFZA,0,SSL_eFZA, 0,0,0,0,SSL_ENC_MASK,0}, |
| 138 | 130 | {0,SSL_TXT_AES, 0,SSL_AES, 0,0,0,0,SSL_ENC_MASK,0}, | |
| 139 | {0,SSL_TXT_NULL,0,SSL_NULL, 0,SSL_ENC_MASK}, | 131 | |
| 140 | {0,SSL_TXT_RSA, 0,SSL_RSA, 0,SSL_AUTH_MASK|SSL_MKEY_MASK}, | 132 | {0,SSL_TXT_MD5, 0,SSL_MD5, 0,0,0,0,SSL_MAC_MASK,0}, |
| 141 | {0,SSL_TXT_ADH, 0,SSL_ADH, 0,SSL_AUTH_MASK|SSL_MKEY_MASK}, | 133 | {0,SSL_TXT_SHA1,0,SSL_SHA1, 0,0,0,0,SSL_MAC_MASK,0}, |
| 142 | {0,SSL_TXT_FZA, 0,SSL_FZA, 0,SSL_AUTH_MASK|SSL_MKEY_MASK|SSL_ENC_MASK}, | 134 | {0,SSL_TXT_SHA, 0,SSL_SHA, 0,0,0,0,SSL_MAC_MASK,0}, |
| 143 | 135 | ||
| 144 | {0,SSL_TXT_EXP, 0,SSL_EXP, 0,SSL_EXP_MASK}, | 136 | {0,SSL_TXT_NULL,0,SSL_NULL, 0,0,0,0,SSL_ENC_MASK,0}, |
| 145 | {0,SSL_TXT_EXPORT,0,SSL_EXPORT,0,SSL_EXP_MASK}, | 137 | {0,SSL_TXT_KRB5,0,SSL_KRB5, 0,0,0,0,SSL_AUTH_MASK|SSL_MKEY_MASK,0}, |
| 146 | {0,SSL_TXT_SSLV2,0,SSL_SSLV2,0,SSL_SSL_MASK}, | 138 | {0,SSL_TXT_RSA, 0,SSL_RSA, 0,0,0,0,SSL_AUTH_MASK|SSL_MKEY_MASK,0}, |
| 147 | {0,SSL_TXT_SSLV3,0,SSL_SSLV3,0,SSL_SSL_MASK}, | 139 | {0,SSL_TXT_ADH, 0,SSL_ADH, 0,0,0,0,SSL_AUTH_MASK|SSL_MKEY_MASK,0}, |
| 148 | {0,SSL_TXT_LOW, 0,SSL_LOW,0,SSL_STRONG_MASK}, | 140 | {0,SSL_TXT_FZA, 0,SSL_FZA, 0,0,0,0,SSL_AUTH_MASK|SSL_MKEY_MASK|SSL_ENC_MASK,0}, |
| 149 | {0,SSL_TXT_MEDIUM,0,SSL_MEDIUM,0,SSL_STRONG_MASK}, | 141 | |
| 150 | {0,SSL_TXT_HIGH, 0,SSL_HIGH,0,SSL_STRONG_MASK}, | 142 | {0,SSL_TXT_SSLV2, 0,SSL_SSLV2, 0,0,0,0,SSL_SSL_MASK,0}, |
| 143 | {0,SSL_TXT_SSLV3, 0,SSL_SSLV3, 0,0,0,0,SSL_SSL_MASK,0}, | ||
| 144 | {0,SSL_TXT_TLSV1, 0,SSL_TLSV1, 0,0,0,0,SSL_SSL_MASK,0}, | ||
| 145 | |||
| 146 | {0,SSL_TXT_EXP ,0, 0,SSL_EXPORT, 0,0,0,0,SSL_EXP_MASK}, | ||
| 147 | {0,SSL_TXT_EXPORT,0, 0,SSL_EXPORT, 0,0,0,0,SSL_EXP_MASK}, | ||
| 148 | {0,SSL_TXT_EXP40, 0, 0, SSL_EXP40, 0,0,0,0,SSL_STRONG_MASK}, | ||
| 149 | {0,SSL_TXT_EXP56, 0, 0, SSL_EXP56, 0,0,0,0,SSL_STRONG_MASK}, | ||
| 150 | {0,SSL_TXT_LOW, 0, 0, SSL_LOW, 0,0,0,0,SSL_STRONG_MASK}, | ||
| 151 | {0,SSL_TXT_MEDIUM,0, 0,SSL_MEDIUM, 0,0,0,0,SSL_STRONG_MASK}, | ||
| 152 | {0,SSL_TXT_HIGH, 0, 0, SSL_HIGH, 0,0,0,0,SSL_STRONG_MASK}, | ||
| 151 | }; | 153 | }; |
| 152 | 154 | ||
| 153 | static int init_ciphers=1; | 155 | static int init_ciphers=1; |
| 154 | static void load_ciphers(); | ||
| 155 | |||
| 156 | static int cmp_by_name(a,b) | ||
| 157 | SSL_CIPHER **a,**b; | ||
| 158 | { | ||
| 159 | return(strcmp((*a)->name,(*b)->name)); | ||
| 160 | } | ||
| 161 | 156 | ||
| 162 | static void load_ciphers() | 157 | static void load_ciphers(void) |
| 163 | { | 158 | { |
| 164 | init_ciphers=0; | 159 | init_ciphers=0; |
| 165 | ssl_cipher_methods[SSL_ENC_DES_IDX]= | 160 | ssl_cipher_methods[SSL_ENC_DES_IDX]= |
| @@ -172,6 +167,10 @@ static void load_ciphers() | |||
| 172 | EVP_get_cipherbyname(SN_rc2_cbc); | 167 | EVP_get_cipherbyname(SN_rc2_cbc); |
| 173 | ssl_cipher_methods[SSL_ENC_IDEA_IDX]= | 168 | ssl_cipher_methods[SSL_ENC_IDEA_IDX]= |
| 174 | EVP_get_cipherbyname(SN_idea_cbc); | 169 | EVP_get_cipherbyname(SN_idea_cbc); |
| 170 | ssl_cipher_methods[SSL_ENC_AES128_IDX]= | ||
| 171 | EVP_get_cipherbyname(SN_aes_128_cbc); | ||
| 172 | ssl_cipher_methods[SSL_ENC_AES256_IDX]= | ||
| 173 | EVP_get_cipherbyname(SN_aes_256_cbc); | ||
| 175 | 174 | ||
| 176 | ssl_digest_methods[SSL_MD_MD5_IDX]= | 175 | ssl_digest_methods[SSL_MD_MD5_IDX]= |
| 177 | EVP_get_digestbyname(SN_md5); | 176 | EVP_get_digestbyname(SN_md5); |
| @@ -179,14 +178,38 @@ static void load_ciphers() | |||
| 179 | EVP_get_digestbyname(SN_sha1); | 178 | EVP_get_digestbyname(SN_sha1); |
| 180 | } | 179 | } |
| 181 | 180 | ||
| 182 | int ssl_cipher_get_evp(c,enc,md) | 181 | int ssl_cipher_get_evp(SSL_SESSION *s, const EVP_CIPHER **enc, |
| 183 | SSL_CIPHER *c; | 182 | const EVP_MD **md, SSL_COMP **comp) |
| 184 | EVP_CIPHER **enc; | ||
| 185 | EVP_MD **md; | ||
| 186 | { | 183 | { |
| 187 | int i; | 184 | int i; |
| 185 | SSL_CIPHER *c; | ||
| 188 | 186 | ||
| 187 | c=s->cipher; | ||
| 189 | if (c == NULL) return(0); | 188 | if (c == NULL) return(0); |
| 189 | if (comp != NULL) | ||
| 190 | { | ||
| 191 | SSL_COMP ctmp; | ||
| 192 | |||
| 193 | if (s->compress_meth == 0) | ||
| 194 | *comp=NULL; | ||
| 195 | else if (ssl_comp_methods == NULL) | ||
| 196 | { | ||
| 197 | /* bad */ | ||
| 198 | *comp=NULL; | ||
| 199 | } | ||
| 200 | else | ||
| 201 | { | ||
| 202 | |||
| 203 | ctmp.id=s->compress_meth; | ||
| 204 | i=sk_SSL_COMP_find(ssl_comp_methods,&ctmp); | ||
| 205 | if (i >= 0) | ||
| 206 | *comp=sk_SSL_COMP_value(ssl_comp_methods,i); | ||
| 207 | else | ||
| 208 | *comp=NULL; | ||
| 209 | } | ||
| 210 | } | ||
| 211 | |||
| 212 | if ((enc == NULL) || (md == NULL)) return(0); | ||
| 190 | 213 | ||
| 191 | switch (c->algorithms & SSL_ENC_MASK) | 214 | switch (c->algorithms & SSL_ENC_MASK) |
| 192 | { | 215 | { |
| @@ -208,6 +231,13 @@ EVP_MD **md; | |||
| 208 | case SSL_eNULL: | 231 | case SSL_eNULL: |
| 209 | i=SSL_ENC_NULL_IDX; | 232 | i=SSL_ENC_NULL_IDX; |
| 210 | break; | 233 | break; |
| 234 | case SSL_AES: | ||
| 235 | switch(c->alg_bits) | ||
| 236 | { | ||
| 237 | case 128: i=SSL_ENC_AES128_IDX; break; | ||
| 238 | case 256: i=SSL_ENC_AES256_IDX; break; | ||
| 239 | default: i=-1; break; | ||
| 240 | } | ||
| 211 | break; | 241 | break; |
| 212 | default: | 242 | default: |
| 213 | i= -1; | 243 | i= -1; |
| @@ -250,8 +280,8 @@ EVP_MD **md; | |||
| 250 | #define ITEM_SEP(a) \ | 280 | #define ITEM_SEP(a) \ |
| 251 | (((a) == ':') || ((a) == ' ') || ((a) == ';') || ((a) == ',')) | 281 | (((a) == ':') || ((a) == ' ') || ((a) == ';') || ((a) == ',')) |
| 252 | 282 | ||
| 253 | static void ll_append_tail(head,curr,tail) | 283 | static void ll_append_tail(CIPHER_ORDER **head, CIPHER_ORDER *curr, |
| 254 | CIPHER_ORDER **head,*curr,**tail; | 284 | CIPHER_ORDER **tail) |
| 255 | { | 285 | { |
| 256 | if (curr == *tail) return; | 286 | if (curr == *tail) return; |
| 257 | if (curr == *head) | 287 | if (curr == *head) |
| @@ -266,181 +296,359 @@ CIPHER_ORDER **head,*curr,**tail; | |||
| 266 | *tail=curr; | 296 | *tail=curr; |
| 267 | } | 297 | } |
| 268 | 298 | ||
| 269 | STACK *ssl_create_cipher_list(ssl_method,cipher_list,cipher_list_by_id,str) | 299 | static unsigned long ssl_cipher_get_disabled(void) |
| 270 | SSL_METHOD *ssl_method; | ||
| 271 | STACK **cipher_list,**cipher_list_by_id; | ||
| 272 | char *str; | ||
| 273 | { | 300 | { |
| 274 | SSL_CIPHER *c; | 301 | unsigned long mask; |
| 275 | char *l; | ||
| 276 | STACK *ret=NULL,*ok=NULL; | ||
| 277 | #define CL_BUF 40 | ||
| 278 | char buf[CL_BUF]; | ||
| 279 | char *tmp_str=NULL; | ||
| 280 | unsigned long mask,algorithms,ma; | ||
| 281 | char *start; | ||
| 282 | int i,j,k,num=0,ch,multi; | ||
| 283 | unsigned long al; | ||
| 284 | STACK *ca_list=NULL; | ||
| 285 | int current_x,num_x; | ||
| 286 | CIPHER_CHOICE *ops=NULL; | ||
| 287 | CIPHER_ORDER *list=NULL,*head=NULL,*tail=NULL,*curr,*tail2,*curr2; | ||
| 288 | int list_num; | ||
| 289 | int type; | ||
| 290 | SSL_CIPHER c_tmp,*cp; | ||
| 291 | |||
| 292 | if (str == NULL) return(NULL); | ||
| 293 | |||
| 294 | if (strncmp(str,"DEFAULT",7) == 0) | ||
| 295 | { | ||
| 296 | i=strlen(str)+2+strlen(SSL_DEFAULT_CIPHER_LIST); | ||
| 297 | if ((tmp_str=Malloc(i)) == NULL) | ||
| 298 | { | ||
| 299 | SSLerr(SSL_F_SSL_CREATE_CIPHER_LIST,ERR_R_MALLOC_FAILURE); | ||
| 300 | goto err; | ||
| 301 | } | ||
| 302 | strcpy(tmp_str,SSL_DEFAULT_CIPHER_LIST); | ||
| 303 | strcat(tmp_str,":"); | ||
| 304 | strcat(tmp_str,&(str[7])); | ||
| 305 | str=tmp_str; | ||
| 306 | } | ||
| 307 | if (init_ciphers) load_ciphers(); | ||
| 308 | |||
| 309 | num=ssl_method->num_ciphers(); | ||
| 310 | |||
| 311 | if ((ret=(STACK *)sk_new(NULL)) == NULL) goto err; | ||
| 312 | if ((ca_list=(STACK *)sk_new(cmp_by_name)) == NULL) goto err; | ||
| 313 | 302 | ||
| 314 | mask =SSL_kFZA; | 303 | mask = SSL_kFZA; |
| 315 | #ifdef NO_RSA | 304 | #ifdef OPENSSL_NO_RSA |
| 316 | mask|=SSL_aRSA|SSL_kRSA; | 305 | mask |= SSL_aRSA|SSL_kRSA; |
| 317 | #endif | 306 | #endif |
| 318 | #ifdef NO_DSA | 307 | #ifdef OPENSSL_NO_DSA |
| 319 | mask|=SSL_aDSS; | 308 | mask |= SSL_aDSS; |
| 320 | #endif | 309 | #endif |
| 321 | #ifdef NO_DH | 310 | #ifdef OPENSSL_NO_DH |
| 322 | mask|=SSL_kDHr|SSL_kDHd|SSL_kEDH|SSL_aDH; | 311 | mask |= SSL_kDHr|SSL_kDHd|SSL_kEDH|SSL_aDH; |
| 312 | #endif | ||
| 313 | #ifdef OPENSSL_NO_KRB5 | ||
| 314 | mask |= SSL_kKRB5|SSL_aKRB5; | ||
| 323 | #endif | 315 | #endif |
| 324 | 316 | ||
| 325 | #ifndef SSL_ALLOW_ENULL | 317 | #ifdef SSL_FORBID_ENULL |
| 326 | mask|=SSL_eNULL; | 318 | mask |= SSL_eNULL; |
| 327 | #endif | 319 | #endif |
| 328 | 320 | ||
| 329 | mask|=(ssl_cipher_methods[SSL_ENC_DES_IDX ] == NULL)?SSL_DES :0; | 321 | mask |= (ssl_cipher_methods[SSL_ENC_DES_IDX ] == NULL) ? SSL_DES :0; |
| 330 | mask|=(ssl_cipher_methods[SSL_ENC_3DES_IDX] == NULL)?SSL_3DES:0; | 322 | mask |= (ssl_cipher_methods[SSL_ENC_3DES_IDX] == NULL) ? SSL_3DES:0; |
| 331 | mask|=(ssl_cipher_methods[SSL_ENC_RC4_IDX ] == NULL)?SSL_RC4 :0; | 323 | mask |= (ssl_cipher_methods[SSL_ENC_RC4_IDX ] == NULL) ? SSL_RC4 :0; |
| 332 | mask|=(ssl_cipher_methods[SSL_ENC_RC2_IDX ] == NULL)?SSL_RC2 :0; | 324 | mask |= (ssl_cipher_methods[SSL_ENC_RC2_IDX ] == NULL) ? SSL_RC2 :0; |
| 333 | mask|=(ssl_cipher_methods[SSL_ENC_IDEA_IDX] == NULL)?SSL_IDEA:0; | 325 | mask |= (ssl_cipher_methods[SSL_ENC_IDEA_IDX] == NULL) ? SSL_IDEA:0; |
| 334 | mask|=(ssl_cipher_methods[SSL_ENC_eFZA_IDX] == NULL)?SSL_eFZA:0; | 326 | mask |= (ssl_cipher_methods[SSL_ENC_eFZA_IDX] == NULL) ? SSL_eFZA:0; |
| 327 | mask |= (ssl_cipher_methods[SSL_ENC_AES128_IDX] == NULL) ? SSL_AES:0; | ||
| 335 | 328 | ||
| 336 | mask|=(ssl_digest_methods[SSL_MD_MD5_IDX ] == NULL)?SSL_MD5 :0; | 329 | mask |= (ssl_digest_methods[SSL_MD_MD5_IDX ] == NULL) ? SSL_MD5 :0; |
| 337 | mask|=(ssl_digest_methods[SSL_MD_SHA1_IDX] == NULL)?SSL_SHA1:0; | 330 | mask |= (ssl_digest_methods[SSL_MD_SHA1_IDX] == NULL) ? SSL_SHA1:0; |
| 338 | 331 | ||
| 339 | if ((list=(CIPHER_ORDER *)Malloc(sizeof(CIPHER_ORDER)*num)) == NULL) | 332 | return(mask); |
| 340 | goto err; | 333 | } |
| 334 | |||
| 335 | static void ssl_cipher_collect_ciphers(const SSL_METHOD *ssl_method, | ||
| 336 | int num_of_ciphers, unsigned long mask, CIPHER_ORDER *list, | ||
| 337 | CIPHER_ORDER **head_p, CIPHER_ORDER **tail_p) | ||
| 338 | { | ||
| 339 | int i, list_num; | ||
| 340 | SSL_CIPHER *c; | ||
| 341 | |||
| 342 | /* | ||
| 343 | * We have num_of_ciphers descriptions compiled in, depending on the | ||
| 344 | * method selected (SSLv2 and/or SSLv3, TLSv1 etc). | ||
| 345 | * These will later be sorted in a linked list with at most num | ||
| 346 | * entries. | ||
| 347 | */ | ||
| 341 | 348 | ||
| 342 | /* Get the initial list of ciphers */ | 349 | /* Get the initial list of ciphers */ |
| 343 | list_num=0; | 350 | list_num = 0; /* actual count of ciphers */ |
| 344 | for (i=0; i<num; i++) | 351 | for (i = 0; i < num_of_ciphers; i++) |
| 345 | { | 352 | { |
| 346 | c=ssl_method->get_cipher((unsigned int)i); | 353 | c = ssl_method->get_cipher(i); |
| 347 | /* drop those that use any of that is not available */ | 354 | /* drop those that use any of that is not available */ |
| 348 | if ((c != NULL) && c->valid && !(c->algorithms & mask)) | 355 | if ((c != NULL) && c->valid && !(c->algorithms & mask)) |
| 349 | { | 356 | { |
| 350 | list[list_num].cipher=c; | 357 | list[list_num].cipher = c; |
| 351 | list[list_num].next=NULL; | 358 | list[list_num].next = NULL; |
| 352 | list[list_num].prev=NULL; | 359 | list[list_num].prev = NULL; |
| 353 | list[list_num].active=0; | 360 | list[list_num].active = 0; |
| 354 | list_num++; | 361 | list_num++; |
| 362 | #ifdef KSSL_DEBUG | ||
| 363 | printf("\t%d: %s %lx %lx\n",i,c->name,c->id,c->algorithms); | ||
| 364 | #endif /* KSSL_DEBUG */ | ||
| 365 | /* | ||
| 355 | if (!sk_push(ca_list,(char *)c)) goto err; | 366 | if (!sk_push(ca_list,(char *)c)) goto err; |
| 367 | */ | ||
| 356 | } | 368 | } |
| 357 | } | 369 | } |
| 358 | 370 | ||
| 359 | for (i=1; i<list_num-1; i++) | 371 | /* |
| 372 | * Prepare linked list from list entries | ||
| 373 | */ | ||
| 374 | for (i = 1; i < list_num - 1; i++) | ||
| 360 | { | 375 | { |
| 361 | list[i].prev= &(list[i-1]); | 376 | list[i].prev = &(list[i-1]); |
| 362 | list[i].next= &(list[i+1]); | 377 | list[i].next = &(list[i+1]); |
| 363 | } | 378 | } |
| 364 | if (list_num > 0) | 379 | if (list_num > 0) |
| 365 | { | 380 | { |
| 366 | head= &(list[0]); | 381 | (*head_p) = &(list[0]); |
| 367 | head->prev=NULL; | 382 | (*head_p)->prev = NULL; |
| 368 | head->next= &(list[1]); | 383 | (*head_p)->next = &(list[1]); |
| 369 | tail= &(list[list_num-1]); | 384 | (*tail_p) = &(list[list_num - 1]); |
| 370 | tail->prev= &(list[list_num-2]); | 385 | (*tail_p)->prev = &(list[list_num - 2]); |
| 371 | tail->next=NULL; | 386 | (*tail_p)->next = NULL; |
| 372 | } | 387 | } |
| 388 | } | ||
| 373 | 389 | ||
| 374 | /* special case */ | 390 | static void ssl_cipher_collect_aliases(SSL_CIPHER **ca_list, |
| 375 | cipher_aliases[0].algorithms= ~mask; | 391 | int num_of_group_aliases, unsigned long mask, |
| 392 | CIPHER_ORDER *head) | ||
| 393 | { | ||
| 394 | CIPHER_ORDER *ciph_curr; | ||
| 395 | SSL_CIPHER **ca_curr; | ||
| 396 | int i; | ||
| 376 | 397 | ||
| 377 | /* get the aliases */ | 398 | /* |
| 378 | k=sizeof(cipher_aliases)/sizeof(SSL_CIPHER); | 399 | * First, add the real ciphers as already collected |
| 379 | for (j=0; j<k; j++) | 400 | */ |
| 401 | ciph_curr = head; | ||
| 402 | ca_curr = ca_list; | ||
| 403 | while (ciph_curr != NULL) | ||
| 380 | { | 404 | { |
| 381 | al=cipher_aliases[j].algorithms; | 405 | *ca_curr = ciph_curr->cipher; |
| 382 | /* Drop those that are not relevent */ | 406 | ca_curr++; |
| 383 | if ((al & mask) == al) continue; | 407 | ciph_curr = ciph_curr->next; |
| 384 | if (!sk_push(ca_list,(char *)&(cipher_aliases[j]))) goto err; | ||
| 385 | } | 408 | } |
| 386 | 409 | ||
| 387 | /* ca_list now holds a 'stack' of SSL_CIPHERS, some real, some | 410 | /* |
| 388 | * 'aliases' */ | 411 | * Now we add the available ones from the cipher_aliases[] table. |
| 412 | * They represent either an algorithm, that must be fully | ||
| 413 | * supported (not match any bit in mask) or represent a cipher | ||
| 414 | * strength value (will be added in any case because algorithms=0). | ||
| 415 | */ | ||
| 416 | for (i = 0; i < num_of_group_aliases; i++) | ||
| 417 | { | ||
| 418 | if ((i == 0) || /* always fetch "ALL" */ | ||
| 419 | !(cipher_aliases[i].algorithms & mask)) | ||
| 420 | { | ||
| 421 | *ca_curr = (SSL_CIPHER *)(cipher_aliases + i); | ||
| 422 | ca_curr++; | ||
| 423 | } | ||
| 424 | } | ||
| 389 | 425 | ||
| 390 | /* how many parameters are there? */ | 426 | *ca_curr = NULL; /* end of list */ |
| 391 | num=1; | 427 | } |
| 392 | for (l=str; *l; l++) | 428 | |
| 393 | if (ITEM_SEP(*l)) | 429 | static void ssl_cipher_apply_rule(unsigned long algorithms, unsigned long mask, |
| 394 | num++; | 430 | unsigned long algo_strength, unsigned long mask_strength, |
| 395 | ops=(CIPHER_CHOICE *)Malloc(sizeof(CIPHER_CHOICE)*num); | 431 | int rule, int strength_bits, CIPHER_ORDER *list, |
| 396 | if (ops == NULL) goto err; | 432 | CIPHER_ORDER **head_p, CIPHER_ORDER **tail_p) |
| 397 | memset(ops,0,sizeof(CIPHER_CHOICE)*num); | 433 | { |
| 434 | CIPHER_ORDER *head, *tail, *curr, *curr2, *tail2; | ||
| 435 | SSL_CIPHER *cp; | ||
| 436 | unsigned long ma, ma_s; | ||
| 398 | 437 | ||
| 399 | /* we now parse the input string and create our operations */ | 438 | #ifdef CIPHER_DEBUG |
| 400 | l=str; | 439 | printf("Applying rule %d with %08lx %08lx %08lx %08lx (%d)\n", |
| 401 | i=0; | 440 | rule, algorithms, mask, algo_strength, mask_strength, |
| 402 | current_x=0; | 441 | strength_bits); |
| 442 | #endif | ||
| 403 | 443 | ||
| 444 | curr = head = *head_p; | ||
| 445 | curr2 = head; | ||
| 446 | tail2 = tail = *tail_p; | ||
| 404 | for (;;) | 447 | for (;;) |
| 405 | { | 448 | { |
| 406 | ch= *l; | 449 | if ((curr == NULL) || (curr == tail2)) break; |
| 450 | curr = curr2; | ||
| 451 | curr2 = curr->next; | ||
| 452 | |||
| 453 | cp = curr->cipher; | ||
| 454 | |||
| 455 | /* | ||
| 456 | * Selection criteria is either the number of strength_bits | ||
| 457 | * or the algorithm used. | ||
| 458 | */ | ||
| 459 | if (strength_bits == -1) | ||
| 460 | { | ||
| 461 | ma = mask & cp->algorithms; | ||
| 462 | ma_s = mask_strength & cp->algo_strength; | ||
| 463 | |||
| 464 | #ifdef CIPHER_DEBUG | ||
| 465 | printf("\nName: %s:\nAlgo = %08lx Algo_strength = %08lx\nMask = %08lx Mask_strength %08lx\n", cp->name, cp->algorithms, cp->algo_strength, mask, mask_strength); | ||
| 466 | printf("ma = %08lx ma_s %08lx, ma&algo=%08lx, ma_s&algos=%08lx\n", ma, ma_s, ma&algorithms, ma_s&algo_strength); | ||
| 467 | #endif | ||
| 468 | /* | ||
| 469 | * Select: if none of the mask bit was met from the | ||
| 470 | * cipher or not all of the bits were met, the | ||
| 471 | * selection does not apply. | ||
| 472 | */ | ||
| 473 | if (((ma == 0) && (ma_s == 0)) || | ||
| 474 | ((ma & algorithms) != ma) || | ||
| 475 | ((ma_s & algo_strength) != ma_s)) | ||
| 476 | continue; /* does not apply */ | ||
| 477 | } | ||
| 478 | else if (strength_bits != cp->strength_bits) | ||
| 479 | continue; /* does not apply */ | ||
| 480 | |||
| 481 | #ifdef CIPHER_DEBUG | ||
| 482 | printf("Action = %d\n", rule); | ||
| 483 | #endif | ||
| 484 | |||
| 485 | /* add the cipher if it has not been added yet. */ | ||
| 486 | if (rule == CIPHER_ADD) | ||
| 487 | { | ||
| 488 | if (!curr->active) | ||
| 489 | { | ||
| 490 | ll_append_tail(&head, curr, &tail); | ||
| 491 | curr->active = 1; | ||
| 492 | } | ||
| 493 | } | ||
| 494 | /* Move the added cipher to this location */ | ||
| 495 | else if (rule == CIPHER_ORD) | ||
| 496 | { | ||
| 497 | if (curr->active) | ||
| 498 | { | ||
| 499 | ll_append_tail(&head, curr, &tail); | ||
| 500 | } | ||
| 501 | } | ||
| 502 | else if (rule == CIPHER_DEL) | ||
| 503 | curr->active = 0; | ||
| 504 | else if (rule == CIPHER_KILL) | ||
| 505 | { | ||
| 506 | if (head == curr) | ||
| 507 | head = curr->next; | ||
| 508 | else | ||
| 509 | curr->prev->next = curr->next; | ||
| 510 | if (tail == curr) | ||
| 511 | tail = curr->prev; | ||
| 512 | curr->active = 0; | ||
| 513 | if (curr->next != NULL) | ||
| 514 | curr->next->prev = curr->prev; | ||
| 515 | if (curr->prev != NULL) | ||
| 516 | curr->prev->next = curr->next; | ||
| 517 | curr->next = NULL; | ||
| 518 | curr->prev = NULL; | ||
| 519 | } | ||
| 520 | } | ||
| 521 | |||
| 522 | *head_p = head; | ||
| 523 | *tail_p = tail; | ||
| 524 | } | ||
| 525 | |||
| 526 | static int ssl_cipher_strength_sort(CIPHER_ORDER *list, CIPHER_ORDER **head_p, | ||
| 527 | CIPHER_ORDER **tail_p) | ||
| 528 | { | ||
| 529 | int max_strength_bits, i, *number_uses; | ||
| 530 | CIPHER_ORDER *curr; | ||
| 531 | |||
| 532 | /* | ||
| 533 | * This routine sorts the ciphers with descending strength. The sorting | ||
| 534 | * must keep the pre-sorted sequence, so we apply the normal sorting | ||
| 535 | * routine as '+' movement to the end of the list. | ||
| 536 | */ | ||
| 537 | max_strength_bits = 0; | ||
| 538 | curr = *head_p; | ||
| 539 | while (curr != NULL) | ||
| 540 | { | ||
| 541 | if (curr->active && | ||
| 542 | (curr->cipher->strength_bits > max_strength_bits)) | ||
| 543 | max_strength_bits = curr->cipher->strength_bits; | ||
| 544 | curr = curr->next; | ||
| 545 | } | ||
| 407 | 546 | ||
| 408 | if (ch == '\0') break; | 547 | number_uses = OPENSSL_malloc((max_strength_bits + 1) * sizeof(int)); |
| 548 | if (!number_uses) | ||
| 549 | { | ||
| 550 | SSLerr(SSL_F_SSL_CIPHER_STRENGTH_SORT,ERR_R_MALLOC_FAILURE); | ||
| 551 | return(0); | ||
| 552 | } | ||
| 553 | memset(number_uses, 0, (max_strength_bits + 1) * sizeof(int)); | ||
| 554 | |||
| 555 | /* | ||
| 556 | * Now find the strength_bits values actually used | ||
| 557 | */ | ||
| 558 | curr = *head_p; | ||
| 559 | while (curr != NULL) | ||
| 560 | { | ||
| 561 | if (curr->active) | ||
| 562 | number_uses[curr->cipher->strength_bits]++; | ||
| 563 | curr = curr->next; | ||
| 564 | } | ||
| 565 | /* | ||
| 566 | * Go through the list of used strength_bits values in descending | ||
| 567 | * order. | ||
| 568 | */ | ||
| 569 | for (i = max_strength_bits; i >= 0; i--) | ||
| 570 | if (number_uses[i] > 0) | ||
| 571 | ssl_cipher_apply_rule(0, 0, 0, 0, CIPHER_ORD, i, | ||
| 572 | list, head_p, tail_p); | ||
| 573 | |||
| 574 | OPENSSL_free(number_uses); | ||
| 575 | return(1); | ||
| 576 | } | ||
| 577 | |||
| 578 | static int ssl_cipher_process_rulestr(const char *rule_str, | ||
| 579 | CIPHER_ORDER *list, CIPHER_ORDER **head_p, | ||
| 580 | CIPHER_ORDER **tail_p, SSL_CIPHER **ca_list) | ||
| 581 | { | ||
| 582 | unsigned long algorithms, mask, algo_strength, mask_strength; | ||
| 583 | const char *l, *start, *buf; | ||
| 584 | int j, multi, found, rule, retval, ok, buflen; | ||
| 585 | char ch; | ||
| 586 | |||
| 587 | retval = 1; | ||
| 588 | l = rule_str; | ||
| 589 | for (;;) | ||
| 590 | { | ||
| 591 | ch = *l; | ||
| 409 | 592 | ||
| 593 | if (ch == '\0') | ||
| 594 | break; /* done */ | ||
| 410 | if (ch == '-') | 595 | if (ch == '-') |
| 411 | { j=CIPHER_DEL; l++; } | 596 | { rule = CIPHER_DEL; l++; } |
| 412 | else if (ch == '+') | 597 | else if (ch == '+') |
| 413 | { j=CIPHER_ORD; l++; } | 598 | { rule = CIPHER_ORD; l++; } |
| 414 | else if (ch == '!') | 599 | else if (ch == '!') |
| 415 | { j=CIPHER_KILL; l++; } | 600 | { rule = CIPHER_KILL; l++; } |
| 416 | else | 601 | else if (ch == '@') |
| 417 | { j=CIPHER_ADD; } | 602 | { rule = CIPHER_SPECIAL; l++; } |
| 603 | else | ||
| 604 | { rule = CIPHER_ADD; } | ||
| 418 | 605 | ||
| 419 | if (ITEM_SEP(ch)) | 606 | if (ITEM_SEP(ch)) |
| 420 | { | 607 | { |
| 421 | l++; | 608 | l++; |
| 422 | continue; | 609 | continue; |
| 423 | } | 610 | } |
| 424 | ops[current_x].type=j; | 611 | |
| 425 | ops[current_x].algorithms=0; | 612 | algorithms = mask = algo_strength = mask_strength = 0; |
| 426 | ops[current_x].mask=0; | ||
| 427 | 613 | ||
| 428 | start=l; | 614 | start=l; |
| 429 | for (;;) | 615 | for (;;) |
| 430 | { | 616 | { |
| 431 | ch= *l; | 617 | ch = *l; |
| 432 | i=0; | 618 | buf = l; |
| 619 | buflen = 0; | ||
| 620 | #ifndef CHARSET_EBCDIC | ||
| 433 | while ( ((ch >= 'A') && (ch <= 'Z')) || | 621 | while ( ((ch >= 'A') && (ch <= 'Z')) || |
| 434 | ((ch >= '0') && (ch <= '9')) || | 622 | ((ch >= '0') && (ch <= '9')) || |
| 435 | ((ch >= 'a') && (ch <= 'z')) || | 623 | ((ch >= 'a') && (ch <= 'z')) || |
| 436 | (ch == '-')) | 624 | (ch == '-')) |
| 625 | #else | ||
| 626 | while ( isalnum(ch) || (ch == '-')) | ||
| 627 | #endif | ||
| 437 | { | 628 | { |
| 438 | buf[i]=ch; | 629 | ch = *(++l); |
| 439 | ch= *(++l); | 630 | buflen++; |
| 440 | i++; | ||
| 441 | if (i >= (CL_BUF-2)) break; | ||
| 442 | } | 631 | } |
| 443 | buf[i]='\0'; | 632 | |
| 633 | if (buflen == 0) | ||
| 634 | { | ||
| 635 | /* | ||
| 636 | * We hit something we cannot deal with, | ||
| 637 | * it is no command or separator nor | ||
| 638 | * alphanumeric, so we call this an error. | ||
| 639 | */ | ||
| 640 | SSLerr(SSL_F_SSL_CIPHER_PROCESS_RULESTR, | ||
| 641 | SSL_R_INVALID_COMMAND); | ||
| 642 | retval = found = 0; | ||
| 643 | l++; | ||
| 644 | break; | ||
| 645 | } | ||
| 646 | |||
| 647 | if (rule == CIPHER_SPECIAL) | ||
| 648 | { | ||
| 649 | found = 0; /* unused -- avoid compiler warning */ | ||
| 650 | break; /* special treatment */ | ||
| 651 | } | ||
| 444 | 652 | ||
| 445 | /* check for multi-part specification */ | 653 | /* check for multi-part specification */ |
| 446 | if (ch == '+') | 654 | if (ch == '+') |
| @@ -451,151 +659,262 @@ char *str; | |||
| 451 | else | 659 | else |
| 452 | multi=0; | 660 | multi=0; |
| 453 | 661 | ||
| 454 | c_tmp.name=buf; | 662 | /* |
| 455 | j=sk_find(ca_list,(char *)&c_tmp); | 663 | * Now search for the cipher alias in the ca_list. Be careful |
| 456 | if (j < 0) | 664 | * with the strncmp, because the "buflen" limitation |
| 457 | goto end_loop; | 665 | * will make the rule "ADH:SOME" and the cipher |
| 666 | * "ADH-MY-CIPHER" look like a match for buflen=3. | ||
| 667 | * So additionally check whether the cipher name found | ||
| 668 | * has the correct length. We can save a strlen() call: | ||
| 669 | * just checking for the '\0' at the right place is | ||
| 670 | * sufficient, we have to strncmp() anyway. | ||
| 671 | */ | ||
| 672 | j = found = 0; | ||
| 673 | while (ca_list[j]) | ||
| 674 | { | ||
| 675 | if ((ca_list[j]->name[buflen] == '\0') && | ||
| 676 | !strncmp(buf, ca_list[j]->name, buflen)) | ||
| 677 | { | ||
| 678 | found = 1; | ||
| 679 | break; | ||
| 680 | } | ||
| 681 | else | ||
| 682 | j++; | ||
| 683 | } | ||
| 684 | if (!found) | ||
| 685 | break; /* ignore this entry */ | ||
| 686 | |||
| 687 | algorithms |= ca_list[j]->algorithms; | ||
| 688 | mask |= ca_list[j]->mask; | ||
| 689 | algo_strength |= ca_list[j]->algo_strength; | ||
| 690 | mask_strength |= ca_list[j]->mask_strength; | ||
| 458 | 691 | ||
| 459 | cp=(SSL_CIPHER *)sk_value(ca_list,j); | ||
| 460 | ops[current_x].algorithms|=cp->algorithms; | ||
| 461 | /* We add the SSL_SSL_MASK so we can match the | ||
| 462 | * SSLv2 and SSLv3 versions of RC4-MD5 */ | ||
| 463 | ops[current_x].mask|=cp->mask; | ||
| 464 | if (!multi) break; | 692 | if (!multi) break; |
| 465 | } | 693 | } |
| 466 | current_x++; | 694 | |
| 467 | if (ch == '\0') break; | 695 | /* |
| 468 | end_loop: | 696 | * Ok, we have the rule, now apply it |
| 469 | /* Make sure we scan until the next valid start point */ | 697 | */ |
| 470 | while ((*l != '\0') && ITEM_SEP(*l)) | 698 | if (rule == CIPHER_SPECIAL) |
| 471 | l++; | 699 | { /* special command */ |
| 700 | ok = 0; | ||
| 701 | if ((buflen == 8) && | ||
| 702 | !strncmp(buf, "STRENGTH", 8)) | ||
| 703 | ok = ssl_cipher_strength_sort(list, | ||
| 704 | head_p, tail_p); | ||
| 705 | else | ||
| 706 | SSLerr(SSL_F_SSL_CIPHER_PROCESS_RULESTR, | ||
| 707 | SSL_R_INVALID_COMMAND); | ||
| 708 | if (ok == 0) | ||
| 709 | retval = 0; | ||
| 710 | /* | ||
| 711 | * We do not support any "multi" options | ||
| 712 | * together with "@", so throw away the | ||
| 713 | * rest of the command, if any left, until | ||
| 714 | * end or ':' is found. | ||
| 715 | */ | ||
| 716 | while ((*l != '\0') && ITEM_SEP(*l)) | ||
| 717 | l++; | ||
| 718 | } | ||
| 719 | else if (found) | ||
| 720 | { | ||
| 721 | ssl_cipher_apply_rule(algorithms, mask, | ||
| 722 | algo_strength, mask_strength, rule, -1, | ||
| 723 | list, head_p, tail_p); | ||
| 724 | } | ||
| 725 | else | ||
| 726 | { | ||
| 727 | while ((*l != '\0') && ITEM_SEP(*l)) | ||
| 728 | l++; | ||
| 729 | } | ||
| 730 | if (*l == '\0') break; /* done */ | ||
| 472 | } | 731 | } |
| 473 | 732 | ||
| 474 | num_x=current_x; | 733 | return(retval); |
| 475 | current_x=0; | 734 | } |
| 735 | |||
| 736 | STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *ssl_method, | ||
| 737 | STACK_OF(SSL_CIPHER) **cipher_list, | ||
| 738 | STACK_OF(SSL_CIPHER) **cipher_list_by_id, | ||
| 739 | const char *rule_str) | ||
| 740 | { | ||
| 741 | int ok, num_of_ciphers, num_of_alias_max, num_of_group_aliases; | ||
| 742 | unsigned long disabled_mask; | ||
| 743 | STACK_OF(SSL_CIPHER) *cipherstack; | ||
| 744 | const char *rule_p; | ||
| 745 | CIPHER_ORDER *list = NULL, *head = NULL, *tail = NULL, *curr; | ||
| 746 | SSL_CIPHER **ca_list = NULL; | ||
| 747 | |||
| 748 | /* | ||
| 749 | * Return with error if nothing to do. | ||
| 750 | */ | ||
| 751 | if (rule_str == NULL) return(NULL); | ||
| 752 | |||
| 753 | if (init_ciphers) load_ciphers(); | ||
| 476 | 754 | ||
| 477 | /* We will now process the list of ciphers, once for each category, to | 755 | /* |
| 478 | * decide what we should do with it. */ | 756 | * To reduce the work to do we only want to process the compiled |
| 479 | for (j=0; j<num_x; j++) | 757 | * in algorithms, so we first get the mask of disabled ciphers. |
| 758 | */ | ||
| 759 | disabled_mask = ssl_cipher_get_disabled(); | ||
| 760 | |||
| 761 | /* | ||
| 762 | * Now we have to collect the available ciphers from the compiled | ||
| 763 | * in ciphers. We cannot get more than the number compiled in, so | ||
| 764 | * it is used for allocation. | ||
| 765 | */ | ||
| 766 | num_of_ciphers = ssl_method->num_ciphers(); | ||
| 767 | #ifdef KSSL_DEBUG | ||
| 768 | printf("ssl_create_cipher_list() for %d ciphers\n", num_of_ciphers); | ||
| 769 | #endif /* KSSL_DEBUG */ | ||
| 770 | list = (CIPHER_ORDER *)OPENSSL_malloc(sizeof(CIPHER_ORDER) * num_of_ciphers); | ||
| 771 | if (list == NULL) | ||
| 480 | { | 772 | { |
| 481 | algorithms=ops[j].algorithms; | 773 | SSLerr(SSL_F_SSL_CREATE_CIPHER_LIST,ERR_R_MALLOC_FAILURE); |
| 482 | type=ops[j].type; | 774 | return(NULL); /* Failure */ |
| 483 | mask=ops[j].mask; | 775 | } |
| 484 | 776 | ||
| 485 | curr=head; | 777 | ssl_cipher_collect_ciphers(ssl_method, num_of_ciphers, disabled_mask, |
| 486 | curr2=head; | 778 | list, &head, &tail); |
| 487 | tail2=tail; | 779 | |
| 488 | for (;;) | 780 | /* |
| 489 | { | 781 | * We also need cipher aliases for selecting based on the rule_str. |
| 490 | if ((curr == NULL) || (curr == tail2)) break; | 782 | * There might be two types of entries in the rule_str: 1) names |
| 491 | curr=curr2; | 783 | * of ciphers themselves 2) aliases for groups of ciphers. |
| 492 | curr2=curr->next; | 784 | * For 1) we need the available ciphers and for 2) the cipher |
| 785 | * groups of cipher_aliases added together in one list (otherwise | ||
| 786 | * we would be happy with just the cipher_aliases table). | ||
| 787 | */ | ||
| 788 | num_of_group_aliases = sizeof(cipher_aliases) / sizeof(SSL_CIPHER); | ||
| 789 | num_of_alias_max = num_of_ciphers + num_of_group_aliases + 1; | ||
| 790 | ca_list = | ||
| 791 | (SSL_CIPHER **)OPENSSL_malloc(sizeof(SSL_CIPHER *) * num_of_alias_max); | ||
| 792 | if (ca_list == NULL) | ||
| 793 | { | ||
| 794 | OPENSSL_free(list); | ||
| 795 | SSLerr(SSL_F_SSL_CREATE_CIPHER_LIST,ERR_R_MALLOC_FAILURE); | ||
| 796 | return(NULL); /* Failure */ | ||
| 797 | } | ||
| 798 | ssl_cipher_collect_aliases(ca_list, num_of_group_aliases, disabled_mask, | ||
| 799 | head); | ||
| 800 | |||
| 801 | /* | ||
| 802 | * If the rule_string begins with DEFAULT, apply the default rule | ||
| 803 | * before using the (possibly available) additional rules. | ||
| 804 | */ | ||
| 805 | ok = 1; | ||
| 806 | rule_p = rule_str; | ||
| 807 | if (strncmp(rule_str,"DEFAULT",7) == 0) | ||
| 808 | { | ||
| 809 | ok = ssl_cipher_process_rulestr(SSL_DEFAULT_CIPHER_LIST, | ||
| 810 | list, &head, &tail, ca_list); | ||
| 811 | rule_p += 7; | ||
| 812 | if (*rule_p == ':') | ||
| 813 | rule_p++; | ||
| 814 | } | ||
| 493 | 815 | ||
| 494 | cp=curr->cipher; | 816 | if (ok && (strlen(rule_p) > 0)) |
| 495 | ma=mask & cp->algorithms; | 817 | ok = ssl_cipher_process_rulestr(rule_p, list, &head, &tail, |
| 496 | if ((ma == 0) || ((ma & algorithms) != ma)) | 818 | ca_list); |
| 497 | { | ||
| 498 | /* does not apply */ | ||
| 499 | continue; | ||
| 500 | } | ||
| 501 | 819 | ||
| 502 | /* add the cipher if it has not been added yet. */ | 820 | OPENSSL_free(ca_list); /* Not needed anymore */ |
| 503 | if (type == CIPHER_ADD) | 821 | |
| 504 | { | 822 | if (!ok) |
| 505 | if (!curr->active) | 823 | { /* Rule processing failure */ |
| 506 | { | 824 | OPENSSL_free(list); |
| 507 | ll_append_tail(&head,curr,&tail); | 825 | return(NULL); |
| 508 | curr->active=1; | 826 | } |
| 509 | } | 827 | /* |
| 510 | } | 828 | * Allocate new "cipherstack" for the result, return with error |
| 511 | /* Move the added cipher to this location */ | 829 | * if we cannot get one. |
| 512 | else if (type == CIPHER_ORD) | 830 | */ |
| 513 | { | 831 | if ((cipherstack = sk_SSL_CIPHER_new_null()) == NULL) |
| 514 | if (curr->active) | 832 | { |
| 515 | { | 833 | OPENSSL_free(list); |
| 516 | ll_append_tail(&head,curr,&tail); | 834 | return(NULL); |
| 517 | } | ||
| 518 | } | ||
| 519 | else if (type == CIPHER_DEL) | ||
| 520 | curr->active=0; | ||
| 521 | if (type == CIPHER_KILL) | ||
| 522 | { | ||
| 523 | if (head == curr) | ||
| 524 | head=curr->next; | ||
| 525 | else | ||
| 526 | curr->prev->next=curr->next; | ||
| 527 | if (tail == curr) | ||
| 528 | tail=curr->prev; | ||
| 529 | curr->active=0; | ||
| 530 | if (curr->next != NULL) | ||
| 531 | curr->next->prev=curr->prev; | ||
| 532 | if (curr->prev != NULL) | ||
| 533 | curr->prev->next=curr->next; | ||
| 534 | curr->next=NULL; | ||
| 535 | curr->prev=NULL; | ||
| 536 | } | ||
| 537 | } | ||
| 538 | } | 835 | } |
| 539 | 836 | ||
| 540 | for (curr=head; curr != NULL; curr=curr->next) | 837 | /* |
| 838 | * The cipher selection for the list is done. The ciphers are added | ||
| 839 | * to the resulting precedence to the STACK_OF(SSL_CIPHER). | ||
| 840 | */ | ||
| 841 | for (curr = head; curr != NULL; curr = curr->next) | ||
| 541 | { | 842 | { |
| 542 | if (curr->active) | 843 | if (curr->active) |
| 543 | { | 844 | { |
| 544 | sk_push(ret,(char *)curr->cipher); | 845 | sk_SSL_CIPHER_push(cipherstack, curr->cipher); |
| 545 | #ifdef CIPHER_DEBUG | 846 | #ifdef CIPHER_DEBUG |
| 546 | printf("<%s>\n",curr->cipher->name); | 847 | printf("<%s>\n",curr->cipher->name); |
| 547 | #endif | 848 | #endif |
| 548 | } | 849 | } |
| 549 | } | 850 | } |
| 550 | 851 | OPENSSL_free(list); /* Not needed any longer */ | |
| 852 | |||
| 853 | /* | ||
| 854 | * The following passage is a little bit odd. If pointer variables | ||
| 855 | * were supplied to hold STACK_OF(SSL_CIPHER) return information, | ||
| 856 | * the old memory pointed to is free()ed. Then, however, the | ||
| 857 | * cipher_list entry will be assigned just a copy of the returned | ||
| 858 | * cipher stack. For cipher_list_by_id a copy of the cipher stack | ||
| 859 | * will be created. See next comment... | ||
| 860 | */ | ||
| 551 | if (cipher_list != NULL) | 861 | if (cipher_list != NULL) |
| 552 | { | 862 | { |
| 553 | if (*cipher_list != NULL) | 863 | if (*cipher_list != NULL) |
| 554 | sk_free(*cipher_list); | 864 | sk_SSL_CIPHER_free(*cipher_list); |
| 555 | *cipher_list=ret; | 865 | *cipher_list = cipherstack; |
| 556 | } | 866 | } |
| 557 | 867 | ||
| 558 | if (cipher_list_by_id != NULL) | 868 | if (cipher_list_by_id != NULL) |
| 559 | { | 869 | { |
| 560 | if (*cipher_list_by_id != NULL) | 870 | if (*cipher_list_by_id != NULL) |
| 561 | sk_free(*cipher_list_by_id); | 871 | sk_SSL_CIPHER_free(*cipher_list_by_id); |
| 562 | *cipher_list_by_id=sk_dup(ret); | 872 | *cipher_list_by_id = sk_SSL_CIPHER_dup(cipherstack); |
| 563 | } | 873 | } |
| 564 | 874 | ||
| 875 | /* | ||
| 876 | * Now it is getting really strange. If something failed during | ||
| 877 | * the previous pointer assignment or if one of the pointers was | ||
| 878 | * not requested, the error condition is met. That might be | ||
| 879 | * discussable. The strange thing is however that in this case | ||
| 880 | * the memory "ret" pointed to is "free()ed" and hence the pointer | ||
| 881 | * cipher_list becomes wild. The memory reserved for | ||
| 882 | * cipher_list_by_id however is not "free()ed" and stays intact. | ||
| 883 | */ | ||
| 565 | if ( (cipher_list_by_id == NULL) || | 884 | if ( (cipher_list_by_id == NULL) || |
| 566 | (*cipher_list_by_id == NULL) || | 885 | (*cipher_list_by_id == NULL) || |
| 567 | (cipher_list == NULL) || | 886 | (cipher_list == NULL) || |
| 568 | (*cipher_list == NULL)) | 887 | (*cipher_list == NULL)) |
| 569 | goto err; | 888 | { |
| 570 | sk_set_cmp_func(*cipher_list_by_id,ssl_cipher_ptr_id_cmp); | 889 | sk_SSL_CIPHER_free(cipherstack); |
| 571 | 890 | return(NULL); | |
| 572 | ok=ret; | 891 | } |
| 573 | ret=NULL; | 892 | |
| 574 | err: | 893 | sk_SSL_CIPHER_set_cmp_func(*cipher_list_by_id,ssl_cipher_ptr_id_cmp); |
| 575 | if (tmp_str) Free(tmp_str); | 894 | |
| 576 | if (ops != NULL) Free(ops); | 895 | return(cipherstack); |
| 577 | if (ret != NULL) sk_free(ret); | ||
| 578 | if (ca_list != NULL) sk_free(ca_list); | ||
| 579 | if (list != NULL) Free(list); | ||
| 580 | return(ok); | ||
| 581 | } | 896 | } |
| 582 | 897 | ||
| 583 | char *SSL_CIPHER_description(cipher,buf,len) | 898 | char *SSL_CIPHER_description(SSL_CIPHER *cipher, char *buf, int len) |
| 584 | SSL_CIPHER *cipher; | ||
| 585 | char *buf; | ||
| 586 | int len; | ||
| 587 | { | 899 | { |
| 588 | int export; | 900 | int is_export,pkl,kl; |
| 589 | char *ver,*exp; | 901 | char *ver,*exp; |
| 590 | char *kx,*au,*enc,*mac; | 902 | char *kx,*au,*enc,*mac; |
| 591 | unsigned long alg,alg2; | 903 | unsigned long alg,alg2,alg_s; |
| 904 | #ifdef KSSL_DEBUG | ||
| 905 | static char *format="%-23s %s Kx=%-8s Au=%-4s Enc=%-9s Mac=%-4s%s AL=%lx\n"; | ||
| 906 | #else | ||
| 592 | static char *format="%-23s %s Kx=%-8s Au=%-4s Enc=%-9s Mac=%-4s%s\n"; | 907 | static char *format="%-23s %s Kx=%-8s Au=%-4s Enc=%-9s Mac=%-4s%s\n"; |
| 593 | 908 | #endif /* KSSL_DEBUG */ | |
| 909 | |||
| 594 | alg=cipher->algorithms; | 910 | alg=cipher->algorithms; |
| 911 | alg_s=cipher->algo_strength; | ||
| 595 | alg2=cipher->algorithm2; | 912 | alg2=cipher->algorithm2; |
| 596 | 913 | ||
| 597 | export=(alg&SSL_EXP)?1:0; | 914 | is_export=SSL_C_IS_EXPORT(cipher); |
| 598 | exp=(export)?" export":""; | 915 | pkl=SSL_C_EXPORT_PKEYLENGTH(cipher); |
| 916 | kl=SSL_C_EXPORT_KEYLENGTH(cipher); | ||
| 917 | exp=is_export?" export":""; | ||
| 599 | 918 | ||
| 600 | if (alg & SSL_SSLV2) | 919 | if (alg & SSL_SSLV2) |
| 601 | ver="SSLv2"; | 920 | ver="SSLv2"; |
| @@ -607,7 +926,7 @@ int len; | |||
| 607 | switch (alg&SSL_MKEY_MASK) | 926 | switch (alg&SSL_MKEY_MASK) |
| 608 | { | 927 | { |
| 609 | case SSL_kRSA: | 928 | case SSL_kRSA: |
| 610 | kx=(export)?"RSA(512)":"RSA"; | 929 | kx=is_export?(pkl == 512 ? "RSA(512)" : "RSA(1024)"):"RSA"; |
| 611 | break; | 930 | break; |
| 612 | case SSL_kDHr: | 931 | case SSL_kDHr: |
| 613 | kx="DH/RSA"; | 932 | kx="DH/RSA"; |
| @@ -615,11 +934,15 @@ int len; | |||
| 615 | case SSL_kDHd: | 934 | case SSL_kDHd: |
| 616 | kx="DH/DSS"; | 935 | kx="DH/DSS"; |
| 617 | break; | 936 | break; |
| 937 | case SSL_kKRB5: /* VRS */ | ||
| 938 | case SSL_KRB5: /* VRS */ | ||
| 939 | kx="KRB5"; | ||
| 940 | break; | ||
| 618 | case SSL_kFZA: | 941 | case SSL_kFZA: |
| 619 | kx="Fortezza"; | 942 | kx="Fortezza"; |
| 620 | break; | 943 | break; |
| 621 | case SSL_kEDH: | 944 | case SSL_kEDH: |
| 622 | kx=(export)?"DH(512)":"DH"; | 945 | kx=is_export?(pkl == 512 ? "DH(512)" : "DH(1024)"):"DH"; |
| 623 | break; | 946 | break; |
| 624 | default: | 947 | default: |
| 625 | kx="unknown"; | 948 | kx="unknown"; |
| @@ -636,6 +959,10 @@ int len; | |||
| 636 | case SSL_aDH: | 959 | case SSL_aDH: |
| 637 | au="DH"; | 960 | au="DH"; |
| 638 | break; | 961 | break; |
| 962 | case SSL_aKRB5: /* VRS */ | ||
| 963 | case SSL_KRB5: /* VRS */ | ||
| 964 | au="KRB5"; | ||
| 965 | break; | ||
| 639 | case SSL_aFZA: | 966 | case SSL_aFZA: |
| 640 | case SSL_aNULL: | 967 | case SSL_aNULL: |
| 641 | au="None"; | 968 | au="None"; |
| @@ -648,16 +975,17 @@ int len; | |||
| 648 | switch (alg&SSL_ENC_MASK) | 975 | switch (alg&SSL_ENC_MASK) |
| 649 | { | 976 | { |
| 650 | case SSL_DES: | 977 | case SSL_DES: |
| 651 | enc=export?"DES(40)":"DES(56)"; | 978 | enc=(is_export && kl == 5)?"DES(40)":"DES(56)"; |
| 652 | break; | 979 | break; |
| 653 | case SSL_3DES: | 980 | case SSL_3DES: |
| 654 | enc="3DES(168)"; | 981 | enc="3DES(168)"; |
| 655 | break; | 982 | break; |
| 656 | case SSL_RC4: | 983 | case SSL_RC4: |
| 657 | enc=export?"RC4(40)":((alg2&SSL2_CF_8_BYTE_ENC)?"RC4(64)":"RC4(128)"); | 984 | enc=is_export?(kl == 5 ? "RC4(40)" : "RC4(56)") |
| 985 | :((alg2&SSL2_CF_8_BYTE_ENC)?"RC4(64)":"RC4(128)"); | ||
| 658 | break; | 986 | break; |
| 659 | case SSL_RC2: | 987 | case SSL_RC2: |
| 660 | enc=export?"RC2(40)":"RC2(128)"; | 988 | enc=is_export?(kl == 5 ? "RC2(40)" : "RC2(56)"):"RC2(128)"; |
| 661 | break; | 989 | break; |
| 662 | case SSL_IDEA: | 990 | case SSL_IDEA: |
| 663 | enc="IDEA(128)"; | 991 | enc="IDEA(128)"; |
| @@ -668,6 +996,15 @@ int len; | |||
| 668 | case SSL_eNULL: | 996 | case SSL_eNULL: |
| 669 | enc="None"; | 997 | enc="None"; |
| 670 | break; | 998 | break; |
| 999 | case SSL_AES: | ||
| 1000 | switch(cipher->strength_bits) | ||
| 1001 | { | ||
| 1002 | case 128: enc="AESdraft(128)"; break; | ||
| 1003 | case 192: enc="AESdraft(192)"; break; | ||
| 1004 | case 256: enc="AESdraft(256)"; break; | ||
| 1005 | default: enc="AESdraft(?""?""?)"; break; | ||
| 1006 | } | ||
| 1007 | break; | ||
| 671 | default: | 1008 | default: |
| 672 | enc="unknown"; | 1009 | enc="unknown"; |
| 673 | break; | 1010 | break; |
| @@ -688,18 +1025,22 @@ int len; | |||
| 688 | 1025 | ||
| 689 | if (buf == NULL) | 1026 | if (buf == NULL) |
| 690 | { | 1027 | { |
| 691 | buf=Malloc(128); | 1028 | len=128; |
| 692 | if (buf == NULL) return("Malloc Error"); | 1029 | buf=OPENSSL_malloc(len); |
| 1030 | if (buf == NULL) return("OPENSSL_malloc Error"); | ||
| 693 | } | 1031 | } |
| 694 | else if (len < 128) | 1032 | else if (len < 128) |
| 695 | return("Buffer too small"); | 1033 | return("Buffer too small"); |
| 696 | 1034 | ||
| 697 | sprintf(buf,format,cipher->name,ver,kx,au,enc,mac,exp); | 1035 | #ifdef KSSL_DEBUG |
| 1036 | BIO_snprintf(buf,len,format,cipher->name,ver,kx,au,enc,mac,exp,alg); | ||
| 1037 | #else | ||
| 1038 | BIO_snprintf(buf,len,format,cipher->name,ver,kx,au,enc,mac,exp); | ||
| 1039 | #endif /* KSSL_DEBUG */ | ||
| 698 | return(buf); | 1040 | return(buf); |
| 699 | } | 1041 | } |
| 700 | 1042 | ||
| 701 | char *SSL_CIPHER_get_version(c) | 1043 | char *SSL_CIPHER_get_version(SSL_CIPHER *c) |
| 702 | SSL_CIPHER *c; | ||
| 703 | { | 1044 | { |
| 704 | int i; | 1045 | int i; |
| 705 | 1046 | ||
| @@ -714,45 +1055,78 @@ SSL_CIPHER *c; | |||
| 714 | } | 1055 | } |
| 715 | 1056 | ||
| 716 | /* return the actual cipher being used */ | 1057 | /* return the actual cipher being used */ |
| 717 | char *SSL_CIPHER_get_name(c) | 1058 | const char *SSL_CIPHER_get_name(SSL_CIPHER *c) |
| 718 | SSL_CIPHER *c; | ||
| 719 | { | 1059 | { |
| 720 | if (c != NULL) | 1060 | if (c != NULL) |
| 721 | return(c->name); | 1061 | return(c->name); |
| 722 | return("(NONE)"); | 1062 | return("(NONE)"); |
| 723 | } | 1063 | } |
| 724 | 1064 | ||
| 725 | /* number of bits for symetric cipher */ | 1065 | /* number of bits for symmetric cipher */ |
| 726 | int SSL_CIPHER_get_bits(c,alg_bits) | 1066 | int SSL_CIPHER_get_bits(SSL_CIPHER *c, int *alg_bits) |
| 727 | SSL_CIPHER *c; | ||
| 728 | int *alg_bits; | ||
| 729 | { | 1067 | { |
| 730 | int ret=0,a=0; | 1068 | int ret=0; |
| 731 | EVP_CIPHER *enc; | ||
| 732 | EVP_MD *md; | ||
| 733 | 1069 | ||
| 734 | if (c != NULL) | 1070 | if (c != NULL) |
| 735 | { | 1071 | { |
| 736 | if (!ssl_cipher_get_evp(c,&enc,&md)) | 1072 | if (alg_bits != NULL) *alg_bits = c->alg_bits; |
| 737 | return(0); | 1073 | ret = c->strength_bits; |
| 1074 | } | ||
| 1075 | return(ret); | ||
| 1076 | } | ||
| 738 | 1077 | ||
| 739 | a=EVP_CIPHER_key_length(enc)*8; | 1078 | SSL_COMP *ssl3_comp_find(STACK_OF(SSL_COMP) *sk, int n) |
| 1079 | { | ||
| 1080 | SSL_COMP *ctmp; | ||
| 1081 | int i,nn; | ||
| 740 | 1082 | ||
| 741 | if (c->algorithms & SSL_EXP) | 1083 | if ((n == 0) || (sk == NULL)) return(NULL); |
| 742 | { | 1084 | nn=sk_SSL_COMP_num(sk); |
| 743 | ret=40; | 1085 | for (i=0; i<nn; i++) |
| 744 | } | 1086 | { |
| 745 | else | 1087 | ctmp=sk_SSL_COMP_value(sk,i); |
| 746 | { | 1088 | if (ctmp->id == n) |
| 747 | if (c->algorithm2 & SSL2_CF_8_BYTE_ENC) | 1089 | return(ctmp); |
| 748 | ret=64; | ||
| 749 | else | ||
| 750 | ret=a; | ||
| 751 | } | ||
| 752 | } | 1090 | } |
| 1091 | return(NULL); | ||
| 1092 | } | ||
| 753 | 1093 | ||
| 754 | if (alg_bits != NULL) *alg_bits=a; | 1094 | static int sk_comp_cmp(const SSL_COMP * const *a, |
| 755 | 1095 | const SSL_COMP * const *b) | |
| 756 | return(ret); | 1096 | { |
| 1097 | return((*a)->id-(*b)->id); | ||
| 757 | } | 1098 | } |
| 758 | 1099 | ||
| 1100 | STACK_OF(SSL_COMP) *SSL_COMP_get_compression_methods(void) | ||
| 1101 | { | ||
| 1102 | return(ssl_comp_methods); | ||
| 1103 | } | ||
| 1104 | |||
| 1105 | int SSL_COMP_add_compression_method(int id, COMP_METHOD *cm) | ||
| 1106 | { | ||
| 1107 | SSL_COMP *comp; | ||
| 1108 | STACK_OF(SSL_COMP) *sk; | ||
| 1109 | |||
| 1110 | if (cm == NULL || cm->type == NID_undef) | ||
| 1111 | return 1; | ||
| 1112 | |||
| 1113 | MemCheck_off(); | ||
| 1114 | comp=(SSL_COMP *)OPENSSL_malloc(sizeof(SSL_COMP)); | ||
| 1115 | comp->id=id; | ||
| 1116 | comp->method=cm; | ||
| 1117 | if (ssl_comp_methods == NULL) | ||
| 1118 | sk=ssl_comp_methods=sk_SSL_COMP_new(sk_comp_cmp); | ||
| 1119 | else | ||
| 1120 | sk=ssl_comp_methods; | ||
| 1121 | if ((sk == NULL) || !sk_SSL_COMP_push(sk,comp)) | ||
| 1122 | { | ||
| 1123 | MemCheck_on(); | ||
| 1124 | SSLerr(SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD,ERR_R_MALLOC_FAILURE); | ||
| 1125 | return(0); | ||
| 1126 | } | ||
| 1127 | else | ||
| 1128 | { | ||
| 1129 | MemCheck_on(); | ||
| 1130 | return(1); | ||
| 1131 | } | ||
| 1132 | } | ||
diff --git a/src/lib/libssl/ssl_err.c b/src/lib/libssl/ssl_err.c index bcbb98591f..c32c4ef6e9 100644 --- a/src/lib/libssl/ssl_err.c +++ b/src/lib/libssl/ssl_err.c | |||
| @@ -1,66 +1,69 @@ | |||
| 1 | /* lib/ssl/ssl_err.c */ | 1 | /* ssl/ssl_err.c */ |
| 2 | /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) | 2 | /* ==================================================================== |
| 3 | * All rights reserved. | 3 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. |
| 4 | * | 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 | 5 | * Redistribution and use in source and binary forms, with or without |
| 24 | * modification, are permitted provided that the following conditions | 6 | * modification, are permitted provided that the following conditions |
| 25 | * are met: | 7 | * are met: |
| 26 | * 1. Redistributions of source code must retain the copyright | 8 | * |
| 27 | * notice, this list of conditions and the following disclaimer. | 9 | * 1. Redistributions of source code must retain the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer. | ||
| 11 | * | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
| 29 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in |
| 30 | * documentation and/or other materials provided with the distribution. | 14 | * the documentation and/or other materials provided with the |
| 31 | * 3. All advertising materials mentioning features or use of this software | 15 | * distribution. |
| 32 | * must display the following acknowledgement: | 16 | * |
| 33 | * "This product includes cryptographic software written by | 17 | * 3. All advertising materials mentioning features or use of this |
| 34 | * Eric Young (eay@cryptsoft.com)" | 18 | * software must display the following acknowledgment: |
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | 19 | * "This product includes software developed by the OpenSSL Project |
| 36 | * being used are not cryptographic related :-). | 20 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" |
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 21 | * |
| 38 | * the apps directory (application code) you must include an acknowledgement: | 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to |
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 23 | * endorse or promote products derived from this software without |
| 40 | * | 24 | * prior written permission. For written permission, please contact |
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 25 | * openssl-core@OpenSSL.org. |
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 26 | * |
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 27 | * 5. Products derived from this software may not be called "OpenSSL" |
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | 28 | * nor may "OpenSSL" appear in their names without prior written |
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 29 | * permission of the OpenSSL Project. |
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 30 | * |
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 31 | * 6. Redistributions of any form whatsoever must retain the following |
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 32 | * acknowledgment: |
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 33 | * "This product includes software developed by the OpenSSL Project |
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 34 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" |
| 51 | * SUCH DAMAGE. | 35 | * |
| 52 | * | 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY |
| 53 | * The licence and distribution terms for any publically available version or | 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 55 | * copied and put under another distribution licence | 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR |
| 56 | * [including the GNU Public Licence.] | 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 48 | * ==================================================================== | ||
| 49 | * | ||
| 50 | * This product includes cryptographic software written by Eric Young | ||
| 51 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 52 | * Hudson (tjh@cryptsoft.com). | ||
| 53 | * | ||
| 57 | */ | 54 | */ |
| 55 | |||
| 56 | /* NOTE: this file was auto generated by the mkerr.pl script: any changes | ||
| 57 | * made to it will be overwritten when the script next updates this file, | ||
| 58 | * only reason strings will be preserved. | ||
| 59 | */ | ||
| 60 | |||
| 58 | #include <stdio.h> | 61 | #include <stdio.h> |
| 59 | #include "err.h" | 62 | #include <openssl/err.h> |
| 60 | #include "ssl.h" | 63 | #include <openssl/ssl.h> |
| 61 | 64 | ||
| 62 | /* BEGIN ERROR CODES */ | 65 | /* BEGIN ERROR CODES */ |
| 63 | #ifndef NO_ERR | 66 | #ifndef OPENSSL_NO_ERR |
| 64 | static ERR_STRING_DATA SSL_str_functs[]= | 67 | static ERR_STRING_DATA SSL_str_functs[]= |
| 65 | { | 68 | { |
| 66 | {ERR_PACK(0,SSL_F_CLIENT_CERTIFICATE,0), "CLIENT_CERTIFICATE"}, | 69 | {ERR_PACK(0,SSL_F_CLIENT_CERTIFICATE,0), "CLIENT_CERTIFICATE"}, |
| @@ -83,21 +86,27 @@ static ERR_STRING_DATA SSL_str_functs[]= | |||
| 83 | {ERR_PACK(0,SSL_F_SSL23_CONNECT,0), "SSL23_CONNECT"}, | 86 | {ERR_PACK(0,SSL_F_SSL23_CONNECT,0), "SSL23_CONNECT"}, |
| 84 | {ERR_PACK(0,SSL_F_SSL23_GET_CLIENT_HELLO,0), "SSL23_GET_CLIENT_HELLO"}, | 87 | {ERR_PACK(0,SSL_F_SSL23_GET_CLIENT_HELLO,0), "SSL23_GET_CLIENT_HELLO"}, |
| 85 | {ERR_PACK(0,SSL_F_SSL23_GET_SERVER_HELLO,0), "SSL23_GET_SERVER_HELLO"}, | 88 | {ERR_PACK(0,SSL_F_SSL23_GET_SERVER_HELLO,0), "SSL23_GET_SERVER_HELLO"}, |
| 89 | {ERR_PACK(0,SSL_F_SSL23_PEEK,0), "SSL23_PEEK"}, | ||
| 86 | {ERR_PACK(0,SSL_F_SSL23_READ,0), "SSL23_READ"}, | 90 | {ERR_PACK(0,SSL_F_SSL23_READ,0), "SSL23_READ"}, |
| 87 | {ERR_PACK(0,SSL_F_SSL23_WRITE,0), "SSL23_WRITE"}, | 91 | {ERR_PACK(0,SSL_F_SSL23_WRITE,0), "SSL23_WRITE"}, |
| 88 | {ERR_PACK(0,SSL_F_SSL2_ACCEPT,0), "SSL2_ACCEPT"}, | 92 | {ERR_PACK(0,SSL_F_SSL2_ACCEPT,0), "SSL2_ACCEPT"}, |
| 89 | {ERR_PACK(0,SSL_F_SSL2_CONNECT,0), "SSL2_CONNECT"}, | 93 | {ERR_PACK(0,SSL_F_SSL2_CONNECT,0), "SSL2_CONNECT"}, |
| 90 | {ERR_PACK(0,SSL_F_SSL2_ENC_INIT,0), "SSL2_ENC_INIT"}, | 94 | {ERR_PACK(0,SSL_F_SSL2_ENC_INIT,0), "SSL2_ENC_INIT"}, |
| 95 | {ERR_PACK(0,SSL_F_SSL2_PEEK,0), "SSL2_PEEK"}, | ||
| 91 | {ERR_PACK(0,SSL_F_SSL2_READ,0), "SSL2_READ"}, | 96 | {ERR_PACK(0,SSL_F_SSL2_READ,0), "SSL2_READ"}, |
| 97 | {ERR_PACK(0,SSL_F_SSL2_READ_INTERNAL,0), "SSL2_READ_INTERNAL"}, | ||
| 92 | {ERR_PACK(0,SSL_F_SSL2_SET_CERTIFICATE,0), "SSL2_SET_CERTIFICATE"}, | 98 | {ERR_PACK(0,SSL_F_SSL2_SET_CERTIFICATE,0), "SSL2_SET_CERTIFICATE"}, |
| 93 | {ERR_PACK(0,SSL_F_SSL2_WRITE,0), "SSL2_WRITE"}, | 99 | {ERR_PACK(0,SSL_F_SSL2_WRITE,0), "SSL2_WRITE"}, |
| 94 | {ERR_PACK(0,SSL_F_SSL3_ACCEPT,0), "SSL3_ACCEPT"}, | 100 | {ERR_PACK(0,SSL_F_SSL3_ACCEPT,0), "SSL3_ACCEPT"}, |
| 101 | {ERR_PACK(0,SSL_F_SSL3_CALLBACK_CTRL,0), "SSL3_CALLBACK_CTRL"}, | ||
| 95 | {ERR_PACK(0,SSL_F_SSL3_CHANGE_CIPHER_STATE,0), "SSL3_CHANGE_CIPHER_STATE"}, | 102 | {ERR_PACK(0,SSL_F_SSL3_CHANGE_CIPHER_STATE,0), "SSL3_CHANGE_CIPHER_STATE"}, |
| 96 | {ERR_PACK(0,SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,0), "SSL3_CHECK_CERT_AND_ALGORITHM"}, | 103 | {ERR_PACK(0,SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,0), "SSL3_CHECK_CERT_AND_ALGORITHM"}, |
| 97 | {ERR_PACK(0,SSL_F_SSL3_CLIENT_HELLO,0), "SSL3_CLIENT_HELLO"}, | 104 | {ERR_PACK(0,SSL_F_SSL3_CLIENT_HELLO,0), "SSL3_CLIENT_HELLO"}, |
| 98 | {ERR_PACK(0,SSL_F_SSL3_CONNECT,0), "SSL3_CONNECT"}, | 105 | {ERR_PACK(0,SSL_F_SSL3_CONNECT,0), "SSL3_CONNECT"}, |
| 106 | {ERR_PACK(0,SSL_F_SSL3_CTRL,0), "SSL3_CTRL"}, | ||
| 99 | {ERR_PACK(0,SSL_F_SSL3_CTX_CTRL,0), "SSL3_CTX_CTRL"}, | 107 | {ERR_PACK(0,SSL_F_SSL3_CTX_CTRL,0), "SSL3_CTX_CTRL"}, |
| 100 | {ERR_PACK(0,SSL_F_SSL3_ENC,0), "SSL3_ENC"}, | 108 | {ERR_PACK(0,SSL_F_SSL3_ENC,0), "SSL3_ENC"}, |
| 109 | {ERR_PACK(0,SSL_F_SSL3_GENERATE_KEY_BLOCK,0), "SSL3_GENERATE_KEY_BLOCK"}, | ||
| 101 | {ERR_PACK(0,SSL_F_SSL3_GET_CERTIFICATE_REQUEST,0), "SSL3_GET_CERTIFICATE_REQUEST"}, | 110 | {ERR_PACK(0,SSL_F_SSL3_GET_CERTIFICATE_REQUEST,0), "SSL3_GET_CERTIFICATE_REQUEST"}, |
| 102 | {ERR_PACK(0,SSL_F_SSL3_GET_CERT_VERIFY,0), "SSL3_GET_CERT_VERIFY"}, | 111 | {ERR_PACK(0,SSL_F_SSL3_GET_CERT_VERIFY,0), "SSL3_GET_CERT_VERIFY"}, |
| 103 | {ERR_PACK(0,SSL_F_SSL3_GET_CLIENT_CERTIFICATE,0), "SSL3_GET_CLIENT_CERTIFICATE"}, | 112 | {ERR_PACK(0,SSL_F_SSL3_GET_CLIENT_CERTIFICATE,0), "SSL3_GET_CLIENT_CERTIFICATE"}, |
| @@ -111,6 +120,7 @@ static ERR_STRING_DATA SSL_str_functs[]= | |||
| 111 | {ERR_PACK(0,SSL_F_SSL3_GET_SERVER_DONE,0), "SSL3_GET_SERVER_DONE"}, | 120 | {ERR_PACK(0,SSL_F_SSL3_GET_SERVER_DONE,0), "SSL3_GET_SERVER_DONE"}, |
| 112 | {ERR_PACK(0,SSL_F_SSL3_GET_SERVER_HELLO,0), "SSL3_GET_SERVER_HELLO"}, | 121 | {ERR_PACK(0,SSL_F_SSL3_GET_SERVER_HELLO,0), "SSL3_GET_SERVER_HELLO"}, |
| 113 | {ERR_PACK(0,SSL_F_SSL3_OUTPUT_CERT_CHAIN,0), "SSL3_OUTPUT_CERT_CHAIN"}, | 122 | {ERR_PACK(0,SSL_F_SSL3_OUTPUT_CERT_CHAIN,0), "SSL3_OUTPUT_CERT_CHAIN"}, |
| 123 | {ERR_PACK(0,SSL_F_SSL3_PEEK,0), "SSL3_PEEK"}, | ||
| 114 | {ERR_PACK(0,SSL_F_SSL3_READ_BYTES,0), "SSL3_READ_BYTES"}, | 124 | {ERR_PACK(0,SSL_F_SSL3_READ_BYTES,0), "SSL3_READ_BYTES"}, |
| 115 | {ERR_PACK(0,SSL_F_SSL3_READ_N,0), "SSL3_READ_N"}, | 125 | {ERR_PACK(0,SSL_F_SSL3_READ_N,0), "SSL3_READ_N"}, |
| 116 | {ERR_PACK(0,SSL_F_SSL3_SEND_CERTIFICATE_REQUEST,0), "SSL3_SEND_CERTIFICATE_REQUEST"}, | 126 | {ERR_PACK(0,SSL_F_SSL3_SEND_CERTIFICATE_REQUEST,0), "SSL3_SEND_CERTIFICATE_REQUEST"}, |
| @@ -123,16 +133,30 @@ static ERR_STRING_DATA SSL_str_functs[]= | |||
| 123 | {ERR_PACK(0,SSL_F_SSL3_SETUP_KEY_BLOCK,0), "SSL3_SETUP_KEY_BLOCK"}, | 133 | {ERR_PACK(0,SSL_F_SSL3_SETUP_KEY_BLOCK,0), "SSL3_SETUP_KEY_BLOCK"}, |
| 124 | {ERR_PACK(0,SSL_F_SSL3_WRITE_BYTES,0), "SSL3_WRITE_BYTES"}, | 134 | {ERR_PACK(0,SSL_F_SSL3_WRITE_BYTES,0), "SSL3_WRITE_BYTES"}, |
| 125 | {ERR_PACK(0,SSL_F_SSL3_WRITE_PENDING,0), "SSL3_WRITE_PENDING"}, | 135 | {ERR_PACK(0,SSL_F_SSL3_WRITE_PENDING,0), "SSL3_WRITE_PENDING"}, |
| 136 | {ERR_PACK(0,SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK,0), "SSL_add_dir_cert_subjects_to_stack"}, | ||
| 137 | {ERR_PACK(0,SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK,0), "SSL_add_file_cert_subjects_to_stack"}, | ||
| 126 | {ERR_PACK(0,SSL_F_SSL_BAD_METHOD,0), "SSL_BAD_METHOD"}, | 138 | {ERR_PACK(0,SSL_F_SSL_BAD_METHOD,0), "SSL_BAD_METHOD"}, |
| 127 | {ERR_PACK(0,SSL_F_SSL_BYTES_TO_CIPHER_LIST,0), "SSL_BYTES_TO_CIPHER_LIST"}, | 139 | {ERR_PACK(0,SSL_F_SSL_BYTES_TO_CIPHER_LIST,0), "SSL_BYTES_TO_CIPHER_LIST"}, |
| 140 | {ERR_PACK(0,SSL_F_SSL_CERT_DUP,0), "SSL_CERT_DUP"}, | ||
| 141 | {ERR_PACK(0,SSL_F_SSL_CERT_INST,0), "SSL_CERT_INST"}, | ||
| 142 | {ERR_PACK(0,SSL_F_SSL_CERT_INSTANTIATE,0), "SSL_CERT_INSTANTIATE"}, | ||
| 128 | {ERR_PACK(0,SSL_F_SSL_CERT_NEW,0), "SSL_CERT_NEW"}, | 143 | {ERR_PACK(0,SSL_F_SSL_CERT_NEW,0), "SSL_CERT_NEW"}, |
| 129 | {ERR_PACK(0,SSL_F_SSL_CHECK_PRIVATE_KEY,0), "SSL_check_private_key"}, | 144 | {ERR_PACK(0,SSL_F_SSL_CHECK_PRIVATE_KEY,0), "SSL_check_private_key"}, |
| 145 | {ERR_PACK(0,SSL_F_SSL_CIPHER_PROCESS_RULESTR,0), "SSL_CIPHER_PROCESS_RULESTR"}, | ||
| 146 | {ERR_PACK(0,SSL_F_SSL_CIPHER_STRENGTH_SORT,0), "SSL_CIPHER_STRENGTH_SORT"}, | ||
| 147 | {ERR_PACK(0,SSL_F_SSL_CLEAR,0), "SSL_clear"}, | ||
| 148 | {ERR_PACK(0,SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD,0), "SSL_COMP_add_compression_method"}, | ||
| 130 | {ERR_PACK(0,SSL_F_SSL_CREATE_CIPHER_LIST,0), "SSL_CREATE_CIPHER_LIST"}, | 149 | {ERR_PACK(0,SSL_F_SSL_CREATE_CIPHER_LIST,0), "SSL_CREATE_CIPHER_LIST"}, |
| 150 | {ERR_PACK(0,SSL_F_SSL_CTRL,0), "SSL_ctrl"}, | ||
| 131 | {ERR_PACK(0,SSL_F_SSL_CTX_CHECK_PRIVATE_KEY,0), "SSL_CTX_check_private_key"}, | 151 | {ERR_PACK(0,SSL_F_SSL_CTX_CHECK_PRIVATE_KEY,0), "SSL_CTX_check_private_key"}, |
| 132 | {ERR_PACK(0,SSL_F_SSL_CTX_NEW,0), "SSL_CTX_new"}, | 152 | {ERR_PACK(0,SSL_F_SSL_CTX_NEW,0), "SSL_CTX_new"}, |
| 153 | {ERR_PACK(0,SSL_F_SSL_CTX_SET_PURPOSE,0), "SSL_CTX_set_purpose"}, | ||
| 154 | {ERR_PACK(0,SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT,0), "SSL_CTX_set_session_id_context"}, | ||
| 133 | {ERR_PACK(0,SSL_F_SSL_CTX_SET_SSL_VERSION,0), "SSL_CTX_set_ssl_version"}, | 155 | {ERR_PACK(0,SSL_F_SSL_CTX_SET_SSL_VERSION,0), "SSL_CTX_set_ssl_version"}, |
| 156 | {ERR_PACK(0,SSL_F_SSL_CTX_SET_TRUST,0), "SSL_CTX_set_trust"}, | ||
| 134 | {ERR_PACK(0,SSL_F_SSL_CTX_USE_CERTIFICATE,0), "SSL_CTX_use_certificate"}, | 157 | {ERR_PACK(0,SSL_F_SSL_CTX_USE_CERTIFICATE,0), "SSL_CTX_use_certificate"}, |
| 135 | {ERR_PACK(0,SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1,0), "SSL_CTX_use_certificate_ASN1"}, | 158 | {ERR_PACK(0,SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1,0), "SSL_CTX_use_certificate_ASN1"}, |
| 159 | {ERR_PACK(0,SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE,0), "SSL_CTX_use_certificate_chain_file"}, | ||
| 136 | {ERR_PACK(0,SSL_F_SSL_CTX_USE_CERTIFICATE_FILE,0), "SSL_CTX_use_certificate_file"}, | 160 | {ERR_PACK(0,SSL_F_SSL_CTX_USE_CERTIFICATE_FILE,0), "SSL_CTX_use_certificate_file"}, |
| 137 | {ERR_PACK(0,SSL_F_SSL_CTX_USE_PRIVATEKEY,0), "SSL_CTX_use_PrivateKey"}, | 161 | {ERR_PACK(0,SSL_F_SSL_CTX_USE_PRIVATEKEY,0), "SSL_CTX_use_PrivateKey"}, |
| 138 | {ERR_PACK(0,SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1,0), "SSL_CTX_use_PrivateKey_ASN1"}, | 162 | {ERR_PACK(0,SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1,0), "SSL_CTX_use_PrivateKey_ASN1"}, |
| @@ -142,21 +166,28 @@ static ERR_STRING_DATA SSL_str_functs[]= | |||
| 142 | {ERR_PACK(0,SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE,0), "SSL_CTX_use_RSAPrivateKey_file"}, | 166 | {ERR_PACK(0,SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE,0), "SSL_CTX_use_RSAPrivateKey_file"}, |
| 143 | {ERR_PACK(0,SSL_F_SSL_DO_HANDSHAKE,0), "SSL_do_handshake"}, | 167 | {ERR_PACK(0,SSL_F_SSL_DO_HANDSHAKE,0), "SSL_do_handshake"}, |
| 144 | {ERR_PACK(0,SSL_F_SSL_GET_NEW_SESSION,0), "SSL_GET_NEW_SESSION"}, | 168 | {ERR_PACK(0,SSL_F_SSL_GET_NEW_SESSION,0), "SSL_GET_NEW_SESSION"}, |
| 169 | {ERR_PACK(0,SSL_F_SSL_GET_PREV_SESSION,0), "SSL_GET_PREV_SESSION"}, | ||
| 145 | {ERR_PACK(0,SSL_F_SSL_GET_SERVER_SEND_CERT,0), "SSL_GET_SERVER_SEND_CERT"}, | 170 | {ERR_PACK(0,SSL_F_SSL_GET_SERVER_SEND_CERT,0), "SSL_GET_SERVER_SEND_CERT"}, |
| 146 | {ERR_PACK(0,SSL_F_SSL_GET_SIGN_PKEY,0), "SSL_GET_SIGN_PKEY"}, | 171 | {ERR_PACK(0,SSL_F_SSL_GET_SIGN_PKEY,0), "SSL_GET_SIGN_PKEY"}, |
| 147 | {ERR_PACK(0,SSL_F_SSL_INIT_WBIO_BUFFER,0), "SSL_INIT_WBIO_BUFFER"}, | 172 | {ERR_PACK(0,SSL_F_SSL_INIT_WBIO_BUFFER,0), "SSL_INIT_WBIO_BUFFER"}, |
| 148 | {ERR_PACK(0,SSL_F_SSL_LOAD_CLIENT_CA_FILE,0), "SSL_load_client_CA_file"}, | 173 | {ERR_PACK(0,SSL_F_SSL_LOAD_CLIENT_CA_FILE,0), "SSL_load_client_CA_file"}, |
| 149 | {ERR_PACK(0,SSL_F_SSL_NEW,0), "SSL_new"}, | 174 | {ERR_PACK(0,SSL_F_SSL_NEW,0), "SSL_new"}, |
| 175 | {ERR_PACK(0,SSL_F_SSL_READ,0), "SSL_read"}, | ||
| 150 | {ERR_PACK(0,SSL_F_SSL_RSA_PRIVATE_DECRYPT,0), "SSL_RSA_PRIVATE_DECRYPT"}, | 176 | {ERR_PACK(0,SSL_F_SSL_RSA_PRIVATE_DECRYPT,0), "SSL_RSA_PRIVATE_DECRYPT"}, |
| 151 | {ERR_PACK(0,SSL_F_SSL_RSA_PUBLIC_ENCRYPT,0), "SSL_RSA_PUBLIC_ENCRYPT"}, | 177 | {ERR_PACK(0,SSL_F_SSL_RSA_PUBLIC_ENCRYPT,0), "SSL_RSA_PUBLIC_ENCRYPT"}, |
| 152 | {ERR_PACK(0,SSL_F_SSL_SESSION_NEW,0), "SSL_SESSION_new"}, | 178 | {ERR_PACK(0,SSL_F_SSL_SESSION_NEW,0), "SSL_SESSION_new"}, |
| 153 | {ERR_PACK(0,SSL_F_SSL_SESSION_PRINT_FP,0), "SSL_SESSION_print_fp"}, | 179 | {ERR_PACK(0,SSL_F_SSL_SESSION_PRINT_FP,0), "SSL_SESSION_print_fp"}, |
| 180 | {ERR_PACK(0,SSL_F_SSL_SESS_CERT_NEW,0), "SSL_SESS_CERT_NEW"}, | ||
| 154 | {ERR_PACK(0,SSL_F_SSL_SET_CERT,0), "SSL_SET_CERT"}, | 181 | {ERR_PACK(0,SSL_F_SSL_SET_CERT,0), "SSL_SET_CERT"}, |
| 155 | {ERR_PACK(0,SSL_F_SSL_SET_FD,0), "SSL_set_fd"}, | 182 | {ERR_PACK(0,SSL_F_SSL_SET_FD,0), "SSL_set_fd"}, |
| 156 | {ERR_PACK(0,SSL_F_SSL_SET_PKEY,0), "SSL_SET_PKEY"}, | 183 | {ERR_PACK(0,SSL_F_SSL_SET_PKEY,0), "SSL_SET_PKEY"}, |
| 184 | {ERR_PACK(0,SSL_F_SSL_SET_PURPOSE,0), "SSL_set_purpose"}, | ||
| 157 | {ERR_PACK(0,SSL_F_SSL_SET_RFD,0), "SSL_set_rfd"}, | 185 | {ERR_PACK(0,SSL_F_SSL_SET_RFD,0), "SSL_set_rfd"}, |
| 158 | {ERR_PACK(0,SSL_F_SSL_SET_SESSION,0), "SSL_set_session"}, | 186 | {ERR_PACK(0,SSL_F_SSL_SET_SESSION,0), "SSL_set_session"}, |
| 187 | {ERR_PACK(0,SSL_F_SSL_SET_SESSION_ID_CONTEXT,0), "SSL_set_session_id_context"}, | ||
| 188 | {ERR_PACK(0,SSL_F_SSL_SET_TRUST,0), "SSL_set_trust"}, | ||
| 159 | {ERR_PACK(0,SSL_F_SSL_SET_WFD,0), "SSL_set_wfd"}, | 189 | {ERR_PACK(0,SSL_F_SSL_SET_WFD,0), "SSL_set_wfd"}, |
| 190 | {ERR_PACK(0,SSL_F_SSL_SHUTDOWN,0), "SSL_shutdown"}, | ||
| 160 | {ERR_PACK(0,SSL_F_SSL_UNDEFINED_FUNCTION,0), "SSL_UNDEFINED_FUNCTION"}, | 191 | {ERR_PACK(0,SSL_F_SSL_UNDEFINED_FUNCTION,0), "SSL_UNDEFINED_FUNCTION"}, |
| 161 | {ERR_PACK(0,SSL_F_SSL_USE_CERTIFICATE,0), "SSL_use_certificate"}, | 192 | {ERR_PACK(0,SSL_F_SSL_USE_CERTIFICATE,0), "SSL_use_certificate"}, |
| 162 | {ERR_PACK(0,SSL_F_SSL_USE_CERTIFICATE_ASN1,0), "SSL_use_certificate_ASN1"}, | 193 | {ERR_PACK(0,SSL_F_SSL_USE_CERTIFICATE_ASN1,0), "SSL_use_certificate_ASN1"}, |
| @@ -167,22 +198,23 @@ static ERR_STRING_DATA SSL_str_functs[]= | |||
| 167 | {ERR_PACK(0,SSL_F_SSL_USE_RSAPRIVATEKEY,0), "SSL_use_RSAPrivateKey"}, | 198 | {ERR_PACK(0,SSL_F_SSL_USE_RSAPRIVATEKEY,0), "SSL_use_RSAPrivateKey"}, |
| 168 | {ERR_PACK(0,SSL_F_SSL_USE_RSAPRIVATEKEY_ASN1,0), "SSL_use_RSAPrivateKey_ASN1"}, | 199 | {ERR_PACK(0,SSL_F_SSL_USE_RSAPRIVATEKEY_ASN1,0), "SSL_use_RSAPrivateKey_ASN1"}, |
| 169 | {ERR_PACK(0,SSL_F_SSL_USE_RSAPRIVATEKEY_FILE,0), "SSL_use_RSAPrivateKey_file"}, | 200 | {ERR_PACK(0,SSL_F_SSL_USE_RSAPRIVATEKEY_FILE,0), "SSL_use_RSAPrivateKey_file"}, |
| 201 | {ERR_PACK(0,SSL_F_SSL_VERIFY_CERT_CHAIN,0), "SSL_VERIFY_CERT_CHAIN"}, | ||
| 170 | {ERR_PACK(0,SSL_F_SSL_WRITE,0), "SSL_write"}, | 202 | {ERR_PACK(0,SSL_F_SSL_WRITE,0), "SSL_write"}, |
| 171 | {ERR_PACK(0,SSL_F_TLS1_CHANGE_CIPHER_STATE,0), "TLS1_CHANGE_CIPHER_STATE"}, | 203 | {ERR_PACK(0,SSL_F_TLS1_CHANGE_CIPHER_STATE,0), "TLS1_CHANGE_CIPHER_STATE"}, |
| 172 | {ERR_PACK(0,SSL_F_TLS1_ENC,0), "TLS1_ENC"}, | 204 | {ERR_PACK(0,SSL_F_TLS1_ENC,0), "TLS1_ENC"}, |
| 173 | {ERR_PACK(0,SSL_F_TLS1_SETUP_KEY_BLOCK,0), "TLS1_SETUP_KEY_BLOCK"}, | 205 | {ERR_PACK(0,SSL_F_TLS1_SETUP_KEY_BLOCK,0), "TLS1_SETUP_KEY_BLOCK"}, |
| 174 | {ERR_PACK(0,SSL_F_WRITE_PENDING,0), "WRITE_PENDING"}, | 206 | {ERR_PACK(0,SSL_F_WRITE_PENDING,0), "WRITE_PENDING"}, |
| 175 | {0,NULL}, | 207 | {0,NULL} |
| 176 | }; | 208 | }; |
| 177 | 209 | ||
| 178 | static ERR_STRING_DATA SSL_str_reasons[]= | 210 | static ERR_STRING_DATA SSL_str_reasons[]= |
| 179 | { | 211 | { |
| 180 | {SSL_R_APP_DATA_IN_HANDSHAKE ,"app data in handshake"}, | 212 | {SSL_R_APP_DATA_IN_HANDSHAKE ,"app data in handshake"}, |
| 213 | {SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT,"attempt to reuse session in different context"}, | ||
| 181 | {SSL_R_BAD_ALERT_RECORD ,"bad alert record"}, | 214 | {SSL_R_BAD_ALERT_RECORD ,"bad alert record"}, |
| 182 | {SSL_R_BAD_AUTHENTICATION_TYPE ,"bad authentication type"}, | 215 | {SSL_R_BAD_AUTHENTICATION_TYPE ,"bad authentication type"}, |
| 183 | {SSL_R_BAD_CHANGE_CIPHER_SPEC ,"bad change cipher spec"}, | 216 | {SSL_R_BAD_CHANGE_CIPHER_SPEC ,"bad change cipher spec"}, |
| 184 | {SSL_R_BAD_CHECKSUM ,"bad checksum"}, | 217 | {SSL_R_BAD_CHECKSUM ,"bad checksum"}, |
| 185 | {SSL_R_BAD_CLIENT_REQUEST ,"bad client request"}, | ||
| 186 | {SSL_R_BAD_DATA_RETURNED_BY_CALLBACK ,"bad data returned by callback"}, | 218 | {SSL_R_BAD_DATA_RETURNED_BY_CALLBACK ,"bad data returned by callback"}, |
| 187 | {SSL_R_BAD_DECOMPRESSION ,"bad decompression"}, | 219 | {SSL_R_BAD_DECOMPRESSION ,"bad decompression"}, |
| 188 | {SSL_R_BAD_DH_G_LENGTH ,"bad dh g length"}, | 220 | {SSL_R_BAD_DH_G_LENGTH ,"bad dh g length"}, |
| @@ -190,6 +222,8 @@ static ERR_STRING_DATA SSL_str_reasons[]= | |||
| 190 | {SSL_R_BAD_DH_P_LENGTH ,"bad dh p length"}, | 222 | {SSL_R_BAD_DH_P_LENGTH ,"bad dh p length"}, |
| 191 | {SSL_R_BAD_DIGEST_LENGTH ,"bad digest length"}, | 223 | {SSL_R_BAD_DIGEST_LENGTH ,"bad digest length"}, |
| 192 | {SSL_R_BAD_DSA_SIGNATURE ,"bad dsa signature"}, | 224 | {SSL_R_BAD_DSA_SIGNATURE ,"bad dsa signature"}, |
| 225 | {SSL_R_BAD_HELLO_REQUEST ,"bad hello request"}, | ||
| 226 | {SSL_R_BAD_LENGTH ,"bad length"}, | ||
| 193 | {SSL_R_BAD_MAC_DECODE ,"bad mac decode"}, | 227 | {SSL_R_BAD_MAC_DECODE ,"bad mac decode"}, |
| 194 | {SSL_R_BAD_MESSAGE_TYPE ,"bad message type"}, | 228 | {SSL_R_BAD_MESSAGE_TYPE ,"bad message type"}, |
| 195 | {SSL_R_BAD_PACKET_LENGTH ,"bad packet length"}, | 229 | {SSL_R_BAD_PACKET_LENGTH ,"bad packet length"}, |
| @@ -219,25 +253,44 @@ static ERR_STRING_DATA SSL_str_reasons[]= | |||
| 219 | {SSL_R_CIPHER_TABLE_SRC_ERROR ,"cipher table src error"}, | 253 | {SSL_R_CIPHER_TABLE_SRC_ERROR ,"cipher table src error"}, |
| 220 | {SSL_R_COMPRESSED_LENGTH_TOO_LONG ,"compressed length too long"}, | 254 | {SSL_R_COMPRESSED_LENGTH_TOO_LONG ,"compressed length too long"}, |
| 221 | {SSL_R_COMPRESSION_FAILURE ,"compression failure"}, | 255 | {SSL_R_COMPRESSION_FAILURE ,"compression failure"}, |
| 256 | {SSL_R_COMPRESSION_LIBRARY_ERROR ,"compression library error"}, | ||
| 222 | {SSL_R_CONNECTION_ID_IS_DIFFERENT ,"connection id is different"}, | 257 | {SSL_R_CONNECTION_ID_IS_DIFFERENT ,"connection id is different"}, |
| 223 | {SSL_R_CONNECTION_TYPE_NOT_SET ,"connection type not set"}, | 258 | {SSL_R_CONNECTION_TYPE_NOT_SET ,"connection type not set"}, |
| 224 | {SSL_R_DATA_BETWEEN_CCS_AND_FINISHED ,"data between ccs and finished"}, | 259 | {SSL_R_DATA_BETWEEN_CCS_AND_FINISHED ,"data between ccs and finished"}, |
| 225 | {SSL_R_DATA_LENGTH_TOO_LONG ,"data length too long"}, | 260 | {SSL_R_DATA_LENGTH_TOO_LONG ,"data length too long"}, |
| 226 | {SSL_R_DECRYPTION_FAILED ,"decryption failed"}, | 261 | {SSL_R_DECRYPTION_FAILED ,"decryption failed"}, |
| 262 | {SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC,"decryption failed or bad record mac"}, | ||
| 227 | {SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG ,"dh public value length is wrong"}, | 263 | {SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG ,"dh public value length is wrong"}, |
| 228 | {SSL_R_DIGEST_CHECK_FAILED ,"digest check failed"}, | 264 | {SSL_R_DIGEST_CHECK_FAILED ,"digest check failed"}, |
| 229 | {SSL_R_ENCRYPTED_LENGTH_TOO_LONG ,"encrypted length too long"}, | 265 | {SSL_R_ENCRYPTED_LENGTH_TOO_LONG ,"encrypted length too long"}, |
| 266 | {SSL_R_ERROR_GENERATING_TMP_RSA_KEY ,"error generating tmp rsa key"}, | ||
| 230 | {SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST ,"error in received cipher list"}, | 267 | {SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST ,"error in received cipher list"}, |
| 231 | {SSL_R_EXCESSIVE_MESSAGE_SIZE ,"excessive message size"}, | 268 | {SSL_R_EXCESSIVE_MESSAGE_SIZE ,"excessive message size"}, |
| 232 | {SSL_R_EXTRA_DATA_IN_MESSAGE ,"extra data in message"}, | 269 | {SSL_R_EXTRA_DATA_IN_MESSAGE ,"extra data in message"}, |
| 233 | {SSL_R_GOT_A_FIN_BEFORE_A_CCS ,"got a fin before a ccs"}, | 270 | {SSL_R_GOT_A_FIN_BEFORE_A_CCS ,"got a fin before a ccs"}, |
| 234 | {SSL_R_HTTPS_PROXY_REQUEST ,"https proxy request"}, | 271 | {SSL_R_HTTPS_PROXY_REQUEST ,"https proxy request"}, |
| 235 | {SSL_R_HTTP_REQUEST ,"http request"}, | 272 | {SSL_R_HTTP_REQUEST ,"http request"}, |
| 236 | {SSL_R_INTERNAL_ERROR ,"internal error"}, | 273 | {SSL_R_ILLEGAL_PADDING ,"illegal padding"}, |
| 237 | {SSL_R_INVALID_CHALLENGE_LENGTH ,"invalid challenge length"}, | 274 | {SSL_R_INVALID_CHALLENGE_LENGTH ,"invalid challenge length"}, |
| 275 | {SSL_R_INVALID_COMMAND ,"invalid command"}, | ||
| 276 | {SSL_R_INVALID_PURPOSE ,"invalid purpose"}, | ||
| 277 | {SSL_R_INVALID_TRUST ,"invalid trust"}, | ||
| 278 | {SSL_R_KRB5 ,"krb5"}, | ||
| 279 | {SSL_R_KRB5_C_CC_PRINC ,"krb5 client cc principal (no tkt?)"}, | ||
| 280 | {SSL_R_KRB5_C_GET_CRED ,"krb5 client get cred"}, | ||
| 281 | {SSL_R_KRB5_C_INIT ,"krb5 client init"}, | ||
| 282 | {SSL_R_KRB5_C_MK_REQ ,"krb5 client mk_req (expired tkt?)"}, | ||
| 283 | {SSL_R_KRB5_S_BAD_TICKET ,"krb5 server bad ticket"}, | ||
| 284 | {SSL_R_KRB5_S_INIT ,"krb5 server init"}, | ||
| 285 | {SSL_R_KRB5_S_RD_REQ ,"krb5 server rd_req (keytab perms?)"}, | ||
| 286 | {SSL_R_KRB5_S_TKT_EXPIRED ,"krb5 server tkt expired"}, | ||
| 287 | {SSL_R_KRB5_S_TKT_NYV ,"krb5 server tkt not yet valid"}, | ||
| 288 | {SSL_R_KRB5_S_TKT_SKEW ,"krb5 server tkt skew"}, | ||
| 238 | {SSL_R_LENGTH_MISMATCH ,"length mismatch"}, | 289 | {SSL_R_LENGTH_MISMATCH ,"length mismatch"}, |
| 239 | {SSL_R_LENGTH_TOO_SHORT ,"length too short"}, | 290 | {SSL_R_LENGTH_TOO_SHORT ,"length too short"}, |
| 291 | {SSL_R_LIBRARY_BUG ,"library bug"}, | ||
| 240 | {SSL_R_LIBRARY_HAS_NO_CIPHERS ,"library has no ciphers"}, | 292 | {SSL_R_LIBRARY_HAS_NO_CIPHERS ,"library has no ciphers"}, |
| 293 | {SSL_R_MESSAGE_TOO_LONG ,"message too long"}, | ||
| 241 | {SSL_R_MISSING_DH_DSA_CERT ,"missing dh dsa cert"}, | 294 | {SSL_R_MISSING_DH_DSA_CERT ,"missing dh dsa cert"}, |
| 242 | {SSL_R_MISSING_DH_KEY ,"missing dh key"}, | 295 | {SSL_R_MISSING_DH_KEY ,"missing dh key"}, |
| 243 | {SSL_R_MISSING_DH_RSA_CERT ,"missing dh rsa cert"}, | 296 | {SSL_R_MISSING_DH_RSA_CERT ,"missing dh rsa cert"}, |
| @@ -264,15 +317,18 @@ static ERR_STRING_DATA SSL_str_reasons[]= | |||
| 264 | {SSL_R_NO_CIPHER_MATCH ,"no cipher match"}, | 317 | {SSL_R_NO_CIPHER_MATCH ,"no cipher match"}, |
| 265 | {SSL_R_NO_CLIENT_CERT_RECEIVED ,"no client cert received"}, | 318 | {SSL_R_NO_CLIENT_CERT_RECEIVED ,"no client cert received"}, |
| 266 | {SSL_R_NO_COMPRESSION_SPECIFIED ,"no compression specified"}, | 319 | {SSL_R_NO_COMPRESSION_SPECIFIED ,"no compression specified"}, |
| 320 | {SSL_R_NO_METHOD_SPECIFIED ,"no method specified"}, | ||
| 267 | {SSL_R_NO_PRIVATEKEY ,"no privatekey"}, | 321 | {SSL_R_NO_PRIVATEKEY ,"no privatekey"}, |
| 268 | {SSL_R_NO_PRIVATE_KEY_ASSIGNED ,"no private key assigned"}, | 322 | {SSL_R_NO_PRIVATE_KEY_ASSIGNED ,"no private key assigned"}, |
| 269 | {SSL_R_NO_PROTOCOLS_AVAILABLE ,"no protocols available"}, | 323 | {SSL_R_NO_PROTOCOLS_AVAILABLE ,"no protocols available"}, |
| 270 | {SSL_R_NO_PUBLICKEY ,"no publickey"}, | 324 | {SSL_R_NO_PUBLICKEY ,"no publickey"}, |
| 271 | {SSL_R_NO_SHARED_CIPHER ,"no shared cipher"}, | 325 | {SSL_R_NO_SHARED_CIPHER ,"no shared cipher"}, |
| 326 | {SSL_R_NO_VERIFY_CALLBACK ,"no verify callback"}, | ||
| 272 | {SSL_R_NULL_SSL_CTX ,"null ssl ctx"}, | 327 | {SSL_R_NULL_SSL_CTX ,"null ssl ctx"}, |
| 273 | {SSL_R_NULL_SSL_METHOD_PASSED ,"null ssl method passed"}, | 328 | {SSL_R_NULL_SSL_METHOD_PASSED ,"null ssl method passed"}, |
| 274 | {SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED ,"old session cipher not returned"}, | 329 | {SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED ,"old session cipher not returned"}, |
| 275 | {SSL_R_PACKET_LENGTH_TOO_LONG ,"packet length too long"}, | 330 | {SSL_R_PACKET_LENGTH_TOO_LONG ,"packet length too long"}, |
| 331 | {SSL_R_PATH_TOO_LONG ,"path too long"}, | ||
| 276 | {SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE ,"peer did not return a certificate"}, | 332 | {SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE ,"peer did not return a certificate"}, |
| 277 | {SSL_R_PEER_ERROR ,"peer error"}, | 333 | {SSL_R_PEER_ERROR ,"peer error"}, |
| 278 | {SSL_R_PEER_ERROR_CERTIFICATE ,"peer error certificate"}, | 334 | {SSL_R_PEER_ERROR_CERTIFICATE ,"peer error certificate"}, |
| @@ -289,12 +345,15 @@ static ERR_STRING_DATA SSL_str_reasons[]= | |||
| 289 | {SSL_R_READ_WRONG_PACKET_TYPE ,"read wrong packet type"}, | 345 | {SSL_R_READ_WRONG_PACKET_TYPE ,"read wrong packet type"}, |
| 290 | {SSL_R_RECORD_LENGTH_MISMATCH ,"record length mismatch"}, | 346 | {SSL_R_RECORD_LENGTH_MISMATCH ,"record length mismatch"}, |
| 291 | {SSL_R_RECORD_TOO_LARGE ,"record too large"}, | 347 | {SSL_R_RECORD_TOO_LARGE ,"record too large"}, |
| 348 | {SSL_R_RECORD_TOO_SMALL ,"record too small"}, | ||
| 292 | {SSL_R_REQUIRED_CIPHER_MISSING ,"required cipher missing"}, | 349 | {SSL_R_REQUIRED_CIPHER_MISSING ,"required cipher missing"}, |
| 293 | {SSL_R_REUSE_CERT_LENGTH_NOT_ZERO ,"reuse cert length not zero"}, | 350 | {SSL_R_REUSE_CERT_LENGTH_NOT_ZERO ,"reuse cert length not zero"}, |
| 294 | {SSL_R_REUSE_CERT_TYPE_NOT_ZERO ,"reuse cert type not zero"}, | 351 | {SSL_R_REUSE_CERT_TYPE_NOT_ZERO ,"reuse cert type not zero"}, |
| 295 | {SSL_R_REUSE_CIPHER_LIST_NOT_ZERO ,"reuse cipher list not zero"}, | 352 | {SSL_R_REUSE_CIPHER_LIST_NOT_ZERO ,"reuse cipher list not zero"}, |
| 353 | {SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED ,"session id context uninitialized"}, | ||
| 296 | {SSL_R_SHORT_READ ,"short read"}, | 354 | {SSL_R_SHORT_READ ,"short read"}, |
| 297 | {SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE,"signature for non signing certificate"}, | 355 | {SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE,"signature for non signing certificate"}, |
| 356 | {SSL_R_SSL23_DOING_SESSION_ID_REUSE ,"ssl23 doing session id reuse"}, | ||
| 298 | {SSL_R_SSL3_SESSION_ID_TOO_SHORT ,"ssl3 session id too short"}, | 357 | {SSL_R_SSL3_SESSION_ID_TOO_SHORT ,"ssl3 session id too short"}, |
| 299 | {SSL_R_SSLV3_ALERT_BAD_CERTIFICATE ,"sslv3 alert bad certificate"}, | 358 | {SSL_R_SSLV3_ALERT_BAD_CERTIFICATE ,"sslv3 alert bad certificate"}, |
| 300 | {SSL_R_SSLV3_ALERT_BAD_RECORD_MAC ,"sslv3 alert bad record mac"}, | 359 | {SSL_R_SSLV3_ALERT_BAD_RECORD_MAC ,"sslv3 alert bad record mac"}, |
| @@ -315,7 +374,23 @@ static ERR_STRING_DATA SSL_str_reasons[]= | |||
| 315 | {SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION,"ssl ctx has no default ssl version"}, | 374 | {SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION,"ssl ctx has no default ssl version"}, |
| 316 | {SSL_R_SSL_HANDSHAKE_FAILURE ,"ssl handshake failure"}, | 375 | {SSL_R_SSL_HANDSHAKE_FAILURE ,"ssl handshake failure"}, |
| 317 | {SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS ,"ssl library has no ciphers"}, | 376 | {SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS ,"ssl library has no ciphers"}, |
| 377 | {SSL_R_SSL_SESSION_ID_CALLBACK_FAILED ,"ssl session id callback failed"}, | ||
| 378 | {SSL_R_SSL_SESSION_ID_CONFLICT ,"ssl session id conflict"}, | ||
| 379 | {SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG ,"ssl session id context too long"}, | ||
| 380 | {SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH ,"ssl session id has bad length"}, | ||
| 318 | {SSL_R_SSL_SESSION_ID_IS_DIFFERENT ,"ssl session id is different"}, | 381 | {SSL_R_SSL_SESSION_ID_IS_DIFFERENT ,"ssl session id is different"}, |
| 382 | {SSL_R_TLSV1_ALERT_ACCESS_DENIED ,"tlsv1 alert access denied"}, | ||
| 383 | {SSL_R_TLSV1_ALERT_DECODE_ERROR ,"tlsv1 alert decode error"}, | ||
| 384 | {SSL_R_TLSV1_ALERT_DECRYPTION_FAILED ,"tlsv1 alert decryption failed"}, | ||
| 385 | {SSL_R_TLSV1_ALERT_DECRYPT_ERROR ,"tlsv1 alert decrypt error"}, | ||
| 386 | {SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION ,"tlsv1 alert export restriction"}, | ||
| 387 | {SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY ,"tlsv1 alert insufficient security"}, | ||
| 388 | {SSL_R_TLSV1_ALERT_INTERNAL_ERROR ,"tlsv1 alert internal error"}, | ||
| 389 | {SSL_R_TLSV1_ALERT_NO_RENEGOTIATION ,"tlsv1 alert no renegotiation"}, | ||
| 390 | {SSL_R_TLSV1_ALERT_PROTOCOL_VERSION ,"tlsv1 alert protocol version"}, | ||
| 391 | {SSL_R_TLSV1_ALERT_RECORD_OVERFLOW ,"tlsv1 alert record overflow"}, | ||
| 392 | {SSL_R_TLSV1_ALERT_UNKNOWN_CA ,"tlsv1 alert unknown ca"}, | ||
| 393 | {SSL_R_TLSV1_ALERT_USER_CANCELLED ,"tlsv1 alert user cancelled"}, | ||
| 319 | {SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER,"tls client cert req with anon cipher"}, | 394 | {SSL_R_TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER,"tls client cert req with anon cipher"}, |
| 320 | {SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST,"tls peer did not respond with certificate list"}, | 395 | {SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST,"tls peer did not respond with certificate list"}, |
| 321 | {SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG,"tls rsa encrypted value length is wrong"}, | 396 | {SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG,"tls rsa encrypted value length is wrong"}, |
| @@ -330,6 +405,7 @@ static ERR_STRING_DATA SSL_str_reasons[]= | |||
| 330 | {SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES ,"unable to load ssl3 sha1 routines"}, | 405 | {SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES ,"unable to load ssl3 sha1 routines"}, |
| 331 | {SSL_R_UNEXPECTED_MESSAGE ,"unexpected message"}, | 406 | {SSL_R_UNEXPECTED_MESSAGE ,"unexpected message"}, |
| 332 | {SSL_R_UNEXPECTED_RECORD ,"unexpected record"}, | 407 | {SSL_R_UNEXPECTED_RECORD ,"unexpected record"}, |
| 408 | {SSL_R_UNINITIALIZED ,"uninitialized"}, | ||
| 333 | {SSL_R_UNKNOWN_ALERT_TYPE ,"unknown alert type"}, | 409 | {SSL_R_UNKNOWN_ALERT_TYPE ,"unknown alert type"}, |
| 334 | {SSL_R_UNKNOWN_CERTIFICATE_TYPE ,"unknown certificate type"}, | 410 | {SSL_R_UNKNOWN_CERTIFICATE_TYPE ,"unknown certificate type"}, |
| 335 | {SSL_R_UNKNOWN_CIPHER_RETURNED ,"unknown cipher returned"}, | 411 | {SSL_R_UNKNOWN_CIPHER_RETURNED ,"unknown cipher returned"}, |
| @@ -342,6 +418,7 @@ static ERR_STRING_DATA SSL_str_reasons[]= | |||
| 342 | {SSL_R_UNKNOWN_STATE ,"unknown state"}, | 418 | {SSL_R_UNKNOWN_STATE ,"unknown state"}, |
| 343 | {SSL_R_UNSUPPORTED_CIPHER ,"unsupported cipher"}, | 419 | {SSL_R_UNSUPPORTED_CIPHER ,"unsupported cipher"}, |
| 344 | {SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM ,"unsupported compression algorithm"}, | 420 | {SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM ,"unsupported compression algorithm"}, |
| 421 | {SSL_R_UNSUPPORTED_OPTION ,"unsupported option"}, | ||
| 345 | {SSL_R_UNSUPPORTED_PROTOCOL ,"unsupported protocol"}, | 422 | {SSL_R_UNSUPPORTED_PROTOCOL ,"unsupported protocol"}, |
| 346 | {SSL_R_UNSUPPORTED_SSL_VERSION ,"unsupported ssl version"}, | 423 | {SSL_R_UNSUPPORTED_SSL_VERSION ,"unsupported ssl version"}, |
| 347 | {SSL_R_WRITE_BIO_NOT_SET ,"write bio not set"}, | 424 | {SSL_R_WRITE_BIO_NOT_SET ,"write bio not set"}, |
| @@ -353,19 +430,20 @@ static ERR_STRING_DATA SSL_str_reasons[]= | |||
| 353 | {SSL_R_WRONG_SSL_VERSION ,"wrong ssl version"}, | 430 | {SSL_R_WRONG_SSL_VERSION ,"wrong ssl version"}, |
| 354 | {SSL_R_WRONG_VERSION_NUMBER ,"wrong version number"}, | 431 | {SSL_R_WRONG_VERSION_NUMBER ,"wrong version number"}, |
| 355 | {SSL_R_X509_LIB ,"x509 lib"}, | 432 | {SSL_R_X509_LIB ,"x509 lib"}, |
| 356 | {0,NULL}, | 433 | {SSL_R_X509_VERIFICATION_SETUP_PROBLEMS ,"x509 verification setup problems"}, |
| 434 | {0,NULL} | ||
| 357 | }; | 435 | }; |
| 358 | 436 | ||
| 359 | #endif | 437 | #endif |
| 360 | 438 | ||
| 361 | void ERR_load_SSL_strings() | 439 | void ERR_load_SSL_strings(void) |
| 362 | { | 440 | { |
| 363 | static int init=1; | 441 | static int init=1; |
| 364 | 442 | ||
| 365 | if (init); | 443 | if (init) |
| 366 | {; | 444 | { |
| 367 | init=0; | 445 | init=0; |
| 368 | #ifndef NO_ERR | 446 | #ifndef OPENSSL_NO_ERR |
| 369 | ERR_load_strings(ERR_LIB_SSL,SSL_str_functs); | 447 | ERR_load_strings(ERR_LIB_SSL,SSL_str_functs); |
| 370 | ERR_load_strings(ERR_LIB_SSL,SSL_str_reasons); | 448 | ERR_load_strings(ERR_LIB_SSL,SSL_str_reasons); |
| 371 | #endif | 449 | #endif |
diff --git a/src/lib/libssl/ssl_err2.c b/src/lib/libssl/ssl_err2.c index 0b91f7b8d2..ea95a5f983 100644 --- a/src/lib/libssl/ssl_err2.c +++ b/src/lib/libssl/ssl_err2.c | |||
| @@ -57,12 +57,12 @@ | |||
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include "err.h" | 60 | #include <openssl/err.h> |
| 61 | #include "ssl.h" | 61 | #include <openssl/ssl.h> |
| 62 | 62 | ||
| 63 | void SSL_load_error_strings() | 63 | void SSL_load_error_strings(void) |
| 64 | { | 64 | { |
| 65 | #ifndef NO_ERR | 65 | #ifndef OPENSSL_NO_ERR |
| 66 | ERR_load_crypto_strings(); | 66 | ERR_load_crypto_strings(); |
| 67 | ERR_load_SSL_strings(); | 67 | ERR_load_SSL_strings(); |
| 68 | #endif | 68 | #endif |
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c index f562ec6b14..df307a80c5 100644 --- a/src/lib/libssl/ssl_lib.c +++ b/src/lib/libssl/ssl_lib.c | |||
| @@ -1,4 +1,6 @@ | |||
| 1 | /* ssl/ssl_lib.c */ | 1 | /*! \file ssl/ssl_lib.c |
| 2 | * \brief Version independent SSL functions. | ||
| 3 | */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 4 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 5 | * All rights reserved. |
| 4 | * | 6 | * |
| @@ -55,52 +57,126 @@ | |||
| 55 | * copied and put under another distribution licence | 57 | * copied and put under another distribution licence |
| 56 | * [including the GNU Public Licence.] | 58 | * [including the GNU Public Licence.] |
| 57 | */ | 59 | */ |
| 60 | /* ==================================================================== | ||
| 61 | * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. | ||
| 62 | * | ||
| 63 | * Redistribution and use in source and binary forms, with or without | ||
| 64 | * modification, are permitted provided that the following conditions | ||
| 65 | * are met: | ||
| 66 | * | ||
| 67 | * 1. Redistributions of source code must retain the above copyright | ||
| 68 | * notice, this list of conditions and the following disclaimer. | ||
| 69 | * | ||
| 70 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 71 | * notice, this list of conditions and the following disclaimer in | ||
| 72 | * the documentation and/or other materials provided with the | ||
| 73 | * distribution. | ||
| 74 | * | ||
| 75 | * 3. All advertising materials mentioning features or use of this | ||
| 76 | * software must display the following acknowledgment: | ||
| 77 | * "This product includes software developed by the OpenSSL Project | ||
| 78 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | ||
| 79 | * | ||
| 80 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 81 | * endorse or promote products derived from this software without | ||
| 82 | * prior written permission. For written permission, please contact | ||
| 83 | * openssl-core@openssl.org. | ||
| 84 | * | ||
| 85 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 86 | * nor may "OpenSSL" appear in their names without prior written | ||
| 87 | * permission of the OpenSSL Project. | ||
| 88 | * | ||
| 89 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 90 | * acknowledgment: | ||
| 91 | * "This product includes software developed by the OpenSSL Project | ||
| 92 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
| 93 | * | ||
| 94 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 95 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 96 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 97 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 98 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 99 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 100 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 101 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 102 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 103 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 104 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 105 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 106 | * ==================================================================== | ||
| 107 | * | ||
| 108 | * This product includes cryptographic software written by Eric Young | ||
| 109 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 110 | * Hudson (tjh@cryptsoft.com). | ||
| 111 | * | ||
| 112 | */ | ||
| 58 | 113 | ||
| 114 | |||
| 115 | #ifdef REF_CHECK | ||
| 116 | # include <assert.h> | ||
| 117 | #endif | ||
| 59 | #include <stdio.h> | 118 | #include <stdio.h> |
| 60 | #include "objects.h" | 119 | #include <openssl/objects.h> |
| 61 | #include "lhash.h" | 120 | #include <openssl/lhash.h> |
| 121 | #include <openssl/x509v3.h> | ||
| 62 | #include "ssl_locl.h" | 122 | #include "ssl_locl.h" |
| 123 | #include "kssl_lcl.h" | ||
| 63 | 124 | ||
| 64 | char *SSL_version_str="SSLeay 0.9.0b 29-Jun-1998"; | 125 | const char *SSL_version_str=OPENSSL_VERSION_TEXT; |
| 65 | |||
| 66 | static STACK *ssl_meth=NULL; | ||
| 67 | static STACK *ssl_ctx_meth=NULL; | ||
| 68 | static int ssl_meth_num=0; | ||
| 69 | static int ssl_ctx_meth_num=0; | ||
| 70 | 126 | ||
| 71 | SSL3_ENC_METHOD ssl3_undef_enc_method={ | 127 | OPENSSL_GLOBAL SSL3_ENC_METHOD ssl3_undef_enc_method={ |
| 72 | ssl_undefined_function, | 128 | /* evil casts, but these functions are only called if there's a library bug */ |
| 73 | ssl_undefined_function, | 129 | (int (*)(SSL *,int))ssl_undefined_function, |
| 74 | ssl_undefined_function, | 130 | (int (*)(SSL *, unsigned char *, int))ssl_undefined_function, |
| 75 | ssl_undefined_function, | ||
| 76 | ssl_undefined_function, | ||
| 77 | ssl_undefined_function, | 131 | ssl_undefined_function, |
| 132 | (int (*)(SSL *, unsigned char *, unsigned char *, int))ssl_undefined_function, | ||
| 133 | (int (*)(SSL*, int))ssl_undefined_function, | ||
| 134 | (int (*)(SSL *, EVP_MD_CTX *, EVP_MD_CTX *, const char*, int, unsigned char *))ssl_undefined_function | ||
| 78 | }; | 135 | }; |
| 79 | 136 | ||
| 80 | void SSL_clear(s) | 137 | int SSL_clear(SSL *s) |
| 81 | SSL *s; | ||
| 82 | { | 138 | { |
| 83 | int state; | ||
| 84 | 139 | ||
| 85 | if (s->method == NULL) return; | 140 | if (s->method == NULL) |
| 141 | { | ||
| 142 | SSLerr(SSL_F_SSL_CLEAR,SSL_R_NO_METHOD_SPECIFIED); | ||
| 143 | return(0); | ||
| 144 | } | ||
| 145 | |||
| 146 | if (ssl_clear_bad_session(s)) | ||
| 147 | { | ||
| 148 | SSL_SESSION_free(s->session); | ||
| 149 | s->session=NULL; | ||
| 150 | } | ||
| 86 | 151 | ||
| 87 | s->error=0; | 152 | s->error=0; |
| 88 | s->hit=0; | 153 | s->hit=0; |
| 154 | s->shutdown=0; | ||
| 89 | 155 | ||
| 156 | #if 0 /* Disabled since version 1.10 of this file (early return not | ||
| 157 | * needed because SSL_clear is not called when doing renegotiation) */ | ||
| 90 | /* This is set if we are doing dynamic renegotiation so keep | 158 | /* This is set if we are doing dynamic renegotiation so keep |
| 91 | * the old cipher. It is sort of a SSL_clear_lite :-) */ | 159 | * the old cipher. It is sort of a SSL_clear_lite :-) */ |
| 92 | if (s->new_session) return; | 160 | if (s->new_session) return(1); |
| 161 | #else | ||
| 162 | if (s->new_session) | ||
| 163 | { | ||
| 164 | SSLerr(SSL_F_SSL_CLEAR,ERR_R_INTERNAL_ERROR); | ||
| 165 | return 0; | ||
| 166 | } | ||
| 167 | #endif | ||
| 93 | 168 | ||
| 94 | state=s->state; /* Keep to check if we throw away the session-id */ | ||
| 95 | s->type=0; | 169 | s->type=0; |
| 96 | 170 | ||
| 171 | s->state=SSL_ST_BEFORE|((s->server)?SSL_ST_ACCEPT:SSL_ST_CONNECT); | ||
| 172 | |||
| 97 | s->version=s->method->version; | 173 | s->version=s->method->version; |
| 174 | s->client_version=s->version; | ||
| 98 | s->rwstate=SSL_NOTHING; | 175 | s->rwstate=SSL_NOTHING; |
| 99 | s->state=SSL_ST_BEFORE; | ||
| 100 | s->rstate=SSL_ST_READ_HEADER; | 176 | s->rstate=SSL_ST_READ_HEADER; |
| 101 | s->read_ahead=s->ctx->default_read_ahead; | 177 | #if 0 |
| 102 | 178 | s->read_ahead=s->ctx->read_ahead; | |
| 103 | /* s->shutdown=(SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN); */ | 179 | #endif |
| 104 | 180 | ||
| 105 | if (s->init_buf != NULL) | 181 | if (s->init_buf != NULL) |
| 106 | { | 182 | { |
| @@ -110,30 +186,34 @@ SSL *s; | |||
| 110 | 186 | ||
| 111 | ssl_clear_cipher_ctx(s); | 187 | ssl_clear_cipher_ctx(s); |
| 112 | 188 | ||
| 113 | if (ssl_clear_bad_session(s)) | ||
| 114 | { | ||
| 115 | SSL_SESSION_free(s->session); | ||
| 116 | s->session=NULL; | ||
| 117 | } | ||
| 118 | |||
| 119 | s->shutdown=(SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN); | ||
| 120 | s->first_packet=0; | 189 | s->first_packet=0; |
| 121 | 190 | ||
| 122 | s->method->ssl_clear(s); | 191 | #if 1 |
| 192 | /* Check to see if we were changed into a different method, if | ||
| 193 | * so, revert back if we are not doing session-id reuse. */ | ||
| 194 | if (!s->in_handshake && (s->session == NULL) && (s->method != s->ctx->method)) | ||
| 195 | { | ||
| 196 | s->method->ssl_free(s); | ||
| 197 | s->method=s->ctx->method; | ||
| 198 | if (!s->method->ssl_new(s)) | ||
| 199 | return(0); | ||
| 200 | } | ||
| 201 | else | ||
| 202 | #endif | ||
| 203 | s->method->ssl_clear(s); | ||
| 204 | return(1); | ||
| 123 | } | 205 | } |
| 124 | 206 | ||
| 125 | /* Used to change an SSL_CTXs default SSL method type */ | 207 | /** Used to change an SSL_CTXs default SSL method type */ |
| 126 | int SSL_CTX_set_ssl_version(ctx,meth) | 208 | int SSL_CTX_set_ssl_version(SSL_CTX *ctx,SSL_METHOD *meth) |
| 127 | SSL_CTX *ctx; | ||
| 128 | SSL_METHOD *meth; | ||
| 129 | { | 209 | { |
| 130 | STACK *sk; | 210 | STACK_OF(SSL_CIPHER) *sk; |
| 131 | 211 | ||
| 132 | ctx->method=meth; | 212 | ctx->method=meth; |
| 133 | 213 | ||
| 134 | sk=ssl_create_cipher_list(ctx->method,&(ctx->cipher_list), | 214 | sk=ssl_create_cipher_list(ctx->method,&(ctx->cipher_list), |
| 135 | &(ctx->cipher_list_by_id),SSL_DEFAULT_CIPHER_LIST); | 215 | &(ctx->cipher_list_by_id),SSL_DEFAULT_CIPHER_LIST); |
| 136 | if ((sk == NULL) || (sk_num(sk) <= 0)) | 216 | if ((sk == NULL) || (sk_SSL_CIPHER_num(sk) <= 0)) |
| 137 | { | 217 | { |
| 138 | SSLerr(SSL_F_SSL_CTX_SET_SSL_VERSION,SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS); | 218 | SSLerr(SSL_F_SSL_CTX_SET_SSL_VERSION,SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS); |
| 139 | return(0); | 219 | return(0); |
| @@ -141,8 +221,7 @@ SSL_METHOD *meth; | |||
| 141 | return(1); | 221 | return(1); |
| 142 | } | 222 | } |
| 143 | 223 | ||
| 144 | SSL *SSL_new(ctx) | 224 | SSL *SSL_new(SSL_CTX *ctx) |
| 145 | SSL_CTX *ctx; | ||
| 146 | { | 225 | { |
| 147 | SSL *s; | 226 | SSL *s; |
| 148 | 227 | ||
| @@ -157,20 +236,50 @@ SSL_CTX *ctx; | |||
| 157 | return(NULL); | 236 | return(NULL); |
| 158 | } | 237 | } |
| 159 | 238 | ||
| 160 | s=(SSL *)Malloc(sizeof(SSL)); | 239 | s=(SSL *)OPENSSL_malloc(sizeof(SSL)); |
| 161 | if (s == NULL) goto err; | 240 | if (s == NULL) goto err; |
| 162 | memset(s,0,sizeof(SSL)); | 241 | memset(s,0,sizeof(SSL)); |
| 163 | 242 | ||
| 164 | if (ctx->default_cert != NULL) | 243 | #ifndef OPENSSL_NO_KRB5 |
| 165 | { | 244 | s->kssl_ctx = kssl_ctx_new(); |
| 166 | CRYPTO_add(&ctx->default_cert->references,1, | 245 | #endif /* OPENSSL_NO_KRB5 */ |
| 167 | CRYPTO_LOCK_SSL_CERT); | 246 | |
| 168 | s->cert=ctx->default_cert; | 247 | s->options=ctx->options; |
| 248 | s->mode=ctx->mode; | ||
| 249 | s->max_cert_list=ctx->max_cert_list; | ||
| 250 | |||
| 251 | if (ctx->cert != NULL) | ||
| 252 | { | ||
| 253 | /* Earlier library versions used to copy the pointer to | ||
| 254 | * the CERT, not its contents; only when setting new | ||
| 255 | * parameters for the per-SSL copy, ssl_cert_new would be | ||
| 256 | * called (and the direct reference to the per-SSL_CTX | ||
| 257 | * settings would be lost, but those still were indirectly | ||
| 258 | * accessed for various purposes, and for that reason they | ||
| 259 | * used to be known as s->ctx->default_cert). | ||
| 260 | * Now we don't look at the SSL_CTX's CERT after having | ||
| 261 | * duplicated it once. */ | ||
| 262 | |||
| 263 | s->cert = ssl_cert_dup(ctx->cert); | ||
| 264 | if (s->cert == NULL) | ||
| 265 | goto err; | ||
| 169 | } | 266 | } |
| 170 | else | 267 | else |
| 171 | s->cert=NULL; | 268 | s->cert=NULL; /* Cannot really happen (see SSL_CTX_new) */ |
| 172 | s->verify_mode=ctx->default_verify_mode; | 269 | |
| 270 | s->read_ahead=ctx->read_ahead; | ||
| 271 | s->msg_callback=ctx->msg_callback; | ||
| 272 | s->msg_callback_arg=ctx->msg_callback_arg; | ||
| 273 | s->verify_mode=ctx->verify_mode; | ||
| 274 | s->verify_depth=ctx->verify_depth; | ||
| 275 | s->sid_ctx_length=ctx->sid_ctx_length; | ||
| 276 | memcpy(&s->sid_ctx,&ctx->sid_ctx,sizeof(s->sid_ctx)); | ||
| 173 | s->verify_callback=ctx->default_verify_callback; | 277 | s->verify_callback=ctx->default_verify_callback; |
| 278 | s->generate_session_id=ctx->generate_session_id; | ||
| 279 | s->purpose = ctx->purpose; | ||
| 280 | s->trust = ctx->trust; | ||
| 281 | s->quiet_shutdown=ctx->quiet_shutdown; | ||
| 282 | |||
| 174 | CRYPTO_add(&ctx->references,1,CRYPTO_LOCK_SSL_CTX); | 283 | CRYPTO_add(&ctx->references,1,CRYPTO_LOCK_SSL_CTX); |
| 175 | s->ctx=ctx; | 284 | s->ctx=ctx; |
| 176 | 285 | ||
| @@ -179,30 +288,130 @@ SSL_CTX *ctx; | |||
| 179 | s->method=ctx->method; | 288 | s->method=ctx->method; |
| 180 | 289 | ||
| 181 | if (!s->method->ssl_new(s)) | 290 | if (!s->method->ssl_new(s)) |
| 182 | { | ||
| 183 | SSL_CTX_free(ctx); | ||
| 184 | Free(s); | ||
| 185 | goto err; | 291 | goto err; |
| 186 | } | ||
| 187 | 292 | ||
| 188 | s->quiet_shutdown=ctx->quiet_shutdown; | ||
| 189 | s->references=1; | 293 | s->references=1; |
| 190 | s->options=ctx->options; | 294 | s->server=(ctx->method->ssl_accept == ssl_undefined_function)?0:1; |
| 295 | |||
| 191 | SSL_clear(s); | 296 | SSL_clear(s); |
| 192 | 297 | ||
| 193 | CRYPTO_new_ex_data(ssl_meth,(char *)s,&s->ex_data); | 298 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data); |
| 194 | 299 | ||
| 195 | return(s); | 300 | return(s); |
| 196 | err: | 301 | err: |
| 302 | if (s != NULL) | ||
| 303 | { | ||
| 304 | if (s->cert != NULL) | ||
| 305 | ssl_cert_free(s->cert); | ||
| 306 | if (s->ctx != NULL) | ||
| 307 | SSL_CTX_free(s->ctx); /* decrement reference count */ | ||
| 308 | OPENSSL_free(s); | ||
| 309 | } | ||
| 197 | SSLerr(SSL_F_SSL_NEW,ERR_R_MALLOC_FAILURE); | 310 | SSLerr(SSL_F_SSL_NEW,ERR_R_MALLOC_FAILURE); |
| 198 | return(NULL); | 311 | return(NULL); |
| 199 | } | 312 | } |
| 200 | 313 | ||
| 201 | void SSL_free(s) | 314 | int SSL_CTX_set_session_id_context(SSL_CTX *ctx,const unsigned char *sid_ctx, |
| 202 | SSL *s; | 315 | unsigned int sid_ctx_len) |
| 316 | { | ||
| 317 | if(sid_ctx_len > SSL_MAX_SID_CTX_LENGTH) | ||
| 318 | { | ||
| 319 | SSLerr(SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT,SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG); | ||
| 320 | return 0; | ||
| 321 | } | ||
| 322 | ctx->sid_ctx_length=sid_ctx_len; | ||
| 323 | memcpy(ctx->sid_ctx,sid_ctx,sid_ctx_len); | ||
| 324 | |||
| 325 | return 1; | ||
| 326 | } | ||
| 327 | |||
| 328 | int SSL_set_session_id_context(SSL *ssl,const unsigned char *sid_ctx, | ||
| 329 | unsigned int sid_ctx_len) | ||
| 330 | { | ||
| 331 | if(sid_ctx_len > SSL_MAX_SID_CTX_LENGTH) | ||
| 332 | { | ||
| 333 | SSLerr(SSL_F_SSL_SET_SESSION_ID_CONTEXT,SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG); | ||
| 334 | return 0; | ||
| 335 | } | ||
| 336 | ssl->sid_ctx_length=sid_ctx_len; | ||
| 337 | memcpy(ssl->sid_ctx,sid_ctx,sid_ctx_len); | ||
| 338 | |||
| 339 | return 1; | ||
| 340 | } | ||
| 341 | |||
| 342 | int SSL_CTX_set_generate_session_id(SSL_CTX *ctx, GEN_SESSION_CB cb) | ||
| 343 | { | ||
| 344 | CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); | ||
| 345 | ctx->generate_session_id = cb; | ||
| 346 | CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX); | ||
| 347 | return 1; | ||
| 348 | } | ||
| 349 | |||
| 350 | int SSL_set_generate_session_id(SSL *ssl, GEN_SESSION_CB cb) | ||
| 351 | { | ||
| 352 | CRYPTO_w_lock(CRYPTO_LOCK_SSL); | ||
| 353 | ssl->generate_session_id = cb; | ||
| 354 | CRYPTO_w_unlock(CRYPTO_LOCK_SSL); | ||
| 355 | return 1; | ||
| 356 | } | ||
| 357 | |||
| 358 | int SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id, | ||
| 359 | unsigned int id_len) | ||
| 360 | { | ||
| 361 | /* A quick examination of SSL_SESSION_hash and SSL_SESSION_cmp shows how | ||
| 362 | * we can "construct" a session to give us the desired check - ie. to | ||
| 363 | * find if there's a session in the hash table that would conflict with | ||
| 364 | * any new session built out of this id/id_len and the ssl_version in | ||
| 365 | * use by this SSL. */ | ||
| 366 | SSL_SESSION r, *p; | ||
| 367 | r.ssl_version = ssl->version; | ||
| 368 | r.session_id_length = id_len; | ||
| 369 | memcpy(r.session_id, id, id_len); | ||
| 370 | /* NB: SSLv2 always uses a fixed 16-byte session ID, so even if a | ||
| 371 | * callback is calling us to check the uniqueness of a shorter ID, it | ||
| 372 | * must be compared as a padded-out ID because that is what it will be | ||
| 373 | * converted to when the callback has finished choosing it. */ | ||
| 374 | if((r.ssl_version == SSL2_VERSION) && | ||
| 375 | (id_len < SSL2_SSL_SESSION_ID_LENGTH)) | ||
| 376 | { | ||
| 377 | memset(r.session_id + id_len, 0, | ||
| 378 | SSL2_SSL_SESSION_ID_LENGTH - id_len); | ||
| 379 | r.session_id_length = SSL2_SSL_SESSION_ID_LENGTH; | ||
| 380 | } | ||
| 381 | |||
| 382 | CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX); | ||
| 383 | p = (SSL_SESSION *)lh_retrieve(ssl->ctx->sessions, &r); | ||
| 384 | CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX); | ||
| 385 | return (p != NULL); | ||
| 386 | } | ||
| 387 | |||
| 388 | int SSL_CTX_set_purpose(SSL_CTX *s, int purpose) | ||
| 389 | { | ||
| 390 | return X509_PURPOSE_set(&s->purpose, purpose); | ||
| 391 | } | ||
| 392 | |||
| 393 | int SSL_set_purpose(SSL *s, int purpose) | ||
| 394 | { | ||
| 395 | return X509_PURPOSE_set(&s->purpose, purpose); | ||
| 396 | } | ||
| 397 | |||
| 398 | int SSL_CTX_set_trust(SSL_CTX *s, int trust) | ||
| 399 | { | ||
| 400 | return X509_TRUST_set(&s->trust, trust); | ||
| 401 | } | ||
| 402 | |||
| 403 | int SSL_set_trust(SSL *s, int trust) | ||
| 404 | { | ||
| 405 | return X509_TRUST_set(&s->trust, trust); | ||
| 406 | } | ||
| 407 | |||
| 408 | void SSL_free(SSL *s) | ||
| 203 | { | 409 | { |
| 204 | int i; | 410 | int i; |
| 205 | 411 | ||
| 412 | if(s == NULL) | ||
| 413 | return; | ||
| 414 | |||
| 206 | i=CRYPTO_add(&s->references,-1,CRYPTO_LOCK_SSL); | 415 | i=CRYPTO_add(&s->references,-1,CRYPTO_LOCK_SSL); |
| 207 | #ifdef REF_PRINT | 416 | #ifdef REF_PRINT |
| 208 | REF_PRINT("SSL",s); | 417 | REF_PRINT("SSL",s); |
| @@ -216,7 +425,7 @@ SSL *s; | |||
| 216 | } | 425 | } |
| 217 | #endif | 426 | #endif |
| 218 | 427 | ||
| 219 | CRYPTO_free_ex_data(ssl_meth,(char *)s,&s->ex_data); | 428 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data); |
| 220 | 429 | ||
| 221 | if (s->bbio != NULL) | 430 | if (s->bbio != NULL) |
| 222 | { | 431 | { |
| @@ -236,8 +445,8 @@ SSL *s; | |||
| 236 | if (s->init_buf != NULL) BUF_MEM_free(s->init_buf); | 445 | if (s->init_buf != NULL) BUF_MEM_free(s->init_buf); |
| 237 | 446 | ||
| 238 | /* add extra stuff */ | 447 | /* add extra stuff */ |
| 239 | if (s->cipher_list != NULL) sk_free(s->cipher_list); | 448 | if (s->cipher_list != NULL) sk_SSL_CIPHER_free(s->cipher_list); |
| 240 | if (s->cipher_list_by_id != NULL) sk_free(s->cipher_list_by_id); | 449 | if (s->cipher_list_by_id != NULL) sk_SSL_CIPHER_free(s->cipher_list_by_id); |
| 241 | 450 | ||
| 242 | /* Make the next call work :-) */ | 451 | /* Make the next call work :-) */ |
| 243 | if (s->session != NULL) | 452 | if (s->session != NULL) |
| @@ -254,17 +463,14 @@ SSL *s; | |||
| 254 | if (s->ctx) SSL_CTX_free(s->ctx); | 463 | if (s->ctx) SSL_CTX_free(s->ctx); |
| 255 | 464 | ||
| 256 | if (s->client_CA != NULL) | 465 | if (s->client_CA != NULL) |
| 257 | sk_pop_free(s->client_CA,X509_NAME_free); | 466 | sk_X509_NAME_pop_free(s->client_CA,X509_NAME_free); |
| 258 | 467 | ||
| 259 | if (s->method != NULL) s->method->ssl_free(s); | 468 | if (s->method != NULL) s->method->ssl_free(s); |
| 260 | 469 | ||
| 261 | Free((char *)s); | 470 | OPENSSL_free(s); |
| 262 | } | 471 | } |
| 263 | 472 | ||
| 264 | void SSL_set_bio(s, rbio,wbio) | 473 | void SSL_set_bio(SSL *s,BIO *rbio,BIO *wbio) |
| 265 | SSL *s; | ||
| 266 | BIO *rbio; | ||
| 267 | BIO *wbio; | ||
| 268 | { | 474 | { |
| 269 | /* If the output buffering BIO is still in place, remove it | 475 | /* If the output buffering BIO is still in place, remove it |
| 270 | */ | 476 | */ |
| @@ -284,16 +490,18 @@ BIO *wbio; | |||
| 284 | s->wbio=wbio; | 490 | s->wbio=wbio; |
| 285 | } | 491 | } |
| 286 | 492 | ||
| 287 | BIO *SSL_get_rbio(s) | 493 | BIO *SSL_get_rbio(SSL *s) |
| 288 | SSL *s; | ||
| 289 | { return(s->rbio); } | 494 | { return(s->rbio); } |
| 290 | 495 | ||
| 291 | BIO *SSL_get_wbio(s) | 496 | BIO *SSL_get_wbio(SSL *s) |
| 292 | SSL *s; | ||
| 293 | { return(s->wbio); } | 497 | { return(s->wbio); } |
| 294 | 498 | ||
| 295 | int SSL_get_fd(s) | 499 | int SSL_get_fd(SSL *s) |
| 296 | SSL *s; | 500 | { |
| 501 | return(SSL_get_rfd(s)); | ||
| 502 | } | ||
| 503 | |||
| 504 | int SSL_get_rfd(SSL *s) | ||
| 297 | { | 505 | { |
| 298 | int ret= -1; | 506 | int ret= -1; |
| 299 | BIO *b,*r; | 507 | BIO *b,*r; |
| @@ -305,10 +513,20 @@ SSL *s; | |||
| 305 | return(ret); | 513 | return(ret); |
| 306 | } | 514 | } |
| 307 | 515 | ||
| 308 | #ifndef NO_SOCK | 516 | int SSL_get_wfd(SSL *s) |
| 309 | int SSL_set_fd(s, fd) | 517 | { |
| 310 | SSL *s; | 518 | int ret= -1; |
| 311 | int fd; | 519 | BIO *b,*r; |
| 520 | |||
| 521 | b=SSL_get_wbio(s); | ||
| 522 | r=BIO_find_type(b,BIO_TYPE_DESCRIPTOR); | ||
| 523 | if (r != NULL) | ||
| 524 | BIO_get_fd(r,&ret); | ||
| 525 | return(ret); | ||
| 526 | } | ||
| 527 | |||
| 528 | #ifndef OPENSSL_NO_SOCK | ||
| 529 | int SSL_set_fd(SSL *s,int fd) | ||
| 312 | { | 530 | { |
| 313 | int ret=0; | 531 | int ret=0; |
| 314 | BIO *bio=NULL; | 532 | BIO *bio=NULL; |
| @@ -327,9 +545,7 @@ err: | |||
| 327 | return(ret); | 545 | return(ret); |
| 328 | } | 546 | } |
| 329 | 547 | ||
| 330 | int SSL_set_wfd(s, fd) | 548 | int SSL_set_wfd(SSL *s,int fd) |
| 331 | SSL *s; | ||
| 332 | int fd; | ||
| 333 | { | 549 | { |
| 334 | int ret=0; | 550 | int ret=0; |
| 335 | BIO *bio=NULL; | 551 | BIO *bio=NULL; |
| @@ -351,9 +567,7 @@ err: | |||
| 351 | return(ret); | 567 | return(ret); |
| 352 | } | 568 | } |
| 353 | 569 | ||
| 354 | int SSL_set_rfd(s, fd) | 570 | int SSL_set_rfd(SSL *s,int fd) |
| 355 | SSL *s; | ||
| 356 | int fd; | ||
| 357 | { | 571 | { |
| 358 | int ret=0; | 572 | int ret=0; |
| 359 | BIO *bio=NULL; | 573 | BIO *bio=NULL; |
| @@ -379,61 +593,104 @@ err: | |||
| 379 | } | 593 | } |
| 380 | #endif | 594 | #endif |
| 381 | 595 | ||
| 382 | int SSL_get_verify_mode(s) | 596 | |
| 383 | SSL *s; | 597 | /* return length of latest Finished message we sent, copy to 'buf' */ |
| 598 | size_t SSL_get_finished(SSL *s, void *buf, size_t count) | ||
| 599 | { | ||
| 600 | size_t ret = 0; | ||
| 601 | |||
| 602 | if (s->s3 != NULL) | ||
| 603 | { | ||
| 604 | ret = s->s3->tmp.finish_md_len; | ||
| 605 | if (count > ret) | ||
| 606 | count = ret; | ||
| 607 | memcpy(buf, s->s3->tmp.finish_md, count); | ||
| 608 | } | ||
| 609 | return ret; | ||
| 610 | } | ||
| 611 | |||
| 612 | /* return length of latest Finished message we expected, copy to 'buf' */ | ||
| 613 | size_t SSL_get_peer_finished(SSL *s, void *buf, size_t count) | ||
| 614 | { | ||
| 615 | size_t ret = 0; | ||
| 616 | |||
| 617 | if (s->s3 != NULL) | ||
| 618 | { | ||
| 619 | ret = s->s3->tmp.peer_finish_md_len; | ||
| 620 | if (count > ret) | ||
| 621 | count = ret; | ||
| 622 | memcpy(buf, s->s3->tmp.peer_finish_md, count); | ||
| 623 | } | ||
| 624 | return ret; | ||
| 625 | } | ||
| 626 | |||
| 627 | |||
| 628 | int SSL_get_verify_mode(SSL *s) | ||
| 384 | { | 629 | { |
| 385 | return(s->verify_mode); | 630 | return(s->verify_mode); |
| 386 | } | 631 | } |
| 387 | 632 | ||
| 388 | int (*SSL_get_verify_callback(s))() | 633 | int SSL_get_verify_depth(SSL *s) |
| 389 | SSL *s; | 634 | { |
| 635 | return(s->verify_depth); | ||
| 636 | } | ||
| 637 | |||
| 638 | int (*SSL_get_verify_callback(SSL *s))(int,X509_STORE_CTX *) | ||
| 390 | { | 639 | { |
| 391 | return(s->verify_callback); | 640 | return(s->verify_callback); |
| 392 | } | 641 | } |
| 393 | 642 | ||
| 394 | int SSL_CTX_get_verify_mode(ctx) | 643 | int SSL_CTX_get_verify_mode(SSL_CTX *ctx) |
| 395 | SSL_CTX *ctx; | ||
| 396 | { | 644 | { |
| 397 | return(ctx->default_verify_mode); | 645 | return(ctx->verify_mode); |
| 398 | } | 646 | } |
| 399 | 647 | ||
| 400 | int (*SSL_CTX_get_verify_callback(ctx))() | 648 | int SSL_CTX_get_verify_depth(SSL_CTX *ctx) |
| 401 | SSL_CTX *ctx; | 649 | { |
| 650 | return(ctx->verify_depth); | ||
| 651 | } | ||
| 652 | |||
| 653 | int (*SSL_CTX_get_verify_callback(SSL_CTX *ctx))(int,X509_STORE_CTX *) | ||
| 402 | { | 654 | { |
| 403 | return(ctx->default_verify_callback); | 655 | return(ctx->default_verify_callback); |
| 404 | } | 656 | } |
| 405 | 657 | ||
| 406 | void SSL_set_verify(s, mode, callback) | 658 | void SSL_set_verify(SSL *s,int mode, |
| 407 | SSL *s; | 659 | int (*callback)(int ok,X509_STORE_CTX *ctx)) |
| 408 | int mode; | ||
| 409 | int (*callback)(); | ||
| 410 | { | 660 | { |
| 411 | s->verify_mode=mode; | 661 | s->verify_mode=mode; |
| 412 | if (callback != NULL) | 662 | if (callback != NULL) |
| 413 | s->verify_callback=callback; | 663 | s->verify_callback=callback; |
| 414 | } | 664 | } |
| 415 | 665 | ||
| 416 | void SSL_set_read_ahead(s, yes) | 666 | void SSL_set_verify_depth(SSL *s,int depth) |
| 417 | SSL *s; | 667 | { |
| 418 | int yes; | 668 | s->verify_depth=depth; |
| 669 | } | ||
| 670 | |||
| 671 | void SSL_set_read_ahead(SSL *s,int yes) | ||
| 419 | { | 672 | { |
| 420 | s->read_ahead=yes; | 673 | s->read_ahead=yes; |
| 421 | } | 674 | } |
| 422 | 675 | ||
| 423 | int SSL_get_read_ahead(s) | 676 | int SSL_get_read_ahead(SSL *s) |
| 424 | SSL *s; | ||
| 425 | { | 677 | { |
| 426 | return(s->read_ahead); | 678 | return(s->read_ahead); |
| 427 | } | 679 | } |
| 428 | 680 | ||
| 429 | int SSL_pending(s) | 681 | int SSL_pending(SSL *s) |
| 430 | SSL *s; | ||
| 431 | { | 682 | { |
| 683 | /* SSL_pending cannot work properly if read-ahead is enabled | ||
| 684 | * (SSL_[CTX_]ctrl(..., SSL_CTRL_SET_READ_AHEAD, 1, NULL)), | ||
| 685 | * and it is impossible to fix since SSL_pending cannot report | ||
| 686 | * errors that may be observed while scanning the new data. | ||
| 687 | * (Note that SSL_pending() is often used as a boolean value, | ||
| 688 | * so we'd better not return -1.) | ||
| 689 | */ | ||
| 432 | return(s->method->ssl_pending(s)); | 690 | return(s->method->ssl_pending(s)); |
| 433 | } | 691 | } |
| 434 | 692 | ||
| 435 | X509 *SSL_get_peer_certificate(s) | 693 | X509 *SSL_get_peer_certificate(SSL *s) |
| 436 | SSL *s; | ||
| 437 | { | 694 | { |
| 438 | X509 *r; | 695 | X509 *r; |
| 439 | 696 | ||
| @@ -449,23 +706,24 @@ SSL *s; | |||
| 449 | return(r); | 706 | return(r); |
| 450 | } | 707 | } |
| 451 | 708 | ||
| 452 | STACK *SSL_get_peer_cert_chain(s) | 709 | STACK_OF(X509) *SSL_get_peer_cert_chain(SSL *s) |
| 453 | SSL *s; | ||
| 454 | { | 710 | { |
| 455 | STACK *r; | 711 | STACK_OF(X509) *r; |
| 456 | 712 | ||
| 457 | if ((s == NULL) || (s->session == NULL) || (s->session->cert == NULL)) | 713 | if ((s == NULL) || (s->session == NULL) || (s->session->sess_cert == NULL)) |
| 458 | r=NULL; | 714 | r=NULL; |
| 459 | else | 715 | else |
| 460 | r=s->session->cert->cert_chain; | 716 | r=s->session->sess_cert->cert_chain; |
| 461 | 717 | ||
| 718 | /* If we are a client, cert_chain includes the peer's own | ||
| 719 | * certificate; if we are a server, it does not. */ | ||
| 720 | |||
| 462 | return(r); | 721 | return(r); |
| 463 | } | 722 | } |
| 464 | 723 | ||
| 465 | /* Now in theory, since the calling process own 't' it should be safe to | 724 | /* Now in theory, since the calling process own 't' it should be safe to |
| 466 | * modify. We need to be able to read f without being hassled */ | 725 | * modify. We need to be able to read f without being hassled */ |
| 467 | void SSL_copy_session_id(t,f) | 726 | void SSL_copy_session_id(SSL *t,SSL *f) |
| 468 | SSL *t,*f; | ||
| 469 | { | 727 | { |
| 470 | CERT *tmp; | 728 | CERT *tmp; |
| 471 | 729 | ||
| @@ -490,30 +748,29 @@ SSL *t,*f; | |||
| 490 | else | 748 | else |
| 491 | t->cert=NULL; | 749 | t->cert=NULL; |
| 492 | if (tmp != NULL) ssl_cert_free(tmp); | 750 | if (tmp != NULL) ssl_cert_free(tmp); |
| 751 | SSL_set_session_id_context(t,f->sid_ctx,f->sid_ctx_length); | ||
| 493 | } | 752 | } |
| 494 | 753 | ||
| 495 | /* Fix this so it checks all the valid key/cert options */ | 754 | /* Fix this so it checks all the valid key/cert options */ |
| 496 | int SSL_CTX_check_private_key(ctx) | 755 | int SSL_CTX_check_private_key(SSL_CTX *ctx) |
| 497 | SSL_CTX *ctx; | ||
| 498 | { | 756 | { |
| 499 | if ( (ctx == NULL) || | 757 | if ( (ctx == NULL) || |
| 500 | (ctx->default_cert == NULL) || | 758 | (ctx->cert == NULL) || |
| 501 | (ctx->default_cert->key->x509 == NULL)) | 759 | (ctx->cert->key->x509 == NULL)) |
| 502 | { | 760 | { |
| 503 | SSLerr(SSL_F_SSL_CTX_CHECK_PRIVATE_KEY,SSL_R_NO_CERTIFICATE_ASSIGNED); | 761 | SSLerr(SSL_F_SSL_CTX_CHECK_PRIVATE_KEY,SSL_R_NO_CERTIFICATE_ASSIGNED); |
| 504 | return(0); | 762 | return(0); |
| 505 | } | 763 | } |
| 506 | if (ctx->default_cert->key->privatekey == NULL) | 764 | if (ctx->cert->key->privatekey == NULL) |
| 507 | { | 765 | { |
| 508 | SSLerr(SSL_F_SSL_CTX_CHECK_PRIVATE_KEY,SSL_R_NO_PRIVATE_KEY_ASSIGNED); | 766 | SSLerr(SSL_F_SSL_CTX_CHECK_PRIVATE_KEY,SSL_R_NO_PRIVATE_KEY_ASSIGNED); |
| 509 | return(0); | 767 | return(0); |
| 510 | } | 768 | } |
| 511 | return(X509_check_private_key(ctx->default_cert->key->x509, ctx->default_cert->key->privatekey)); | 769 | return(X509_check_private_key(ctx->cert->key->x509, ctx->cert->key->privatekey)); |
| 512 | } | 770 | } |
| 513 | 771 | ||
| 514 | /* Fix this function so that it takes an optional type parameter */ | 772 | /* Fix this function so that it takes an optional type parameter */ |
| 515 | int SSL_check_private_key(ssl) | 773 | int SSL_check_private_key(SSL *ssl) |
| 516 | SSL *ssl; | ||
| 517 | { | 774 | { |
| 518 | if (ssl == NULL) | 775 | if (ssl == NULL) |
| 519 | { | 776 | { |
| @@ -521,7 +778,10 @@ SSL *ssl; | |||
| 521 | return(0); | 778 | return(0); |
| 522 | } | 779 | } |
| 523 | if (ssl->cert == NULL) | 780 | if (ssl->cert == NULL) |
| 524 | return(SSL_CTX_check_private_key(ssl->ctx)); | 781 | { |
| 782 | SSLerr(SSL_F_SSL_CHECK_PRIVATE_KEY,SSL_R_NO_CERTIFICATE_ASSIGNED); | ||
| 783 | return 0; | ||
| 784 | } | ||
| 525 | if (ssl->cert->key->x509 == NULL) | 785 | if (ssl->cert->key->x509 == NULL) |
| 526 | { | 786 | { |
| 527 | SSLerr(SSL_F_SSL_CHECK_PRIVATE_KEY,SSL_R_NO_CERTIFICATE_ASSIGNED); | 787 | SSLerr(SSL_F_SSL_CHECK_PRIVATE_KEY,SSL_R_NO_CERTIFICATE_ASSIGNED); |
| @@ -536,29 +796,37 @@ SSL *ssl; | |||
| 536 | ssl->cert->key->privatekey)); | 796 | ssl->cert->key->privatekey)); |
| 537 | } | 797 | } |
| 538 | 798 | ||
| 539 | int SSL_accept(s) | 799 | int SSL_accept(SSL *s) |
| 540 | SSL *s; | ||
| 541 | { | 800 | { |
| 801 | if (s->handshake_func == 0) | ||
| 802 | /* Not properly initialized yet */ | ||
| 803 | SSL_set_accept_state(s); | ||
| 804 | |||
| 542 | return(s->method->ssl_accept(s)); | 805 | return(s->method->ssl_accept(s)); |
| 543 | } | 806 | } |
| 544 | 807 | ||
| 545 | int SSL_connect(s) | 808 | int SSL_connect(SSL *s) |
| 546 | SSL *s; | ||
| 547 | { | 809 | { |
| 810 | if (s->handshake_func == 0) | ||
| 811 | /* Not properly initialized yet */ | ||
| 812 | SSL_set_connect_state(s); | ||
| 813 | |||
| 548 | return(s->method->ssl_connect(s)); | 814 | return(s->method->ssl_connect(s)); |
| 549 | } | 815 | } |
| 550 | 816 | ||
| 551 | long SSL_get_default_timeout(s) | 817 | long SSL_get_default_timeout(SSL *s) |
| 552 | SSL *s; | ||
| 553 | { | 818 | { |
| 554 | return(s->method->get_timeout()); | 819 | return(s->method->get_timeout()); |
| 555 | } | 820 | } |
| 556 | 821 | ||
| 557 | int SSL_read(s,buf,num) | 822 | int SSL_read(SSL *s,void *buf,int num) |
| 558 | SSL *s; | ||
| 559 | char *buf; | ||
| 560 | int num; | ||
| 561 | { | 823 | { |
| 824 | if (s->handshake_func == 0) | ||
| 825 | { | ||
| 826 | SSLerr(SSL_F_SSL_READ, SSL_R_UNINITIALIZED); | ||
| 827 | return -1; | ||
| 828 | } | ||
| 829 | |||
| 562 | if (s->shutdown & SSL_RECEIVED_SHUTDOWN) | 830 | if (s->shutdown & SSL_RECEIVED_SHUTDOWN) |
| 563 | { | 831 | { |
| 564 | s->rwstate=SSL_NOTHING; | 832 | s->rwstate=SSL_NOTHING; |
| @@ -567,11 +835,14 @@ int num; | |||
| 567 | return(s->method->ssl_read(s,buf,num)); | 835 | return(s->method->ssl_read(s,buf,num)); |
| 568 | } | 836 | } |
| 569 | 837 | ||
| 570 | int SSL_peek(s,buf,num) | 838 | int SSL_peek(SSL *s,void *buf,int num) |
| 571 | SSL *s; | ||
| 572 | char *buf; | ||
| 573 | int num; | ||
| 574 | { | 839 | { |
| 840 | if (s->handshake_func == 0) | ||
| 841 | { | ||
| 842 | SSLerr(SSL_F_SSL_READ, SSL_R_UNINITIALIZED); | ||
| 843 | return -1; | ||
| 844 | } | ||
| 845 | |||
| 575 | if (s->shutdown & SSL_RECEIVED_SHUTDOWN) | 846 | if (s->shutdown & SSL_RECEIVED_SHUTDOWN) |
| 576 | { | 847 | { |
| 577 | return(0); | 848 | return(0); |
| @@ -579,11 +850,14 @@ int num; | |||
| 579 | return(s->method->ssl_peek(s,buf,num)); | 850 | return(s->method->ssl_peek(s,buf,num)); |
| 580 | } | 851 | } |
| 581 | 852 | ||
| 582 | int SSL_write(s,buf,num) | 853 | int SSL_write(SSL *s,const void *buf,int num) |
| 583 | SSL *s; | ||
| 584 | char *buf; | ||
| 585 | int num; | ||
| 586 | { | 854 | { |
| 855 | if (s->handshake_func == 0) | ||
| 856 | { | ||
| 857 | SSLerr(SSL_F_SSL_WRITE, SSL_R_UNINITIALIZED); | ||
| 858 | return -1; | ||
| 859 | } | ||
| 860 | |||
| 587 | if (s->shutdown & SSL_SENT_SHUTDOWN) | 861 | if (s->shutdown & SSL_SENT_SHUTDOWN) |
| 588 | { | 862 | { |
| 589 | s->rwstate=SSL_NOTHING; | 863 | s->rwstate=SSL_NOTHING; |
| @@ -593,42 +867,176 @@ int num; | |||
| 593 | return(s->method->ssl_write(s,buf,num)); | 867 | return(s->method->ssl_write(s,buf,num)); |
| 594 | } | 868 | } |
| 595 | 869 | ||
| 596 | int SSL_shutdown(s) | 870 | int SSL_shutdown(SSL *s) |
| 597 | SSL *s; | ||
| 598 | { | 871 | { |
| 872 | /* Note that this function behaves differently from what one might | ||
| 873 | * expect. Return values are 0 for no success (yet), | ||
| 874 | * 1 for success; but calling it once is usually not enough, | ||
| 875 | * even if blocking I/O is used (see ssl3_shutdown). | ||
| 876 | */ | ||
| 877 | |||
| 878 | if (s->handshake_func == 0) | ||
| 879 | { | ||
| 880 | SSLerr(SSL_F_SSL_SHUTDOWN, SSL_R_UNINITIALIZED); | ||
| 881 | return -1; | ||
| 882 | } | ||
| 883 | |||
| 599 | if ((s != NULL) && !SSL_in_init(s)) | 884 | if ((s != NULL) && !SSL_in_init(s)) |
| 600 | return(s->method->ssl_shutdown(s)); | 885 | return(s->method->ssl_shutdown(s)); |
| 601 | else | 886 | else |
| 602 | return(1); | 887 | return(1); |
| 603 | } | 888 | } |
| 604 | 889 | ||
| 605 | int SSL_renegotiate(s) | 890 | int SSL_renegotiate(SSL *s) |
| 606 | SSL *s; | ||
| 607 | { | 891 | { |
| 608 | s->new_session=1; | 892 | if (s->new_session == 0) |
| 893 | { | ||
| 894 | s->new_session=1; | ||
| 895 | } | ||
| 609 | return(s->method->ssl_renegotiate(s)); | 896 | return(s->method->ssl_renegotiate(s)); |
| 610 | } | 897 | } |
| 611 | 898 | ||
| 612 | long SSL_ctrl(s,cmd,larg,parg) | 899 | int SSL_renegotiate_pending(SSL *s) |
| 613 | SSL *s; | 900 | { |
| 614 | int cmd; | 901 | /* becomes true when negotiation is requested; |
| 615 | long larg; | 902 | * false again once a handshake has finished */ |
| 616 | char *parg; | 903 | return (s->new_session != 0); |
| 904 | } | ||
| 905 | |||
| 906 | long SSL_ctrl(SSL *s,int cmd,long larg,void *parg) | ||
| 617 | { | 907 | { |
| 618 | return(s->method->ssl_ctrl(s,cmd,larg,parg)); | 908 | long l; |
| 909 | |||
| 910 | switch (cmd) | ||
| 911 | { | ||
| 912 | case SSL_CTRL_GET_READ_AHEAD: | ||
| 913 | return(s->read_ahead); | ||
| 914 | case SSL_CTRL_SET_READ_AHEAD: | ||
| 915 | l=s->read_ahead; | ||
| 916 | s->read_ahead=larg; | ||
| 917 | return(l); | ||
| 918 | |||
| 919 | case SSL_CTRL_SET_MSG_CALLBACK_ARG: | ||
| 920 | s->msg_callback_arg = parg; | ||
| 921 | return 1; | ||
| 922 | |||
| 923 | case SSL_CTRL_OPTIONS: | ||
| 924 | return(s->options|=larg); | ||
| 925 | case SSL_CTRL_MODE: | ||
| 926 | return(s->mode|=larg); | ||
| 927 | case SSL_CTRL_GET_MAX_CERT_LIST: | ||
| 928 | return(s->max_cert_list); | ||
| 929 | case SSL_CTRL_SET_MAX_CERT_LIST: | ||
| 930 | l=s->max_cert_list; | ||
| 931 | s->max_cert_list=larg; | ||
| 932 | return(l); | ||
| 933 | default: | ||
| 934 | return(s->method->ssl_ctrl(s,cmd,larg,parg)); | ||
| 935 | } | ||
| 936 | } | ||
| 937 | |||
| 938 | long SSL_callback_ctrl(SSL *s, int cmd, void (*fp)()) | ||
| 939 | { | ||
| 940 | switch(cmd) | ||
| 941 | { | ||
| 942 | case SSL_CTRL_SET_MSG_CALLBACK: | ||
| 943 | s->msg_callback = (void (*)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg))(fp); | ||
| 944 | return 1; | ||
| 945 | |||
| 946 | default: | ||
| 947 | return(s->method->ssl_callback_ctrl(s,cmd,fp)); | ||
| 948 | } | ||
| 619 | } | 949 | } |
| 620 | 950 | ||
| 621 | long SSL_CTX_ctrl(ctx,cmd,larg,parg) | 951 | struct lhash_st *SSL_CTX_sessions(SSL_CTX *ctx) |
| 622 | SSL_CTX *ctx; | ||
| 623 | int cmd; | ||
| 624 | long larg; | ||
| 625 | char *parg; | ||
| 626 | { | 952 | { |
| 627 | return(ctx->method->ssl_ctx_ctrl(ctx,cmd,larg,parg)); | 953 | return ctx->sessions; |
| 628 | } | 954 | } |
| 629 | 955 | ||
| 630 | int ssl_cipher_id_cmp(a,b) | 956 | long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd,long larg,void *parg) |
| 631 | SSL_CIPHER *a,*b; | 957 | { |
| 958 | long l; | ||
| 959 | |||
| 960 | switch (cmd) | ||
| 961 | { | ||
| 962 | case SSL_CTRL_GET_READ_AHEAD: | ||
| 963 | return(ctx->read_ahead); | ||
| 964 | case SSL_CTRL_SET_READ_AHEAD: | ||
| 965 | l=ctx->read_ahead; | ||
| 966 | ctx->read_ahead=larg; | ||
| 967 | return(l); | ||
| 968 | |||
| 969 | case SSL_CTRL_SET_MSG_CALLBACK_ARG: | ||
| 970 | ctx->msg_callback_arg = parg; | ||
| 971 | return 1; | ||
| 972 | |||
| 973 | case SSL_CTRL_GET_MAX_CERT_LIST: | ||
| 974 | return(ctx->max_cert_list); | ||
| 975 | case SSL_CTRL_SET_MAX_CERT_LIST: | ||
| 976 | l=ctx->max_cert_list; | ||
| 977 | ctx->max_cert_list=larg; | ||
| 978 | return(l); | ||
| 979 | |||
| 980 | case SSL_CTRL_SET_SESS_CACHE_SIZE: | ||
| 981 | l=ctx->session_cache_size; | ||
| 982 | ctx->session_cache_size=larg; | ||
| 983 | return(l); | ||
| 984 | case SSL_CTRL_GET_SESS_CACHE_SIZE: | ||
| 985 | return(ctx->session_cache_size); | ||
| 986 | case SSL_CTRL_SET_SESS_CACHE_MODE: | ||
| 987 | l=ctx->session_cache_mode; | ||
| 988 | ctx->session_cache_mode=larg; | ||
| 989 | return(l); | ||
| 990 | case SSL_CTRL_GET_SESS_CACHE_MODE: | ||
| 991 | return(ctx->session_cache_mode); | ||
| 992 | |||
| 993 | case SSL_CTRL_SESS_NUMBER: | ||
| 994 | return(ctx->sessions->num_items); | ||
| 995 | case SSL_CTRL_SESS_CONNECT: | ||
| 996 | return(ctx->stats.sess_connect); | ||
| 997 | case SSL_CTRL_SESS_CONNECT_GOOD: | ||
| 998 | return(ctx->stats.sess_connect_good); | ||
| 999 | case SSL_CTRL_SESS_CONNECT_RENEGOTIATE: | ||
| 1000 | return(ctx->stats.sess_connect_renegotiate); | ||
| 1001 | case SSL_CTRL_SESS_ACCEPT: | ||
| 1002 | return(ctx->stats.sess_accept); | ||
| 1003 | case SSL_CTRL_SESS_ACCEPT_GOOD: | ||
| 1004 | return(ctx->stats.sess_accept_good); | ||
| 1005 | case SSL_CTRL_SESS_ACCEPT_RENEGOTIATE: | ||
| 1006 | return(ctx->stats.sess_accept_renegotiate); | ||
| 1007 | case SSL_CTRL_SESS_HIT: | ||
| 1008 | return(ctx->stats.sess_hit); | ||
| 1009 | case SSL_CTRL_SESS_CB_HIT: | ||
| 1010 | return(ctx->stats.sess_cb_hit); | ||
| 1011 | case SSL_CTRL_SESS_MISSES: | ||
| 1012 | return(ctx->stats.sess_miss); | ||
| 1013 | case SSL_CTRL_SESS_TIMEOUTS: | ||
| 1014 | return(ctx->stats.sess_timeout); | ||
| 1015 | case SSL_CTRL_SESS_CACHE_FULL: | ||
| 1016 | return(ctx->stats.sess_cache_full); | ||
| 1017 | case SSL_CTRL_OPTIONS: | ||
| 1018 | return(ctx->options|=larg); | ||
| 1019 | case SSL_CTRL_MODE: | ||
| 1020 | return(ctx->mode|=larg); | ||
| 1021 | default: | ||
| 1022 | return(ctx->method->ssl_ctx_ctrl(ctx,cmd,larg,parg)); | ||
| 1023 | } | ||
| 1024 | } | ||
| 1025 | |||
| 1026 | long SSL_CTX_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)()) | ||
| 1027 | { | ||
| 1028 | switch(cmd) | ||
| 1029 | { | ||
| 1030 | case SSL_CTRL_SET_MSG_CALLBACK: | ||
| 1031 | ctx->msg_callback = (void (*)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg))(fp); | ||
| 1032 | return 1; | ||
| 1033 | |||
| 1034 | default: | ||
| 1035 | return(ctx->method->ssl_ctx_callback_ctrl(ctx,cmd,fp)); | ||
| 1036 | } | ||
| 1037 | } | ||
| 1038 | |||
| 1039 | int ssl_cipher_id_cmp(const SSL_CIPHER *a, const SSL_CIPHER *b) | ||
| 632 | { | 1040 | { |
| 633 | long l; | 1041 | long l; |
| 634 | 1042 | ||
| @@ -639,8 +1047,8 @@ SSL_CIPHER *a,*b; | |||
| 639 | return((l > 0)?1:-1); | 1047 | return((l > 0)?1:-1); |
| 640 | } | 1048 | } |
| 641 | 1049 | ||
| 642 | int ssl_cipher_ptr_id_cmp(ap,bp) | 1050 | int ssl_cipher_ptr_id_cmp(const SSL_CIPHER * const *ap, |
| 643 | SSL_CIPHER **ap,**bp; | 1051 | const SSL_CIPHER * const *bp) |
| 644 | { | 1052 | { |
| 645 | long l; | 1053 | long l; |
| 646 | 1054 | ||
| @@ -651,10 +1059,9 @@ SSL_CIPHER **ap,**bp; | |||
| 651 | return((l > 0)?1:-1); | 1059 | return((l > 0)?1:-1); |
| 652 | } | 1060 | } |
| 653 | 1061 | ||
| 654 | /* return a STACK of the ciphers available for the SSL and in order of | 1062 | /** return a STACK of the ciphers available for the SSL and in order of |
| 655 | * preference */ | 1063 | * preference */ |
| 656 | STACK *SSL_get_ciphers(s) | 1064 | STACK_OF(SSL_CIPHER) *SSL_get_ciphers(SSL *s) |
| 657 | SSL *s; | ||
| 658 | { | 1065 | { |
| 659 | if ((s != NULL) && (s->cipher_list != NULL)) | 1066 | if ((s != NULL) && (s->cipher_list != NULL)) |
| 660 | { | 1067 | { |
| @@ -668,10 +1075,9 @@ SSL *s; | |||
| 668 | return(NULL); | 1075 | return(NULL); |
| 669 | } | 1076 | } |
| 670 | 1077 | ||
| 671 | /* return a STACK of the ciphers available for the SSL and in order of | 1078 | /** return a STACK of the ciphers available for the SSL and in order of |
| 672 | * algorithm id */ | 1079 | * algorithm id */ |
| 673 | STACK *ssl_get_ciphers_by_id(s) | 1080 | STACK_OF(SSL_CIPHER) *ssl_get_ciphers_by_id(SSL *s) |
| 674 | SSL *s; | ||
| 675 | { | 1081 | { |
| 676 | if ((s != NULL) && (s->cipher_list_by_id != NULL)) | 1082 | if ((s != NULL) && (s->cipher_list_by_id != NULL)) |
| 677 | { | 1083 | { |
| @@ -685,29 +1091,25 @@ SSL *s; | |||
| 685 | return(NULL); | 1091 | return(NULL); |
| 686 | } | 1092 | } |
| 687 | 1093 | ||
| 688 | /* The old interface to get the same thing as SSL_get_ciphers() */ | 1094 | /** The old interface to get the same thing as SSL_get_ciphers() */ |
| 689 | char *SSL_get_cipher_list(s,n) | 1095 | const char *SSL_get_cipher_list(SSL *s,int n) |
| 690 | SSL *s; | ||
| 691 | int n; | ||
| 692 | { | 1096 | { |
| 693 | SSL_CIPHER *c; | 1097 | SSL_CIPHER *c; |
| 694 | STACK *sk; | 1098 | STACK_OF(SSL_CIPHER) *sk; |
| 695 | 1099 | ||
| 696 | if (s == NULL) return(NULL); | 1100 | if (s == NULL) return(NULL); |
| 697 | sk=SSL_get_ciphers(s); | 1101 | sk=SSL_get_ciphers(s); |
| 698 | if ((sk == NULL) || (sk_num(sk) <= n)) | 1102 | if ((sk == NULL) || (sk_SSL_CIPHER_num(sk) <= n)) |
| 699 | return(NULL); | 1103 | return(NULL); |
| 700 | c=(SSL_CIPHER *)sk_value(sk,n); | 1104 | c=sk_SSL_CIPHER_value(sk,n); |
| 701 | if (c == NULL) return(NULL); | 1105 | if (c == NULL) return(NULL); |
| 702 | return(c->name); | 1106 | return(c->name); |
| 703 | } | 1107 | } |
| 704 | 1108 | ||
| 705 | /* specify the ciphers to be used by defaut by the SSL_CTX */ | 1109 | /** specify the ciphers to be used by default by the SSL_CTX */ |
| 706 | int SSL_CTX_set_cipher_list(ctx,str) | 1110 | int SSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str) |
| 707 | SSL_CTX *ctx; | ||
| 708 | char *str; | ||
| 709 | { | 1111 | { |
| 710 | STACK *sk; | 1112 | STACK_OF(SSL_CIPHER) *sk; |
| 711 | 1113 | ||
| 712 | sk=ssl_create_cipher_list(ctx->method,&ctx->cipher_list, | 1114 | sk=ssl_create_cipher_list(ctx->method,&ctx->cipher_list, |
| 713 | &ctx->cipher_list_by_id,str); | 1115 | &ctx->cipher_list_by_id,str); |
| @@ -715,12 +1117,10 @@ char *str; | |||
| 715 | return((sk == NULL)?0:1); | 1117 | return((sk == NULL)?0:1); |
| 716 | } | 1118 | } |
| 717 | 1119 | ||
| 718 | /* specify the ciphers to be used by the SSL */ | 1120 | /** specify the ciphers to be used by the SSL */ |
| 719 | int SSL_set_cipher_list(s, str) | 1121 | int SSL_set_cipher_list(SSL *s,const char *str) |
| 720 | SSL *s; | ||
| 721 | char *str; | ||
| 722 | { | 1122 | { |
| 723 | STACK *sk; | 1123 | STACK_OF(SSL_CIPHER) *sk; |
| 724 | 1124 | ||
| 725 | sk=ssl_create_cipher_list(s->ctx->method,&s->cipher_list, | 1125 | sk=ssl_create_cipher_list(s->ctx->method,&s->cipher_list, |
| 726 | &s->cipher_list_by_id,str); | 1126 | &s->cipher_list_by_id,str); |
| @@ -729,13 +1129,11 @@ char *str; | |||
| 729 | } | 1129 | } |
| 730 | 1130 | ||
| 731 | /* works well for SSLv2, not so good for SSLv3 */ | 1131 | /* works well for SSLv2, not so good for SSLv3 */ |
| 732 | char *SSL_get_shared_ciphers(s,buf,len) | 1132 | char *SSL_get_shared_ciphers(SSL *s,char *buf,int len) |
| 733 | SSL *s; | ||
| 734 | char *buf; | ||
| 735 | int len; | ||
| 736 | { | 1133 | { |
| 737 | char *p,*cp; | 1134 | char *p; |
| 738 | STACK *sk; | 1135 | const char *cp; |
| 1136 | STACK_OF(SSL_CIPHER) *sk; | ||
| 739 | SSL_CIPHER *c; | 1137 | SSL_CIPHER *c; |
| 740 | int i; | 1138 | int i; |
| 741 | 1139 | ||
| @@ -745,11 +1143,11 @@ int len; | |||
| 745 | 1143 | ||
| 746 | p=buf; | 1144 | p=buf; |
| 747 | sk=s->session->ciphers; | 1145 | sk=s->session->ciphers; |
| 748 | for (i=0; i<sk_num(sk); i++) | 1146 | for (i=0; i<sk_SSL_CIPHER_num(sk); i++) |
| 749 | { | 1147 | { |
| 750 | /* Decrement for either the ':' or a '\0' */ | 1148 | /* Decrement for either the ':' or a '\0' */ |
| 751 | len--; | 1149 | len--; |
| 752 | c=(SSL_CIPHER *)sk_value(sk,i); | 1150 | c=sk_SSL_CIPHER_value(sk,i); |
| 753 | for (cp=c->name; *cp; ) | 1151 | for (cp=c->name; *cp; ) |
| 754 | { | 1152 | { |
| 755 | if (len-- == 0) | 1153 | if (len-- == 0) |
| @@ -766,35 +1164,36 @@ int len; | |||
| 766 | return(buf); | 1164 | return(buf); |
| 767 | } | 1165 | } |
| 768 | 1166 | ||
| 769 | int ssl_cipher_list_to_bytes(s,sk,p) | 1167 | int ssl_cipher_list_to_bytes(SSL *s,STACK_OF(SSL_CIPHER) *sk,unsigned char *p) |
| 770 | SSL *s; | ||
| 771 | STACK *sk; | ||
| 772 | unsigned char *p; | ||
| 773 | { | 1168 | { |
| 774 | int i,j=0; | 1169 | int i,j=0; |
| 775 | SSL_CIPHER *c; | 1170 | SSL_CIPHER *c; |
| 776 | unsigned char *q; | 1171 | unsigned char *q; |
| 1172 | #ifndef OPENSSL_NO_KRB5 | ||
| 1173 | int nokrb5 = !kssl_tgt_is_available(s->kssl_ctx); | ||
| 1174 | #endif /* OPENSSL_NO_KRB5 */ | ||
| 777 | 1175 | ||
| 778 | if (sk == NULL) return(0); | 1176 | if (sk == NULL) return(0); |
| 779 | q=p; | 1177 | q=p; |
| 780 | 1178 | ||
| 781 | for (i=0; i<sk_num(sk); i++) | 1179 | for (i=0; i<sk_SSL_CIPHER_num(sk); i++) |
| 782 | { | 1180 | { |
| 783 | c=(SSL_CIPHER *)sk_value(sk,i); | 1181 | c=sk_SSL_CIPHER_value(sk,i); |
| 1182 | #ifndef OPENSSL_NO_KRB5 | ||
| 1183 | if ((c->algorithms & SSL_KRB5) && nokrb5) | ||
| 1184 | continue; | ||
| 1185 | #endif /* OPENSSL_NO_KRB5 */ | ||
| 784 | j=ssl_put_cipher_by_char(s,c,p); | 1186 | j=ssl_put_cipher_by_char(s,c,p); |
| 785 | p+=j; | 1187 | p+=j; |
| 786 | } | 1188 | } |
| 787 | return(p-q); | 1189 | return(p-q); |
| 788 | } | 1190 | } |
| 789 | 1191 | ||
| 790 | STACK *ssl_bytes_to_cipher_list(s,p,num,skp) | 1192 | STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s,unsigned char *p,int num, |
| 791 | SSL *s; | 1193 | STACK_OF(SSL_CIPHER) **skp) |
| 792 | unsigned char *p; | ||
| 793 | int num; | ||
| 794 | STACK **skp; | ||
| 795 | { | 1194 | { |
| 796 | SSL_CIPHER *c; | 1195 | SSL_CIPHER *c; |
| 797 | STACK *sk; | 1196 | STACK_OF(SSL_CIPHER) *sk; |
| 798 | int i,n; | 1197 | int i,n; |
| 799 | 1198 | ||
| 800 | n=ssl_put_cipher_by_char(s,NULL,NULL); | 1199 | n=ssl_put_cipher_by_char(s,NULL,NULL); |
| @@ -804,11 +1203,11 @@ STACK **skp; | |||
| 804 | return(NULL); | 1203 | return(NULL); |
| 805 | } | 1204 | } |
| 806 | if ((skp == NULL) || (*skp == NULL)) | 1205 | if ((skp == NULL) || (*skp == NULL)) |
| 807 | sk=sk_new(NULL); /* change perhaps later */ | 1206 | sk=sk_SSL_CIPHER_new_null(); /* change perhaps later */ |
| 808 | else | 1207 | else |
| 809 | { | 1208 | { |
| 810 | sk= *skp; | 1209 | sk= *skp; |
| 811 | sk_zero(sk); | 1210 | sk_SSL_CIPHER_zero(sk); |
| 812 | } | 1211 | } |
| 813 | 1212 | ||
| 814 | for (i=0; i<num; i+=n) | 1213 | for (i=0; i<num; i+=n) |
| @@ -817,7 +1216,7 @@ STACK **skp; | |||
| 817 | p+=n; | 1216 | p+=n; |
| 818 | if (c != NULL) | 1217 | if (c != NULL) |
| 819 | { | 1218 | { |
| 820 | if (!sk_push(sk,(char *)c)) | 1219 | if (!sk_SSL_CIPHER_push(sk,c)) |
| 821 | { | 1220 | { |
| 822 | SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST,ERR_R_MALLOC_FAILURE); | 1221 | SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST,ERR_R_MALLOC_FAILURE); |
| 823 | goto err; | 1222 | goto err; |
| @@ -830,23 +1229,28 @@ STACK **skp; | |||
| 830 | return(sk); | 1229 | return(sk); |
| 831 | err: | 1230 | err: |
| 832 | if ((skp == NULL) || (*skp == NULL)) | 1231 | if ((skp == NULL) || (*skp == NULL)) |
| 833 | sk_free(sk); | 1232 | sk_SSL_CIPHER_free(sk); |
| 834 | return(NULL); | 1233 | return(NULL); |
| 835 | } | 1234 | } |
| 836 | 1235 | ||
| 837 | unsigned long SSL_SESSION_hash(a) | 1236 | unsigned long SSL_SESSION_hash(SSL_SESSION *a) |
| 838 | SSL_SESSION *a; | ||
| 839 | { | 1237 | { |
| 840 | unsigned long l; | 1238 | unsigned long l; |
| 841 | 1239 | ||
| 842 | l= (a->session_id[0] )|(a->session_id[1]<< 8L)| | 1240 | l=(unsigned long) |
| 843 | (a->session_id[2]<<16L)|(a->session_id[3]<<24L); | 1241 | ((unsigned int) a->session_id[0] )| |
| 1242 | ((unsigned int) a->session_id[1]<< 8L)| | ||
| 1243 | ((unsigned long)a->session_id[2]<<16L)| | ||
| 1244 | ((unsigned long)a->session_id[3]<<24L); | ||
| 844 | return(l); | 1245 | return(l); |
| 845 | } | 1246 | } |
| 846 | 1247 | ||
| 847 | int SSL_SESSION_cmp(a, b) | 1248 | /* NB: If this function (or indeed the hash function which uses a sort of |
| 848 | SSL_SESSION *a; | 1249 | * coarser function than this one) is changed, ensure |
| 849 | SSL_SESSION *b; | 1250 | * SSL_CTX_has_matching_session_id() is checked accordingly. It relies on being |
| 1251 | * able to construct an SSL_SESSION that will collide with any existing session | ||
| 1252 | * with a matching session ID. */ | ||
| 1253 | int SSL_SESSION_cmp(SSL_SESSION *a,SSL_SESSION *b) | ||
| 850 | { | 1254 | { |
| 851 | if (a->ssl_version != b->ssl_version) | 1255 | if (a->ssl_version != b->ssl_version) |
| 852 | return(1); | 1256 | return(1); |
| @@ -855,17 +1259,29 @@ SSL_SESSION *b; | |||
| 855 | return(memcmp(a->session_id,b->session_id,a->session_id_length)); | 1259 | return(memcmp(a->session_id,b->session_id,a->session_id_length)); |
| 856 | } | 1260 | } |
| 857 | 1261 | ||
| 858 | SSL_CTX *SSL_CTX_new(meth) | 1262 | /* These wrapper functions should remain rather than redeclaring |
| 859 | SSL_METHOD *meth; | 1263 | * SSL_SESSION_hash and SSL_SESSION_cmp for void* types and casting each |
| 1264 | * variable. The reason is that the functions aren't static, they're exposed via | ||
| 1265 | * ssl.h. */ | ||
| 1266 | static IMPLEMENT_LHASH_HASH_FN(SSL_SESSION_hash, SSL_SESSION *) | ||
| 1267 | static IMPLEMENT_LHASH_COMP_FN(SSL_SESSION_cmp, SSL_SESSION *) | ||
| 1268 | |||
| 1269 | SSL_CTX *SSL_CTX_new(SSL_METHOD *meth) | ||
| 860 | { | 1270 | { |
| 861 | SSL_CTX *ret; | 1271 | SSL_CTX *ret=NULL; |
| 862 | 1272 | ||
| 863 | if (meth == NULL) | 1273 | if (meth == NULL) |
| 864 | { | 1274 | { |
| 865 | SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_NULL_SSL_METHOD_PASSED); | 1275 | SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_NULL_SSL_METHOD_PASSED); |
| 866 | return(NULL); | 1276 | return(NULL); |
| 867 | } | 1277 | } |
| 868 | ret=(SSL_CTX *)Malloc(sizeof(SSL_CTX)); | 1278 | |
| 1279 | if (SSL_get_ex_data_X509_STORE_CTX_idx() < 0) | ||
| 1280 | { | ||
| 1281 | SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_X509_VERIFICATION_SETUP_PROBLEMS); | ||
| 1282 | goto err; | ||
| 1283 | } | ||
| 1284 | ret=(SSL_CTX *)OPENSSL_malloc(sizeof(SSL_CTX)); | ||
| 869 | if (ret == NULL) | 1285 | if (ret == NULL) |
| 870 | goto err; | 1286 | goto err; |
| 871 | 1287 | ||
| @@ -882,21 +1298,12 @@ SSL_METHOD *meth; | |||
| 882 | /* We take the system default */ | 1298 | /* We take the system default */ |
| 883 | ret->session_timeout=meth->get_timeout(); | 1299 | ret->session_timeout=meth->get_timeout(); |
| 884 | 1300 | ||
| 885 | ret->new_session_cb=NULL; | 1301 | ret->new_session_cb=0; |
| 886 | ret->remove_session_cb=NULL; | 1302 | ret->remove_session_cb=0; |
| 887 | ret->get_session_cb=NULL; | 1303 | ret->get_session_cb=0; |
| 888 | 1304 | ret->generate_session_id=0; | |
| 889 | ret->sess_connect=0; | 1305 | |
| 890 | ret->sess_connect_good=0; | 1306 | memset((char *)&ret->stats,0,sizeof(ret->stats)); |
| 891 | ret->sess_accept=0; | ||
| 892 | ret->sess_accept_renegotiate=0; | ||
| 893 | ret->sess_connect_renegotiate=0; | ||
| 894 | ret->sess_accept_good=0; | ||
| 895 | ret->sess_miss=0; | ||
| 896 | ret->sess_timeout=0; | ||
| 897 | ret->sess_cache_full=0; | ||
| 898 | ret->sess_hit=0; | ||
| 899 | ret->sess_cb_hit=0; | ||
| 900 | 1307 | ||
| 901 | ret->references=1; | 1308 | ret->references=1; |
| 902 | ret->quiet_shutdown=0; | 1309 | ret->quiet_shutdown=0; |
| @@ -909,19 +1316,26 @@ SSL_METHOD *meth; | |||
| 909 | 1316 | ||
| 910 | ret->info_callback=NULL; | 1317 | ret->info_callback=NULL; |
| 911 | 1318 | ||
| 912 | ret->app_verify_callback=NULL; | 1319 | ret->app_verify_callback=0; |
| 913 | ret->app_verify_arg=NULL; | 1320 | ret->app_verify_arg=NULL; |
| 914 | 1321 | ||
| 915 | ret->default_read_ahead=0; | 1322 | ret->max_cert_list=SSL_MAX_CERT_LIST_DEFAULT; |
| 916 | ret->default_verify_mode=SSL_VERIFY_NONE; | 1323 | ret->read_ahead=0; |
| 1324 | ret->msg_callback=0; | ||
| 1325 | ret->msg_callback_arg=NULL; | ||
| 1326 | ret->verify_mode=SSL_VERIFY_NONE; | ||
| 1327 | ret->verify_depth=-1; /* Don't impose a limit (but x509_lu.c does) */ | ||
| 1328 | ret->sid_ctx_length=0; | ||
| 917 | ret->default_verify_callback=NULL; | 1329 | ret->default_verify_callback=NULL; |
| 918 | if ((ret->default_cert=ssl_cert_new()) == NULL) | 1330 | if ((ret->cert=ssl_cert_new()) == NULL) |
| 919 | goto err; | 1331 | goto err; |
| 920 | 1332 | ||
| 921 | ret->default_passwd_callback=NULL; | 1333 | ret->default_passwd_callback=0; |
| 922 | ret->client_cert_cb=NULL; | 1334 | ret->default_passwd_callback_userdata=NULL; |
| 1335 | ret->client_cert_cb=0; | ||
| 923 | 1336 | ||
| 924 | ret->sessions=lh_new(SSL_SESSION_hash,SSL_SESSION_cmp); | 1337 | ret->sessions=lh_new(LHASH_HASH_FN(SSL_SESSION_hash), |
| 1338 | LHASH_COMP_FN(SSL_SESSION_cmp)); | ||
| 925 | if (ret->sessions == NULL) goto err; | 1339 | if (ret->sessions == NULL) goto err; |
| 926 | ret->cert_store=X509_STORE_new(); | 1340 | ret->cert_store=X509_STORE_new(); |
| 927 | if (ret->cert_store == NULL) goto err; | 1341 | if (ret->cert_store == NULL) goto err; |
| @@ -929,7 +1343,8 @@ SSL_METHOD *meth; | |||
| 929 | ssl_create_cipher_list(ret->method, | 1343 | ssl_create_cipher_list(ret->method, |
| 930 | &ret->cipher_list,&ret->cipher_list_by_id, | 1344 | &ret->cipher_list,&ret->cipher_list_by_id, |
| 931 | SSL_DEFAULT_CIPHER_LIST); | 1345 | SSL_DEFAULT_CIPHER_LIST); |
| 932 | if ((ret->cipher_list == NULL) || (sk_num(ret->cipher_list) <= 0)) | 1346 | if (ret->cipher_list == NULL |
| 1347 | || sk_SSL_CIPHER_num(ret->cipher_list) <= 0) | ||
| 933 | { | 1348 | { |
| 934 | SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_LIBRARY_HAS_NO_CIPHERS); | 1349 | SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_LIBRARY_HAS_NO_CIPHERS); |
| 935 | goto err2; | 1350 | goto err2; |
| @@ -951,10 +1366,13 @@ SSL_METHOD *meth; | |||
| 951 | goto err2; | 1366 | goto err2; |
| 952 | } | 1367 | } |
| 953 | 1368 | ||
| 954 | if ((ret->client_CA=sk_new_null()) == NULL) | 1369 | if ((ret->client_CA=sk_X509_NAME_new_null()) == NULL) |
| 955 | goto err; | 1370 | goto err; |
| 956 | 1371 | ||
| 957 | CRYPTO_new_ex_data(ssl_ctx_meth,(char *)ret,&ret->ex_data); | 1372 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_CTX, ret, &ret->ex_data); |
| 1373 | |||
| 1374 | ret->extra_certs=NULL; | ||
| 1375 | ret->comp_methods=SSL_COMP_get_compression_methods(); | ||
| 958 | 1376 | ||
| 959 | return(ret); | 1377 | return(ret); |
| 960 | err: | 1378 | err: |
| @@ -964,8 +1382,12 @@ err2: | |||
| 964 | return(NULL); | 1382 | return(NULL); |
| 965 | } | 1383 | } |
| 966 | 1384 | ||
| 967 | void SSL_CTX_free(a) | 1385 | #if 0 |
| 968 | SSL_CTX *a; | 1386 | static void SSL_COMP_free(SSL_COMP *comp) |
| 1387 | { OPENSSL_free(comp); } | ||
| 1388 | #endif | ||
| 1389 | |||
| 1390 | void SSL_CTX_free(SSL_CTX *a) | ||
| 969 | { | 1391 | { |
| 970 | int i; | 1392 | int i; |
| 971 | 1393 | ||
| @@ -983,7 +1405,7 @@ SSL_CTX *a; | |||
| 983 | abort(); /* ok */ | 1405 | abort(); /* ok */ |
| 984 | } | 1406 | } |
| 985 | #endif | 1407 | #endif |
| 986 | CRYPTO_free_ex_data(ssl_ctx_meth,(char *)a,&a->ex_data); | 1408 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_CTX, a, &a->ex_data); |
| 987 | 1409 | ||
| 988 | if (a->sessions != NULL) | 1410 | if (a->sessions != NULL) |
| 989 | { | 1411 | { |
| @@ -993,96 +1415,105 @@ SSL_CTX *a; | |||
| 993 | if (a->cert_store != NULL) | 1415 | if (a->cert_store != NULL) |
| 994 | X509_STORE_free(a->cert_store); | 1416 | X509_STORE_free(a->cert_store); |
| 995 | if (a->cipher_list != NULL) | 1417 | if (a->cipher_list != NULL) |
| 996 | sk_free(a->cipher_list); | 1418 | sk_SSL_CIPHER_free(a->cipher_list); |
| 997 | if (a->cipher_list_by_id != NULL) | 1419 | if (a->cipher_list_by_id != NULL) |
| 998 | sk_free(a->cipher_list_by_id); | 1420 | sk_SSL_CIPHER_free(a->cipher_list_by_id); |
| 999 | if (a->default_cert != NULL) | 1421 | if (a->cert != NULL) |
| 1000 | ssl_cert_free(a->default_cert); | 1422 | ssl_cert_free(a->cert); |
| 1001 | if (a->client_CA != NULL) | 1423 | if (a->client_CA != NULL) |
| 1002 | sk_pop_free(a->client_CA,X509_NAME_free); | 1424 | sk_X509_NAME_pop_free(a->client_CA,X509_NAME_free); |
| 1003 | Free((char *)a); | 1425 | if (a->extra_certs != NULL) |
| 1426 | sk_X509_pop_free(a->extra_certs,X509_free); | ||
| 1427 | #if 0 /* This should never be done, since it removes a global database */ | ||
| 1428 | if (a->comp_methods != NULL) | ||
| 1429 | sk_SSL_COMP_pop_free(a->comp_methods,SSL_COMP_free); | ||
| 1430 | #else | ||
| 1431 | a->comp_methods = NULL; | ||
| 1432 | #endif | ||
| 1433 | OPENSSL_free(a); | ||
| 1004 | } | 1434 | } |
| 1005 | 1435 | ||
| 1006 | void SSL_CTX_set_default_passwd_cb(ctx,cb) | 1436 | void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb) |
| 1007 | SSL_CTX *ctx; | ||
| 1008 | int (*cb)(); | ||
| 1009 | { | 1437 | { |
| 1010 | ctx->default_passwd_callback=cb; | 1438 | ctx->default_passwd_callback=cb; |
| 1011 | } | 1439 | } |
| 1012 | 1440 | ||
| 1013 | void SSL_CTX_set_cert_verify_cb(ctx,cb,arg) | 1441 | void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx,void *u) |
| 1014 | SSL_CTX *ctx; | 1442 | { |
| 1015 | int (*cb)(); | 1443 | ctx->default_passwd_callback_userdata=u; |
| 1016 | char *arg; | 1444 | } |
| 1445 | |||
| 1446 | void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, int (*cb)(X509_STORE_CTX *,void *), void *arg) | ||
| 1017 | { | 1447 | { |
| 1018 | ctx->app_verify_callback=cb; | 1448 | ctx->app_verify_callback=cb; |
| 1019 | ctx->app_verify_arg=arg; | 1449 | ctx->app_verify_arg=arg; |
| 1020 | } | 1450 | } |
| 1021 | 1451 | ||
| 1022 | void SSL_CTX_set_verify(ctx,mode,cb) | 1452 | void SSL_CTX_set_verify(SSL_CTX *ctx,int mode,int (*cb)(int, X509_STORE_CTX *)) |
| 1023 | SSL_CTX *ctx; | ||
| 1024 | int mode; | ||
| 1025 | int (*cb)(); | ||
| 1026 | { | 1453 | { |
| 1027 | ctx->default_verify_mode=mode; | 1454 | ctx->verify_mode=mode; |
| 1028 | ctx->default_verify_callback=cb; | 1455 | ctx->default_verify_callback=cb; |
| 1029 | /* This needs cleaning up EAY EAY EAY */ | ||
| 1030 | X509_STORE_set_verify_cb_func(ctx->cert_store,cb); | ||
| 1031 | } | 1456 | } |
| 1032 | 1457 | ||
| 1033 | void ssl_set_cert_masks(c) | 1458 | void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth) |
| 1034 | CERT *c; | 1459 | { |
| 1460 | ctx->verify_depth=depth; | ||
| 1461 | } | ||
| 1462 | |||
| 1463 | void ssl_set_cert_masks(CERT *c, SSL_CIPHER *cipher) | ||
| 1035 | { | 1464 | { |
| 1036 | CERT_PKEY *cpk; | 1465 | CERT_PKEY *cpk; |
| 1037 | int rsa_enc,rsa_tmp,rsa_sign,dh_tmp,dh_rsa,dh_dsa,dsa_sign; | 1466 | int rsa_enc,rsa_tmp,rsa_sign,dh_tmp,dh_rsa,dh_dsa,dsa_sign; |
| 1038 | int rsa_enc_export,dh_rsa_export,dh_dsa_export; | 1467 | int rsa_enc_export,dh_rsa_export,dh_dsa_export; |
| 1039 | int rsa_tmp_export,dh_tmp_export; | 1468 | int rsa_tmp_export,dh_tmp_export,kl; |
| 1040 | unsigned long mask,emask; | 1469 | unsigned long mask,emask; |
| 1041 | 1470 | ||
| 1042 | if ((c == NULL) || (c->valid)) return; | 1471 | if (c == NULL) return; |
| 1043 | 1472 | ||
| 1044 | #ifndef NO_RSA | 1473 | kl=SSL_C_EXPORT_PKEYLENGTH(cipher); |
| 1045 | rsa_tmp=((c->rsa_tmp != NULL) || (c->rsa_tmp_cb != NULL))?1:0; | 1474 | |
| 1046 | rsa_tmp_export=((c->rsa_tmp_cb != NULL) || | 1475 | #ifndef OPENSSL_NO_RSA |
| 1047 | (rsa_tmp && (RSA_size(c->rsa_tmp)*8 <= 512)))?1:0; | 1476 | rsa_tmp=(c->rsa_tmp != NULL || c->rsa_tmp_cb != NULL); |
| 1477 | rsa_tmp_export=(c->rsa_tmp_cb != NULL || | ||
| 1478 | (rsa_tmp && RSA_size(c->rsa_tmp)*8 <= kl)); | ||
| 1048 | #else | 1479 | #else |
| 1049 | rsa_tmp=rsa_tmp_export=0; | 1480 | rsa_tmp=rsa_tmp_export=0; |
| 1050 | #endif | 1481 | #endif |
| 1051 | #ifndef NO_DH | 1482 | #ifndef OPENSSL_NO_DH |
| 1052 | dh_tmp=((c->dh_tmp != NULL) || (c->dh_tmp_cb != NULL))?1:0; | 1483 | dh_tmp=(c->dh_tmp != NULL || c->dh_tmp_cb != NULL); |
| 1053 | dh_tmp_export=((c->dh_tmp_cb != NULL) || | 1484 | dh_tmp_export=(c->dh_tmp_cb != NULL || |
| 1054 | (dh_tmp && (DH_size(c->dh_tmp)*8 <= 512)))?1:0; | 1485 | (dh_tmp && DH_size(c->dh_tmp)*8 <= kl)); |
| 1055 | #else | 1486 | #else |
| 1056 | dh_tmp=dh_tmp_export=0; | 1487 | dh_tmp=dh_tmp_export=0; |
| 1057 | #endif | 1488 | #endif |
| 1058 | 1489 | ||
| 1059 | cpk= &(c->pkeys[SSL_PKEY_RSA_ENC]); | 1490 | cpk= &(c->pkeys[SSL_PKEY_RSA_ENC]); |
| 1060 | rsa_enc= ((cpk->x509 != NULL) && (cpk->privatekey != NULL))?1:0; | 1491 | rsa_enc= (cpk->x509 != NULL && cpk->privatekey != NULL); |
| 1061 | rsa_enc_export=(rsa_enc && (EVP_PKEY_size(cpk->privatekey)*8 <= 512))?1:0; | 1492 | rsa_enc_export=(rsa_enc && EVP_PKEY_size(cpk->privatekey)*8 <= kl); |
| 1062 | cpk= &(c->pkeys[SSL_PKEY_RSA_SIGN]); | 1493 | cpk= &(c->pkeys[SSL_PKEY_RSA_SIGN]); |
| 1063 | rsa_sign=((cpk->x509 != NULL) && (cpk->privatekey != NULL))?1:0; | 1494 | rsa_sign=(cpk->x509 != NULL && cpk->privatekey != NULL); |
| 1064 | cpk= &(c->pkeys[SSL_PKEY_DSA_SIGN]); | 1495 | cpk= &(c->pkeys[SSL_PKEY_DSA_SIGN]); |
| 1065 | dsa_sign=((cpk->x509 != NULL) && (cpk->privatekey != NULL))?1:0; | 1496 | dsa_sign=(cpk->x509 != NULL && cpk->privatekey != NULL); |
| 1066 | cpk= &(c->pkeys[SSL_PKEY_DH_RSA]); | 1497 | cpk= &(c->pkeys[SSL_PKEY_DH_RSA]); |
| 1067 | dh_rsa= ((cpk->x509 != NULL) && (cpk->privatekey != NULL))?1:0; | 1498 | dh_rsa= (cpk->x509 != NULL && cpk->privatekey != NULL); |
| 1068 | dh_rsa_export=(dh_rsa && (EVP_PKEY_size(cpk->privatekey)*8 <= 512))?1:0; | 1499 | dh_rsa_export=(dh_rsa && EVP_PKEY_size(cpk->privatekey)*8 <= kl); |
| 1069 | cpk= &(c->pkeys[SSL_PKEY_DH_DSA]); | 1500 | cpk= &(c->pkeys[SSL_PKEY_DH_DSA]); |
| 1070 | /* FIX THIS EAY EAY EAY */ | 1501 | /* FIX THIS EAY EAY EAY */ |
| 1071 | dh_dsa= ((cpk->x509 != NULL) && (cpk->privatekey != NULL))?1:0; | 1502 | dh_dsa= (cpk->x509 != NULL && cpk->privatekey != NULL); |
| 1072 | dh_dsa_export=(dh_dsa && (EVP_PKEY_size(cpk->privatekey)*8 <= 512))?1:0; | 1503 | dh_dsa_export=(dh_dsa && EVP_PKEY_size(cpk->privatekey)*8 <= kl); |
| 1073 | 1504 | ||
| 1074 | mask=0; | 1505 | mask=0; |
| 1075 | emask=0; | 1506 | emask=0; |
| 1076 | 1507 | ||
| 1077 | #ifdef CIPHER_DEBUG | 1508 | #ifdef CIPHER_DEBUG |
| 1078 | printf("rt=%d dht=%d re=%d rs=%d ds=%d dhr=%d dhd=%d\n", | 1509 | printf("rt=%d rte=%d dht=%d re=%d ree=%d rs=%d ds=%d dhr=%d dhd=%d\n", |
| 1079 | rsa_tmp,dh_tmp, | 1510 | rsa_tmp,rsa_tmp_export,dh_tmp, |
| 1080 | rsa_enc,rsa_sign,dsa_sign,dh_rsa,dh_dsa); | 1511 | rsa_enc,rsa_enc_export,rsa_sign,dsa_sign,dh_rsa,dh_dsa); |
| 1081 | #endif | 1512 | #endif |
| 1082 | 1513 | ||
| 1083 | if (rsa_enc || (rsa_tmp && rsa_sign)) | 1514 | if (rsa_enc || (rsa_tmp && rsa_sign)) |
| 1084 | mask|=SSL_kRSA; | 1515 | mask|=SSL_kRSA; |
| 1085 | if (rsa_enc_export || (rsa_tmp_export && rsa_sign)) | 1516 | if (rsa_enc_export || (rsa_tmp_export && (rsa_sign || rsa_enc))) |
| 1086 | emask|=SSL_kRSA; | 1517 | emask|=SSL_kRSA; |
| 1087 | 1518 | ||
| 1088 | #if 0 | 1519 | #if 0 |
| @@ -1119,9 +1550,12 @@ CERT *c; | |||
| 1119 | emask|=SSL_aDSS; | 1550 | emask|=SSL_aDSS; |
| 1120 | } | 1551 | } |
| 1121 | 1552 | ||
| 1122 | #ifdef SSL_ALLOW_ADH | ||
| 1123 | mask|=SSL_aNULL; | 1553 | mask|=SSL_aNULL; |
| 1124 | emask|=SSL_aNULL; | 1554 | emask|=SSL_aNULL; |
| 1555 | |||
| 1556 | #ifndef OPENSSL_NO_KRB5 | ||
| 1557 | mask|=SSL_kKRB5|SSL_aKRB5; | ||
| 1558 | emask|=SSL_kKRB5|SSL_aKRB5; | ||
| 1125 | #endif | 1559 | #endif |
| 1126 | 1560 | ||
| 1127 | c->mask=mask; | 1561 | c->mask=mask; |
| @@ -1130,18 +1564,17 @@ CERT *c; | |||
| 1130 | } | 1564 | } |
| 1131 | 1565 | ||
| 1132 | /* THIS NEEDS CLEANING UP */ | 1566 | /* THIS NEEDS CLEANING UP */ |
| 1133 | X509 *ssl_get_server_send_cert(s) | 1567 | X509 *ssl_get_server_send_cert(SSL *s) |
| 1134 | SSL *s; | ||
| 1135 | { | 1568 | { |
| 1136 | unsigned long alg,mask,kalg; | 1569 | unsigned long alg,mask,kalg; |
| 1137 | CERT *c; | 1570 | CERT *c; |
| 1138 | int i,export; | 1571 | int i,is_export; |
| 1139 | 1572 | ||
| 1140 | c=s->cert; | 1573 | c=s->cert; |
| 1141 | ssl_set_cert_masks(c); | 1574 | ssl_set_cert_masks(c, s->s3->tmp.new_cipher); |
| 1142 | alg=s->s3->tmp.new_cipher->algorithms; | 1575 | alg=s->s3->tmp.new_cipher->algorithms; |
| 1143 | export=(alg & SSL_EXPORT)?1:0; | 1576 | is_export=SSL_C_IS_EXPORT(s->s3->tmp.new_cipher); |
| 1144 | mask=(export)?c->export_mask:c->mask; | 1577 | mask=is_export?c->export_mask:c->mask; |
| 1145 | kalg=alg&(SSL_MKEY_MASK|SSL_AUTH_MASK); | 1578 | kalg=alg&(SSL_MKEY_MASK|SSL_AUTH_MASK); |
| 1146 | 1579 | ||
| 1147 | if (kalg & SSL_kDHr) | 1580 | if (kalg & SSL_kDHr) |
| @@ -1157,18 +1590,21 @@ SSL *s; | |||
| 1157 | else | 1590 | else |
| 1158 | i=SSL_PKEY_RSA_ENC; | 1591 | i=SSL_PKEY_RSA_ENC; |
| 1159 | } | 1592 | } |
| 1593 | else if (kalg & SSL_aKRB5) | ||
| 1594 | { | ||
| 1595 | /* VRS something else here? */ | ||
| 1596 | return(NULL); | ||
| 1597 | } | ||
| 1160 | else /* if (kalg & SSL_aNULL) */ | 1598 | else /* if (kalg & SSL_aNULL) */ |
| 1161 | { | 1599 | { |
| 1162 | SSLerr(SSL_F_SSL_GET_SERVER_SEND_CERT,SSL_R_INTERNAL_ERROR); | 1600 | SSLerr(SSL_F_SSL_GET_SERVER_SEND_CERT,ERR_R_INTERNAL_ERROR); |
| 1163 | return(NULL); | 1601 | return(NULL); |
| 1164 | } | 1602 | } |
| 1165 | if (c->pkeys[i].x509 == NULL) return(NULL); | 1603 | if (c->pkeys[i].x509 == NULL) return(NULL); |
| 1166 | return(c->pkeys[i].x509); | 1604 | return(c->pkeys[i].x509); |
| 1167 | } | 1605 | } |
| 1168 | 1606 | ||
| 1169 | EVP_PKEY *ssl_get_sign_pkey(s,cipher) | 1607 | EVP_PKEY *ssl_get_sign_pkey(SSL *s,SSL_CIPHER *cipher) |
| 1170 | SSL *s; | ||
| 1171 | SSL_CIPHER *cipher; | ||
| 1172 | { | 1608 | { |
| 1173 | unsigned long alg; | 1609 | unsigned long alg; |
| 1174 | CERT *c; | 1610 | CERT *c; |
| @@ -1190,14 +1626,12 @@ SSL_CIPHER *cipher; | |||
| 1190 | } | 1626 | } |
| 1191 | else /* if (alg & SSL_aNULL) */ | 1627 | else /* if (alg & SSL_aNULL) */ |
| 1192 | { | 1628 | { |
| 1193 | SSLerr(SSL_F_SSL_GET_SIGN_PKEY,SSL_R_INTERNAL_ERROR); | 1629 | SSLerr(SSL_F_SSL_GET_SIGN_PKEY,ERR_R_INTERNAL_ERROR); |
| 1194 | return(NULL); | 1630 | return(NULL); |
| 1195 | } | 1631 | } |
| 1196 | } | 1632 | } |
| 1197 | 1633 | ||
| 1198 | void ssl_update_cache(s,mode) | 1634 | void ssl_update_cache(SSL *s,int mode) |
| 1199 | SSL *s; | ||
| 1200 | int mode; | ||
| 1201 | { | 1635 | { |
| 1202 | int i; | 1636 | int i; |
| 1203 | 1637 | ||
| @@ -1205,9 +1639,10 @@ int mode; | |||
| 1205 | * and it would be rather hard to do anyway :-) */ | 1639 | * and it would be rather hard to do anyway :-) */ |
| 1206 | if (s->session->session_id_length == 0) return; | 1640 | if (s->session->session_id_length == 0) return; |
| 1207 | 1641 | ||
| 1208 | if ((s->ctx->session_cache_mode & mode) | 1642 | i=s->ctx->session_cache_mode; |
| 1209 | && (!s->hit) | 1643 | if ((i & mode) && (!s->hit) |
| 1210 | && SSL_CTX_add_session(s->ctx,s->session) | 1644 | && ((i & SSL_SESS_CACHE_NO_INTERNAL_LOOKUP) |
| 1645 | || SSL_CTX_add_session(s->ctx,s->session)) | ||
| 1211 | && (s->ctx->new_session_cb != NULL)) | 1646 | && (s->ctx->new_session_cb != NULL)) |
| 1212 | { | 1647 | { |
| 1213 | CRYPTO_add(&s->session->references,1,CRYPTO_LOCK_SSL_SESSION); | 1648 | CRYPTO_add(&s->session->references,1,CRYPTO_LOCK_SSL_SESSION); |
| @@ -1216,28 +1651,24 @@ int mode; | |||
| 1216 | } | 1651 | } |
| 1217 | 1652 | ||
| 1218 | /* auto flush every 255 connections */ | 1653 | /* auto flush every 255 connections */ |
| 1219 | i=s->ctx->session_cache_mode; | ||
| 1220 | if ((!(i & SSL_SESS_CACHE_NO_AUTO_CLEAR)) && | 1654 | if ((!(i & SSL_SESS_CACHE_NO_AUTO_CLEAR)) && |
| 1221 | ((i & mode) == mode)) | 1655 | ((i & mode) == mode)) |
| 1222 | { | 1656 | { |
| 1223 | if ( (((mode & SSL_SESS_CACHE_CLIENT) | 1657 | if ( (((mode & SSL_SESS_CACHE_CLIENT) |
| 1224 | ?s->ctx->sess_connect_good | 1658 | ?s->ctx->stats.sess_connect_good |
| 1225 | :s->ctx->sess_accept_good) & 0xff) == 0xff) | 1659 | :s->ctx->stats.sess_accept_good) & 0xff) == 0xff) |
| 1226 | { | 1660 | { |
| 1227 | SSL_CTX_flush_sessions(s->ctx,time(NULL)); | 1661 | SSL_CTX_flush_sessions(s->ctx,time(NULL)); |
| 1228 | } | 1662 | } |
| 1229 | } | 1663 | } |
| 1230 | } | 1664 | } |
| 1231 | 1665 | ||
| 1232 | SSL_METHOD *SSL_get_ssl_method(s) | 1666 | SSL_METHOD *SSL_get_ssl_method(SSL *s) |
| 1233 | SSL *s; | ||
| 1234 | { | 1667 | { |
| 1235 | return(s->method); | 1668 | return(s->method); |
| 1236 | } | 1669 | } |
| 1237 | 1670 | ||
| 1238 | int SSL_set_ssl_method(s,meth) | 1671 | int SSL_set_ssl_method(SSL *s,SSL_METHOD *meth) |
| 1239 | SSL *s; | ||
| 1240 | SSL_METHOD *meth; | ||
| 1241 | { | 1672 | { |
| 1242 | int conn= -1; | 1673 | int conn= -1; |
| 1243 | int ret=1; | 1674 | int ret=1; |
| @@ -1264,17 +1695,23 @@ SSL_METHOD *meth; | |||
| 1264 | return(ret); | 1695 | return(ret); |
| 1265 | } | 1696 | } |
| 1266 | 1697 | ||
| 1267 | int SSL_get_error(s,i) | 1698 | int SSL_get_error(SSL *s,int i) |
| 1268 | SSL *s; | ||
| 1269 | int i; | ||
| 1270 | { | 1699 | { |
| 1271 | int reason; | 1700 | int reason; |
| 1701 | unsigned long l; | ||
| 1272 | BIO *bio; | 1702 | BIO *bio; |
| 1273 | 1703 | ||
| 1274 | if (i > 0) return(SSL_ERROR_NONE); | 1704 | if (i > 0) return(SSL_ERROR_NONE); |
| 1275 | 1705 | ||
| 1276 | if (ERR_peek_error() != 0) | 1706 | /* Make things return SSL_ERROR_SYSCALL when doing SSL_do_handshake |
| 1277 | return(SSL_ERROR_SSL); | 1707 | * etc, where we do encode the error */ |
| 1708 | if ((l=ERR_peek_error()) != 0) | ||
| 1709 | { | ||
| 1710 | if (ERR_GET_LIB(l) == ERR_LIB_SYS) | ||
| 1711 | return(SSL_ERROR_SYSCALL); | ||
| 1712 | else | ||
| 1713 | return(SSL_ERROR_SSL); | ||
| 1714 | } | ||
| 1278 | 1715 | ||
| 1279 | if ((i < 0) && SSL_want_read(s)) | 1716 | if ((i < 0) && SSL_want_read(s)) |
| 1280 | { | 1717 | { |
| @@ -1282,12 +1719,23 @@ int i; | |||
| 1282 | if (BIO_should_read(bio)) | 1719 | if (BIO_should_read(bio)) |
| 1283 | return(SSL_ERROR_WANT_READ); | 1720 | return(SSL_ERROR_WANT_READ); |
| 1284 | else if (BIO_should_write(bio)) | 1721 | else if (BIO_should_write(bio)) |
| 1722 | /* This one doesn't make too much sense ... We never try | ||
| 1723 | * to write to the rbio, and an application program where | ||
| 1724 | * rbio and wbio are separate couldn't even know what it | ||
| 1725 | * should wait for. | ||
| 1726 | * However if we ever set s->rwstate incorrectly | ||
| 1727 | * (so that we have SSL_want_read(s) instead of | ||
| 1728 | * SSL_want_write(s)) and rbio and wbio *are* the same, | ||
| 1729 | * this test works around that bug; so it might be safer | ||
| 1730 | * to keep it. */ | ||
| 1285 | return(SSL_ERROR_WANT_WRITE); | 1731 | return(SSL_ERROR_WANT_WRITE); |
| 1286 | else if (BIO_should_io_special(bio)) | 1732 | else if (BIO_should_io_special(bio)) |
| 1287 | { | 1733 | { |
| 1288 | reason=BIO_get_retry_reason(bio); | 1734 | reason=BIO_get_retry_reason(bio); |
| 1289 | if (reason == BIO_RR_CONNECT) | 1735 | if (reason == BIO_RR_CONNECT) |
| 1290 | return(SSL_ERROR_WANT_CONNECT); | 1736 | return(SSL_ERROR_WANT_CONNECT); |
| 1737 | else if (reason == BIO_RR_ACCEPT) | ||
| 1738 | return(SSL_ERROR_WANT_ACCEPT); | ||
| 1291 | else | 1739 | else |
| 1292 | return(SSL_ERROR_SYSCALL); /* unknown */ | 1740 | return(SSL_ERROR_SYSCALL); /* unknown */ |
| 1293 | } | 1741 | } |
| @@ -1299,12 +1747,15 @@ int i; | |||
| 1299 | if (BIO_should_write(bio)) | 1747 | if (BIO_should_write(bio)) |
| 1300 | return(SSL_ERROR_WANT_WRITE); | 1748 | return(SSL_ERROR_WANT_WRITE); |
| 1301 | else if (BIO_should_read(bio)) | 1749 | else if (BIO_should_read(bio)) |
| 1750 | /* See above (SSL_want_read(s) with BIO_should_write(bio)) */ | ||
| 1302 | return(SSL_ERROR_WANT_READ); | 1751 | return(SSL_ERROR_WANT_READ); |
| 1303 | else if (BIO_should_io_special(bio)) | 1752 | else if (BIO_should_io_special(bio)) |
| 1304 | { | 1753 | { |
| 1305 | reason=BIO_get_retry_reason(bio); | 1754 | reason=BIO_get_retry_reason(bio); |
| 1306 | if (reason == BIO_RR_CONNECT) | 1755 | if (reason == BIO_RR_CONNECT) |
| 1307 | return(SSL_ERROR_WANT_CONNECT); | 1756 | return(SSL_ERROR_WANT_CONNECT); |
| 1757 | else if (reason == BIO_RR_ACCEPT) | ||
| 1758 | return(SSL_ERROR_WANT_ACCEPT); | ||
| 1308 | else | 1759 | else |
| 1309 | return(SSL_ERROR_SYSCALL); | 1760 | return(SSL_ERROR_SYSCALL); |
| 1310 | } | 1761 | } |
| @@ -1331,8 +1782,7 @@ int i; | |||
| 1331 | return(SSL_ERROR_SYSCALL); | 1782 | return(SSL_ERROR_SYSCALL); |
| 1332 | } | 1783 | } |
| 1333 | 1784 | ||
| 1334 | int SSL_do_handshake(s) | 1785 | int SSL_do_handshake(SSL *s) |
| 1335 | SSL *s; | ||
| 1336 | { | 1786 | { |
| 1337 | int ret=1; | 1787 | int ret=1; |
| 1338 | 1788 | ||
| @@ -1341,7 +1791,9 @@ SSL *s; | |||
| 1341 | SSLerr(SSL_F_SSL_DO_HANDSHAKE,SSL_R_CONNECTION_TYPE_NOT_SET); | 1791 | SSLerr(SSL_F_SSL_DO_HANDSHAKE,SSL_R_CONNECTION_TYPE_NOT_SET); |
| 1342 | return(-1); | 1792 | return(-1); |
| 1343 | } | 1793 | } |
| 1344 | if (s->s3->renegotiate) ssl3_renegotiate_check(s); | 1794 | |
| 1795 | s->method->ssl_renegotiate_check(s); | ||
| 1796 | |||
| 1345 | if (SSL_in_init(s) || SSL_in_before(s)) | 1797 | if (SSL_in_init(s) || SSL_in_before(s)) |
| 1346 | { | 1798 | { |
| 1347 | ret=s->handshake_func(s); | 1799 | ret=s->handshake_func(s); |
| @@ -1351,9 +1803,9 @@ SSL *s; | |||
| 1351 | 1803 | ||
| 1352 | /* For the next 2 functions, SSL_clear() sets shutdown and so | 1804 | /* For the next 2 functions, SSL_clear() sets shutdown and so |
| 1353 | * one of these calls will reset it */ | 1805 | * one of these calls will reset it */ |
| 1354 | void SSL_set_accept_state(s) | 1806 | void SSL_set_accept_state(SSL *s) |
| 1355 | SSL *s; | ||
| 1356 | { | 1807 | { |
| 1808 | s->server=1; | ||
| 1357 | s->shutdown=0; | 1809 | s->shutdown=0; |
| 1358 | s->state=SSL_ST_ACCEPT|SSL_ST_BEFORE; | 1810 | s->state=SSL_ST_ACCEPT|SSL_ST_BEFORE; |
| 1359 | s->handshake_func=s->method->ssl_accept; | 1811 | s->handshake_func=s->method->ssl_accept; |
| @@ -1361,9 +1813,9 @@ SSL *s; | |||
| 1361 | ssl_clear_cipher_ctx(s); | 1813 | ssl_clear_cipher_ctx(s); |
| 1362 | } | 1814 | } |
| 1363 | 1815 | ||
| 1364 | void SSL_set_connect_state(s) | 1816 | void SSL_set_connect_state(SSL *s) |
| 1365 | SSL *s; | ||
| 1366 | { | 1817 | { |
| 1818 | s->server=0; | ||
| 1367 | s->shutdown=0; | 1819 | s->shutdown=0; |
| 1368 | s->state=SSL_ST_CONNECT|SSL_ST_BEFORE; | 1820 | s->state=SSL_ST_CONNECT|SSL_ST_BEFORE; |
| 1369 | s->handshake_func=s->method->ssl_connect; | 1821 | s->handshake_func=s->method->ssl_connect; |
| @@ -1371,22 +1823,19 @@ SSL *s; | |||
| 1371 | ssl_clear_cipher_ctx(s); | 1823 | ssl_clear_cipher_ctx(s); |
| 1372 | } | 1824 | } |
| 1373 | 1825 | ||
| 1374 | int ssl_undefined_function(s) | 1826 | int ssl_undefined_function(SSL *s) |
| 1375 | SSL *s; | ||
| 1376 | { | 1827 | { |
| 1377 | SSLerr(SSL_F_SSL_UNDEFINED_FUNCTION,ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | 1828 | SSLerr(SSL_F_SSL_UNDEFINED_FUNCTION,ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); |
| 1378 | return(0); | 1829 | return(0); |
| 1379 | } | 1830 | } |
| 1380 | 1831 | ||
| 1381 | SSL_METHOD *ssl_bad_method(ver) | 1832 | SSL_METHOD *ssl_bad_method(int ver) |
| 1382 | int ver; | ||
| 1383 | { | 1833 | { |
| 1384 | SSLerr(SSL_F_SSL_BAD_METHOD,ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | 1834 | SSLerr(SSL_F_SSL_BAD_METHOD,ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); |
| 1385 | return(NULL); | 1835 | return(NULL); |
| 1386 | } | 1836 | } |
| 1387 | 1837 | ||
| 1388 | char *SSL_get_version(s) | 1838 | const char *SSL_get_version(SSL *s) |
| 1389 | SSL *s; | ||
| 1390 | { | 1839 | { |
| 1391 | if (s->version == TLS1_VERSION) | 1840 | if (s->version == TLS1_VERSION) |
| 1392 | return("TLSv1"); | 1841 | return("TLSv1"); |
| @@ -1398,30 +1847,67 @@ SSL *s; | |||
| 1398 | return("unknown"); | 1847 | return("unknown"); |
| 1399 | } | 1848 | } |
| 1400 | 1849 | ||
| 1401 | SSL *SSL_dup(s) | 1850 | SSL *SSL_dup(SSL *s) |
| 1402 | SSL *s; | 1851 | { |
| 1403 | { | 1852 | STACK_OF(X509_NAME) *sk; |
| 1404 | STACK *sk; | ||
| 1405 | X509_NAME *xn; | 1853 | X509_NAME *xn; |
| 1406 | SSL *ret; | 1854 | SSL *ret; |
| 1407 | int i; | 1855 | int i; |
| 1408 | 1856 | ||
| 1409 | if ((ret=SSL_new(SSL_get_SSL_CTX(s))) == NULL) return(NULL); | 1857 | if ((ret=SSL_new(SSL_get_SSL_CTX(s))) == NULL) |
| 1410 | 1858 | return(NULL); | |
| 1411 | /* This copies version, session-id, SSL_METHOD and 'cert' */ | 1859 | |
| 1412 | SSL_copy_session_id(ret,s); | 1860 | ret->version = s->version; |
| 1861 | ret->type = s->type; | ||
| 1862 | ret->method = s->method; | ||
| 1863 | |||
| 1864 | if (s->session != NULL) | ||
| 1865 | { | ||
| 1866 | /* This copies session-id, SSL_METHOD, sid_ctx, and 'cert' */ | ||
| 1867 | SSL_copy_session_id(ret,s); | ||
| 1868 | } | ||
| 1869 | else | ||
| 1870 | { | ||
| 1871 | /* No session has been established yet, so we have to expect | ||
| 1872 | * that s->cert or ret->cert will be changed later -- | ||
| 1873 | * they should not both point to the same object, | ||
| 1874 | * and thus we can't use SSL_copy_session_id. */ | ||
| 1413 | 1875 | ||
| 1876 | ret->method = s->method; | ||
| 1877 | ret->method->ssl_new(ret); | ||
| 1878 | |||
| 1879 | if (s->cert != NULL) | ||
| 1880 | { | ||
| 1881 | if (ret->cert != NULL) | ||
| 1882 | { | ||
| 1883 | ssl_cert_free(ret->cert); | ||
| 1884 | } | ||
| 1885 | ret->cert = ssl_cert_dup(s->cert); | ||
| 1886 | if (ret->cert == NULL) | ||
| 1887 | goto err; | ||
| 1888 | } | ||
| 1889 | |||
| 1890 | SSL_set_session_id_context(ret, | ||
| 1891 | s->sid_ctx, s->sid_ctx_length); | ||
| 1892 | } | ||
| 1893 | |||
| 1894 | ret->options=s->options; | ||
| 1895 | ret->mode=s->mode; | ||
| 1896 | SSL_set_max_cert_list(ret,SSL_get_max_cert_list(s)); | ||
| 1414 | SSL_set_read_ahead(ret,SSL_get_read_ahead(s)); | 1897 | SSL_set_read_ahead(ret,SSL_get_read_ahead(s)); |
| 1898 | ret->msg_callback = s->msg_callback; | ||
| 1899 | ret->msg_callback_arg = s->msg_callback_arg; | ||
| 1415 | SSL_set_verify(ret,SSL_get_verify_mode(s), | 1900 | SSL_set_verify(ret,SSL_get_verify_mode(s), |
| 1416 | SSL_get_verify_callback(s)); | 1901 | SSL_get_verify_callback(s)); |
| 1902 | SSL_set_verify_depth(ret,SSL_get_verify_depth(s)); | ||
| 1903 | ret->generate_session_id = s->generate_session_id; | ||
| 1417 | 1904 | ||
| 1418 | SSL_set_info_callback(ret,SSL_get_info_callback(s)); | 1905 | SSL_set_info_callback(ret,SSL_get_info_callback(s)); |
| 1419 | 1906 | ||
| 1420 | ret->debug=s->debug; | 1907 | ret->debug=s->debug; |
| 1421 | ret->options=s->options; | ||
| 1422 | 1908 | ||
| 1423 | /* copy app data, a little dangerous perhaps */ | 1909 | /* copy app data, a little dangerous perhaps */ |
| 1424 | if (!CRYPTO_dup_ex_data(ssl_meth,&ret->ex_data,&s->ex_data)) | 1910 | if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_SSL, &ret->ex_data, &s->ex_data)) |
| 1425 | goto err; | 1911 | goto err; |
| 1426 | 1912 | ||
| 1427 | /* setup rbio, and wbio */ | 1913 | /* setup rbio, and wbio */ |
| @@ -1440,27 +1926,40 @@ SSL *s; | |||
| 1440 | else | 1926 | else |
| 1441 | ret->wbio=ret->rbio; | 1927 | ret->wbio=ret->rbio; |
| 1442 | } | 1928 | } |
| 1929 | ret->rwstate = s->rwstate; | ||
| 1930 | ret->in_handshake = s->in_handshake; | ||
| 1931 | ret->handshake_func = s->handshake_func; | ||
| 1932 | ret->server = s->server; | ||
| 1933 | ret->new_session = s->new_session; | ||
| 1934 | ret->quiet_shutdown = s->quiet_shutdown; | ||
| 1935 | ret->shutdown=s->shutdown; | ||
| 1936 | ret->state=s->state; /* SSL_dup does not really work at any state, though */ | ||
| 1937 | ret->rstate=s->rstate; | ||
| 1938 | ret->init_num = 0; /* would have to copy ret->init_buf, ret->init_msg, ret->init_num, ret->init_off */ | ||
| 1939 | ret->hit=s->hit; | ||
| 1940 | ret->purpose=s->purpose; | ||
| 1941 | ret->trust=s->trust; | ||
| 1443 | 1942 | ||
| 1444 | /* dup the cipher_list and cipher_list_by_id stacks */ | 1943 | /* dup the cipher_list and cipher_list_by_id stacks */ |
| 1445 | if (s->cipher_list != NULL) | 1944 | if (s->cipher_list != NULL) |
| 1446 | { | 1945 | { |
| 1447 | if ((ret->cipher_list=sk_dup(s->cipher_list)) == NULL) | 1946 | if ((ret->cipher_list=sk_SSL_CIPHER_dup(s->cipher_list)) == NULL) |
| 1448 | goto err; | 1947 | goto err; |
| 1449 | } | 1948 | } |
| 1450 | if (s->cipher_list_by_id != NULL) | 1949 | if (s->cipher_list_by_id != NULL) |
| 1451 | if ((ret->cipher_list_by_id=sk_dup(s->cipher_list_by_id)) | 1950 | if ((ret->cipher_list_by_id=sk_SSL_CIPHER_dup(s->cipher_list_by_id)) |
| 1452 | == NULL) | 1951 | == NULL) |
| 1453 | goto err; | 1952 | goto err; |
| 1454 | 1953 | ||
| 1455 | /* Dup the client_CA list */ | 1954 | /* Dup the client_CA list */ |
| 1456 | if (s->client_CA != NULL) | 1955 | if (s->client_CA != NULL) |
| 1457 | { | 1956 | { |
| 1458 | if ((sk=sk_dup(s->client_CA)) == NULL) goto err; | 1957 | if ((sk=sk_X509_NAME_dup(s->client_CA)) == NULL) goto err; |
| 1459 | ret->client_CA=sk; | 1958 | ret->client_CA=sk; |
| 1460 | for (i=0; i<sk_num(sk); i++) | 1959 | for (i=0; i<sk_X509_NAME_num(sk); i++) |
| 1461 | { | 1960 | { |
| 1462 | xn=(X509_NAME *)sk_value(sk,i); | 1961 | xn=sk_X509_NAME_value(sk,i); |
| 1463 | if ((sk_value(sk,i)=(char *)X509_NAME_dup(xn)) == NULL) | 1962 | if (sk_X509_NAME_set(sk,i,X509_NAME_dup(xn)) == NULL) |
| 1464 | { | 1963 | { |
| 1465 | X509_NAME_free(xn); | 1964 | X509_NAME_free(xn); |
| 1466 | goto err; | 1965 | goto err; |
| @@ -1468,10 +1967,6 @@ SSL *s; | |||
| 1468 | } | 1967 | } |
| 1469 | } | 1968 | } |
| 1470 | 1969 | ||
| 1471 | ret->shutdown=s->shutdown; | ||
| 1472 | ret->state=s->state; | ||
| 1473 | ret->handshake_func=s->handshake_func; | ||
| 1474 | |||
| 1475 | if (0) | 1970 | if (0) |
| 1476 | { | 1971 | { |
| 1477 | err: | 1972 | err: |
| @@ -1481,26 +1976,34 @@ err: | |||
| 1481 | return(ret); | 1976 | return(ret); |
| 1482 | } | 1977 | } |
| 1483 | 1978 | ||
| 1484 | void ssl_clear_cipher_ctx(s) | 1979 | void ssl_clear_cipher_ctx(SSL *s) |
| 1485 | SSL *s; | ||
| 1486 | { | 1980 | { |
| 1487 | if (s->enc_read_ctx != NULL) | 1981 | if (s->enc_read_ctx != NULL) |
| 1488 | { | 1982 | { |
| 1489 | EVP_CIPHER_CTX_cleanup(s->enc_read_ctx); | 1983 | EVP_CIPHER_CTX_cleanup(s->enc_read_ctx); |
| 1490 | Free(s->enc_read_ctx); | 1984 | OPENSSL_free(s->enc_read_ctx); |
| 1491 | s->enc_read_ctx=NULL; | 1985 | s->enc_read_ctx=NULL; |
| 1492 | } | 1986 | } |
| 1493 | if (s->enc_write_ctx != NULL) | 1987 | if (s->enc_write_ctx != NULL) |
| 1494 | { | 1988 | { |
| 1495 | EVP_CIPHER_CTX_cleanup(s->enc_write_ctx); | 1989 | EVP_CIPHER_CTX_cleanup(s->enc_write_ctx); |
| 1496 | Free(s->enc_write_ctx); | 1990 | OPENSSL_free(s->enc_write_ctx); |
| 1497 | s->enc_write_ctx=NULL; | 1991 | s->enc_write_ctx=NULL; |
| 1498 | } | 1992 | } |
| 1993 | if (s->expand != NULL) | ||
| 1994 | { | ||
| 1995 | COMP_CTX_free(s->expand); | ||
| 1996 | s->expand=NULL; | ||
| 1997 | } | ||
| 1998 | if (s->compress != NULL) | ||
| 1999 | { | ||
| 2000 | COMP_CTX_free(s->compress); | ||
| 2001 | s->compress=NULL; | ||
| 2002 | } | ||
| 1499 | } | 2003 | } |
| 1500 | 2004 | ||
| 1501 | /* Fix this function so that it takes an optional type parameter */ | 2005 | /* Fix this function so that it takes an optional type parameter */ |
| 1502 | X509 *SSL_get_certificate(s) | 2006 | X509 *SSL_get_certificate(SSL *s) |
| 1503 | SSL *s; | ||
| 1504 | { | 2007 | { |
| 1505 | if (s->cert != NULL) | 2008 | if (s->cert != NULL) |
| 1506 | return(s->cert->key->x509); | 2009 | return(s->cert->key->x509); |
| @@ -1509,8 +2012,7 @@ SSL *s; | |||
| 1509 | } | 2012 | } |
| 1510 | 2013 | ||
| 1511 | /* Fix this function so that it takes an optional type parameter */ | 2014 | /* Fix this function so that it takes an optional type parameter */ |
| 1512 | EVP_PKEY *SSL_get_privatekey(s) | 2015 | EVP_PKEY *SSL_get_privatekey(SSL *s) |
| 1513 | SSL *s; | ||
| 1514 | { | 2016 | { |
| 1515 | if (s->cert != NULL) | 2017 | if (s->cert != NULL) |
| 1516 | return(s->cert->key->privatekey); | 2018 | return(s->cert->key->privatekey); |
| @@ -1518,17 +2020,14 @@ SSL *s; | |||
| 1518 | return(NULL); | 2020 | return(NULL); |
| 1519 | } | 2021 | } |
| 1520 | 2022 | ||
| 1521 | SSL_CIPHER *SSL_get_current_cipher(s) | 2023 | SSL_CIPHER *SSL_get_current_cipher(SSL *s) |
| 1522 | SSL *s; | ||
| 1523 | { | 2024 | { |
| 1524 | if ((s->session != NULL) && (s->session->cipher != NULL)) | 2025 | if ((s->session != NULL) && (s->session->cipher != NULL)) |
| 1525 | return(s->session->cipher); | 2026 | return(s->session->cipher); |
| 1526 | return(NULL); | 2027 | return(NULL); |
| 1527 | } | 2028 | } |
| 1528 | 2029 | ||
| 1529 | int ssl_init_wbio_buffer(s,push) | 2030 | int ssl_init_wbio_buffer(SSL *s,int push) |
| 1530 | SSL *s; | ||
| 1531 | int push; | ||
| 1532 | { | 2031 | { |
| 1533 | BIO *bbio; | 2032 | BIO *bbio; |
| 1534 | 2033 | ||
| @@ -1544,7 +2043,7 @@ int push; | |||
| 1544 | if (s->bbio == s->wbio) | 2043 | if (s->bbio == s->wbio) |
| 1545 | s->wbio=BIO_pop(s->wbio); | 2044 | s->wbio=BIO_pop(s->wbio); |
| 1546 | } | 2045 | } |
| 1547 | BIO_reset(bbio); | 2046 | (void)BIO_reset(bbio); |
| 1548 | /* if (!BIO_set_write_buffer_size(bbio,16*1024)) */ | 2047 | /* if (!BIO_set_write_buffer_size(bbio,16*1024)) */ |
| 1549 | if (!BIO_set_read_buffer_size(bbio,1)) | 2048 | if (!BIO_set_read_buffer_size(bbio,1)) |
| 1550 | { | 2049 | { |
| @@ -1563,159 +2062,230 @@ int push; | |||
| 1563 | } | 2062 | } |
| 1564 | return(1); | 2063 | return(1); |
| 1565 | } | 2064 | } |
| 2065 | |||
| 2066 | void ssl_free_wbio_buffer(SSL *s) | ||
| 2067 | { | ||
| 2068 | if (s->bbio == NULL) return; | ||
| 2069 | |||
| 2070 | if (s->bbio == s->wbio) | ||
| 2071 | { | ||
| 2072 | /* remove buffering */ | ||
| 2073 | s->wbio=BIO_pop(s->wbio); | ||
| 2074 | #ifdef REF_CHECK /* not the usual REF_CHECK, but this avoids adding one more preprocessor symbol */ | ||
| 2075 | assert(s->wbio != NULL); | ||
| 2076 | #endif | ||
| 2077 | } | ||
| 2078 | BIO_free(s->bbio); | ||
| 2079 | s->bbio=NULL; | ||
| 2080 | } | ||
| 1566 | 2081 | ||
| 1567 | void SSL_CTX_set_quiet_shutdown(ctx,mode) | 2082 | void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx,int mode) |
| 1568 | SSL_CTX *ctx; | ||
| 1569 | int mode; | ||
| 1570 | { | 2083 | { |
| 1571 | ctx->quiet_shutdown=mode; | 2084 | ctx->quiet_shutdown=mode; |
| 1572 | } | 2085 | } |
| 1573 | 2086 | ||
| 1574 | int SSL_CTX_get_quiet_shutdown(ctx) | 2087 | int SSL_CTX_get_quiet_shutdown(SSL_CTX *ctx) |
| 1575 | SSL_CTX *ctx; | ||
| 1576 | { | 2088 | { |
| 1577 | return(ctx->quiet_shutdown); | 2089 | return(ctx->quiet_shutdown); |
| 1578 | } | 2090 | } |
| 1579 | 2091 | ||
| 1580 | void SSL_set_quiet_shutdown(s,mode) | 2092 | void SSL_set_quiet_shutdown(SSL *s,int mode) |
| 1581 | SSL *s; | ||
| 1582 | int mode; | ||
| 1583 | { | 2093 | { |
| 1584 | s->quiet_shutdown=mode; | 2094 | s->quiet_shutdown=mode; |
| 1585 | } | 2095 | } |
| 1586 | 2096 | ||
| 1587 | int SSL_get_quiet_shutdown(s) | 2097 | int SSL_get_quiet_shutdown(SSL *s) |
| 1588 | SSL *s; | ||
| 1589 | { | 2098 | { |
| 1590 | return(s->quiet_shutdown); | 2099 | return(s->quiet_shutdown); |
| 1591 | } | 2100 | } |
| 1592 | 2101 | ||
| 1593 | void SSL_set_shutdown(s,mode) | 2102 | void SSL_set_shutdown(SSL *s,int mode) |
| 1594 | SSL *s; | ||
| 1595 | int mode; | ||
| 1596 | { | 2103 | { |
| 1597 | s->shutdown=mode; | 2104 | s->shutdown=mode; |
| 1598 | } | 2105 | } |
| 1599 | 2106 | ||
| 1600 | int SSL_get_shutdown(s) | 2107 | int SSL_get_shutdown(SSL *s) |
| 1601 | SSL *s; | ||
| 1602 | { | 2108 | { |
| 1603 | return(s->shutdown); | 2109 | return(s->shutdown); |
| 1604 | } | 2110 | } |
| 1605 | 2111 | ||
| 1606 | int SSL_version(s) | 2112 | int SSL_version(SSL *s) |
| 1607 | SSL *s; | ||
| 1608 | { | 2113 | { |
| 1609 | return(s->version); | 2114 | return(s->version); |
| 1610 | } | 2115 | } |
| 1611 | 2116 | ||
| 1612 | SSL_CTX *SSL_get_SSL_CTX(ssl) | 2117 | SSL_CTX *SSL_get_SSL_CTX(SSL *ssl) |
| 1613 | SSL *ssl; | ||
| 1614 | { | 2118 | { |
| 1615 | return(ssl->ctx); | 2119 | return(ssl->ctx); |
| 1616 | } | 2120 | } |
| 1617 | 2121 | ||
| 1618 | int SSL_CTX_set_default_verify_paths(ctx) | 2122 | #ifndef OPENSSL_NO_STDIO |
| 1619 | SSL_CTX *ctx; | 2123 | int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx) |
| 1620 | { | 2124 | { |
| 1621 | return(X509_STORE_set_default_paths(ctx->cert_store)); | 2125 | return(X509_STORE_set_default_paths(ctx->cert_store)); |
| 1622 | } | 2126 | } |
| 1623 | 2127 | ||
| 1624 | int SSL_CTX_load_verify_locations(ctx,CAfile,CApath) | 2128 | int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, |
| 1625 | SSL_CTX *ctx; | 2129 | const char *CApath) |
| 1626 | char *CAfile; | ||
| 1627 | char *CApath; | ||
| 1628 | { | 2130 | { |
| 1629 | return(X509_STORE_load_locations(ctx->cert_store,CAfile,CApath)); | 2131 | return(X509_STORE_load_locations(ctx->cert_store,CAfile,CApath)); |
| 1630 | } | 2132 | } |
| 2133 | #endif | ||
| 1631 | 2134 | ||
| 1632 | void SSL_set_info_callback(ssl,cb) | 2135 | void SSL_set_info_callback(SSL *ssl, |
| 1633 | SSL *ssl; | 2136 | void (*cb)(const SSL *ssl,int type,int val)) |
| 1634 | void (*cb)(); | ||
| 1635 | { | 2137 | { |
| 1636 | ssl->info_callback=cb; | 2138 | ssl->info_callback=cb; |
| 1637 | } | 2139 | } |
| 1638 | 2140 | ||
| 1639 | void (*SSL_get_info_callback(ssl))() | 2141 | void (*SSL_get_info_callback(SSL *ssl))(const SSL *ssl,int type,int val) |
| 1640 | SSL *ssl; | ||
| 1641 | { | 2142 | { |
| 1642 | return(ssl->info_callback); | 2143 | return ssl->info_callback; |
| 1643 | } | 2144 | } |
| 1644 | 2145 | ||
| 1645 | int SSL_state(ssl) | 2146 | int SSL_state(SSL *ssl) |
| 1646 | SSL *ssl; | ||
| 1647 | { | 2147 | { |
| 1648 | return(ssl->state); | 2148 | return(ssl->state); |
| 1649 | } | 2149 | } |
| 1650 | 2150 | ||
| 1651 | void SSL_set_verify_result(ssl,arg) | 2151 | void SSL_set_verify_result(SSL *ssl,long arg) |
| 1652 | SSL *ssl; | ||
| 1653 | long arg; | ||
| 1654 | { | 2152 | { |
| 1655 | ssl->verify_result=arg; | 2153 | ssl->verify_result=arg; |
| 1656 | } | 2154 | } |
| 1657 | 2155 | ||
| 1658 | long SSL_get_verify_result(ssl) | 2156 | long SSL_get_verify_result(SSL *ssl) |
| 1659 | SSL *ssl; | ||
| 1660 | { | 2157 | { |
| 1661 | return(ssl->verify_result); | 2158 | return(ssl->verify_result); |
| 1662 | } | 2159 | } |
| 1663 | 2160 | ||
| 1664 | int SSL_get_ex_new_index(argl,argp,new_func,dup_func,free_func) | 2161 | int SSL_get_ex_new_index(long argl,void *argp,CRYPTO_EX_new *new_func, |
| 1665 | long argl; | 2162 | CRYPTO_EX_dup *dup_func,CRYPTO_EX_free *free_func) |
| 1666 | char *argp; | 2163 | { |
| 1667 | int (*new_func)(); | 2164 | return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL, argl, argp, |
| 1668 | int (*dup_func)(); | 2165 | new_func, dup_func, free_func); |
| 1669 | void (*free_func)(); | 2166 | } |
| 1670 | { | ||
| 1671 | ssl_meth_num++; | ||
| 1672 | return(CRYPTO_get_ex_new_index(ssl_meth_num-1, | ||
| 1673 | &ssl_meth,argl,argp,new_func,dup_func,free_func)); | ||
| 1674 | } | ||
| 1675 | 2167 | ||
| 1676 | int SSL_set_ex_data(s,idx,arg) | 2168 | int SSL_set_ex_data(SSL *s,int idx,void *arg) |
| 1677 | SSL *s; | ||
| 1678 | int idx; | ||
| 1679 | char *arg; | ||
| 1680 | { | 2169 | { |
| 1681 | return(CRYPTO_set_ex_data(&s->ex_data,idx,arg)); | 2170 | return(CRYPTO_set_ex_data(&s->ex_data,idx,arg)); |
| 1682 | } | 2171 | } |
| 1683 | 2172 | ||
| 1684 | char *SSL_get_ex_data(s,idx) | 2173 | void *SSL_get_ex_data(SSL *s,int idx) |
| 1685 | SSL *s; | ||
| 1686 | int idx; | ||
| 1687 | { | 2174 | { |
| 1688 | return(CRYPTO_get_ex_data(&s->ex_data,idx)); | 2175 | return(CRYPTO_get_ex_data(&s->ex_data,idx)); |
| 1689 | } | 2176 | } |
| 1690 | 2177 | ||
| 1691 | int SSL_CTX_get_ex_new_index(argl,argp,new_func,dup_func,free_func) | 2178 | int SSL_CTX_get_ex_new_index(long argl,void *argp,CRYPTO_EX_new *new_func, |
| 1692 | long argl; | 2179 | CRYPTO_EX_dup *dup_func,CRYPTO_EX_free *free_func) |
| 1693 | char *argp; | 2180 | { |
| 1694 | int (*new_func)(); | 2181 | return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL_CTX, argl, argp, |
| 1695 | int (*dup_func)(); | 2182 | new_func, dup_func, free_func); |
| 1696 | void (*free_func)(); | 2183 | } |
| 1697 | { | ||
| 1698 | ssl_ctx_meth_num++; | ||
| 1699 | return(CRYPTO_get_ex_new_index(ssl_ctx_meth_num-1, | ||
| 1700 | &ssl_ctx_meth,argl,argp,new_func,dup_func,free_func)); | ||
| 1701 | } | ||
| 1702 | 2184 | ||
| 1703 | int SSL_CTX_set_ex_data(s,idx,arg) | 2185 | int SSL_CTX_set_ex_data(SSL_CTX *s,int idx,void *arg) |
| 1704 | SSL_CTX *s; | ||
| 1705 | int idx; | ||
| 1706 | char *arg; | ||
| 1707 | { | 2186 | { |
| 1708 | return(CRYPTO_set_ex_data(&s->ex_data,idx,arg)); | 2187 | return(CRYPTO_set_ex_data(&s->ex_data,idx,arg)); |
| 1709 | } | 2188 | } |
| 1710 | 2189 | ||
| 1711 | char *SSL_CTX_get_ex_data(s,idx) | 2190 | void *SSL_CTX_get_ex_data(SSL_CTX *s,int idx) |
| 1712 | SSL_CTX *s; | ||
| 1713 | int idx; | ||
| 1714 | { | 2191 | { |
| 1715 | return(CRYPTO_get_ex_data(&s->ex_data,idx)); | 2192 | return(CRYPTO_get_ex_data(&s->ex_data,idx)); |
| 1716 | } | 2193 | } |
| 1717 | 2194 | ||
| 1718 | #if defined(_WINDLL) && defined(WIN16) | 2195 | int ssl_ok(SSL *s) |
| 2196 | { | ||
| 2197 | return(1); | ||
| 2198 | } | ||
| 2199 | |||
| 2200 | X509_STORE *SSL_CTX_get_cert_store(SSL_CTX *ctx) | ||
| 2201 | { | ||
| 2202 | return(ctx->cert_store); | ||
| 2203 | } | ||
| 2204 | |||
| 2205 | void SSL_CTX_set_cert_store(SSL_CTX *ctx,X509_STORE *store) | ||
| 2206 | { | ||
| 2207 | if (ctx->cert_store != NULL) | ||
| 2208 | X509_STORE_free(ctx->cert_store); | ||
| 2209 | ctx->cert_store=store; | ||
| 2210 | } | ||
| 2211 | |||
| 2212 | int SSL_want(SSL *s) | ||
| 2213 | { | ||
| 2214 | return(s->rwstate); | ||
| 2215 | } | ||
| 2216 | |||
| 2217 | /*! | ||
| 2218 | * \brief Set the callback for generating temporary RSA keys. | ||
| 2219 | * \param ctx the SSL context. | ||
| 2220 | * \param cb the callback | ||
| 2221 | */ | ||
| 2222 | |||
| 2223 | #ifndef OPENSSL_NO_RSA | ||
| 2224 | void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,RSA *(*cb)(SSL *ssl, | ||
| 2225 | int is_export, | ||
| 2226 | int keylength)) | ||
| 2227 | { | ||
| 2228 | SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TMP_RSA_CB,(void (*)())cb); | ||
| 2229 | } | ||
| 2230 | |||
| 2231 | void SSL_set_tmp_rsa_callback(SSL *ssl,RSA *(*cb)(SSL *ssl, | ||
| 2232 | int is_export, | ||
| 2233 | int keylength)) | ||
| 2234 | { | ||
| 2235 | SSL_callback_ctrl(ssl,SSL_CTRL_SET_TMP_RSA_CB,(void (*)())cb); | ||
| 2236 | } | ||
| 2237 | #endif | ||
| 2238 | |||
| 2239 | #ifdef DOXYGEN | ||
| 2240 | /*! | ||
| 2241 | * \brief The RSA temporary key callback function. | ||
| 2242 | * \param ssl the SSL session. | ||
| 2243 | * \param is_export \c TRUE if the temp RSA key is for an export ciphersuite. | ||
| 2244 | * \param keylength if \c is_export is \c TRUE, then \c keylength is the size | ||
| 2245 | * of the required key in bits. | ||
| 2246 | * \return the temporary RSA key. | ||
| 2247 | * \sa SSL_CTX_set_tmp_rsa_callback, SSL_set_tmp_rsa_callback | ||
| 2248 | */ | ||
| 2249 | |||
| 2250 | RSA *cb(SSL *ssl,int is_export,int keylength) | ||
| 2251 | {} | ||
| 2252 | #endif | ||
| 2253 | |||
| 2254 | /*! | ||
| 2255 | * \brief Set the callback for generating temporary DH keys. | ||
| 2256 | * \param ctx the SSL context. | ||
| 2257 | * \param dh the callback | ||
| 2258 | */ | ||
| 2259 | |||
| 2260 | #ifndef OPENSSL_NO_DH | ||
| 2261 | void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,DH *(*dh)(SSL *ssl,int is_export, | ||
| 2262 | int keylength)) | ||
| 2263 | { | ||
| 2264 | SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TMP_DH_CB,(void (*)())dh); | ||
| 2265 | } | ||
| 2266 | |||
| 2267 | void SSL_set_tmp_dh_callback(SSL *ssl,DH *(*dh)(SSL *ssl,int is_export, | ||
| 2268 | int keylength)) | ||
| 2269 | { | ||
| 2270 | SSL_callback_ctrl(ssl,SSL_CTRL_SET_TMP_DH_CB,(void (*)())dh); | ||
| 2271 | } | ||
| 2272 | #endif | ||
| 2273 | |||
| 2274 | |||
| 2275 | void SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)) | ||
| 2276 | { | ||
| 2277 | SSL_CTX_callback_ctrl(ctx, SSL_CTRL_SET_MSG_CALLBACK, (void (*)())cb); | ||
| 2278 | } | ||
| 2279 | void SSL_set_msg_callback(SSL *ssl, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)) | ||
| 2280 | { | ||
| 2281 | SSL_callback_ctrl(ssl, SSL_CTRL_SET_MSG_CALLBACK, (void (*)())cb); | ||
| 2282 | } | ||
| 2283 | |||
| 2284 | |||
| 2285 | |||
| 2286 | #if defined(_WINDLL) && defined(OPENSSL_SYS_WIN16) | ||
| 1719 | #include "../crypto/bio/bss_file.c" | 2287 | #include "../crypto/bio/bss_file.c" |
| 1720 | #endif | 2288 | #endif |
| 1721 | 2289 | ||
| 2290 | IMPLEMENT_STACK_OF(SSL_CIPHER) | ||
| 2291 | IMPLEMENT_STACK_OF(SSL_COMP) | ||
diff --git a/src/lib/libssl/ssl_locl.h b/src/lib/libssl/ssl_locl.h index b29517081b..17e9bef832 100644 --- a/src/lib/libssl/ssl_locl.h +++ b/src/lib/libssl/ssl_locl.h | |||
| @@ -55,6 +55,59 @@ | |||
| 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-2001 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 | ||
| 59 | #ifndef HEADER_SSL_LOCL_H | 112 | #ifndef HEADER_SSL_LOCL_H |
| 60 | #define HEADER_SSL_LOCL_H | 113 | #define HEADER_SSL_LOCL_H |
| @@ -65,15 +118,23 @@ | |||
| 65 | 118 | ||
| 66 | #include "e_os.h" | 119 | #include "e_os.h" |
| 67 | 120 | ||
| 68 | #include "buffer.h" | 121 | #include <openssl/buffer.h> |
| 69 | #include "bio.h" | 122 | #include <openssl/comp.h> |
| 70 | #include "crypto.h" | 123 | #include <openssl/bio.h> |
| 71 | #include "evp.h" | 124 | #include <openssl/crypto.h> |
| 72 | #include "stack.h" | 125 | #include <openssl/evp.h> |
| 73 | #include "x509.h" | 126 | #include <openssl/stack.h> |
| 74 | #include "err.h" | 127 | #include <openssl/x509.h> |
| 75 | #include "ssl.h" | 128 | #include <openssl/err.h> |
| 129 | #include <openssl/ssl.h> | ||
| 130 | #include <openssl/symhacks.h> | ||
| 131 | |||
| 132 | #ifdef OPENSSL_BUILD_SHLIBSSL | ||
| 133 | # undef OPENSSL_EXTERN | ||
| 134 | # define OPENSSL_EXTERN OPENSSL_EXPORT | ||
| 135 | #endif | ||
| 76 | 136 | ||
| 137 | #define PKCS1_CHECK | ||
| 77 | 138 | ||
| 78 | #define c2l(c,l) (l = ((unsigned long)(*((c)++))) , \ | 139 | #define c2l(c,l) (l = ((unsigned long)(*((c)++))) , \ |
| 79 | l|=(((unsigned long)(*((c)++)))<< 8), \ | 140 | l|=(((unsigned long)(*((c)++)))<< 8), \ |
| @@ -126,18 +187,18 @@ | |||
| 126 | } \ | 187 | } \ |
| 127 | } | 188 | } |
| 128 | 189 | ||
| 129 | #define n2s(c,s) (s =((unsigned int)(*((c)++)))<< 8, \ | 190 | #define n2s(c,s) ((s=(((unsigned int)(c[0]))<< 8)| \ |
| 130 | s|=((unsigned int)(*((c)++)))) | 191 | (((unsigned int)(c[1])) )),c+=2) |
| 131 | #define s2n(s,c) (*((c)++)=(unsigned char)(((s)>> 8)&0xff), \ | 192 | #define s2n(s,c) ((c[0]=(unsigned char)(((s)>> 8)&0xff), \ |
| 132 | *((c)++)=(unsigned char)(((s) )&0xff)) | 193 | c[1]=(unsigned char)(((s) )&0xff)),c+=2) |
| 133 | 194 | ||
| 134 | #define n2l3(c,l) (l =((unsigned long)(*((c)++)))<<16, \ | 195 | #define n2l3(c,l) ((l =(((unsigned long)(c[0]))<<16)| \ |
| 135 | l|=((unsigned long)(*((c)++)))<< 8, \ | 196 | (((unsigned long)(c[1]))<< 8)| \ |
| 136 | l|=((unsigned long)(*((c)++)))) | 197 | (((unsigned long)(c[2])) )),c+=3) |
| 137 | 198 | ||
| 138 | #define l2n3(l,c) (*((c)++)=(unsigned char)(((l)>>16)&0xff), \ | 199 | #define l2n3(l,c) ((c[0]=(unsigned char)(((l)>>16)&0xff), \ |
| 139 | *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ | 200 | c[1]=(unsigned char)(((l)>> 8)&0xff), \ |
| 140 | *((c)++)=(unsigned char)(((l) )&0xff)) | 201 | c[2]=(unsigned char)(((l) )&0xff)),c+=3) |
| 141 | 202 | ||
| 142 | /* LOCAL STUFF */ | 203 | /* LOCAL STUFF */ |
| 143 | 204 | ||
| @@ -153,60 +214,128 @@ | |||
| 153 | #define DEC32(a) ((a)=((a)-1)&0xffffffffL) | 214 | #define DEC32(a) ((a)=((a)-1)&0xffffffffL) |
| 154 | #define MAX_MAC_SIZE 20 /* up from 16 for SSLv3 */ | 215 | #define MAX_MAC_SIZE 20 /* up from 16 for SSLv3 */ |
| 155 | 216 | ||
| 156 | #define SSL_MKEY_MASK 0x0000001FL | 217 | /* |
| 218 | * Define the Bitmasks for SSL_CIPHER.algorithms. | ||
| 219 | * This bits are used packed as dense as possible. If new methods/ciphers | ||
| 220 | * etc will be added, the bits a likely to change, so this information | ||
| 221 | * is for internal library use only, even though SSL_CIPHER.algorithms | ||
| 222 | * can be publicly accessed. | ||
| 223 | * Use the according functions for cipher management instead. | ||
| 224 | * | ||
| 225 | * The bit mask handling in the selection and sorting scheme in | ||
| 226 | * ssl_create_cipher_list() has only limited capabilities, reflecting | ||
| 227 | * that the different entities within are mutually exclusive: | ||
| 228 | * ONLY ONE BIT PER MASK CAN BE SET AT A TIME. | ||
| 229 | */ | ||
| 230 | #define SSL_MKEY_MASK 0x0000003FL | ||
| 157 | #define SSL_kRSA 0x00000001L /* RSA key exchange */ | 231 | #define SSL_kRSA 0x00000001L /* RSA key exchange */ |
| 158 | #define SSL_kDHr 0x00000002L /* DH cert RSA CA cert */ | 232 | #define SSL_kDHr 0x00000002L /* DH cert RSA CA cert */ |
| 159 | #define SSL_kDHd 0x00000004L /* DH cert DSA CA cert */ | 233 | #define SSL_kDHd 0x00000004L /* DH cert DSA CA cert */ |
| 160 | #define SSL_kFZA 0x00000008L | 234 | #define SSL_kFZA 0x00000008L |
| 161 | #define SSL_kEDH 0x00000010L /* tmp DH key no DH cert */ | 235 | #define SSL_kEDH 0x00000010L /* tmp DH key no DH cert */ |
| 236 | #define SSL_kKRB5 0x00000020L /* Kerberos5 key exchange */ | ||
| 162 | #define SSL_EDH (SSL_kEDH|(SSL_AUTH_MASK^SSL_aNULL)) | 237 | #define SSL_EDH (SSL_kEDH|(SSL_AUTH_MASK^SSL_aNULL)) |
| 163 | 238 | ||
| 164 | #define SSL_AUTH_MASK 0x000003e0L | 239 | #define SSL_AUTH_MASK 0x00000FC0L |
| 165 | #define SSL_aRSA 0x00000020L /* Authenticate with RSA */ | 240 | #define SSL_aRSA 0x00000040L /* Authenticate with RSA */ |
| 166 | #define SSL_aDSS 0x00000040L /* Authenticate with DSS */ | 241 | #define SSL_aDSS 0x00000080L /* Authenticate with DSS */ |
| 167 | #define SSL_DSS SSL_aDSS | 242 | #define SSL_DSS SSL_aDSS |
| 168 | #define SSL_aFZA 0x00000080L | 243 | #define SSL_aFZA 0x00000100L |
| 169 | #define SSL_aNULL 0x00000100L /* no Authenticate, ADH */ | 244 | #define SSL_aNULL 0x00000200L /* no Authenticate, ADH */ |
| 170 | #define SSL_aDH 0x00000200L /* no Authenticate, ADH */ | 245 | #define SSL_aDH 0x00000400L /* no Authenticate, ADH */ |
| 246 | #define SSL_aKRB5 0x00000800L /* Authenticate with KRB5 */ | ||
| 171 | 247 | ||
| 172 | #define SSL_NULL (SSL_eNULL) | 248 | #define SSL_NULL (SSL_eNULL) |
| 173 | #define SSL_ADH (SSL_kEDH|SSL_aNULL) | 249 | #define SSL_ADH (SSL_kEDH|SSL_aNULL) |
| 174 | #define SSL_RSA (SSL_kRSA|SSL_aRSA) | 250 | #define SSL_RSA (SSL_kRSA|SSL_aRSA) |
| 175 | #define SSL_DH (SSL_kDHr|SSL_kDHd|SSL_kEDH) | 251 | #define SSL_DH (SSL_kDHr|SSL_kDHd|SSL_kEDH) |
| 176 | #define SSL_FZA (SSL_aFZA|SSL_kFZA|SSL_eFZA) | 252 | #define SSL_FZA (SSL_aFZA|SSL_kFZA|SSL_eFZA) |
| 177 | 253 | #define SSL_KRB5 (SSL_kKRB5|SSL_aKRB5) | |
| 178 | #define SSL_ENC_MASK 0x0001Fc00L | 254 | |
| 179 | #define SSL_DES 0x00000400L | 255 | #define SSL_ENC_MASK 0x0087F000L |
| 180 | #define SSL_3DES 0x00000800L | 256 | #define SSL_DES 0x00001000L |
| 181 | #define SSL_RC4 0x00001000L | 257 | #define SSL_3DES 0x00002000L |
| 182 | #define SSL_RC2 0x00002000L | 258 | #define SSL_RC4 0x00004000L |
| 183 | #define SSL_IDEA 0x00004000L | 259 | #define SSL_RC2 0x00008000L |
| 184 | #define SSL_eFZA 0x00008000L | 260 | #define SSL_IDEA 0x00010000L |
| 185 | #define SSL_eNULL 0x00010000L | 261 | #define SSL_eFZA 0x00020000L |
| 186 | 262 | #define SSL_eNULL 0x00040000L | |
| 187 | #define SSL_MAC_MASK 0x00060000L | 263 | #define SSL_AES 0x00800000L |
| 188 | #define SSL_MD5 0x00020000L | 264 | |
| 189 | #define SSL_SHA1 0x00040000L | 265 | #define SSL_MAC_MASK 0x00180000L |
| 266 | #define SSL_MD5 0x00080000L | ||
| 267 | #define SSL_SHA1 0x00100000L | ||
| 190 | #define SSL_SHA (SSL_SHA1) | 268 | #define SSL_SHA (SSL_SHA1) |
| 191 | 269 | ||
| 192 | #define SSL_EXP_MASK 0x00300000L | 270 | #define SSL_SSL_MASK 0x00600000L |
| 193 | #define SSL_EXP 0x00100000L | 271 | #define SSL_SSLV2 0x00200000L |
| 194 | #define SSL_NOT_EXP 0x00200000L | 272 | #define SSL_SSLV3 0x00400000L |
| 195 | #define SSL_EXPORT SSL_EXP | 273 | #define SSL_TLSV1 SSL_SSLV3 /* for now */ |
| 196 | 274 | ||
| 197 | #define SSL_SSL_MASK 0x00c00000L | 275 | /* we have used 007fffff - 9 bits left to go */ |
| 198 | #define SSL_SSLV2 0x00400000L | 276 | |
| 199 | #define SSL_SSLV3 0x00800000L | 277 | /* |
| 278 | * Export and cipher strength information. For each cipher we have to decide | ||
| 279 | * whether it is exportable or not. This information is likely to change | ||
| 280 | * over time, since the export control rules are no static technical issue. | ||
| 281 | * | ||
| 282 | * Independent of the export flag the cipher strength is sorted into classes. | ||
| 283 | * SSL_EXP40 was denoting the 40bit US export limit of past times, which now | ||
| 284 | * is at 56bit (SSL_EXP56). If the exportable cipher class is going to change | ||
| 285 | * again (eg. to 64bit) the use of "SSL_EXP*" becomes blurred even more, | ||
| 286 | * since SSL_EXP64 could be similar to SSL_LOW. | ||
| 287 | * For this reason SSL_MICRO and SSL_MINI macros are included to widen the | ||
| 288 | * namespace of SSL_LOW-SSL_HIGH to lower values. As development of speed | ||
| 289 | * and ciphers goes, another extension to SSL_SUPER and/or SSL_ULTRA would | ||
| 290 | * be possible. | ||
| 291 | */ | ||
| 292 | #define SSL_EXP_MASK 0x00000003L | ||
| 293 | #define SSL_NOT_EXP 0x00000001L | ||
| 294 | #define SSL_EXPORT 0x00000002L | ||
| 295 | |||
| 296 | #define SSL_STRONG_MASK 0x0000007cL | ||
| 297 | #define SSL_EXP40 0x00000004L | ||
| 298 | #define SSL_MICRO (SSL_EXP40) | ||
| 299 | #define SSL_EXP56 0x00000008L | ||
| 300 | #define SSL_MINI (SSL_EXP56) | ||
| 301 | #define SSL_LOW 0x00000010L | ||
| 302 | #define SSL_MEDIUM 0x00000020L | ||
| 303 | #define SSL_HIGH 0x00000040L | ||
| 304 | |||
| 305 | /* we have used 0000007f - 25 bits left to go */ | ||
| 306 | |||
| 307 | /* | ||
| 308 | * Macros to check the export status and cipher strength for export ciphers. | ||
| 309 | * Even though the macros for EXPORT and EXPORT40/56 have similar names, | ||
| 310 | * their meaning is different: | ||
| 311 | * *_EXPORT macros check the 'exportable' status. | ||
| 312 | * *_EXPORT40/56 macros are used to check whether a certain cipher strength | ||
| 313 | * is given. | ||
| 314 | * Since the SSL_IS_EXPORT* and SSL_EXPORT* macros depend on the correct | ||
| 315 | * algorithm structure element to be passed (algorithms, algo_strength) and no | ||
| 316 | * typechecking can be done as they are all of type unsigned long, their | ||
| 317 | * direct usage is discouraged. | ||
| 318 | * Use the SSL_C_* macros instead. | ||
| 319 | */ | ||
| 320 | #define SSL_IS_EXPORT(a) ((a)&SSL_EXPORT) | ||
| 321 | #define SSL_IS_EXPORT56(a) ((a)&SSL_EXP56) | ||
| 322 | #define SSL_IS_EXPORT40(a) ((a)&SSL_EXP40) | ||
| 323 | #define SSL_C_IS_EXPORT(c) SSL_IS_EXPORT((c)->algo_strength) | ||
| 324 | #define SSL_C_IS_EXPORT56(c) SSL_IS_EXPORT56((c)->algo_strength) | ||
| 325 | #define SSL_C_IS_EXPORT40(c) SSL_IS_EXPORT40((c)->algo_strength) | ||
| 326 | |||
| 327 | #define SSL_EXPORT_KEYLENGTH(a,s) (SSL_IS_EXPORT40(s) ? 5 : \ | ||
| 328 | ((a)&SSL_ENC_MASK) == SSL_DES ? 8 : 7) | ||
| 329 | #define SSL_EXPORT_PKEYLENGTH(a) (SSL_IS_EXPORT40(a) ? 512 : 1024) | ||
| 330 | #define SSL_C_EXPORT_KEYLENGTH(c) SSL_EXPORT_KEYLENGTH((c)->algorithms, \ | ||
| 331 | (c)->algo_strength) | ||
| 332 | #define SSL_C_EXPORT_PKEYLENGTH(c) SSL_EXPORT_PKEYLENGTH((c)->algo_strength) | ||
| 200 | 333 | ||
| 201 | #define SSL_STRONG_MASK 0x07000000L | ||
| 202 | #define SSL_LOW 0x01000000L | ||
| 203 | #define SSL_MEDIUM 0x02000000L | ||
| 204 | #define SSL_HIGH 0x04000000L | ||
| 205 | 334 | ||
| 206 | /* we have used 0fffffff - 4 bits left to go */ | ||
| 207 | #define SSL_ALL 0xffffffffL | 335 | #define SSL_ALL 0xffffffffL |
| 208 | #define SSL_ALL_CIPHERS (SSL_MKEY_MASK|SSL_AUTH_MASK|SSL_ENC_MASK|\ | 336 | #define SSL_ALL_CIPHERS (SSL_MKEY_MASK|SSL_AUTH_MASK|SSL_ENC_MASK|\ |
| 209 | SSL_MAC_MASK|SSL_EXP_MASK) | 337 | SSL_MAC_MASK) |
| 338 | #define SSL_ALL_STRENGTHS (SSL_EXP_MASK|SSL_STRONG_MASK) | ||
| 210 | 339 | ||
| 211 | /* Mostly for SSLv3 */ | 340 | /* Mostly for SSLv3 */ |
| 212 | #define SSL_PKEY_RSA_ENC 0 | 341 | #define SSL_PKEY_RSA_ENC 0 |
| @@ -233,44 +362,59 @@ | |||
| 233 | typedef struct cert_pkey_st | 362 | typedef struct cert_pkey_st |
| 234 | { | 363 | { |
| 235 | X509 *x509; | 364 | X509 *x509; |
| 236 | /* EVP_PKEY *publickey; *//* when extracted */ | ||
| 237 | EVP_PKEY *privatekey; | 365 | EVP_PKEY *privatekey; |
| 238 | } CERT_PKEY; | 366 | } CERT_PKEY; |
| 239 | 367 | ||
| 240 | typedef struct cert_st | 368 | typedef struct cert_st |
| 241 | { | 369 | { |
| 242 | int cert_type; | ||
| 243 | |||
| 244 | #ifdef undef | ||
| 245 | X509 *x509; | ||
| 246 | EVP_PKEY *publickey; /* when extracted */ | ||
| 247 | EVP_PKEY *privatekey; | ||
| 248 | |||
| 249 | pkeys[SSL_PKEY_RSA_ENC].x509 | ||
| 250 | /* pkeys[SSL_PKEY_RSA_ENC].publickey */ | ||
| 251 | pkeys[SSL_PKEY_RSA_ENC].privatekey | ||
| 252 | #endif | ||
| 253 | |||
| 254 | /* Current active set */ | 370 | /* Current active set */ |
| 255 | CERT_PKEY *key; | 371 | CERT_PKEY *key; /* ALWAYS points to an element of the pkeys array |
| 256 | 372 | * Probably it would make more sense to store | |
| 373 | * an index, not a pointer. */ | ||
| 374 | |||
| 257 | /* The following masks are for the key and auth | 375 | /* The following masks are for the key and auth |
| 258 | * algorithms that are supported by the certs below */ | 376 | * algorithms that are supported by the certs below */ |
| 259 | int valid; | 377 | int valid; |
| 260 | unsigned long mask; | 378 | unsigned long mask; |
| 261 | unsigned long export_mask; | 379 | unsigned long export_mask; |
| 262 | 380 | #ifndef OPENSSL_NO_RSA | |
| 263 | RSA *rsa_tmp; | 381 | RSA *rsa_tmp; |
| 382 | RSA *(*rsa_tmp_cb)(SSL *ssl,int is_export,int keysize); | ||
| 383 | #endif | ||
| 384 | #ifndef OPENSSL_NO_DH | ||
| 264 | DH *dh_tmp; | 385 | DH *dh_tmp; |
| 265 | RSA *(*rsa_tmp_cb)(); | 386 | DH *(*dh_tmp_cb)(SSL *ssl,int is_export,int keysize); |
| 266 | DH *(*dh_tmp_cb)(); | 387 | #endif |
| 267 | CERT_PKEY pkeys[SSL_PKEY_NUM]; | ||
| 268 | 388 | ||
| 269 | STACK *cert_chain; | 389 | CERT_PKEY pkeys[SSL_PKEY_NUM]; |
| 270 | 390 | ||
| 271 | int references; | 391 | int references; /* >1 only if SSL_copy_session_id is used */ |
| 272 | } CERT; | 392 | } CERT; |
| 273 | 393 | ||
| 394 | |||
| 395 | typedef struct sess_cert_st | ||
| 396 | { | ||
| 397 | STACK_OF(X509) *cert_chain; /* as received from peer (not for SSL2) */ | ||
| 398 | |||
| 399 | /* The 'peer_...' members are used only by clients. */ | ||
| 400 | int peer_cert_type; | ||
| 401 | |||
| 402 | CERT_PKEY *peer_key; /* points to an element of peer_pkeys (never NULL!) */ | ||
| 403 | CERT_PKEY peer_pkeys[SSL_PKEY_NUM]; | ||
| 404 | /* Obviously we don't have the private keys of these, | ||
| 405 | * so maybe we shouldn't even use the CERT_PKEY type here. */ | ||
| 406 | |||
| 407 | #ifndef OPENSSL_NO_RSA | ||
| 408 | RSA *peer_rsa_tmp; /* not used for SSL 2 */ | ||
| 409 | #endif | ||
| 410 | #ifndef OPENSSL_NO_DH | ||
| 411 | DH *peer_dh_tmp; /* not used for SSL 2 */ | ||
| 412 | #endif | ||
| 413 | |||
| 414 | int references; /* actually always 1 at the moment */ | ||
| 415 | } SESS_CERT; | ||
| 416 | |||
| 417 | |||
| 274 | /*#define MAC_DEBUG */ | 418 | /*#define MAC_DEBUG */ |
| 275 | 419 | ||
| 276 | /*#define ERR_DEBUG */ | 420 | /*#define ERR_DEBUG */ |
| @@ -282,12 +426,7 @@ typedef struct cert_st | |||
| 282 | /*#define RSA_DEBUG */ | 426 | /*#define RSA_DEBUG */ |
| 283 | /*#define IDEA_DEBUG */ | 427 | /*#define IDEA_DEBUG */ |
| 284 | 428 | ||
| 285 | #ifndef NOPROTO | ||
| 286 | #define FP_ICC (int (*)(const void *,const void *)) | 429 | #define FP_ICC (int (*)(const void *,const void *)) |
| 287 | #else | ||
| 288 | #define FP_ICC | ||
| 289 | #endif | ||
| 290 | |||
| 291 | #define ssl_put_cipher_by_char(ssl,ciph,ptr) \ | 430 | #define ssl_put_cipher_by_char(ssl,ciph,ptr) \ |
| 292 | ((ssl)->method->put_cipher_by_char((ciph),(ptr))) | 431 | ((ssl)->method->put_cipher_by_char((ciph),(ptr))) |
| 293 | #define ssl_get_cipher_by_char(ssl,ptr) \ | 432 | #define ssl_get_cipher_by_char(ssl,ptr) \ |
| @@ -295,29 +434,41 @@ typedef struct cert_st | |||
| 295 | 434 | ||
| 296 | /* This is for the SSLv3/TLSv1.0 differences in crypto/hash stuff | 435 | /* This is for the SSLv3/TLSv1.0 differences in crypto/hash stuff |
| 297 | * It is a bit of a mess of functions, but hell, think of it as | 436 | * It is a bit of a mess of functions, but hell, think of it as |
| 298 | * an opaque strucute :-) */ | 437 | * an opaque structure :-) */ |
| 299 | typedef struct ssl3_enc_method | 438 | typedef struct ssl3_enc_method |
| 300 | { | 439 | { |
| 301 | int (*enc)(); | 440 | int (*enc)(SSL *, int); |
| 302 | int (*mac)(); | 441 | int (*mac)(SSL *, unsigned char *, int); |
| 303 | int (*setup_key_block)(); | 442 | int (*setup_key_block)(SSL *); |
| 304 | int (*generate_master_secret)(); | 443 | int (*generate_master_secret)(SSL *, unsigned char *, unsigned char *, int); |
| 305 | int (*change_cipher_state)(); | 444 | int (*change_cipher_state)(SSL *, int); |
| 306 | int (*final_finish_mac)(); | 445 | int (*final_finish_mac)(SSL *, EVP_MD_CTX *, EVP_MD_CTX *, const char *, int, unsigned char *); |
| 307 | int finish_mac_length; | 446 | int finish_mac_length; |
| 308 | int (*cert_verify_mac)(); | 447 | int (*cert_verify_mac)(SSL *, EVP_MD_CTX *, unsigned char *); |
| 309 | unsigned char client_finished[20]; | 448 | const char *client_finished_label; |
| 310 | int client_finished_len; | 449 | int client_finished_label_len; |
| 311 | unsigned char server_finished[20]; | 450 | const char *server_finished_label; |
| 312 | int server_finished_len; | 451 | int server_finished_label_len; |
| 313 | int (*alert_value)(); | 452 | int (*alert_value)(int); |
| 314 | } SSL3_ENC_METHOD; | 453 | } SSL3_ENC_METHOD; |
| 315 | 454 | ||
| 316 | extern SSL3_ENC_METHOD ssl3_undef_enc_method; | 455 | /* Used for holding the relevant compression methods loaded into SSL_CTX */ |
| 317 | extern SSL_CIPHER ssl2_ciphers[]; | 456 | typedef struct ssl3_comp_st |
| 318 | extern SSL_CIPHER ssl3_ciphers[]; | 457 | { |
| 458 | int comp_id; /* The identifier byte for this compression type */ | ||
| 459 | char *name; /* Text name used for the compression type */ | ||
| 460 | COMP_METHOD *method; /* The method :-) */ | ||
| 461 | } SSL3_COMP; | ||
| 462 | |||
| 463 | OPENSSL_EXTERN SSL3_ENC_METHOD ssl3_undef_enc_method; | ||
| 464 | OPENSSL_EXTERN SSL_CIPHER ssl2_ciphers[]; | ||
| 465 | OPENSSL_EXTERN SSL_CIPHER ssl3_ciphers[]; | ||
| 466 | |||
| 467 | #ifdef OPENSSL_SYS_VMS | ||
| 468 | #undef SSL_COMP_get_compression_methods | ||
| 469 | #define SSL_COMP_get_compression_methods SSL_COMP_get_compress_methods | ||
| 470 | #endif | ||
| 319 | 471 | ||
| 320 | #ifndef NOPROTO | ||
| 321 | 472 | ||
| 322 | SSL_METHOD *ssl_bad_method(int ver); | 473 | SSL_METHOD *ssl_bad_method(int ver); |
| 323 | SSL_METHOD *sslv2_base_method(void); | 474 | SSL_METHOD *sslv2_base_method(void); |
| @@ -327,33 +478,42 @@ SSL_METHOD *sslv3_base_method(void); | |||
| 327 | void ssl_clear_cipher_ctx(SSL *s); | 478 | void ssl_clear_cipher_ctx(SSL *s); |
| 328 | int ssl_clear_bad_session(SSL *s); | 479 | int ssl_clear_bad_session(SSL *s); |
| 329 | CERT *ssl_cert_new(void); | 480 | CERT *ssl_cert_new(void); |
| 481 | CERT *ssl_cert_dup(CERT *cert); | ||
| 482 | int ssl_cert_inst(CERT **o); | ||
| 330 | void ssl_cert_free(CERT *c); | 483 | void ssl_cert_free(CERT *c); |
| 331 | int ssl_set_cert_type(CERT *c, int type); | 484 | SESS_CERT *ssl_sess_cert_new(void); |
| 485 | void ssl_sess_cert_free(SESS_CERT *sc); | ||
| 486 | int ssl_set_peer_cert_type(SESS_CERT *c, int type); | ||
| 332 | int ssl_get_new_session(SSL *s, int session); | 487 | int ssl_get_new_session(SSL *s, int session); |
| 333 | int ssl_get_prev_session(SSL *s, unsigned char *session,int len); | 488 | int ssl_get_prev_session(SSL *s, unsigned char *session,int len); |
| 334 | int ssl_cipher_id_cmp(SSL_CIPHER *a,SSL_CIPHER *b); | 489 | int ssl_cipher_id_cmp(const SSL_CIPHER *a,const SSL_CIPHER *b); |
| 335 | int ssl_cipher_ptr_id_cmp(SSL_CIPHER **ap,SSL_CIPHER **bp); | 490 | int ssl_cipher_ptr_id_cmp(const SSL_CIPHER * const *ap, |
| 336 | STACK *ssl_bytes_to_cipher_list(SSL *s,unsigned char *p,int num,STACK **skp); | 491 | const SSL_CIPHER * const *bp); |
| 337 | int ssl_cipher_list_to_bytes(SSL *s,STACK *sk,unsigned char *p); | 492 | STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s,unsigned char *p,int num, |
| 338 | STACK *ssl_create_cipher_list(SSL_METHOD *meth,STACK **pref, | 493 | STACK_OF(SSL_CIPHER) **skp); |
| 339 | STACK **sorted,char *str); | 494 | int ssl_cipher_list_to_bytes(SSL *s,STACK_OF(SSL_CIPHER) *sk,unsigned char *p); |
| 495 | STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(const SSL_METHOD *meth, | ||
| 496 | STACK_OF(SSL_CIPHER) **pref, | ||
| 497 | STACK_OF(SSL_CIPHER) **sorted, | ||
| 498 | const char *rule_str); | ||
| 340 | void ssl_update_cache(SSL *s, int mode); | 499 | void ssl_update_cache(SSL *s, int mode); |
| 341 | int ssl_cipher_get_evp(SSL_CIPHER *c, EVP_CIPHER **enc, EVP_MD **md); | 500 | int ssl_cipher_get_evp(SSL_SESSION *s,const EVP_CIPHER **enc,const EVP_MD **md, |
| 342 | int ssl_verify_cert_chain(SSL *s,STACK *sk); | 501 | SSL_COMP **comp); |
| 502 | int ssl_verify_cert_chain(SSL *s,STACK_OF(X509) *sk); | ||
| 343 | int ssl_undefined_function(SSL *s); | 503 | int ssl_undefined_function(SSL *s); |
| 344 | X509 *ssl_get_server_send_cert(SSL *); | 504 | X509 *ssl_get_server_send_cert(SSL *); |
| 345 | EVP_PKEY *ssl_get_sign_pkey(SSL *,SSL_CIPHER *); | 505 | EVP_PKEY *ssl_get_sign_pkey(SSL *,SSL_CIPHER *); |
| 346 | int ssl_cert_type(X509 *x,EVP_PKEY *pkey); | 506 | int ssl_cert_type(X509 *x,EVP_PKEY *pkey); |
| 347 | void ssl_set_cert_masks(CERT *c); | 507 | void ssl_set_cert_masks(CERT *c, SSL_CIPHER *cipher); |
| 348 | STACK *ssl_get_ciphers_by_id(SSL *s); | 508 | STACK_OF(SSL_CIPHER) *ssl_get_ciphers_by_id(SSL *s); |
| 349 | int ssl_verify_alarm_type(long type); | 509 | int ssl_verify_alarm_type(long type); |
| 350 | 510 | ||
| 351 | int ssl2_enc_init(SSL *s, int client); | 511 | int ssl2_enc_init(SSL *s, int client); |
| 352 | void ssl2_generate_key_material(SSL *s); | 512 | void ssl2_generate_key_material(SSL *s); |
| 353 | void ssl2_enc(SSL *s,int send_data); | 513 | void ssl2_enc(SSL *s,int send_data); |
| 354 | void ssl2_mac(SSL *s,unsigned char *mac,int send_data); | 514 | void ssl2_mac(SSL *s,unsigned char *mac,int send_data); |
| 355 | SSL_CIPHER *ssl2_get_cipher_by_char(unsigned char *p); | 515 | SSL_CIPHER *ssl2_get_cipher_by_char(const unsigned char *p); |
| 356 | int ssl2_put_cipher_by_char(SSL_CIPHER *c,unsigned char *p); | 516 | int ssl2_put_cipher_by_char(const SSL_CIPHER *c,unsigned char *p); |
| 357 | int ssl2_part_read(SSL *s, unsigned long f, int i); | 517 | int ssl2_part_read(SSL *s, unsigned long f, int i); |
| 358 | int ssl2_do_write(SSL *s); | 518 | int ssl2_do_write(SSL *s); |
| 359 | int ssl2_set_certificate(SSL *s, int type, int len, unsigned char *data); | 519 | int ssl2_set_certificate(SSL *s, int type, int len, unsigned char *data); |
| @@ -365,17 +525,19 @@ int ssl2_new(SSL *s); | |||
| 365 | void ssl2_free(SSL *s); | 525 | void ssl2_free(SSL *s); |
| 366 | int ssl2_accept(SSL *s); | 526 | int ssl2_accept(SSL *s); |
| 367 | int ssl2_connect(SSL *s); | 527 | int ssl2_connect(SSL *s); |
| 368 | int ssl2_read(SSL *s, char *buf, int len); | 528 | int ssl2_read(SSL *s, void *buf, int len); |
| 369 | int ssl2_peek(SSL *s, char *buf, int len); | 529 | int ssl2_peek(SSL *s, void *buf, int len); |
| 370 | int ssl2_write(SSL *s, char *buf, int len); | 530 | int ssl2_write(SSL *s, const void *buf, int len); |
| 371 | int ssl2_shutdown(SSL *s); | 531 | int ssl2_shutdown(SSL *s); |
| 372 | void ssl2_clear(SSL *s); | 532 | void ssl2_clear(SSL *s); |
| 373 | long ssl2_ctrl(SSL *s,int cmd, long larg, char *parg); | 533 | long ssl2_ctrl(SSL *s,int cmd, long larg, void *parg); |
| 374 | long ssl2_ctx_ctrl(SSL_CTX *s,int cmd, long larg, char *parg); | 534 | long ssl2_ctx_ctrl(SSL_CTX *s,int cmd, long larg, void *parg); |
| 535 | long ssl2_callback_ctrl(SSL *s,int cmd, void (*fp)()); | ||
| 536 | long ssl2_ctx_callback_ctrl(SSL_CTX *s,int cmd, void (*fp)()); | ||
| 375 | int ssl2_pending(SSL *s); | 537 | int ssl2_pending(SSL *s); |
| 376 | 538 | ||
| 377 | SSL_CIPHER *ssl3_get_cipher_by_char(unsigned char *p); | 539 | SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p); |
| 378 | int ssl3_put_cipher_by_char(SSL_CIPHER *c,unsigned char *p); | 540 | int ssl3_put_cipher_by_char(const SSL_CIPHER *c,unsigned char *p); |
| 379 | void ssl3_init_finished_mac(SSL *s); | 541 | void ssl3_init_finished_mac(SSL *s); |
| 380 | int ssl3_send_server_certificate(SSL *s); | 542 | int ssl3_send_server_certificate(SSL *s); |
| 381 | int ssl3_get_finished(SSL *s,int state_a,int state_b); | 543 | int ssl3_get_finished(SSL *s,int state_a,int state_b); |
| @@ -389,35 +551,37 @@ int ssl3_generate_master_secret(SSL *s, unsigned char *out, | |||
| 389 | unsigned char *p, int len); | 551 | unsigned char *p, int len); |
| 390 | int ssl3_get_req_cert_type(SSL *s,unsigned char *p); | 552 | int ssl3_get_req_cert_type(SSL *s,unsigned char *p); |
| 391 | long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok); | 553 | long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok); |
| 392 | int ssl3_send_finished(SSL *s, int a, int b, unsigned char *sender,int slen); | 554 | int ssl3_send_finished(SSL *s, int a, int b, const char *sender,int slen); |
| 393 | int ssl3_num_ciphers(void); | 555 | int ssl3_num_ciphers(void); |
| 394 | SSL_CIPHER *ssl3_get_cipher(unsigned int u); | 556 | SSL_CIPHER *ssl3_get_cipher(unsigned int u); |
| 395 | int ssl3_renegotiate(SSL *ssl); | 557 | int ssl3_renegotiate(SSL *ssl); |
| 396 | int ssl3_renegotiate_check(SSL *ssl); | 558 | int ssl3_renegotiate_check(SSL *ssl); |
| 397 | int ssl3_dispatch_alert(SSL *s); | 559 | int ssl3_dispatch_alert(SSL *s); |
| 398 | int ssl3_read_bytes(SSL *s, int type, char *buf, int len); | 560 | int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek); |
| 399 | int ssl3_part_read(SSL *s, int i); | 561 | int ssl3_write_bytes(SSL *s, int type, const void *buf, int len); |
| 400 | int ssl3_write_bytes(SSL *s, int type, char *buf, int len); | 562 | int ssl3_final_finish_mac(SSL *s, EVP_MD_CTX *ctx1, EVP_MD_CTX *ctx2, |
| 401 | int ssl3_final_finish_mac(SSL *s, EVP_MD_CTX *ctx1,EVP_MD_CTX *ctx2, | 563 | const char *sender, int slen,unsigned char *p); |
| 402 | unsigned char *sender, int slen,unsigned char *p); | ||
| 403 | int ssl3_cert_verify_mac(SSL *s, EVP_MD_CTX *in, unsigned char *p); | 564 | int ssl3_cert_verify_mac(SSL *s, EVP_MD_CTX *in, unsigned char *p); |
| 404 | void ssl3_finish_mac(SSL *s, unsigned char *buf, int len); | 565 | void ssl3_finish_mac(SSL *s, const unsigned char *buf, int len); |
| 405 | int ssl3_enc(SSL *s, int send_data); | 566 | int ssl3_enc(SSL *s, int send_data); |
| 406 | int ssl3_mac(SSL *ssl, unsigned char *md, int send_data); | 567 | int ssl3_mac(SSL *ssl, unsigned char *md, int send_data); |
| 407 | unsigned long ssl3_output_cert_chain(SSL *s, X509 *x); | 568 | unsigned long ssl3_output_cert_chain(SSL *s, X509 *x); |
| 408 | SSL_CIPHER *ssl3_choose_cipher(SSL *ssl,STACK *have,STACK *pref); | 569 | SSL_CIPHER *ssl3_choose_cipher(SSL *ssl,STACK_OF(SSL_CIPHER) *clnt, |
| 570 | STACK_OF(SSL_CIPHER) *srvr); | ||
| 409 | int ssl3_setup_buffers(SSL *s); | 571 | int ssl3_setup_buffers(SSL *s); |
| 410 | int ssl3_new(SSL *s); | 572 | int ssl3_new(SSL *s); |
| 411 | void ssl3_free(SSL *s); | 573 | void ssl3_free(SSL *s); |
| 412 | int ssl3_accept(SSL *s); | 574 | int ssl3_accept(SSL *s); |
| 413 | int ssl3_connect(SSL *s); | 575 | int ssl3_connect(SSL *s); |
| 414 | int ssl3_read(SSL *s, char *buf, int len); | 576 | int ssl3_read(SSL *s, void *buf, int len); |
| 415 | int ssl3_peek(SSL *s,char *buf, int len); | 577 | int ssl3_peek(SSL *s, void *buf, int len); |
| 416 | int ssl3_write(SSL *s, char *buf, int len); | 578 | int ssl3_write(SSL *s, const void *buf, int len); |
| 417 | int ssl3_shutdown(SSL *s); | 579 | int ssl3_shutdown(SSL *s); |
| 418 | void ssl3_clear(SSL *s); | 580 | void ssl3_clear(SSL *s); |
| 419 | long ssl3_ctrl(SSL *s,int cmd, long larg, char *parg); | 581 | long ssl3_ctrl(SSL *s,int cmd, long larg, void *parg); |
| 420 | long ssl3_ctx_ctrl(SSL_CTX *s,int cmd, long larg, char *parg); | 582 | long ssl3_ctx_ctrl(SSL_CTX *s,int cmd, long larg, void *parg); |
| 583 | long ssl3_callback_ctrl(SSL *s,int cmd, void (*fp)()); | ||
| 584 | long ssl3_ctx_callback_ctrl(SSL_CTX *s,int cmd, void (*fp)()); | ||
| 421 | int ssl3_pending(SSL *s); | 585 | int ssl3_pending(SSL *s); |
| 422 | 586 | ||
| 423 | int ssl23_accept(SSL *s); | 587 | int ssl23_accept(SSL *s); |
| @@ -428,131 +592,28 @@ int ssl23_write_bytes(SSL *s); | |||
| 428 | int tls1_new(SSL *s); | 592 | int tls1_new(SSL *s); |
| 429 | void tls1_free(SSL *s); | 593 | void tls1_free(SSL *s); |
| 430 | void tls1_clear(SSL *s); | 594 | void tls1_clear(SSL *s); |
| 431 | long tls1_ctrl(SSL *s,int cmd, long larg, char *parg); | 595 | long tls1_ctrl(SSL *s,int cmd, long larg, void *parg); |
| 596 | long tls1_callback_ctrl(SSL *s,int cmd, void (*fp)()); | ||
| 432 | SSL_METHOD *tlsv1_base_method(void ); | 597 | SSL_METHOD *tlsv1_base_method(void ); |
| 433 | 598 | ||
| 434 | |||
| 435 | int ssl_init_wbio_buffer(SSL *s, int push); | 599 | int ssl_init_wbio_buffer(SSL *s, int push); |
| 600 | void ssl_free_wbio_buffer(SSL *s); | ||
| 436 | 601 | ||
| 437 | int tls1_change_cipher_state(SSL *s, int which); | 602 | int tls1_change_cipher_state(SSL *s, int which); |
| 438 | int tls1_setup_key_block(SSL *s); | 603 | int tls1_setup_key_block(SSL *s); |
| 439 | int tls1_enc(SSL *s, int snd); | 604 | int tls1_enc(SSL *s, int snd); |
| 440 | int tls1_final_finish_mac(SSL *s, EVP_MD_CTX *in1_ctx, EVP_MD_CTX *in2_ctx, | 605 | int tls1_final_finish_mac(SSL *s, EVP_MD_CTX *in1_ctx, EVP_MD_CTX *in2_ctx, |
| 441 | unsigned char *str, int slen, unsigned char *p); | 606 | const char *str, int slen, unsigned char *p); |
| 442 | int tls1_cert_verify_mac(SSL *s, EVP_MD_CTX *in, unsigned char *p); | 607 | int tls1_cert_verify_mac(SSL *s, EVP_MD_CTX *in, unsigned char *p); |
| 443 | int tls1_mac(SSL *ssl, unsigned char *md, int snd); | 608 | int tls1_mac(SSL *ssl, unsigned char *md, int snd); |
| 444 | int tls1_generate_master_secret(SSL *s, unsigned char *out, | 609 | int tls1_generate_master_secret(SSL *s, unsigned char *out, |
| 445 | unsigned char *p, int len); | 610 | unsigned char *p, int len); |
| 446 | int tls1_alert_code(int code); | 611 | int tls1_alert_code(int code); |
| 447 | int ssl3_alert_code(int code); | 612 | int ssl3_alert_code(int code); |
| 613 | int ssl_ok(SSL *s); | ||
| 448 | 614 | ||
| 615 | SSL_COMP *ssl3_comp_find(STACK_OF(SSL_COMP) *sk, int n); | ||
| 616 | STACK_OF(SSL_COMP) *SSL_COMP_get_compression_methods(void); | ||
| 449 | 617 | ||
| 450 | #else | ||
| 451 | |||
| 452 | SSL_METHOD *ssl_bad_method(); | ||
| 453 | SSL_METHOD *sslv2_base_method(); | ||
| 454 | SSL_METHOD *sslv23_base_method(); | ||
| 455 | SSL_METHOD *sslv3_base_method(); | ||
| 456 | |||
| 457 | void ssl_clear_cipher_ctx(); | ||
| 458 | int ssl_clear_bad_session(); | ||
| 459 | CERT *ssl_cert_new(); | ||
| 460 | void ssl_cert_free(); | ||
| 461 | int ssl_set_cert_type(); | ||
| 462 | int ssl_get_new_session(); | ||
| 463 | int ssl_get_prev_session(); | ||
| 464 | int ssl_cipher_id_cmp(); | ||
| 465 | int ssl_cipher_ptr_id_cmp(); | ||
| 466 | STACK *ssl_bytes_to_cipher_list(); | ||
| 467 | int ssl_cipher_list_to_bytes(); | ||
| 468 | STACK *ssl_create_cipher_list(); | ||
| 469 | void ssl_update_cache(); | ||
| 470 | int ssl_session_get_ciphers(); | ||
| 471 | int ssl_verify_cert_chain(); | ||
| 472 | int ssl_undefined_function(); | ||
| 473 | X509 *ssl_get_server_send_cert(); | ||
| 474 | EVP_PKEY *ssl_get_sign_pkey(); | ||
| 475 | int ssl_cert_type(); | ||
| 476 | void ssl_set_cert_masks(); | ||
| 477 | STACK *ssl_get_ciphers_by_id(); | ||
| 478 | int ssl_verify_alarm_type(); | ||
| 479 | |||
| 480 | int ssl2_enc_init(); | ||
| 481 | void ssl2_generate_key_material(); | ||
| 482 | void ssl2_enc(); | ||
| 483 | void ssl2_mac(); | ||
| 484 | SSL_CIPHER *ssl2_get_cipher_by_char(); | ||
| 485 | int ssl2_put_cipher_by_char(); | ||
| 486 | int ssl2_part_read(); | ||
| 487 | int ssl2_do_write(); | ||
| 488 | int ssl2_set_certificate(); | ||
| 489 | void ssl2_return_error(); | ||
| 490 | void ssl2_write_error(); | ||
| 491 | int ssl2_num_ciphers(); | ||
| 492 | SSL_CIPHER *ssl2_get_cipher(); | ||
| 493 | int ssl2_new(); | ||
| 494 | void ssl2_free(); | ||
| 495 | int ssl2_accept(); | ||
| 496 | int ssl2_connect(); | ||
| 497 | int ssl2_read(); | ||
| 498 | int ssl2_peek(); | ||
| 499 | int ssl2_write(); | ||
| 500 | int ssl2_shutdown(); | ||
| 501 | void ssl2_clear(); | ||
| 502 | long ssl2_ctrl(); | ||
| 503 | long ssl2_ctx_ctrl(); | ||
| 504 | int ssl2_pending(); | ||
| 505 | |||
| 506 | SSL_CIPHER *ssl3_get_cipher_by_char(); | ||
| 507 | int ssl3_put_cipher_by_char(); | ||
| 508 | void ssl3_init_finished_mac(); | ||
| 509 | int ssl3_send_server_certificate(); | ||
| 510 | int ssl3_get_finished(); | ||
| 511 | int ssl3_setup_key_block(); | ||
| 512 | int ssl3_send_change_cipher_spec(); | ||
| 513 | int ssl3_change_cipher_state(); | ||
| 514 | void ssl3_cleanup_key_block(); | ||
| 515 | int ssl3_do_write(); | ||
| 516 | void ssl3_send_alert(); | ||
| 517 | int ssl3_generate_master_secret(); | ||
| 518 | int ssl3_get_req_cert_type(); | ||
| 519 | long ssl3_get_message(); | ||
| 520 | int ssl3_send_finished(); | ||
| 521 | int ssl3_num_ciphers(); | ||
| 522 | SSL_CIPHER *ssl3_get_cipher(); | ||
| 523 | int ssl3_renegotiate(); | ||
| 524 | int ssl3_renegotiate_check(); | ||
| 525 | int ssl3_dispatch_alert(); | ||
| 526 | int ssl3_read_bytes(); | ||
| 527 | int ssl3_part_read(); | ||
| 528 | int ssl3_write_bytes(); | ||
| 529 | int ssl3_final_finish_mac(); | ||
| 530 | void ssl3_finish_mac(); | ||
| 531 | int ssl3_enc(); | ||
| 532 | int ssl3_mac(); | ||
| 533 | unsigned long ssl3_output_cert_chain(); | ||
| 534 | SSL_CIPHER *ssl3_choose_cipher(); | ||
| 535 | int ssl3_setup_buffers(); | ||
| 536 | int ssl3_new(); | ||
| 537 | void ssl3_free(); | ||
| 538 | int ssl3_accept(); | ||
| 539 | int ssl3_connect(); | ||
| 540 | int ssl3_read(); | ||
| 541 | int ssl3_peek(); | ||
| 542 | int ssl3_write(); | ||
| 543 | int ssl3_shutdown(); | ||
| 544 | void ssl3_clear(); | ||
| 545 | long ssl3_ctrl(); | ||
| 546 | long ssl3_ctx_ctrl(); | ||
| 547 | int ssl3_pending(); | ||
| 548 | |||
| 549 | int ssl23_accept(); | ||
| 550 | int ssl23_connect(); | ||
| 551 | int ssl23_read_bytes(); | ||
| 552 | int ssl23_write_bytes(); | ||
| 553 | |||
| 554 | int ssl_init_wbio_buffer(); | ||
| 555 | |||
| 556 | #endif | ||
| 557 | 618 | ||
| 558 | #endif | 619 | #endif |
diff --git a/src/lib/libssl/ssl_rsa.c b/src/lib/libssl/ssl_rsa.c index 140475e5fb..1cf8e20934 100644 --- a/src/lib/libssl/ssl_rsa.c +++ b/src/lib/libssl/ssl_rsa.c | |||
| @@ -57,53 +57,32 @@ | |||
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include "bio.h" | 60 | #include <openssl/bio.h> |
| 61 | #include "objects.h" | 61 | #include <openssl/objects.h> |
| 62 | #include "evp.h" | 62 | #include <openssl/evp.h> |
| 63 | #include "x509.h" | 63 | #include <openssl/x509.h> |
| 64 | #include "pem.h" | 64 | #include <openssl/pem.h> |
| 65 | #include "ssl_locl.h" | 65 | #include "ssl_locl.h" |
| 66 | 66 | ||
| 67 | #ifndef NOPROTO | ||
| 68 | static int ssl_set_cert(CERT *c, X509 *x509); | 67 | static int ssl_set_cert(CERT *c, X509 *x509); |
| 69 | static int ssl_set_pkey(CERT *c, EVP_PKEY *pkey); | 68 | static int ssl_set_pkey(CERT *c, EVP_PKEY *pkey); |
| 70 | #else | 69 | int SSL_use_certificate(SSL *ssl, X509 *x) |
| 71 | static int ssl_set_cert(); | ||
| 72 | static int ssl_set_pkey(); | ||
| 73 | #endif | ||
| 74 | |||
| 75 | int SSL_use_certificate(ssl, x) | ||
| 76 | SSL *ssl; | ||
| 77 | X509 *x; | ||
| 78 | { | 70 | { |
| 79 | CERT *c; | ||
| 80 | |||
| 81 | if (x == NULL) | 71 | if (x == NULL) |
| 82 | { | 72 | { |
| 83 | SSLerr(SSL_F_SSL_USE_CERTIFICATE,ERR_R_PASSED_NULL_PARAMETER); | 73 | SSLerr(SSL_F_SSL_USE_CERTIFICATE,ERR_R_PASSED_NULL_PARAMETER); |
| 84 | return(0); | 74 | return(0); |
| 85 | } | 75 | } |
| 86 | if ((ssl->cert == NULL) || (ssl->cert == ssl->ctx->default_cert)) | 76 | if (!ssl_cert_inst(&ssl->cert)) |
| 87 | { | 77 | { |
| 88 | c=ssl_cert_new(); | 78 | SSLerr(SSL_F_SSL_USE_CERTIFICATE,ERR_R_MALLOC_FAILURE); |
| 89 | if (c == NULL) | 79 | return(0); |
| 90 | { | ||
| 91 | SSLerr(SSL_F_SSL_USE_CERTIFICATE,ERR_R_MALLOC_FAILURE); | ||
| 92 | return(0); | ||
| 93 | } | ||
| 94 | if (ssl->cert != NULL) ssl_cert_free(ssl->cert); | ||
| 95 | ssl->cert=c; | ||
| 96 | } | 80 | } |
| 97 | c=ssl->cert; | 81 | return(ssl_set_cert(ssl->cert,x)); |
| 98 | |||
| 99 | return(ssl_set_cert(c,x)); | ||
| 100 | } | 82 | } |
| 101 | 83 | ||
| 102 | #ifndef NO_STDIO | 84 | #ifndef OPENSSL_NO_STDIO |
| 103 | int SSL_use_certificate_file(ssl, file, type) | 85 | int SSL_use_certificate_file(SSL *ssl, const char *file, int type) |
| 104 | SSL *ssl; | ||
| 105 | char *file; | ||
| 106 | int type; | ||
| 107 | { | 86 | { |
| 108 | int j; | 87 | int j; |
| 109 | BIO *in; | 88 | BIO *in; |
| @@ -130,7 +109,7 @@ int type; | |||
| 130 | else if (type == SSL_FILETYPE_PEM) | 109 | else if (type == SSL_FILETYPE_PEM) |
| 131 | { | 110 | { |
| 132 | j=ERR_R_PEM_LIB; | 111 | j=ERR_R_PEM_LIB; |
| 133 | x=PEM_read_bio_X509(in,NULL,ssl->ctx->default_passwd_callback); | 112 | x=PEM_read_bio_X509(in,NULL,ssl->ctx->default_passwd_callback,ssl->ctx->default_passwd_callback_userdata); |
| 134 | } | 113 | } |
| 135 | else | 114 | else |
| 136 | { | 115 | { |
| @@ -152,10 +131,7 @@ end: | |||
| 152 | } | 131 | } |
| 153 | #endif | 132 | #endif |
| 154 | 133 | ||
| 155 | int SSL_use_certificate_ASN1(ssl, len, d) | 134 | int SSL_use_certificate_ASN1(SSL *ssl, unsigned char *d, int len) |
| 156 | SSL *ssl; | ||
| 157 | int len; | ||
| 158 | unsigned char *d; | ||
| 159 | { | 135 | { |
| 160 | X509 *x; | 136 | X509 *x; |
| 161 | int ret; | 137 | int ret; |
| @@ -172,12 +148,9 @@ unsigned char *d; | |||
| 172 | return(ret); | 148 | return(ret); |
| 173 | } | 149 | } |
| 174 | 150 | ||
| 175 | #ifndef NO_RSA | 151 | #ifndef OPENSSL_NO_RSA |
| 176 | int SSL_use_RSAPrivateKey(ssl, rsa) | 152 | int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa) |
| 177 | SSL *ssl; | ||
| 178 | RSA *rsa; | ||
| 179 | { | 153 | { |
| 180 | CERT *c; | ||
| 181 | EVP_PKEY *pkey; | 154 | EVP_PKEY *pkey; |
| 182 | int ret; | 155 | int ret; |
| 183 | 156 | ||
| @@ -186,37 +159,27 @@ RSA *rsa; | |||
| 186 | SSLerr(SSL_F_SSL_USE_RSAPRIVATEKEY,ERR_R_PASSED_NULL_PARAMETER); | 159 | SSLerr(SSL_F_SSL_USE_RSAPRIVATEKEY,ERR_R_PASSED_NULL_PARAMETER); |
| 187 | return(0); | 160 | return(0); |
| 188 | } | 161 | } |
| 189 | 162 | if (!ssl_cert_inst(&ssl->cert)) | |
| 190 | if ((ssl->cert == NULL) || (ssl->cert == ssl->ctx->default_cert)) | 163 | { |
| 191 | { | 164 | SSLerr(SSL_F_SSL_USE_RSAPRIVATEKEY,ERR_R_MALLOC_FAILURE); |
| 192 | c=ssl_cert_new(); | 165 | return(0); |
| 193 | if (c == NULL) | ||
| 194 | { | ||
| 195 | SSLerr(SSL_F_SSL_USE_RSAPRIVATEKEY,ERR_R_MALLOC_FAILURE); | ||
| 196 | return(0); | ||
| 197 | } | ||
| 198 | if (ssl->cert != NULL) ssl_cert_free(ssl->cert); | ||
| 199 | ssl->cert=c; | ||
| 200 | } | 166 | } |
| 201 | c=ssl->cert; | ||
| 202 | if ((pkey=EVP_PKEY_new()) == NULL) | 167 | if ((pkey=EVP_PKEY_new()) == NULL) |
| 203 | { | 168 | { |
| 204 | SSLerr(SSL_F_SSL_USE_RSAPRIVATEKEY,ERR_R_EVP_LIB); | 169 | SSLerr(SSL_F_SSL_USE_RSAPRIVATEKEY,ERR_R_EVP_LIB); |
| 205 | return(0); | 170 | return(0); |
| 206 | } | 171 | } |
| 207 | 172 | ||
| 208 | CRYPTO_add(&rsa->references,1,CRYPTO_LOCK_RSA); | 173 | RSA_up_ref(rsa); |
| 209 | EVP_PKEY_assign_RSA(pkey,rsa); | 174 | EVP_PKEY_assign_RSA(pkey,rsa); |
| 210 | 175 | ||
| 211 | ret=ssl_set_pkey(c,pkey); | 176 | ret=ssl_set_pkey(ssl->cert,pkey); |
| 212 | EVP_PKEY_free(pkey); | 177 | EVP_PKEY_free(pkey); |
| 213 | return(ret); | 178 | return(ret); |
| 214 | } | 179 | } |
| 215 | #endif | 180 | #endif |
| 216 | 181 | ||
| 217 | static int ssl_set_pkey(c,pkey) | 182 | static int ssl_set_pkey(CERT *c, EVP_PKEY *pkey) |
| 218 | CERT *c; | ||
| 219 | EVP_PKEY *pkey; | ||
| 220 | { | 183 | { |
| 221 | int i,ok=0,bad=0; | 184 | int i,ok=0,bad=0; |
| 222 | 185 | ||
| @@ -229,7 +192,13 @@ EVP_PKEY *pkey; | |||
| 229 | 192 | ||
| 230 | if (c->pkeys[i].x509 != NULL) | 193 | if (c->pkeys[i].x509 != NULL) |
| 231 | { | 194 | { |
| 232 | #ifndef NO_RSA | 195 | EVP_PKEY *pktmp; |
| 196 | pktmp = X509_get_pubkey(c->pkeys[i].x509); | ||
| 197 | EVP_PKEY_copy_parameters(pktmp,pkey); | ||
| 198 | EVP_PKEY_free(pktmp); | ||
| 199 | ERR_clear_error(); | ||
| 200 | |||
| 201 | #ifndef OPENSSL_NO_RSA | ||
| 233 | /* Don't check the public/private key, this is mostly | 202 | /* Don't check the public/private key, this is mostly |
| 234 | * for smart cards. */ | 203 | * for smart cards. */ |
| 235 | if ((pkey->type == EVP_PKEY_RSA) && | 204 | if ((pkey->type == EVP_PKEY_RSA) && |
| @@ -282,12 +251,9 @@ EVP_PKEY *pkey; | |||
| 282 | return(1); | 251 | return(1); |
| 283 | } | 252 | } |
| 284 | 253 | ||
| 285 | #ifndef NO_RSA | 254 | #ifndef OPENSSL_NO_RSA |
| 286 | #ifndef NO_STDIO | 255 | #ifndef OPENSSL_NO_STDIO |
| 287 | int SSL_use_RSAPrivateKey_file(ssl, file, type) | 256 | int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type) |
| 288 | SSL *ssl; | ||
| 289 | char *file; | ||
| 290 | int type; | ||
| 291 | { | 257 | { |
| 292 | int j,ret=0; | 258 | int j,ret=0; |
| 293 | BIO *in; | 259 | BIO *in; |
| @@ -314,7 +280,7 @@ int type; | |||
| 314 | { | 280 | { |
| 315 | j=ERR_R_PEM_LIB; | 281 | j=ERR_R_PEM_LIB; |
| 316 | rsa=PEM_read_bio_RSAPrivateKey(in,NULL, | 282 | rsa=PEM_read_bio_RSAPrivateKey(in,NULL, |
| 317 | ssl->ctx->default_passwd_callback); | 283 | ssl->ctx->default_passwd_callback,ssl->ctx->default_passwd_callback_userdata); |
| 318 | } | 284 | } |
| 319 | else | 285 | else |
| 320 | { | 286 | { |
| @@ -334,13 +300,10 @@ end: | |||
| 334 | } | 300 | } |
| 335 | #endif | 301 | #endif |
| 336 | 302 | ||
| 337 | int SSL_use_RSAPrivateKey_ASN1(ssl,d,len) | 303 | int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len) |
| 338 | SSL *ssl; | ||
| 339 | unsigned char *d; | ||
| 340 | long len; | ||
| 341 | { | 304 | { |
| 342 | int ret; | 305 | int ret; |
| 343 | unsigned char *p; | 306 | const unsigned char *p; |
| 344 | RSA *rsa; | 307 | RSA *rsa; |
| 345 | 308 | ||
| 346 | p=d; | 309 | p=d; |
| @@ -354,13 +317,10 @@ long len; | |||
| 354 | RSA_free(rsa); | 317 | RSA_free(rsa); |
| 355 | return(ret); | 318 | return(ret); |
| 356 | } | 319 | } |
| 357 | #endif /* !NO_RSA */ | 320 | #endif /* !OPENSSL_NO_RSA */ |
| 358 | 321 | ||
| 359 | int SSL_use_PrivateKey(ssl, pkey) | 322 | int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey) |
| 360 | SSL *ssl; | ||
| 361 | EVP_PKEY *pkey; | ||
| 362 | { | 323 | { |
| 363 | CERT *c; | ||
| 364 | int ret; | 324 | int ret; |
| 365 | 325 | ||
| 366 | if (pkey == NULL) | 326 | if (pkey == NULL) |
| @@ -368,29 +328,17 @@ EVP_PKEY *pkey; | |||
| 368 | SSLerr(SSL_F_SSL_USE_PRIVATEKEY,ERR_R_PASSED_NULL_PARAMETER); | 328 | SSLerr(SSL_F_SSL_USE_PRIVATEKEY,ERR_R_PASSED_NULL_PARAMETER); |
| 369 | return(0); | 329 | return(0); |
| 370 | } | 330 | } |
| 371 | 331 | if (!ssl_cert_inst(&ssl->cert)) | |
| 372 | if ((ssl->cert == NULL) || (ssl->cert == ssl->ctx->default_cert)) | 332 | { |
| 373 | { | 333 | SSLerr(SSL_F_SSL_USE_PRIVATEKEY,ERR_R_MALLOC_FAILURE); |
| 374 | c=ssl_cert_new(); | 334 | return(0); |
| 375 | if (c == NULL) | ||
| 376 | { | ||
| 377 | SSLerr(SSL_F_SSL_USE_PRIVATEKEY,ERR_R_MALLOC_FAILURE); | ||
| 378 | return(0); | ||
| 379 | } | ||
| 380 | if (ssl->cert != NULL) ssl_cert_free(ssl->cert); | ||
| 381 | ssl->cert=c; | ||
| 382 | } | 335 | } |
| 383 | c=ssl->cert; | 336 | ret=ssl_set_pkey(ssl->cert,pkey); |
| 384 | |||
| 385 | ret=ssl_set_pkey(c,pkey); | ||
| 386 | return(ret); | 337 | return(ret); |
| 387 | } | 338 | } |
| 388 | 339 | ||
| 389 | #ifndef NO_STDIO | 340 | #ifndef OPENSSL_NO_STDIO |
| 390 | int SSL_use_PrivateKey_file(ssl, file, type) | 341 | int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type) |
| 391 | SSL *ssl; | ||
| 392 | char *file; | ||
| 393 | int type; | ||
| 394 | { | 342 | { |
| 395 | int j,ret=0; | 343 | int j,ret=0; |
| 396 | BIO *in; | 344 | BIO *in; |
| @@ -412,7 +360,7 @@ int type; | |||
| 412 | { | 360 | { |
| 413 | j=ERR_R_PEM_LIB; | 361 | j=ERR_R_PEM_LIB; |
| 414 | pkey=PEM_read_bio_PrivateKey(in,NULL, | 362 | pkey=PEM_read_bio_PrivateKey(in,NULL, |
| 415 | ssl->ctx->default_passwd_callback); | 363 | ssl->ctx->default_passwd_callback,ssl->ctx->default_passwd_callback_userdata); |
| 416 | } | 364 | } |
| 417 | else | 365 | else |
| 418 | { | 366 | { |
| @@ -432,11 +380,7 @@ end: | |||
| 432 | } | 380 | } |
| 433 | #endif | 381 | #endif |
| 434 | 382 | ||
| 435 | int SSL_use_PrivateKey_ASN1(type,ssl,d,len) | 383 | int SSL_use_PrivateKey_ASN1(int type, SSL *ssl, unsigned char *d, long len) |
| 436 | int type; | ||
| 437 | SSL *ssl; | ||
| 438 | unsigned char *d; | ||
| 439 | long len; | ||
| 440 | { | 384 | { |
| 441 | int ret; | 385 | int ret; |
| 442 | unsigned char *p; | 386 | unsigned char *p; |
| @@ -454,36 +398,22 @@ long len; | |||
| 454 | return(ret); | 398 | return(ret); |
| 455 | } | 399 | } |
| 456 | 400 | ||
| 457 | int SSL_CTX_use_certificate(ctx, x) | 401 | int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x) |
| 458 | SSL_CTX *ctx; | ||
| 459 | X509 *x; | ||
| 460 | { | 402 | { |
| 461 | CERT *c; | ||
| 462 | |||
| 463 | if (x == NULL) | 403 | if (x == NULL) |
| 464 | { | 404 | { |
| 465 | SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE,ERR_R_PASSED_NULL_PARAMETER); | 405 | SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE,ERR_R_PASSED_NULL_PARAMETER); |
| 466 | return(0); | 406 | return(0); |
| 467 | } | 407 | } |
| 468 | 408 | if (!ssl_cert_inst(&ctx->cert)) | |
| 469 | if (ctx->default_cert == NULL) | ||
| 470 | { | 409 | { |
| 471 | c=ssl_cert_new(); | 410 | SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE,ERR_R_MALLOC_FAILURE); |
| 472 | if (c == NULL) | 411 | return(0); |
| 473 | { | ||
| 474 | SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE,ERR_R_MALLOC_FAILURE); | ||
| 475 | return(0); | ||
| 476 | } | ||
| 477 | ctx->default_cert=c; | ||
| 478 | } | 412 | } |
| 479 | c=ctx->default_cert; | 413 | return(ssl_set_cert(ctx->cert, x)); |
| 480 | |||
| 481 | return(ssl_set_cert(c,x)); | ||
| 482 | } | 414 | } |
| 483 | 415 | ||
| 484 | static int ssl_set_cert(c,x) | 416 | static int ssl_set_cert(CERT *c, X509 *x) |
| 485 | CERT *c; | ||
| 486 | X509 *x; | ||
| 487 | { | 417 | { |
| 488 | EVP_PKEY *pkey; | 418 | EVP_PKEY *pkey; |
| 489 | int i,ok=0,bad=0; | 419 | int i,ok=0,bad=0; |
| @@ -499,11 +429,25 @@ X509 *x; | |||
| 499 | if (i < 0) | 429 | if (i < 0) |
| 500 | { | 430 | { |
| 501 | SSLerr(SSL_F_SSL_SET_CERT,SSL_R_UNKNOWN_CERTIFICATE_TYPE); | 431 | SSLerr(SSL_F_SSL_SET_CERT,SSL_R_UNKNOWN_CERTIFICATE_TYPE); |
| 432 | EVP_PKEY_free(pkey); | ||
| 502 | return(0); | 433 | return(0); |
| 503 | } | 434 | } |
| 504 | 435 | ||
| 505 | if (c->pkeys[i].privatekey != NULL) | 436 | if (c->pkeys[i].privatekey != NULL) |
| 506 | { | 437 | { |
| 438 | EVP_PKEY_copy_parameters(pkey,c->pkeys[i].privatekey); | ||
| 439 | ERR_clear_error(); | ||
| 440 | |||
| 441 | #ifndef OPENSSL_NO_RSA | ||
| 442 | /* Don't check the public/private key, this is mostly | ||
| 443 | * for smart cards. */ | ||
| 444 | if ((c->pkeys[i].privatekey->type == EVP_PKEY_RSA) && | ||
| 445 | (RSA_flags(c->pkeys[i].privatekey->pkey.rsa) & | ||
| 446 | RSA_METHOD_FLAG_NO_CHECK)) | ||
| 447 | ok=1; | ||
| 448 | else | ||
| 449 | #endif | ||
| 450 | { | ||
| 507 | if (!X509_check_private_key(x,c->pkeys[i].privatekey)) | 451 | if (!X509_check_private_key(x,c->pkeys[i].privatekey)) |
| 508 | { | 452 | { |
| 509 | if ((i == SSL_PKEY_DH_RSA) || (i == SSL_PKEY_DH_DSA)) | 453 | if ((i == SSL_PKEY_DH_RSA) || (i == SSL_PKEY_DH_DSA)) |
| @@ -527,10 +471,12 @@ X509 *x; | |||
| 527 | } | 471 | } |
| 528 | else | 472 | else |
| 529 | ok=1; | 473 | ok=1; |
| 474 | } /* OPENSSL_NO_RSA */ | ||
| 530 | } | 475 | } |
| 531 | else | 476 | else |
| 532 | ok=1; | 477 | ok=1; |
| 533 | 478 | ||
| 479 | EVP_PKEY_free(pkey); | ||
| 534 | if (bad) | 480 | if (bad) |
| 535 | { | 481 | { |
| 536 | EVP_PKEY_free(c->pkeys[i].privatekey); | 482 | EVP_PKEY_free(c->pkeys[i].privatekey); |
| @@ -547,11 +493,8 @@ X509 *x; | |||
| 547 | return(1); | 493 | return(1); |
| 548 | } | 494 | } |
| 549 | 495 | ||
| 550 | #ifndef NO_STDIO | 496 | #ifndef OPENSSL_NO_STDIO |
| 551 | int SSL_CTX_use_certificate_file(ctx, file, type) | 497 | int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type) |
| 552 | SSL_CTX *ctx; | ||
| 553 | char *file; | ||
| 554 | int type; | ||
| 555 | { | 498 | { |
| 556 | int j; | 499 | int j; |
| 557 | BIO *in; | 500 | BIO *in; |
| @@ -578,7 +521,7 @@ int type; | |||
| 578 | else if (type == SSL_FILETYPE_PEM) | 521 | else if (type == SSL_FILETYPE_PEM) |
| 579 | { | 522 | { |
| 580 | j=ERR_R_PEM_LIB; | 523 | j=ERR_R_PEM_LIB; |
| 581 | x=PEM_read_bio_X509(in,NULL,ctx->default_passwd_callback); | 524 | x=PEM_read_bio_X509(in,NULL,ctx->default_passwd_callback,ctx->default_passwd_callback_userdata); |
| 582 | } | 525 | } |
| 583 | else | 526 | else |
| 584 | { | 527 | { |
| @@ -600,10 +543,7 @@ end: | |||
| 600 | } | 543 | } |
| 601 | #endif | 544 | #endif |
| 602 | 545 | ||
| 603 | int SSL_CTX_use_certificate_ASN1(ctx, len, d) | 546 | int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, unsigned char *d) |
| 604 | SSL_CTX *ctx; | ||
| 605 | int len; | ||
| 606 | unsigned char *d; | ||
| 607 | { | 547 | { |
| 608 | X509 *x; | 548 | X509 *x; |
| 609 | int ret; | 549 | int ret; |
| @@ -620,13 +560,10 @@ unsigned char *d; | |||
| 620 | return(ret); | 560 | return(ret); |
| 621 | } | 561 | } |
| 622 | 562 | ||
| 623 | #ifndef NO_RSA | 563 | #ifndef OPENSSL_NO_RSA |
| 624 | int SSL_CTX_use_RSAPrivateKey(ctx, rsa) | 564 | int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa) |
| 625 | SSL_CTX *ctx; | ||
| 626 | RSA *rsa; | ||
| 627 | { | 565 | { |
| 628 | int ret; | 566 | int ret; |
| 629 | CERT *c; | ||
| 630 | EVP_PKEY *pkey; | 567 | EVP_PKEY *pkey; |
| 631 | 568 | ||
| 632 | if (rsa == NULL) | 569 | if (rsa == NULL) |
| @@ -634,37 +571,27 @@ RSA *rsa; | |||
| 634 | SSLerr(SSL_F_SSL_CTX_USE_RSAPRIVATEKEY,ERR_R_PASSED_NULL_PARAMETER); | 571 | SSLerr(SSL_F_SSL_CTX_USE_RSAPRIVATEKEY,ERR_R_PASSED_NULL_PARAMETER); |
| 635 | return(0); | 572 | return(0); |
| 636 | } | 573 | } |
| 637 | if (ctx->default_cert == NULL) | 574 | if (!ssl_cert_inst(&ctx->cert)) |
| 638 | { | 575 | { |
| 639 | c=ssl_cert_new(); | 576 | SSLerr(SSL_F_SSL_CTX_USE_RSAPRIVATEKEY,ERR_R_MALLOC_FAILURE); |
| 640 | if (c == NULL) | 577 | return(0); |
| 641 | { | ||
| 642 | SSLerr(SSL_F_SSL_CTX_USE_RSAPRIVATEKEY,ERR_R_MALLOC_FAILURE); | ||
| 643 | return(0); | ||
| 644 | } | ||
| 645 | ctx->default_cert=c; | ||
| 646 | } | 578 | } |
| 647 | c=ctx->default_cert; | ||
| 648 | |||
| 649 | if ((pkey=EVP_PKEY_new()) == NULL) | 579 | if ((pkey=EVP_PKEY_new()) == NULL) |
| 650 | { | 580 | { |
| 651 | SSLerr(SSL_F_SSL_CTX_USE_RSAPRIVATEKEY,ERR_R_EVP_LIB); | 581 | SSLerr(SSL_F_SSL_CTX_USE_RSAPRIVATEKEY,ERR_R_EVP_LIB); |
| 652 | return(0); | 582 | return(0); |
| 653 | } | 583 | } |
| 654 | 584 | ||
| 655 | CRYPTO_add(&rsa->references,1,CRYPTO_LOCK_RSA); | 585 | RSA_up_ref(rsa); |
| 656 | EVP_PKEY_assign_RSA(pkey,rsa); | 586 | EVP_PKEY_assign_RSA(pkey,rsa); |
| 657 | 587 | ||
| 658 | ret=ssl_set_pkey(c,pkey); | 588 | ret=ssl_set_pkey(ctx->cert, pkey); |
| 659 | EVP_PKEY_free(pkey); | 589 | EVP_PKEY_free(pkey); |
| 660 | return(ret); | 590 | return(ret); |
| 661 | } | 591 | } |
| 662 | 592 | ||
| 663 | #ifndef NO_STDIO | 593 | #ifndef OPENSSL_NO_STDIO |
| 664 | int SSL_CTX_use_RSAPrivateKey_file(ctx, file, type) | 594 | int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type) |
| 665 | SSL_CTX *ctx; | ||
| 666 | char *file; | ||
| 667 | int type; | ||
| 668 | { | 595 | { |
| 669 | int j,ret=0; | 596 | int j,ret=0; |
| 670 | BIO *in; | 597 | BIO *in; |
| @@ -691,7 +618,7 @@ int type; | |||
| 691 | { | 618 | { |
| 692 | j=ERR_R_PEM_LIB; | 619 | j=ERR_R_PEM_LIB; |
| 693 | rsa=PEM_read_bio_RSAPrivateKey(in,NULL, | 620 | rsa=PEM_read_bio_RSAPrivateKey(in,NULL, |
| 694 | ctx->default_passwd_callback); | 621 | ctx->default_passwd_callback,ctx->default_passwd_callback_userdata); |
| 695 | } | 622 | } |
| 696 | else | 623 | else |
| 697 | { | 624 | { |
| @@ -711,13 +638,10 @@ end: | |||
| 711 | } | 638 | } |
| 712 | #endif | 639 | #endif |
| 713 | 640 | ||
| 714 | int SSL_CTX_use_RSAPrivateKey_ASN1(ctx,d,len) | 641 | int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, unsigned char *d, long len) |
| 715 | SSL_CTX *ctx; | ||
| 716 | unsigned char *d; | ||
| 717 | long len; | ||
| 718 | { | 642 | { |
| 719 | int ret; | 643 | int ret; |
| 720 | unsigned char *p; | 644 | const unsigned char *p; |
| 721 | RSA *rsa; | 645 | RSA *rsa; |
| 722 | 646 | ||
| 723 | p=d; | 647 | p=d; |
| @@ -731,40 +655,25 @@ long len; | |||
| 731 | RSA_free(rsa); | 655 | RSA_free(rsa); |
| 732 | return(ret); | 656 | return(ret); |
| 733 | } | 657 | } |
| 734 | #endif /* !NO_RSA */ | 658 | #endif /* !OPENSSL_NO_RSA */ |
| 735 | 659 | ||
| 736 | int SSL_CTX_use_PrivateKey(ctx, pkey) | 660 | int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey) |
| 737 | SSL_CTX *ctx; | ||
| 738 | EVP_PKEY *pkey; | ||
| 739 | { | 661 | { |
| 740 | CERT *c; | ||
| 741 | |||
| 742 | if (pkey == NULL) | 662 | if (pkey == NULL) |
| 743 | { | 663 | { |
| 744 | SSLerr(SSL_F_SSL_CTX_USE_PRIVATEKEY,ERR_R_PASSED_NULL_PARAMETER); | 664 | SSLerr(SSL_F_SSL_CTX_USE_PRIVATEKEY,ERR_R_PASSED_NULL_PARAMETER); |
| 745 | return(0); | 665 | return(0); |
| 746 | } | 666 | } |
| 747 | 667 | if (!ssl_cert_inst(&ctx->cert)) | |
| 748 | if (ctx->default_cert == NULL) | ||
| 749 | { | 668 | { |
| 750 | c=ssl_cert_new(); | 669 | SSLerr(SSL_F_SSL_CTX_USE_PRIVATEKEY,ERR_R_MALLOC_FAILURE); |
| 751 | if (c == NULL) | 670 | return(0); |
| 752 | { | ||
| 753 | SSLerr(SSL_F_SSL_CTX_USE_PRIVATEKEY,ERR_R_MALLOC_FAILURE); | ||
| 754 | return(0); | ||
| 755 | } | ||
| 756 | ctx->default_cert=c; | ||
| 757 | } | 671 | } |
| 758 | c=ctx->default_cert; | 672 | return(ssl_set_pkey(ctx->cert,pkey)); |
| 759 | |||
| 760 | return(ssl_set_pkey(c,pkey)); | ||
| 761 | } | 673 | } |
| 762 | 674 | ||
| 763 | #ifndef NO_STDIO | 675 | #ifndef OPENSSL_NO_STDIO |
| 764 | int SSL_CTX_use_PrivateKey_file(ctx, file, type) | 676 | int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type) |
| 765 | SSL_CTX *ctx; | ||
| 766 | char *file; | ||
| 767 | int type; | ||
| 768 | { | 677 | { |
| 769 | int j,ret=0; | 678 | int j,ret=0; |
| 770 | BIO *in; | 679 | BIO *in; |
| @@ -786,7 +695,7 @@ int type; | |||
| 786 | { | 695 | { |
| 787 | j=ERR_R_PEM_LIB; | 696 | j=ERR_R_PEM_LIB; |
| 788 | pkey=PEM_read_bio_PrivateKey(in,NULL, | 697 | pkey=PEM_read_bio_PrivateKey(in,NULL, |
| 789 | ctx->default_passwd_callback); | 698 | ctx->default_passwd_callback,ctx->default_passwd_callback_userdata); |
| 790 | } | 699 | } |
| 791 | else | 700 | else |
| 792 | { | 701 | { |
| @@ -806,11 +715,8 @@ end: | |||
| 806 | } | 715 | } |
| 807 | #endif | 716 | #endif |
| 808 | 717 | ||
| 809 | int SSL_CTX_use_PrivateKey_ASN1(type,ctx,d,len) | 718 | int SSL_CTX_use_PrivateKey_ASN1(int type, SSL_CTX *ctx, unsigned char *d, |
| 810 | int type; | 719 | long len) |
| 811 | SSL_CTX *ctx; | ||
| 812 | unsigned char *d; | ||
| 813 | long len; | ||
| 814 | { | 720 | { |
| 815 | int ret; | 721 | int ret; |
| 816 | unsigned char *p; | 722 | unsigned char *p; |
| @@ -829,3 +735,81 @@ long len; | |||
| 829 | } | 735 | } |
| 830 | 736 | ||
| 831 | 737 | ||
| 738 | #ifndef OPENSSL_NO_STDIO | ||
| 739 | /* Read a file that contains our certificate in "PEM" format, | ||
| 740 | * possibly followed by a sequence of CA certificates that should be | ||
| 741 | * sent to the peer in the Certificate message. | ||
| 742 | */ | ||
| 743 | int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file) | ||
| 744 | { | ||
| 745 | BIO *in; | ||
| 746 | int ret=0; | ||
| 747 | X509 *x=NULL; | ||
| 748 | |||
| 749 | in=BIO_new(BIO_s_file_internal()); | ||
| 750 | if (in == NULL) | ||
| 751 | { | ||
| 752 | SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE,ERR_R_BUF_LIB); | ||
| 753 | goto end; | ||
| 754 | } | ||
| 755 | |||
| 756 | if (BIO_read_filename(in,file) <= 0) | ||
| 757 | { | ||
| 758 | SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE,ERR_R_SYS_LIB); | ||
| 759 | goto end; | ||
| 760 | } | ||
| 761 | |||
| 762 | x=PEM_read_bio_X509(in,NULL,ctx->default_passwd_callback,ctx->default_passwd_callback_userdata); | ||
| 763 | if (x == NULL) | ||
| 764 | { | ||
| 765 | SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE,ERR_R_PEM_LIB); | ||
| 766 | goto end; | ||
| 767 | } | ||
| 768 | |||
| 769 | ret=SSL_CTX_use_certificate(ctx,x); | ||
| 770 | if (ERR_peek_error() != 0) | ||
| 771 | ret = 0; /* Key/certificate mismatch doesn't imply ret==0 ... */ | ||
| 772 | if (ret) | ||
| 773 | { | ||
| 774 | /* If we could set up our certificate, now proceed to | ||
| 775 | * the CA certificates. | ||
| 776 | */ | ||
| 777 | X509 *ca; | ||
| 778 | int r; | ||
| 779 | unsigned long err; | ||
| 780 | |||
| 781 | if (ctx->extra_certs != NULL) | ||
| 782 | { | ||
| 783 | sk_X509_pop_free(ctx->extra_certs, X509_free); | ||
| 784 | ctx->extra_certs = NULL; | ||
| 785 | } | ||
| 786 | |||
| 787 | while ((ca = PEM_read_bio_X509(in,NULL,ctx->default_passwd_callback,ctx->default_passwd_callback_userdata)) | ||
| 788 | != NULL) | ||
| 789 | { | ||
| 790 | r = SSL_CTX_add_extra_chain_cert(ctx, ca); | ||
| 791 | if (!r) | ||
| 792 | { | ||
| 793 | X509_free(ca); | ||
| 794 | ret = 0; | ||
| 795 | goto end; | ||
| 796 | } | ||
| 797 | /* Note that we must not free r if it was successfully | ||
| 798 | * added to the chain (while we must free the main | ||
| 799 | * certificate, since its reference count is increased | ||
| 800 | * by SSL_CTX_use_certificate). */ | ||
| 801 | } | ||
| 802 | /* When the while loop ends, it's usually just EOF. */ | ||
| 803 | err = ERR_peek_last_error(); | ||
| 804 | if (ERR_GET_LIB(err) == ERR_LIB_PEM && ERR_GET_REASON(err) == PEM_R_NO_START_LINE) | ||
| 805 | (void)ERR_get_error(); | ||
| 806 | else | ||
| 807 | ret = 0; /* some real error */ | ||
| 808 | } | ||
| 809 | |||
| 810 | end: | ||
| 811 | if (x != NULL) X509_free(x); | ||
| 812 | if (in != NULL) BIO_free(in); | ||
| 813 | return(ret); | ||
| 814 | } | ||
| 815 | #endif | ||
diff --git a/src/lib/libssl/ssl_sess.c b/src/lib/libssl/ssl_sess.c index 8212600e40..6424f775e2 100644 --- a/src/lib/libssl/ssl_sess.c +++ b/src/lib/libssl/ssl_sess.c | |||
| @@ -57,60 +57,57 @@ | |||
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include "lhash.h" | 60 | #include <openssl/lhash.h> |
| 61 | #include "rand.h" | 61 | #include <openssl/rand.h> |
| 62 | #include "ssl_locl.h" | 62 | #include "ssl_locl.h" |
| 63 | 63 | ||
| 64 | #ifndef NOPROTO | ||
| 65 | static void SSL_SESSION_list_remove(SSL_CTX *ctx, SSL_SESSION *s); | 64 | static void SSL_SESSION_list_remove(SSL_CTX *ctx, SSL_SESSION *s); |
| 66 | static void SSL_SESSION_list_add(SSL_CTX *ctx,SSL_SESSION *s); | 65 | static void SSL_SESSION_list_add(SSL_CTX *ctx,SSL_SESSION *s); |
| 67 | #else | 66 | static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck); |
| 68 | static void SSL_SESSION_list_remove(); | ||
| 69 | static void SSL_SESSION_list_add(); | ||
| 70 | #endif | ||
| 71 | |||
| 72 | static ssl_session_num=0; | ||
| 73 | static STACK *ssl_session_meth=NULL; | ||
| 74 | 67 | ||
| 75 | SSL_SESSION *SSL_get_session(ssl) | 68 | SSL_SESSION *SSL_get_session(SSL *ssl) |
| 76 | SSL *ssl; | 69 | /* aka SSL_get0_session; gets 0 objects, just returns a copy of the pointer */ |
| 77 | { | 70 | { |
| 78 | return(ssl->session); | 71 | return(ssl->session); |
| 79 | } | 72 | } |
| 80 | 73 | ||
| 81 | int SSL_SESSION_get_ex_new_index(argl,argp,new_func,dup_func,free_func) | 74 | SSL_SESSION *SSL_get1_session(SSL *ssl) |
| 82 | long argl; | 75 | /* variant of SSL_get_session: caller really gets something */ |
| 83 | char *argp; | 76 | { |
| 84 | int (*new_func)(); | 77 | SSL_SESSION *sess; |
| 85 | int (*dup_func)(); | 78 | /* Need to lock this all up rather than just use CRYPTO_add so that |
| 86 | void (*free_func)(); | 79 | * somebody doesn't free ssl->session between when we check it's |
| 87 | { | 80 | * non-null and when we up the reference count. */ |
| 88 | ssl_session_num++; | 81 | CRYPTO_r_lock(CRYPTO_LOCK_SSL_SESSION); |
| 89 | return(CRYPTO_get_ex_new_index(ssl_session_num-1, | 82 | sess = ssl->session; |
| 90 | &ssl_session_meth, | 83 | if(sess) |
| 91 | argl,argp,new_func,dup_func,free_func)); | 84 | sess->references++; |
| 92 | } | 85 | CRYPTO_r_unlock(CRYPTO_LOCK_SSL_SESSION); |
| 93 | 86 | return(sess); | |
| 94 | int SSL_SESSION_set_ex_data(s,idx,arg) | 87 | } |
| 95 | SSL_SESSION *s; | 88 | |
| 96 | int idx; | 89 | int SSL_SESSION_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, |
| 97 | char *arg; | 90 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) |
| 91 | { | ||
| 92 | return CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL_SESSION, argl, argp, | ||
| 93 | new_func, dup_func, free_func); | ||
| 94 | } | ||
| 95 | |||
| 96 | int SSL_SESSION_set_ex_data(SSL_SESSION *s, int idx, void *arg) | ||
| 98 | { | 97 | { |
| 99 | return(CRYPTO_set_ex_data(&s->ex_data,idx,arg)); | 98 | return(CRYPTO_set_ex_data(&s->ex_data,idx,arg)); |
| 100 | } | 99 | } |
| 101 | 100 | ||
| 102 | char *SSL_SESSION_get_ex_data(s,idx) | 101 | void *SSL_SESSION_get_ex_data(SSL_SESSION *s, int idx) |
| 103 | SSL_SESSION *s; | ||
| 104 | int idx; | ||
| 105 | { | 102 | { |
| 106 | return(CRYPTO_get_ex_data(&s->ex_data,idx)); | 103 | return(CRYPTO_get_ex_data(&s->ex_data,idx)); |
| 107 | } | 104 | } |
| 108 | 105 | ||
| 109 | SSL_SESSION *SSL_SESSION_new() | 106 | SSL_SESSION *SSL_SESSION_new(void) |
| 110 | { | 107 | { |
| 111 | SSL_SESSION *ss; | 108 | SSL_SESSION *ss; |
| 112 | 109 | ||
| 113 | ss=(SSL_SESSION *)Malloc(sizeof(SSL_SESSION)); | 110 | ss=(SSL_SESSION *)OPENSSL_malloc(sizeof(SSL_SESSION)); |
| 114 | if (ss == NULL) | 111 | if (ss == NULL) |
| 115 | { | 112 | { |
| 116 | SSLerr(SSL_F_SSL_SESSION_NEW,ERR_R_MALLOC_FAILURE); | 113 | SSLerr(SSL_F_SSL_SESSION_NEW,ERR_R_MALLOC_FAILURE); |
| @@ -118,26 +115,64 @@ SSL_SESSION *SSL_SESSION_new() | |||
| 118 | } | 115 | } |
| 119 | memset(ss,0,sizeof(SSL_SESSION)); | 116 | memset(ss,0,sizeof(SSL_SESSION)); |
| 120 | 117 | ||
| 118 | ss->verify_result = 1; /* avoid 0 (= X509_V_OK) just in case */ | ||
| 121 | ss->references=1; | 119 | ss->references=1; |
| 122 | ss->timeout=60*5+4; /* 5 minute timeout by default */ | 120 | ss->timeout=60*5+4; /* 5 minute timeout by default */ |
| 123 | ss->time=time(NULL); | 121 | ss->time=time(NULL); |
| 124 | ss->prev=NULL; | 122 | ss->prev=NULL; |
| 125 | ss->next=NULL; | 123 | ss->next=NULL; |
| 126 | CRYPTO_new_ex_data(ssl_session_meth,(char *)ss,&ss->ex_data); | 124 | ss->compress_meth=0; |
| 125 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data); | ||
| 127 | return(ss); | 126 | return(ss); |
| 128 | } | 127 | } |
| 129 | 128 | ||
| 130 | int ssl_get_new_session(s, session) | 129 | /* Even with SSLv2, we have 16 bytes (128 bits) of session ID space. SSLv3/TLSv1 |
| 131 | SSL *s; | 130 | * has 32 bytes (256 bits). As such, filling the ID with random gunk repeatedly |
| 132 | int session; | 131 | * until we have no conflict is going to complete in one iteration pretty much |
| 132 | * "most" of the time (btw: understatement). So, if it takes us 10 iterations | ||
| 133 | * and we still can't avoid a conflict - well that's a reasonable point to call | ||
| 134 | * it quits. Either the RAND code is broken or someone is trying to open roughly | ||
| 135 | * very close to 2^128 (or 2^256) SSL sessions to our server. How you might | ||
| 136 | * store that many sessions is perhaps a more interesting question ... */ | ||
| 137 | |||
| 138 | #define MAX_SESS_ID_ATTEMPTS 10 | ||
| 139 | static int def_generate_session_id(const SSL *ssl, unsigned char *id, | ||
| 140 | unsigned int *id_len) | ||
| 141 | { | ||
| 142 | unsigned int retry = 0; | ||
| 143 | do | ||
| 144 | RAND_pseudo_bytes(id, *id_len); | ||
| 145 | while(SSL_has_matching_session_id(ssl, id, *id_len) && | ||
| 146 | (++retry < MAX_SESS_ID_ATTEMPTS)); | ||
| 147 | if(retry < MAX_SESS_ID_ATTEMPTS) | ||
| 148 | return 1; | ||
| 149 | /* else - woops a session_id match */ | ||
| 150 | /* XXX We should also check the external cache -- | ||
| 151 | * but the probability of a collision is negligible, and | ||
| 152 | * we could not prevent the concurrent creation of sessions | ||
| 153 | * with identical IDs since we currently don't have means | ||
| 154 | * to atomically check whether a session ID already exists | ||
| 155 | * and make a reservation for it if it does not | ||
| 156 | * (this problem applies to the internal cache as well). | ||
| 157 | */ | ||
| 158 | return 0; | ||
| 159 | } | ||
| 160 | |||
| 161 | int ssl_get_new_session(SSL *s, int session) | ||
| 133 | { | 162 | { |
| 163 | /* This gets used by clients and servers. */ | ||
| 164 | |||
| 165 | unsigned int tmp; | ||
| 134 | SSL_SESSION *ss=NULL; | 166 | SSL_SESSION *ss=NULL; |
| 167 | GEN_SESSION_CB cb = def_generate_session_id; | ||
| 135 | 168 | ||
| 136 | if ((ss=SSL_SESSION_new()) == NULL) return(0); | 169 | if ((ss=SSL_SESSION_new()) == NULL) return(0); |
| 137 | 170 | ||
| 138 | /* If the context has a default timeout, use it */ | 171 | /* If the context has a default timeout, use it */ |
| 139 | if (s->ctx->session_timeout != 0) | 172 | if (s->ctx->session_timeout == 0) |
| 140 | ss->timeout=SSL_get_default_timeout(s); | 173 | ss->timeout=SSL_get_default_timeout(s); |
| 174 | else | ||
| 175 | ss->timeout=s->ctx->session_timeout; | ||
| 141 | 176 | ||
| 142 | if (s->session != NULL) | 177 | if (s->session != NULL) |
| 143 | { | 178 | { |
| @@ -147,7 +182,7 @@ int session; | |||
| 147 | 182 | ||
| 148 | if (session) | 183 | if (session) |
| 149 | { | 184 | { |
| 150 | if (s->version == SSL2_CLIENT_VERSION) | 185 | if (s->version == SSL2_VERSION) |
| 151 | { | 186 | { |
| 152 | ss->ssl_version=SSL2_VERSION; | 187 | ss->ssl_version=SSL2_VERSION; |
| 153 | ss->session_id_length=SSL2_SSL_SESSION_ID_LENGTH; | 188 | ss->session_id_length=SSL2_SSL_SESSION_ID_LENGTH; |
| @@ -168,18 +203,46 @@ int session; | |||
| 168 | SSL_SESSION_free(ss); | 203 | SSL_SESSION_free(ss); |
| 169 | return(0); | 204 | return(0); |
| 170 | } | 205 | } |
| 171 | 206 | /* Choose which callback will set the session ID */ | |
| 172 | for (;;) | 207 | CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX); |
| 208 | if(s->generate_session_id) | ||
| 209 | cb = s->generate_session_id; | ||
| 210 | else if(s->ctx->generate_session_id) | ||
| 211 | cb = s->ctx->generate_session_id; | ||
| 212 | CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX); | ||
| 213 | /* Choose a session ID */ | ||
| 214 | tmp = ss->session_id_length; | ||
| 215 | if(!cb(s, ss->session_id, &tmp)) | ||
| 216 | { | ||
| 217 | /* The callback failed */ | ||
| 218 | SSLerr(SSL_F_SSL_GET_NEW_SESSION, | ||
| 219 | SSL_R_SSL_SESSION_ID_CALLBACK_FAILED); | ||
| 220 | SSL_SESSION_free(ss); | ||
| 221 | return(0); | ||
| 222 | } | ||
| 223 | /* Don't allow the callback to set the session length to zero. | ||
| 224 | * nor set it higher than it was. */ | ||
| 225 | if(!tmp || (tmp > ss->session_id_length)) | ||
| 226 | { | ||
| 227 | /* The callback set an illegal length */ | ||
| 228 | SSLerr(SSL_F_SSL_GET_NEW_SESSION, | ||
| 229 | SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH); | ||
| 230 | SSL_SESSION_free(ss); | ||
| 231 | return(0); | ||
| 232 | } | ||
| 233 | /* If the session length was shrunk and we're SSLv2, pad it */ | ||
| 234 | if((tmp < ss->session_id_length) && (s->version == SSL2_VERSION)) | ||
| 235 | memset(ss->session_id + tmp, 0, ss->session_id_length - tmp); | ||
| 236 | else | ||
| 237 | ss->session_id_length = tmp; | ||
| 238 | /* Finally, check for a conflict */ | ||
| 239 | if(SSL_has_matching_session_id(s, ss->session_id, | ||
| 240 | ss->session_id_length)) | ||
| 173 | { | 241 | { |
| 174 | SSL_SESSION *r; | 242 | SSLerr(SSL_F_SSL_GET_NEW_SESSION, |
| 175 | 243 | SSL_R_SSL_SESSION_ID_CONFLICT); | |
| 176 | RAND_bytes(ss->session_id,ss->session_id_length); | 244 | SSL_SESSION_free(ss); |
| 177 | CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX); | 245 | return(0); |
| 178 | r=(SSL_SESSION *)lh_retrieve(s->ctx->sessions, | ||
| 179 | (char *)ss); | ||
| 180 | CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX); | ||
| 181 | if (r == NULL) break; | ||
| 182 | /* else - woops a session_id match */ | ||
| 183 | } | 246 | } |
| 184 | } | 247 | } |
| 185 | else | 248 | else |
| @@ -187,58 +250,100 @@ int session; | |||
| 187 | ss->session_id_length=0; | 250 | ss->session_id_length=0; |
| 188 | } | 251 | } |
| 189 | 252 | ||
| 253 | memcpy(ss->sid_ctx,s->sid_ctx,s->sid_ctx_length); | ||
| 254 | ss->sid_ctx_length=s->sid_ctx_length; | ||
| 190 | s->session=ss; | 255 | s->session=ss; |
| 191 | ss->ssl_version=s->version; | 256 | ss->ssl_version=s->version; |
| 257 | ss->verify_result = X509_V_OK; | ||
| 192 | 258 | ||
| 193 | return(1); | 259 | return(1); |
| 194 | } | 260 | } |
| 195 | 261 | ||
| 196 | int ssl_get_prev_session(s,session_id,len) | 262 | int ssl_get_prev_session(SSL *s, unsigned char *session_id, int len) |
| 197 | SSL *s; | ||
| 198 | unsigned char *session_id; | ||
| 199 | int len; | ||
| 200 | { | 263 | { |
| 264 | /* This is used only by servers. */ | ||
| 265 | |||
| 201 | SSL_SESSION *ret=NULL,data; | 266 | SSL_SESSION *ret=NULL,data; |
| 267 | int fatal = 0; | ||
| 202 | 268 | ||
| 203 | /* conn_init();*/ | ||
| 204 | data.ssl_version=s->version; | 269 | data.ssl_version=s->version; |
| 205 | data.session_id_length=len; | 270 | data.session_id_length=len; |
| 206 | if (len > SSL_MAX_SSL_SESSION_ID_LENGTH) | 271 | if (len > SSL_MAX_SSL_SESSION_ID_LENGTH) |
| 207 | return(0); | 272 | goto err; |
| 208 | memcpy(data.session_id,session_id,len);; | 273 | memcpy(data.session_id,session_id,len); |
| 209 | 274 | ||
| 210 | if (!(s->ctx->session_cache_mode & SSL_SESS_CACHE_NO_INTERNAL_LOOKUP)) | 275 | if (!(s->ctx->session_cache_mode & SSL_SESS_CACHE_NO_INTERNAL_LOOKUP)) |
| 211 | { | 276 | { |
| 212 | CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX); | 277 | CRYPTO_r_lock(CRYPTO_LOCK_SSL_CTX); |
| 213 | ret=(SSL_SESSION *)lh_retrieve(s->ctx->sessions,(char *)&data); | 278 | ret=(SSL_SESSION *)lh_retrieve(s->ctx->sessions,&data); |
| 279 | if (ret != NULL) | ||
| 280 | /* don't allow other threads to steal it: */ | ||
| 281 | CRYPTO_add(&ret->references,1,CRYPTO_LOCK_SSL_SESSION); | ||
| 214 | CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX); | 282 | CRYPTO_r_unlock(CRYPTO_LOCK_SSL_CTX); |
| 215 | } | 283 | } |
| 216 | 284 | ||
| 217 | if (ret == NULL) | 285 | if (ret == NULL) |
| 218 | { | 286 | { |
| 219 | int copy=1; | 287 | int copy=1; |
| 220 | 288 | ||
| 221 | s->ctx->sess_miss++; | 289 | s->ctx->stats.sess_miss++; |
| 222 | ret=NULL; | 290 | ret=NULL; |
| 223 | if ((s->ctx->get_session_cb != NULL) && | 291 | if (s->ctx->get_session_cb != NULL |
| 224 | ((ret=s->ctx->get_session_cb(s,session_id,len,©)) | 292 | && (ret=s->ctx->get_session_cb(s,session_id,len,©)) |
| 225 | != NULL)) | 293 | != NULL) |
| 226 | { | 294 | { |
| 227 | s->ctx->sess_cb_hit++; | 295 | s->ctx->stats.sess_cb_hit++; |
| 296 | |||
| 297 | /* Increment reference count now if the session callback | ||
| 298 | * asks us to do so (note that if the session structures | ||
| 299 | * returned by the callback are shared between threads, | ||
| 300 | * it must handle the reference count itself [i.e. copy == 0], | ||
| 301 | * or things won't be thread-safe). */ | ||
| 302 | if (copy) | ||
| 303 | CRYPTO_add(&ret->references,1,CRYPTO_LOCK_SSL_SESSION); | ||
| 228 | 304 | ||
| 229 | /* The following should not return 1, otherwise, | 305 | /* The following should not return 1, otherwise, |
| 230 | * things are very strange */ | 306 | * things are very strange */ |
| 231 | SSL_CTX_add_session(s->ctx,ret); | 307 | SSL_CTX_add_session(s->ctx,ret); |
| 232 | /* auto free it */ | ||
| 233 | if (!copy) | ||
| 234 | SSL_SESSION_free(ret); | ||
| 235 | } | 308 | } |
| 236 | if (ret == NULL) return(0); | 309 | if (ret == NULL) |
| 310 | goto err; | ||
| 311 | } | ||
| 312 | |||
| 313 | /* Now ret is non-NULL, and we own one of its reference counts. */ | ||
| 314 | |||
| 315 | if((s->verify_mode&SSL_VERIFY_PEER) | ||
| 316 | && (!s->sid_ctx_length || ret->sid_ctx_length != s->sid_ctx_length | ||
| 317 | || memcmp(ret->sid_ctx,s->sid_ctx,ret->sid_ctx_length))) | ||
| 318 | { | ||
| 319 | /* We've found the session named by the client, but we don't | ||
| 320 | * want to use it in this context. */ | ||
| 321 | |||
| 322 | if (s->sid_ctx_length == 0) | ||
| 323 | { | ||
| 324 | /* application should have used SSL[_CTX]_set_session_id_context | ||
| 325 | * -- we could tolerate this and just pretend we never heard | ||
| 326 | * of this session, but then applications could effectively | ||
| 327 | * disable the session cache by accident without anyone noticing */ | ||
| 328 | |||
| 329 | SSLerr(SSL_F_SSL_GET_PREV_SESSION,SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED); | ||
| 330 | fatal = 1; | ||
| 331 | goto err; | ||
| 332 | } | ||
| 333 | else | ||
| 334 | { | ||
| 335 | #if 0 /* The client cannot always know when a session is not appropriate, | ||
| 336 | * so we shouldn't generate an error message. */ | ||
| 337 | |||
| 338 | SSLerr(SSL_F_SSL_GET_PREV_SESSION,SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT); | ||
| 339 | #endif | ||
| 340 | goto err; /* treat like cache miss */ | ||
| 341 | } | ||
| 237 | } | 342 | } |
| 238 | 343 | ||
| 239 | if (ret->cipher == NULL) | 344 | if (ret->cipher == NULL) |
| 240 | { | 345 | { |
| 241 | char buf[5],*p; | 346 | unsigned char buf[5],*p; |
| 242 | unsigned long l; | 347 | unsigned long l; |
| 243 | 348 | ||
| 244 | p=buf; | 349 | p=buf; |
| @@ -249,25 +354,28 @@ int len; | |||
| 249 | else | 354 | else |
| 250 | ret->cipher=ssl_get_cipher_by_char(s,&(buf[1])); | 355 | ret->cipher=ssl_get_cipher_by_char(s,&(buf[1])); |
| 251 | if (ret->cipher == NULL) | 356 | if (ret->cipher == NULL) |
| 252 | return(0); | 357 | goto err; |
| 253 | } | 358 | } |
| 254 | 359 | ||
| 360 | |||
| 361 | #if 0 /* This is way too late. */ | ||
| 362 | |||
| 255 | /* If a thread got the session, then 'swaped', and another got | 363 | /* If a thread got the session, then 'swaped', and another got |
| 256 | * it and then due to a time-out decided to 'Free' it we could | 364 | * it and then due to a time-out decided to 'OPENSSL_free' it we could |
| 257 | * be in trouble. So I'll increment it now, then double decrement | 365 | * be in trouble. So I'll increment it now, then double decrement |
| 258 | * later - am I speaking rubbish?. */ | 366 | * later - am I speaking rubbish?. */ |
| 259 | CRYPTO_add(&ret->references,1,CRYPTO_LOCK_SSL_SESSION); | 367 | CRYPTO_add(&ret->references,1,CRYPTO_LOCK_SSL_SESSION); |
| 368 | #endif | ||
| 260 | 369 | ||
| 261 | if ((long)(ret->time+ret->timeout) < (long)time(NULL)) /* timeout */ | 370 | if ((long)(ret->time+ret->timeout) < (long)time(NULL)) /* timeout */ |
| 262 | { | 371 | { |
| 263 | s->ctx->sess_timeout++; | 372 | s->ctx->stats.sess_timeout++; |
| 264 | /* remove it from the cache */ | 373 | /* remove it from the cache */ |
| 265 | SSL_CTX_remove_session(s->ctx,ret); | 374 | SSL_CTX_remove_session(s->ctx,ret); |
| 266 | SSL_SESSION_free(ret); /* again to actually Free it */ | 375 | goto err; |
| 267 | return(0); | ||
| 268 | } | 376 | } |
| 269 | 377 | ||
| 270 | s->ctx->sess_hit++; | 378 | s->ctx->stats.sess_hit++; |
| 271 | 379 | ||
| 272 | /* ret->time=time(NULL); */ /* rezero timeout? */ | 380 | /* ret->time=time(NULL); */ /* rezero timeout? */ |
| 273 | /* again, just leave the session | 381 | /* again, just leave the session |
| @@ -276,37 +384,64 @@ int len; | |||
| 276 | if (s->session != NULL) | 384 | if (s->session != NULL) |
| 277 | SSL_SESSION_free(s->session); | 385 | SSL_SESSION_free(s->session); |
| 278 | s->session=ret; | 386 | s->session=ret; |
| 387 | s->verify_result = s->session->verify_result; | ||
| 279 | return(1); | 388 | return(1); |
| 389 | |||
| 390 | err: | ||
| 391 | if (ret != NULL) | ||
| 392 | SSL_SESSION_free(ret); | ||
| 393 | if (fatal) | ||
| 394 | return -1; | ||
| 395 | else | ||
| 396 | return 0; | ||
| 280 | } | 397 | } |
| 281 | 398 | ||
| 282 | int SSL_CTX_add_session(ctx,c) | 399 | int SSL_CTX_add_session(SSL_CTX *ctx, SSL_SESSION *c) |
| 283 | SSL_CTX *ctx; | ||
| 284 | SSL_SESSION *c; | ||
| 285 | { | 400 | { |
| 286 | int ret=0; | 401 | int ret=0; |
| 287 | SSL_SESSION *s; | 402 | SSL_SESSION *s; |
| 288 | 403 | ||
| 289 | /* conn_init(); */ | 404 | /* add just 1 reference count for the SSL_CTX's session cache |
| 405 | * even though it has two ways of access: each session is in a | ||
| 406 | * doubly linked list and an lhash */ | ||
| 290 | CRYPTO_add(&c->references,1,CRYPTO_LOCK_SSL_SESSION); | 407 | CRYPTO_add(&c->references,1,CRYPTO_LOCK_SSL_SESSION); |
| 408 | /* if session c is in already in cache, we take back the increment later */ | ||
| 291 | 409 | ||
| 292 | CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); | 410 | CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); |
| 293 | s=(SSL_SESSION *)lh_insert(ctx->sessions,(char *)c); | 411 | s=(SSL_SESSION *)lh_insert(ctx->sessions,c); |
| 294 | 412 | ||
| 295 | /* Put on the end of the queue unless it is already in the cache */ | 413 | /* s != NULL iff we already had a session with the given PID. |
| 414 | * In this case, s == c should hold (then we did not really modify | ||
| 415 | * ctx->sessions), or we're in trouble. */ | ||
| 416 | if (s != NULL && s != c) | ||
| 417 | { | ||
| 418 | /* We *are* in trouble ... */ | ||
| 419 | SSL_SESSION_list_remove(ctx,s); | ||
| 420 | SSL_SESSION_free(s); | ||
| 421 | /* ... so pretend the other session did not exist in cache | ||
| 422 | * (we cannot handle two SSL_SESSION structures with identical | ||
| 423 | * session ID in the same cache, which could happen e.g. when | ||
| 424 | * two threads concurrently obtain the same session from an external | ||
| 425 | * cache) */ | ||
| 426 | s = NULL; | ||
| 427 | } | ||
| 428 | |||
| 429 | /* Put at the head of the queue unless it is already in the cache */ | ||
| 296 | if (s == NULL) | 430 | if (s == NULL) |
| 297 | SSL_SESSION_list_add(ctx,c); | 431 | SSL_SESSION_list_add(ctx,c); |
| 298 | 432 | ||
| 299 | /* If the same session if is being 're-added', Free the old | ||
| 300 | * one when the last person stops using it. | ||
| 301 | * This will also work if it is alread in the cache. | ||
| 302 | * The references will go up and then down :-) */ | ||
| 303 | if (s != NULL) | 433 | if (s != NULL) |
| 304 | { | 434 | { |
| 305 | SSL_SESSION_free(s); | 435 | /* existing cache entry -- decrement previously incremented reference |
| 436 | * count because it already takes into account the cache */ | ||
| 437 | |||
| 438 | SSL_SESSION_free(s); /* s == c */ | ||
| 306 | ret=0; | 439 | ret=0; |
| 307 | } | 440 | } |
| 308 | else | 441 | else |
| 309 | { | 442 | { |
| 443 | /* new cache entry -- remove old ones if cache has become too large */ | ||
| 444 | |||
| 310 | ret=1; | 445 | ret=1; |
| 311 | 446 | ||
| 312 | if (SSL_CTX_sess_get_cache_size(ctx) > 0) | 447 | if (SSL_CTX_sess_get_cache_size(ctx) > 0) |
| @@ -314,11 +449,11 @@ SSL_SESSION *c; | |||
| 314 | while (SSL_CTX_sess_number(ctx) > | 449 | while (SSL_CTX_sess_number(ctx) > |
| 315 | SSL_CTX_sess_get_cache_size(ctx)) | 450 | SSL_CTX_sess_get_cache_size(ctx)) |
| 316 | { | 451 | { |
| 317 | if (!SSL_CTX_remove_session(ctx, | 452 | if (!remove_session_lock(ctx, |
| 318 | ctx->session_cache_tail)) | 453 | ctx->session_cache_tail, 0)) |
| 319 | break; | 454 | break; |
| 320 | else | 455 | else |
| 321 | ctx->sess_cache_full++; | 456 | ctx->stats.sess_cache_full++; |
| 322 | } | 457 | } |
| 323 | } | 458 | } |
| 324 | } | 459 | } |
| @@ -326,24 +461,27 @@ SSL_SESSION *c; | |||
| 326 | return(ret); | 461 | return(ret); |
| 327 | } | 462 | } |
| 328 | 463 | ||
| 329 | int SSL_CTX_remove_session(ctx,c) | 464 | int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c) |
| 330 | SSL_CTX *ctx; | 465 | { |
| 331 | SSL_SESSION *c; | 466 | return remove_session_lock(ctx, c, 1); |
| 467 | } | ||
| 468 | |||
| 469 | static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck) | ||
| 332 | { | 470 | { |
| 333 | SSL_SESSION *r; | 471 | SSL_SESSION *r; |
| 334 | int ret=0; | 472 | int ret=0; |
| 335 | 473 | ||
| 336 | if ((c != NULL) && (c->session_id_length != 0)) | 474 | if ((c != NULL) && (c->session_id_length != 0)) |
| 337 | { | 475 | { |
| 338 | CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); | 476 | if(lck) CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); |
| 339 | r=(SSL_SESSION *)lh_delete(ctx->sessions,(char *)c); | 477 | if ((r = (SSL_SESSION *)lh_retrieve(ctx->sessions,c)) == c) |
| 340 | if (r != NULL) | ||
| 341 | { | 478 | { |
| 342 | ret=1; | 479 | ret=1; |
| 480 | r=(SSL_SESSION *)lh_delete(ctx->sessions,c); | ||
| 343 | SSL_SESSION_list_remove(ctx,c); | 481 | SSL_SESSION_list_remove(ctx,c); |
| 344 | } | 482 | } |
| 345 | 483 | ||
| 346 | CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX); | 484 | if(lck) CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX); |
| 347 | 485 | ||
| 348 | if (ret) | 486 | if (ret) |
| 349 | { | 487 | { |
| @@ -358,11 +496,13 @@ SSL_SESSION *c; | |||
| 358 | return(ret); | 496 | return(ret); |
| 359 | } | 497 | } |
| 360 | 498 | ||
| 361 | void SSL_SESSION_free(ss) | 499 | void SSL_SESSION_free(SSL_SESSION *ss) |
| 362 | SSL_SESSION *ss; | ||
| 363 | { | 500 | { |
| 364 | int i; | 501 | int i; |
| 365 | 502 | ||
| 503 | if(ss == NULL) | ||
| 504 | return; | ||
| 505 | |||
| 366 | i=CRYPTO_add(&ss->references,-1,CRYPTO_LOCK_SSL_SESSION); | 506 | i=CRYPTO_add(&ss->references,-1,CRYPTO_LOCK_SSL_SESSION); |
| 367 | #ifdef REF_PRINT | 507 | #ifdef REF_PRINT |
| 368 | REF_PRINT("SSL_SESSION",ss); | 508 | REF_PRINT("SSL_SESSION",ss); |
| @@ -376,21 +516,19 @@ SSL_SESSION *ss; | |||
| 376 | } | 516 | } |
| 377 | #endif | 517 | #endif |
| 378 | 518 | ||
| 379 | CRYPTO_free_ex_data(ssl_session_meth,(char *)ss,&ss->ex_data); | 519 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data); |
| 380 | 520 | ||
| 381 | memset(ss->key_arg,0,SSL_MAX_KEY_ARG_LENGTH); | 521 | memset(ss->key_arg,0,SSL_MAX_KEY_ARG_LENGTH); |
| 382 | memset(ss->master_key,0,SSL_MAX_MASTER_KEY_LENGTH); | 522 | memset(ss->master_key,0,SSL_MAX_MASTER_KEY_LENGTH); |
| 383 | memset(ss->session_id,0,SSL_MAX_SSL_SESSION_ID_LENGTH); | 523 | memset(ss->session_id,0,SSL_MAX_SSL_SESSION_ID_LENGTH); |
| 384 | if (ss->cert != NULL) ssl_cert_free(ss->cert); | 524 | if (ss->sess_cert != NULL) ssl_sess_cert_free(ss->sess_cert); |
| 385 | if (ss->peer != NULL) X509_free(ss->peer); | 525 | if (ss->peer != NULL) X509_free(ss->peer); |
| 386 | if (ss->ciphers != NULL) sk_free(ss->ciphers); | 526 | if (ss->ciphers != NULL) sk_SSL_CIPHER_free(ss->ciphers); |
| 387 | memset(ss,0,sizeof(*ss)); | 527 | memset(ss,0,sizeof(*ss)); |
| 388 | Free(ss); | 528 | OPENSSL_free(ss); |
| 389 | } | 529 | } |
| 390 | 530 | ||
| 391 | int SSL_set_session(s, session) | 531 | int SSL_set_session(SSL *s, SSL_SESSION *session) |
| 392 | SSL *s; | ||
| 393 | SSL_SESSION *session; | ||
| 394 | { | 532 | { |
| 395 | int ret=0; | 533 | int ret=0; |
| 396 | SSL_METHOD *meth; | 534 | SSL_METHOD *meth; |
| @@ -410,14 +548,29 @@ SSL_SESSION *session; | |||
| 410 | { | 548 | { |
| 411 | if (!SSL_set_ssl_method(s,meth)) | 549 | if (!SSL_set_ssl_method(s,meth)) |
| 412 | return(0); | 550 | return(0); |
| 413 | session->timeout=SSL_get_default_timeout(s); | 551 | if (s->ctx->session_timeout == 0) |
| 552 | session->timeout=SSL_get_default_timeout(s); | ||
| 553 | else | ||
| 554 | session->timeout=s->ctx->session_timeout; | ||
| 414 | } | 555 | } |
| 415 | 556 | ||
| 557 | #ifndef OPENSSL_NO_KRB5 | ||
| 558 | if (s->kssl_ctx && !s->kssl_ctx->client_princ && | ||
| 559 | session->krb5_client_princ_len > 0) | ||
| 560 | { | ||
| 561 | s->kssl_ctx->client_princ = (char *)malloc(session->krb5_client_princ_len + 1); | ||
| 562 | memcpy(s->kssl_ctx->client_princ,session->krb5_client_princ, | ||
| 563 | session->krb5_client_princ_len); | ||
| 564 | s->kssl_ctx->client_princ[session->krb5_client_princ_len] = '\0'; | ||
| 565 | } | ||
| 566 | #endif /* OPENSSL_NO_KRB5 */ | ||
| 567 | |||
| 416 | /* CRYPTO_w_lock(CRYPTO_LOCK_SSL);*/ | 568 | /* CRYPTO_w_lock(CRYPTO_LOCK_SSL);*/ |
| 417 | CRYPTO_add(&session->references,1,CRYPTO_LOCK_SSL_SESSION); | 569 | CRYPTO_add(&session->references,1,CRYPTO_LOCK_SSL_SESSION); |
| 418 | if (s->session != NULL) | 570 | if (s->session != NULL) |
| 419 | SSL_SESSION_free(s->session); | 571 | SSL_SESSION_free(s->session); |
| 420 | s->session=session; | 572 | s->session=session; |
| 573 | s->verify_result = s->session->verify_result; | ||
| 421 | /* CRYPTO_w_unlock(CRYPTO_LOCK_SSL);*/ | 574 | /* CRYPTO_w_unlock(CRYPTO_LOCK_SSL);*/ |
| 422 | ret=1; | 575 | ret=1; |
| 423 | } | 576 | } |
| @@ -428,42 +581,59 @@ SSL_SESSION *session; | |||
| 428 | SSL_SESSION_free(s->session); | 581 | SSL_SESSION_free(s->session); |
| 429 | s->session=NULL; | 582 | s->session=NULL; |
| 430 | } | 583 | } |
| 584 | |||
| 585 | meth=s->ctx->method; | ||
| 586 | if (meth != s->method) | ||
| 587 | { | ||
| 588 | if (!SSL_set_ssl_method(s,meth)) | ||
| 589 | return(0); | ||
| 590 | } | ||
| 591 | ret=1; | ||
| 431 | } | 592 | } |
| 432 | return(ret); | 593 | return(ret); |
| 433 | } | 594 | } |
| 434 | 595 | ||
| 435 | long SSL_SESSION_set_timeout(s,t) | 596 | long SSL_SESSION_set_timeout(SSL_SESSION *s, long t) |
| 436 | SSL_SESSION *s; | ||
| 437 | long t; | ||
| 438 | { | 597 | { |
| 439 | if (s == NULL) return(0); | 598 | if (s == NULL) return(0); |
| 440 | s->timeout=t; | 599 | s->timeout=t; |
| 441 | return(1); | 600 | return(1); |
| 442 | } | 601 | } |
| 443 | 602 | ||
| 444 | long SSL_SESSION_get_timeout(s) | 603 | long SSL_SESSION_get_timeout(SSL_SESSION *s) |
| 445 | SSL_SESSION *s; | ||
| 446 | { | 604 | { |
| 447 | if (s == NULL) return(0); | 605 | if (s == NULL) return(0); |
| 448 | return(s->timeout); | 606 | return(s->timeout); |
| 449 | } | 607 | } |
| 450 | 608 | ||
| 451 | long SSL_SESSION_get_time(s) | 609 | long SSL_SESSION_get_time(SSL_SESSION *s) |
| 452 | SSL_SESSION *s; | ||
| 453 | { | 610 | { |
| 454 | if (s == NULL) return(0); | 611 | if (s == NULL) return(0); |
| 455 | return(s->time); | 612 | return(s->time); |
| 456 | } | 613 | } |
| 457 | 614 | ||
| 458 | long SSL_SESSION_set_time(s,t) | 615 | long SSL_SESSION_set_time(SSL_SESSION *s, long t) |
| 459 | SSL_SESSION *s; | ||
| 460 | long t; | ||
| 461 | { | 616 | { |
| 462 | if (s == NULL) return(0); | 617 | if (s == NULL) return(0); |
| 463 | s->time=t; | 618 | s->time=t; |
| 464 | return(t); | 619 | return(t); |
| 465 | } | 620 | } |
| 466 | 621 | ||
| 622 | long SSL_CTX_set_timeout(SSL_CTX *s, long t) | ||
| 623 | { | ||
| 624 | long l; | ||
| 625 | if (s == NULL) return(0); | ||
| 626 | l=s->session_timeout; | ||
| 627 | s->session_timeout=t; | ||
| 628 | return(l); | ||
| 629 | } | ||
| 630 | |||
| 631 | long SSL_CTX_get_timeout(SSL_CTX *s) | ||
| 632 | { | ||
| 633 | if (s == NULL) return(0); | ||
| 634 | return(s->session_timeout); | ||
| 635 | } | ||
| 636 | |||
| 467 | typedef struct timeout_param_st | 637 | typedef struct timeout_param_st |
| 468 | { | 638 | { |
| 469 | SSL_CTX *ctx; | 639 | SSL_CTX *ctx; |
| @@ -471,15 +641,13 @@ typedef struct timeout_param_st | |||
| 471 | LHASH *cache; | 641 | LHASH *cache; |
| 472 | } TIMEOUT_PARAM; | 642 | } TIMEOUT_PARAM; |
| 473 | 643 | ||
| 474 | static void timeout(s,p) | 644 | static void timeout(SSL_SESSION *s, TIMEOUT_PARAM *p) |
| 475 | SSL_SESSION *s; | ||
| 476 | TIMEOUT_PARAM *p; | ||
| 477 | { | 645 | { |
| 478 | if ((p->time == 0) || (p->time > (s->time+s->timeout))) /* timeout */ | 646 | if ((p->time == 0) || (p->time > (s->time+s->timeout))) /* timeout */ |
| 479 | { | 647 | { |
| 480 | /* The reason we don't call SSL_CTX_remove_session() is to | 648 | /* The reason we don't call SSL_CTX_remove_session() is to |
| 481 | * save on locking overhead */ | 649 | * save on locking overhead */ |
| 482 | lh_delete(p->cache,(char *)s); | 650 | lh_delete(p->cache,s); |
| 483 | SSL_SESSION_list_remove(p->ctx,s); | 651 | SSL_SESSION_list_remove(p->ctx,s); |
| 484 | s->not_resumable=1; | 652 | s->not_resumable=1; |
| 485 | if (p->ctx->remove_session_cb != NULL) | 653 | if (p->ctx->remove_session_cb != NULL) |
| @@ -488,27 +656,26 @@ TIMEOUT_PARAM *p; | |||
| 488 | } | 656 | } |
| 489 | } | 657 | } |
| 490 | 658 | ||
| 491 | void SSL_CTX_flush_sessions(s,t) | 659 | static IMPLEMENT_LHASH_DOALL_ARG_FN(timeout, SSL_SESSION *, TIMEOUT_PARAM *) |
| 492 | SSL_CTX *s; | 660 | |
| 493 | long t; | 661 | void SSL_CTX_flush_sessions(SSL_CTX *s, long t) |
| 494 | { | 662 | { |
| 495 | unsigned long i; | 663 | unsigned long i; |
| 496 | TIMEOUT_PARAM tp; | 664 | TIMEOUT_PARAM tp; |
| 497 | 665 | ||
| 498 | tp.ctx=s; | 666 | tp.ctx=s; |
| 499 | tp.cache=SSL_CTX_sessions(s); | 667 | tp.cache=s->sessions; |
| 500 | if (tp.cache == NULL) return; | 668 | if (tp.cache == NULL) return; |
| 501 | tp.time=t; | 669 | tp.time=t; |
| 502 | CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); | 670 | CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX); |
| 503 | i=tp.cache->down_load; | 671 | i=tp.cache->down_load; |
| 504 | tp.cache->down_load=0; | 672 | tp.cache->down_load=0; |
| 505 | lh_doall_arg(tp.cache,(void (*)())timeout,(char *)&tp); | 673 | lh_doall_arg(tp.cache, LHASH_DOALL_ARG_FN(timeout), &tp); |
| 506 | tp.cache->down_load=i; | 674 | tp.cache->down_load=i; |
| 507 | CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX); | 675 | CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX); |
| 508 | } | 676 | } |
| 509 | 677 | ||
| 510 | int ssl_clear_bad_session(s) | 678 | int ssl_clear_bad_session(SSL *s) |
| 511 | SSL *s; | ||
| 512 | { | 679 | { |
| 513 | if ( (s->session != NULL) && | 680 | if ( (s->session != NULL) && |
| 514 | !(s->shutdown & SSL_SENT_SHUTDOWN) && | 681 | !(s->shutdown & SSL_SENT_SHUTDOWN) && |
| @@ -522,9 +689,7 @@ SSL *s; | |||
| 522 | } | 689 | } |
| 523 | 690 | ||
| 524 | /* locked by SSL_CTX in the calling function */ | 691 | /* locked by SSL_CTX in the calling function */ |
| 525 | static void SSL_SESSION_list_remove(ctx,s) | 692 | static void SSL_SESSION_list_remove(SSL_CTX *ctx, SSL_SESSION *s) |
| 526 | SSL_CTX *ctx; | ||
| 527 | SSL_SESSION *s; | ||
| 528 | { | 693 | { |
| 529 | if ((s->next == NULL) || (s->prev == NULL)) return; | 694 | if ((s->next == NULL) || (s->prev == NULL)) return; |
| 530 | 695 | ||
| @@ -557,9 +722,7 @@ SSL_SESSION *s; | |||
| 557 | s->prev=s->next=NULL; | 722 | s->prev=s->next=NULL; |
| 558 | } | 723 | } |
| 559 | 724 | ||
| 560 | static void SSL_SESSION_list_add(ctx,s) | 725 | static void SSL_SESSION_list_add(SSL_CTX *ctx, SSL_SESSION *s) |
| 561 | SSL_CTX *ctx; | ||
| 562 | SSL_SESSION *s; | ||
| 563 | { | 726 | { |
| 564 | if ((s->next != NULL) && (s->prev != NULL)) | 727 | if ((s->next != NULL) && (s->prev != NULL)) |
| 565 | SSL_SESSION_list_remove(ctx,s); | 728 | SSL_SESSION_list_remove(ctx,s); |
diff --git a/src/lib/libssl/ssl_stat.c b/src/lib/libssl/ssl_stat.c index a1daf25dd4..b16d253081 100644 --- a/src/lib/libssl/ssl_stat.c +++ b/src/lib/libssl/ssl_stat.c | |||
| @@ -59,23 +59,22 @@ | |||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include "ssl_locl.h" | 60 | #include "ssl_locl.h" |
| 61 | 61 | ||
| 62 | char *SSL_state_string_long(s) | 62 | const char *SSL_state_string_long(const SSL *s) |
| 63 | SSL *s; | ||
| 64 | { | 63 | { |
| 65 | char *str; | 64 | const char *str; |
| 66 | 65 | ||
| 67 | switch (s->state) | 66 | switch (s->state) |
| 68 | { | 67 | { |
| 69 | case SSL_ST_BEFORE: str="before SSL initalisation"; break; | 68 | case SSL_ST_BEFORE: str="before SSL initialization"; break; |
| 70 | case SSL_ST_ACCEPT: str="before accept initalisation"; break; | 69 | case SSL_ST_ACCEPT: str="before accept initialization"; break; |
| 71 | case SSL_ST_CONNECT: str="before connect initalisation"; break; | 70 | case SSL_ST_CONNECT: str="before connect initialization"; break; |
| 72 | case SSL_ST_OK: str="SSL negotiation finished successfully"; break; | 71 | case SSL_ST_OK: str="SSL negotiation finished successfully"; break; |
| 73 | case SSL_ST_RENEGOTIATE: str="SSL renegotiate ciphers"; break; | 72 | case SSL_ST_RENEGOTIATE: str="SSL renegotiate ciphers"; break; |
| 74 | case SSL_ST_BEFORE|SSL_ST_CONNECT: str="before/connect initalisation"; break; | 73 | case SSL_ST_BEFORE|SSL_ST_CONNECT: str="before/connect initialization"; break; |
| 75 | case SSL_ST_OK|SSL_ST_CONNECT: str="ok/connect SSL initalisation"; break; | 74 | case SSL_ST_OK|SSL_ST_CONNECT: str="ok/connect SSL initialization"; break; |
| 76 | case SSL_ST_BEFORE|SSL_ST_ACCEPT: str="before/accept initalisation"; break; | 75 | case SSL_ST_BEFORE|SSL_ST_ACCEPT: str="before/accept initialization"; break; |
| 77 | case SSL_ST_OK|SSL_ST_ACCEPT: str="ok/accept SSL initalisation"; break; | 76 | case SSL_ST_OK|SSL_ST_ACCEPT: str="ok/accept SSL initialization"; break; |
| 78 | #ifndef NO_SSL2 | 77 | #ifndef OPENSSL_NO_SSL2 |
| 79 | case SSL2_ST_CLIENT_START_ENCRYPTION: str="SSLv2 client start encryption"; break; | 78 | case SSL2_ST_CLIENT_START_ENCRYPTION: str="SSLv2 client start encryption"; break; |
| 80 | case SSL2_ST_SERVER_START_ENCRYPTION: str="SSLv2 server start encryption"; break; | 79 | case SSL2_ST_SERVER_START_ENCRYPTION: str="SSLv2 server start encryption"; break; |
| 81 | case SSL2_ST_SEND_CLIENT_HELLO_A: str="SSLv2 write client hello A"; break; | 80 | case SSL2_ST_SEND_CLIENT_HELLO_A: str="SSLv2 write client hello A"; break; |
| @@ -116,7 +115,7 @@ case SSL2_ST_X509_GET_SERVER_CERTIFICATE: str="SSLv2 X509 read server certificat | |||
| 116 | case SSL2_ST_X509_GET_CLIENT_CERTIFICATE: str="SSLv2 X509 read client certificate"; break; | 115 | case SSL2_ST_X509_GET_CLIENT_CERTIFICATE: str="SSLv2 X509 read client certificate"; break; |
| 117 | #endif | 116 | #endif |
| 118 | 117 | ||
| 119 | #ifndef NO_SSL3 | 118 | #ifndef OPENSSL_NO_SSL3 |
| 120 | /* SSLv3 additions */ | 119 | /* SSLv3 additions */ |
| 121 | case SSL3_ST_CW_CLNT_HELLO_A: str="SSLv3 write client hello A"; break; | 120 | case SSL3_ST_CW_CLNT_HELLO_A: str="SSLv3 write client hello A"; break; |
| 122 | case SSL3_ST_CW_CLNT_HELLO_B: str="SSLv3 write client hello B"; break; | 121 | case SSL3_ST_CW_CLNT_HELLO_B: str="SSLv3 write client hello B"; break; |
| @@ -132,10 +131,12 @@ case SSL3_ST_CR_SRVR_DONE_A: str="SSLv3 read server done A"; break; | |||
| 132 | case SSL3_ST_CR_SRVR_DONE_B: str="SSLv3 read server done B"; break; | 131 | case SSL3_ST_CR_SRVR_DONE_B: str="SSLv3 read server done B"; break; |
| 133 | case SSL3_ST_CW_CERT_A: str="SSLv3 write client certificate A"; break; | 132 | case SSL3_ST_CW_CERT_A: str="SSLv3 write client certificate A"; break; |
| 134 | case SSL3_ST_CW_CERT_B: str="SSLv3 write client certificate B"; break; | 133 | case SSL3_ST_CW_CERT_B: str="SSLv3 write client certificate B"; break; |
| 134 | case SSL3_ST_CW_CERT_C: str="SSLv3 write client certificate C"; break; | ||
| 135 | case SSL3_ST_CW_CERT_D: str="SSLv3 write client certificate D"; break; | ||
| 135 | case SSL3_ST_CW_KEY_EXCH_A: str="SSLv3 write client key exchange A"; break; | 136 | case SSL3_ST_CW_KEY_EXCH_A: str="SSLv3 write client key exchange A"; break; |
| 136 | case SSL3_ST_CW_KEY_EXCH_B: str="SSLv3 write client key exchange B"; break; | 137 | case SSL3_ST_CW_KEY_EXCH_B: str="SSLv3 write client key exchange B"; break; |
| 137 | case SSL3_ST_CW_CERT_VRFY_A: str="SSLv3 write certificate verify A"; break; | 138 | case SSL3_ST_CW_CERT_VRFY_A: str="SSLv3 write certificate verify A"; break; |
| 138 | case SSL3_ST_CW_CERT_VRFY_B: str="SSLv3 write certificate verify A"; break; | 139 | case SSL3_ST_CW_CERT_VRFY_B: str="SSLv3 write certificate verify B"; break; |
| 139 | 140 | ||
| 140 | case SSL3_ST_CW_CHANGE_A: | 141 | case SSL3_ST_CW_CHANGE_A: |
| 141 | case SSL3_ST_SW_CHANGE_A: str="SSLv3 write change cipher spec A"; break; | 142 | case SSL3_ST_SW_CHANGE_A: str="SSLv3 write change cipher spec A"; break; |
| @@ -144,7 +145,7 @@ case SSL3_ST_SW_CHANGE_B: str="SSLv3 write change cipher spec B"; break; | |||
| 144 | case SSL3_ST_CW_FINISHED_A: | 145 | case SSL3_ST_CW_FINISHED_A: |
| 145 | case SSL3_ST_SW_FINISHED_A: str="SSLv3 write finished A"; break; | 146 | case SSL3_ST_SW_FINISHED_A: str="SSLv3 write finished A"; break; |
| 146 | case SSL3_ST_CW_FINISHED_B: | 147 | case SSL3_ST_CW_FINISHED_B: |
| 147 | case SSL3_ST_SW_FINISHED_B: str="SSLv3 write finished A"; break; | 148 | case SSL3_ST_SW_FINISHED_B: str="SSLv3 write finished B"; break; |
| 148 | case SSL3_ST_CR_CHANGE_A: | 149 | case SSL3_ST_CR_CHANGE_A: |
| 149 | case SSL3_ST_SR_CHANGE_A: str="SSLv3 read change cipher spec A"; break; | 150 | case SSL3_ST_SR_CHANGE_A: str="SSLv3 read change cipher spec A"; break; |
| 150 | case SSL3_ST_CR_CHANGE_B: | 151 | case SSL3_ST_CR_CHANGE_B: |
| @@ -181,8 +182,8 @@ case SSL3_ST_SR_CERT_VRFY_A: str="SSLv3 read certificate verify A"; break; | |||
| 181 | case SSL3_ST_SR_CERT_VRFY_B: str="SSLv3 read certificate verify B"; break; | 182 | case SSL3_ST_SR_CERT_VRFY_B: str="SSLv3 read certificate verify B"; break; |
| 182 | #endif | 183 | #endif |
| 183 | 184 | ||
| 184 | #if !defined(NO_SSL2) && !defined(NO_SSL3) | 185 | #if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3) |
| 185 | /* SSLv2/v3 compatablitity states */ | 186 | /* SSLv2/v3 compatibility states */ |
| 186 | /* client */ | 187 | /* client */ |
| 187 | case SSL23_ST_CW_CLNT_HELLO_A: str="SSLv2/v3 write client hello A"; break; | 188 | case SSL23_ST_CW_CLNT_HELLO_A: str="SSLv2/v3 write client hello A"; break; |
| 188 | case SSL23_ST_CW_CLNT_HELLO_B: str="SSLv2/v3 write client hello B"; break; | 189 | case SSL23_ST_CW_CLNT_HELLO_B: str="SSLv2/v3 write client hello B"; break; |
| @@ -198,10 +199,9 @@ default: str="unknown state"; break; | |||
| 198 | return(str); | 199 | return(str); |
| 199 | } | 200 | } |
| 200 | 201 | ||
| 201 | char *SSL_rstate_string_long(s) | 202 | const char *SSL_rstate_string_long(const SSL *s) |
| 202 | SSL *s; | ||
| 203 | { | 203 | { |
| 204 | char *str; | 204 | const char *str; |
| 205 | 205 | ||
| 206 | switch (s->rstate) | 206 | switch (s->rstate) |
| 207 | { | 207 | { |
| @@ -213,10 +213,9 @@ SSL *s; | |||
| 213 | return(str); | 213 | return(str); |
| 214 | } | 214 | } |
| 215 | 215 | ||
| 216 | char *SSL_state_string(s) | 216 | const char *SSL_state_string(const SSL *s) |
| 217 | SSL *s; | ||
| 218 | { | 217 | { |
| 219 | char *str; | 218 | const char *str; |
| 220 | 219 | ||
| 221 | switch (s->state) | 220 | switch (s->state) |
| 222 | { | 221 | { |
| @@ -224,7 +223,7 @@ case SSL_ST_BEFORE: str="PINIT "; break; | |||
| 224 | case SSL_ST_ACCEPT: str="AINIT "; break; | 223 | case SSL_ST_ACCEPT: str="AINIT "; break; |
| 225 | case SSL_ST_CONNECT: str="CINIT "; break; | 224 | case SSL_ST_CONNECT: str="CINIT "; break; |
| 226 | case SSL_ST_OK: str="SSLOK "; break; | 225 | case SSL_ST_OK: str="SSLOK "; break; |
| 227 | #ifndef NO_SSL2 | 226 | #ifndef OPENSSL_NO_SSL2 |
| 228 | case SSL2_ST_CLIENT_START_ENCRYPTION: str="2CSENC"; break; | 227 | case SSL2_ST_CLIENT_START_ENCRYPTION: str="2CSENC"; break; |
| 229 | case SSL2_ST_SERVER_START_ENCRYPTION: str="2SSENC"; break; | 228 | case SSL2_ST_SERVER_START_ENCRYPTION: str="2SSENC"; break; |
| 230 | case SSL2_ST_SEND_CLIENT_HELLO_A: str="2SCH_A"; break; | 229 | case SSL2_ST_SEND_CLIENT_HELLO_A: str="2SCH_A"; break; |
| @@ -265,7 +264,7 @@ case SSL2_ST_X509_GET_SERVER_CERTIFICATE: str="2X9GSC"; break; | |||
| 265 | case SSL2_ST_X509_GET_CLIENT_CERTIFICATE: str="2X9GCC"; break; | 264 | case SSL2_ST_X509_GET_CLIENT_CERTIFICATE: str="2X9GCC"; break; |
| 266 | #endif | 265 | #endif |
| 267 | 266 | ||
| 268 | #ifndef NO_SSL3 | 267 | #ifndef OPENSSL_NO_SSL3 |
| 269 | /* SSLv3 additions */ | 268 | /* SSLv3 additions */ |
| 270 | case SSL3_ST_SW_FLUSH: | 269 | case SSL3_ST_SW_FLUSH: |
| 271 | case SSL3_ST_CW_FLUSH: str="3FLUSH"; break; | 270 | case SSL3_ST_CW_FLUSH: str="3FLUSH"; break; |
| @@ -283,6 +282,8 @@ case SSL3_ST_CR_SRVR_DONE_A: str="3RSD_A"; break; | |||
| 283 | case SSL3_ST_CR_SRVR_DONE_B: str="3RSD_B"; break; | 282 | case SSL3_ST_CR_SRVR_DONE_B: str="3RSD_B"; break; |
| 284 | case SSL3_ST_CW_CERT_A: str="3WCC_A"; break; | 283 | case SSL3_ST_CW_CERT_A: str="3WCC_A"; break; |
| 285 | case SSL3_ST_CW_CERT_B: str="3WCC_B"; break; | 284 | case SSL3_ST_CW_CERT_B: str="3WCC_B"; break; |
| 285 | case SSL3_ST_CW_CERT_C: str="3WCC_C"; break; | ||
| 286 | case SSL3_ST_CW_CERT_D: str="3WCC_D"; break; | ||
| 286 | case SSL3_ST_CW_KEY_EXCH_A: str="3WCKEA"; break; | 287 | case SSL3_ST_CW_KEY_EXCH_A: str="3WCKEA"; break; |
| 287 | case SSL3_ST_CW_KEY_EXCH_B: str="3WCKEB"; break; | 288 | case SSL3_ST_CW_KEY_EXCH_B: str="3WCKEB"; break; |
| 288 | case SSL3_ST_CW_CERT_VRFY_A: str="3WCV_A"; break; | 289 | case SSL3_ST_CW_CERT_VRFY_A: str="3WCV_A"; break; |
| @@ -329,8 +330,8 @@ case SSL3_ST_SR_CERT_VRFY_A: str="3RCV_A"; break; | |||
| 329 | case SSL3_ST_SR_CERT_VRFY_B: str="3RCV_B"; break; | 330 | case SSL3_ST_SR_CERT_VRFY_B: str="3RCV_B"; break; |
| 330 | #endif | 331 | #endif |
| 331 | 332 | ||
| 332 | #if !defined(NO_SSL2) && !defined(NO_SSL3) | 333 | #if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3) |
| 333 | /* SSLv2/v3 compatablitity states */ | 334 | /* SSLv2/v3 compatibility states */ |
| 334 | /* client */ | 335 | /* client */ |
| 335 | case SSL23_ST_CW_CLNT_HELLO_A: str="23WCHA"; break; | 336 | case SSL23_ST_CW_CLNT_HELLO_A: str="23WCHA"; break; |
| 336 | case SSL23_ST_CW_CLNT_HELLO_B: str="23WCHB"; break; | 337 | case SSL23_ST_CW_CLNT_HELLO_B: str="23WCHB"; break; |
| @@ -346,8 +347,7 @@ default: str="UNKWN "; break; | |||
| 346 | return(str); | 347 | return(str); |
| 347 | } | 348 | } |
| 348 | 349 | ||
| 349 | char *SSL_alert_type_string_long(value) | 350 | const char *SSL_alert_type_string_long(int value) |
| 350 | int value; | ||
| 351 | { | 351 | { |
| 352 | value>>=8; | 352 | value>>=8; |
| 353 | if (value == SSL3_AL_WARNING) | 353 | if (value == SSL3_AL_WARNING) |
| @@ -358,8 +358,7 @@ int value; | |||
| 358 | return("unknown"); | 358 | return("unknown"); |
| 359 | } | 359 | } |
| 360 | 360 | ||
| 361 | char *SSL_alert_type_string(value) | 361 | const char *SSL_alert_type_string(int value) |
| 362 | int value; | ||
| 363 | { | 362 | { |
| 364 | value>>=8; | 363 | value>>=8; |
| 365 | if (value == SSL3_AL_WARNING) | 364 | if (value == SSL3_AL_WARNING) |
| @@ -370,10 +369,9 @@ int value; | |||
| 370 | return("U"); | 369 | return("U"); |
| 371 | } | 370 | } |
| 372 | 371 | ||
| 373 | char *SSL_alert_desc_string(value) | 372 | const char *SSL_alert_desc_string(int value) |
| 374 | int value; | ||
| 375 | { | 373 | { |
| 376 | char *str; | 374 | const char *str; |
| 377 | 375 | ||
| 378 | switch (value & 0xff) | 376 | switch (value & 0xff) |
| 379 | { | 377 | { |
| @@ -389,15 +387,26 @@ int value; | |||
| 389 | case SSL3_AD_CERTIFICATE_EXPIRED: str="CE"; break; | 387 | case SSL3_AD_CERTIFICATE_EXPIRED: str="CE"; break; |
| 390 | case SSL3_AD_CERTIFICATE_UNKNOWN: str="CU"; break; | 388 | case SSL3_AD_CERTIFICATE_UNKNOWN: str="CU"; break; |
| 391 | case SSL3_AD_ILLEGAL_PARAMETER: str="IP"; break; | 389 | case SSL3_AD_ILLEGAL_PARAMETER: str="IP"; break; |
| 390 | case TLS1_AD_DECRYPTION_FAILED: str="DC"; break; | ||
| 391 | case TLS1_AD_RECORD_OVERFLOW: str="RO"; break; | ||
| 392 | case TLS1_AD_UNKNOWN_CA: str="CA"; break; | ||
| 393 | case TLS1_AD_ACCESS_DENIED: str="AD"; break; | ||
| 394 | case TLS1_AD_DECODE_ERROR: str="DE"; break; | ||
| 395 | case TLS1_AD_DECRYPT_ERROR: str="CY"; break; | ||
| 396 | case TLS1_AD_EXPORT_RESTRICTION: str="ER"; break; | ||
| 397 | case TLS1_AD_PROTOCOL_VERSION: str="PV"; break; | ||
| 398 | case TLS1_AD_INSUFFICIENT_SECURITY: str="IS"; break; | ||
| 399 | case TLS1_AD_INTERNAL_ERROR: str="IE"; break; | ||
| 400 | case TLS1_AD_USER_CANCELLED: str="US"; break; | ||
| 401 | case TLS1_AD_NO_RENEGOTIATION: str="NR"; break; | ||
| 392 | default: str="UK"; break; | 402 | default: str="UK"; break; |
| 393 | } | 403 | } |
| 394 | return(str); | 404 | return(str); |
| 395 | } | 405 | } |
| 396 | 406 | ||
| 397 | char *SSL_alert_desc_string_long(value) | 407 | const char *SSL_alert_desc_string_long(int value) |
| 398 | int value; | ||
| 399 | { | 408 | { |
| 400 | char *str; | 409 | const char *str; |
| 401 | 410 | ||
| 402 | switch (value & 0xff) | 411 | switch (value & 0xff) |
| 403 | { | 412 | { |
| @@ -405,7 +414,7 @@ int value; | |||
| 405 | str="close notify"; | 414 | str="close notify"; |
| 406 | break; | 415 | break; |
| 407 | case SSL3_AD_UNEXPECTED_MESSAGE: | 416 | case SSL3_AD_UNEXPECTED_MESSAGE: |
| 408 | str="unexected_message"; | 417 | str="unexpected_message"; |
| 409 | break; | 418 | break; |
| 410 | case SSL3_AD_BAD_RECORD_MAC: | 419 | case SSL3_AD_BAD_RECORD_MAC: |
| 411 | str="bad record mac"; | 420 | str="bad record mac"; |
| @@ -432,20 +441,55 @@ int value; | |||
| 432 | str="certificate expired"; | 441 | str="certificate expired"; |
| 433 | break; | 442 | break; |
| 434 | case SSL3_AD_CERTIFICATE_UNKNOWN: | 443 | case SSL3_AD_CERTIFICATE_UNKNOWN: |
| 435 | str="certifcate unknown"; | 444 | str="certificate unknown"; |
| 436 | break; | 445 | break; |
| 437 | case SSL3_AD_ILLEGAL_PARAMETER: | 446 | case SSL3_AD_ILLEGAL_PARAMETER: |
| 438 | str="illegal parameter"; | 447 | str="illegal parameter"; |
| 439 | break; | 448 | break; |
| 449 | case TLS1_AD_DECRYPTION_FAILED: | ||
| 450 | str="decryption failed"; | ||
| 451 | break; | ||
| 452 | case TLS1_AD_RECORD_OVERFLOW: | ||
| 453 | str="record overflow"; | ||
| 454 | break; | ||
| 455 | case TLS1_AD_UNKNOWN_CA: | ||
| 456 | str="unknown CA"; | ||
| 457 | break; | ||
| 458 | case TLS1_AD_ACCESS_DENIED: | ||
| 459 | str="access denied"; | ||
| 460 | break; | ||
| 461 | case TLS1_AD_DECODE_ERROR: | ||
| 462 | str="decode error"; | ||
| 463 | break; | ||
| 464 | case TLS1_AD_DECRYPT_ERROR: | ||
| 465 | str="decrypt error"; | ||
| 466 | break; | ||
| 467 | case TLS1_AD_EXPORT_RESTRICTION: | ||
| 468 | str="export restriction"; | ||
| 469 | break; | ||
| 470 | case TLS1_AD_PROTOCOL_VERSION: | ||
| 471 | str="protocol version"; | ||
| 472 | break; | ||
| 473 | case TLS1_AD_INSUFFICIENT_SECURITY: | ||
| 474 | str="insufficient security"; | ||
| 475 | break; | ||
| 476 | case TLS1_AD_INTERNAL_ERROR: | ||
| 477 | str="internal error"; | ||
| 478 | break; | ||
| 479 | case TLS1_AD_USER_CANCELLED: | ||
| 480 | str="user canceled"; | ||
| 481 | break; | ||
| 482 | case TLS1_AD_NO_RENEGOTIATION: | ||
| 483 | str="no renegotiation"; | ||
| 484 | break; | ||
| 440 | default: str="unknown"; break; | 485 | default: str="unknown"; break; |
| 441 | } | 486 | } |
| 442 | return(str); | 487 | return(str); |
| 443 | } | 488 | } |
| 444 | 489 | ||
| 445 | char *SSL_rstate_string(s) | 490 | const char *SSL_rstate_string(const SSL *s) |
| 446 | SSL *s; | ||
| 447 | { | 491 | { |
| 448 | char *str; | 492 | const char *str; |
| 449 | 493 | ||
| 450 | switch (s->rstate) | 494 | switch (s->rstate) |
| 451 | { | 495 | { |
diff --git a/src/lib/libssl/ssl_txt.c b/src/lib/libssl/ssl_txt.c index ce60e1a6dd..40b76b1b26 100644 --- a/src/lib/libssl/ssl_txt.c +++ b/src/lib/libssl/ssl_txt.c | |||
| @@ -57,35 +57,31 @@ | |||
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include "buffer.h" | 60 | #include <openssl/buffer.h> |
| 61 | #include "ssl_locl.h" | 61 | #include "ssl_locl.h" |
| 62 | 62 | ||
| 63 | #ifndef NO_FP_API | 63 | #ifndef OPENSSL_NO_FP_API |
| 64 | int SSL_SESSION_print_fp(fp, x) | 64 | int SSL_SESSION_print_fp(FILE *fp, SSL_SESSION *x) |
| 65 | FILE *fp; | 65 | { |
| 66 | SSL_SESSION *x; | 66 | BIO *b; |
| 67 | { | 67 | int ret; |
| 68 | BIO *b; | ||
| 69 | int ret; | ||
| 70 | 68 | ||
| 71 | if ((b=BIO_new(BIO_s_file_internal())) == NULL) | 69 | if ((b=BIO_new(BIO_s_file_internal())) == NULL) |
| 72 | { | 70 | { |
| 73 | SSLerr(SSL_F_SSL_SESSION_PRINT_FP,ERR_R_BUF_LIB); | 71 | SSLerr(SSL_F_SSL_SESSION_PRINT_FP,ERR_R_BUF_LIB); |
| 74 | return(0); | 72 | return(0); |
| 75 | } | 73 | } |
| 76 | BIO_set_fp(b,fp,BIO_NOCLOSE); | 74 | BIO_set_fp(b,fp,BIO_NOCLOSE); |
| 77 | ret=SSL_SESSION_print(b,x); | 75 | ret=SSL_SESSION_print(b,x); |
| 78 | BIO_free(b); | 76 | BIO_free(b); |
| 79 | return(ret); | 77 | return(ret); |
| 80 | } | 78 | } |
| 81 | #endif | 79 | #endif |
| 82 | 80 | ||
| 83 | int SSL_SESSION_print(bp,x) | 81 | int SSL_SESSION_print(BIO *bp, SSL_SESSION *x) |
| 84 | BIO *bp; | ||
| 85 | SSL_SESSION *x; | ||
| 86 | { | 82 | { |
| 87 | int i; | 83 | unsigned int i; |
| 88 | char str[128],*s; | 84 | char *s; |
| 89 | 85 | ||
| 90 | if (x == NULL) goto err; | 86 | if (x == NULL) goto err; |
| 91 | if (BIO_puts(bp,"SSL-Session:\n") <= 0) goto err; | 87 | if (BIO_puts(bp,"SSL-Session:\n") <= 0) goto err; |
| @@ -97,30 +93,41 @@ SSL_SESSION *x; | |||
| 97 | s="TLSv1"; | 93 | s="TLSv1"; |
| 98 | else | 94 | else |
| 99 | s="unknown"; | 95 | s="unknown"; |
| 100 | sprintf(str," Protocol : %s\n",s); | 96 | if (BIO_printf(bp," Protocol : %s\n",s) <= 0) goto err; |
| 101 | if (BIO_puts(bp,str) <= 0) goto err; | ||
| 102 | 97 | ||
| 103 | if (x->cipher == NULL) | 98 | if (x->cipher == NULL) |
| 104 | { | 99 | { |
| 105 | if (((x->cipher_id) & 0xff000000) == 0x02000000) | 100 | if (((x->cipher_id) & 0xff000000) == 0x02000000) |
| 106 | sprintf(str," Cipher : %06lX\n",x->cipher_id&0xffffff); | 101 | { |
| 102 | if (BIO_printf(bp," Cipher : %06lX\n",x->cipher_id&0xffffff) <= 0) | ||
| 103 | goto err; | ||
| 104 | } | ||
| 107 | else | 105 | else |
| 108 | sprintf(str," Cipher : %04lX\n",x->cipher_id&0xffff); | 106 | { |
| 107 | if (BIO_printf(bp," Cipher : %04lX\n",x->cipher_id&0xffff) <= 0) | ||
| 108 | goto err; | ||
| 109 | } | ||
| 109 | } | 110 | } |
| 110 | else | 111 | else |
| 111 | sprintf(str," Cipher : %s\n",(x->cipher == NULL)?"unknown":x->cipher->name); | 112 | { |
| 112 | if (BIO_puts(bp,str) <= 0) goto err; | 113 | if (BIO_printf(bp," Cipher : %s\n",((x->cipher == NULL)?"unknown":x->cipher->name)) <= 0) |
| 114 | goto err; | ||
| 115 | } | ||
| 113 | if (BIO_puts(bp," Session-ID: ") <= 0) goto err; | 116 | if (BIO_puts(bp," Session-ID: ") <= 0) goto err; |
| 114 | for (i=0; i<(int)x->session_id_length; i++) | 117 | for (i=0; i<x->session_id_length; i++) |
| 118 | { | ||
| 119 | if (BIO_printf(bp,"%02X",x->session_id[i]) <= 0) goto err; | ||
| 120 | } | ||
| 121 | if (BIO_puts(bp,"\n Session-ID-ctx: ") <= 0) goto err; | ||
| 122 | for (i=0; i<x->sid_ctx_length; i++) | ||
| 115 | { | 123 | { |
| 116 | sprintf(str,"%02X",x->session_id[i]); | 124 | if (BIO_printf(bp,"%02X",x->sid_ctx[i]) <= 0) |
| 117 | if (BIO_puts(bp,str) <= 0) goto err; | 125 | goto err; |
| 118 | } | 126 | } |
| 119 | if (BIO_puts(bp,"\n Master-Key: ") <= 0) goto err; | 127 | if (BIO_puts(bp,"\n Master-Key: ") <= 0) goto err; |
| 120 | for (i=0; i<(int)x->master_key_length; i++) | 128 | for (i=0; i<(unsigned int)x->master_key_length; i++) |
| 121 | { | 129 | { |
| 122 | sprintf(str,"%02X",x->master_key[i]); | 130 | if (BIO_printf(bp,"%02X",x->master_key[i]) <= 0) goto err; |
| 123 | if (BIO_puts(bp,str) <= 0) goto err; | ||
| 124 | } | 131 | } |
| 125 | if (BIO_puts(bp,"\n Key-Arg : ") <= 0) goto err; | 132 | if (BIO_puts(bp,"\n Key-Arg : ") <= 0) goto err; |
| 126 | if (x->key_arg_length == 0) | 133 | if (x->key_arg_length == 0) |
| @@ -128,22 +135,49 @@ SSL_SESSION *x; | |||
| 128 | if (BIO_puts(bp,"None") <= 0) goto err; | 135 | if (BIO_puts(bp,"None") <= 0) goto err; |
| 129 | } | 136 | } |
| 130 | else | 137 | else |
| 131 | for (i=0; i<(int)x->key_arg_length; i++) | 138 | for (i=0; i<x->key_arg_length; i++) |
| 132 | { | 139 | { |
| 133 | sprintf(str,"%02X",x->key_arg[i]); | 140 | if (BIO_printf(bp,"%02X",x->key_arg[i]) <= 0) goto err; |
| 134 | if (BIO_puts(bp,str) <= 0) goto err; | ||
| 135 | } | 141 | } |
| 142 | #ifndef OPENSSL_NO_KRB5 | ||
| 143 | if (BIO_puts(bp,"\n Krb5 Principal: ") <= 0) goto err; | ||
| 144 | if (x->krb5_client_princ_len == 0) | ||
| 145 | { | ||
| 146 | if (BIO_puts(bp,"None") <= 0) goto err; | ||
| 147 | } | ||
| 148 | else | ||
| 149 | for (i=0; i<x->krb5_client_princ_len; i++) | ||
| 150 | { | ||
| 151 | if (BIO_printf(bp,"%02X",x->krb5_client_princ[i]) <= 0) goto err; | ||
| 152 | } | ||
| 153 | #endif /* OPENSSL_NO_KRB5 */ | ||
| 154 | if (x->compress_meth != 0) | ||
| 155 | { | ||
| 156 | SSL_COMP *comp; | ||
| 157 | |||
| 158 | ssl_cipher_get_evp(x,NULL,NULL,&comp); | ||
| 159 | if (comp == NULL) | ||
| 160 | { | ||
| 161 | if (BIO_printf(bp,"\n Compression: %d",x->compress_meth) <= 0) goto err; | ||
| 162 | } | ||
| 163 | else | ||
| 164 | { | ||
| 165 | if (BIO_printf(bp,"\n Compression: %d (%s)", comp->id,comp->method->name) <= 0) goto err; | ||
| 166 | } | ||
| 167 | } | ||
| 136 | if (x->time != 0L) | 168 | if (x->time != 0L) |
| 137 | { | 169 | { |
| 138 | sprintf(str,"\n Start Time: %ld",x->time); | 170 | if (BIO_printf(bp, "\n Start Time: %ld",x->time) <= 0) goto err; |
| 139 | if (BIO_puts(bp,str) <= 0) goto err; | ||
| 140 | } | 171 | } |
| 141 | if (x->timeout != 0L) | 172 | if (x->timeout != 0L) |
| 142 | { | 173 | { |
| 143 | sprintf(str,"\n Timeout : %ld (sec)",x->timeout); | 174 | if (BIO_printf(bp, "\n Timeout : %ld (sec)",x->timeout) <= 0) goto err; |
| 144 | if (BIO_puts(bp,str) <= 0) goto err; | ||
| 145 | } | 175 | } |
| 146 | if (BIO_puts(bp,"\n") <= 0) goto err; | 176 | if (BIO_puts(bp,"\n") <= 0) goto err; |
| 177 | |||
| 178 | if (BIO_puts(bp, " Verify return code: ") <= 0) goto err; | ||
| 179 | if (BIO_printf(bp, "%ld (%s)\n", x->verify_result, | ||
| 180 | X509_verify_cert_error_string(x->verify_result)) <= 0) goto err; | ||
| 147 | 181 | ||
| 148 | return(1); | 182 | return(1); |
| 149 | err: | 183 | err: |
diff --git a/src/lib/libssl/t1_clnt.c b/src/lib/libssl/t1_clnt.c index 986d2436e2..9745630a00 100644 --- a/src/lib/libssl/t1_clnt.c +++ b/src/lib/libssl/t1_clnt.c | |||
| @@ -57,14 +57,14 @@ | |||
| 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 | static SSL_METHOD *tls1_get_client_method(ver) | 66 | static SSL_METHOD *tls1_get_client_method(int ver); |
| 67 | int ver; | 67 | static SSL_METHOD *tls1_get_client_method(int ver) |
| 68 | { | 68 | { |
| 69 | if (ver == TLS1_VERSION) | 69 | if (ver == TLS1_VERSION) |
| 70 | return(TLSv1_client_method()); | 70 | return(TLSv1_client_method()); |
| @@ -72,18 +72,18 @@ int ver; | |||
| 72 | return(NULL); | 72 | return(NULL); |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | SSL_METHOD *TLSv1_client_method() | 75 | SSL_METHOD *TLSv1_client_method(void) |
| 76 | { | 76 | { |
| 77 | static int init=1; | 77 | static int init=1; |
| 78 | static SSL_METHOD TLSv1_client_data; | 78 | static SSL_METHOD TLSv1_client_data; |
| 79 | 79 | ||
| 80 | if (init) | 80 | if (init) |
| 81 | { | 81 | { |
| 82 | init=0; | ||
| 83 | memcpy((char *)&TLSv1_client_data,(char *)tlsv1_base_method(), | 82 | memcpy((char *)&TLSv1_client_data,(char *)tlsv1_base_method(), |
| 84 | sizeof(SSL_METHOD)); | 83 | sizeof(SSL_METHOD)); |
| 85 | TLSv1_client_data.ssl_connect=ssl3_connect; | 84 | TLSv1_client_data.ssl_connect=ssl3_connect; |
| 86 | TLSv1_client_data.get_ssl_method=tls1_get_client_method; | 85 | TLSv1_client_data.get_ssl_method=tls1_get_client_method; |
| 86 | init=0; | ||
| 87 | } | 87 | } |
| 88 | return(&TLSv1_client_data); | 88 | return(&TLSv1_client_data); |
| 89 | } | 89 | } |
diff --git a/src/lib/libssl/t1_enc.c b/src/lib/libssl/t1_enc.c index fbdd3bffb5..b80525f3ba 100644 --- a/src/lib/libssl/t1_enc.c +++ b/src/lib/libssl/t1_enc.c | |||
| @@ -55,20 +55,70 @@ | |||
| 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 | ||
| 59 | #include <stdio.h> | 112 | #include <stdio.h> |
| 60 | #include "evp.h" | 113 | #include <openssl/comp.h> |
| 61 | #include "hmac.h" | 114 | #include <openssl/evp.h> |
| 115 | #include <openssl/hmac.h> | ||
| 62 | #include "ssl_locl.h" | 116 | #include "ssl_locl.h" |
| 117 | #include <openssl/md5.h> | ||
| 63 | 118 | ||
| 64 | static void tls1_P_hash(md,sec,sec_len,seed,seed_len,out,olen) | 119 | static void tls1_P_hash(const EVP_MD *md, const unsigned char *sec, |
| 65 | EVP_MD *md; | 120 | int sec_len, unsigned char *seed, int seed_len, |
| 66 | unsigned char *sec; | 121 | unsigned char *out, int olen) |
| 67 | int sec_len; | ||
| 68 | unsigned char *seed; | ||
| 69 | int seed_len; | ||
| 70 | unsigned char *out; | ||
| 71 | int olen; | ||
| 72 | { | 122 | { |
| 73 | int chunk,n; | 123 | int chunk,n; |
| 74 | unsigned int j; | 124 | unsigned int j; |
| @@ -79,16 +129,20 @@ int olen; | |||
| 79 | 129 | ||
| 80 | chunk=EVP_MD_size(md); | 130 | chunk=EVP_MD_size(md); |
| 81 | 131 | ||
| 82 | HMAC_Init(&ctx,sec,sec_len,md); | 132 | HMAC_CTX_init(&ctx); |
| 133 | HMAC_CTX_init(&ctx_tmp); | ||
| 134 | HMAC_Init_ex(&ctx,sec,sec_len,md, NULL); | ||
| 135 | HMAC_Init_ex(&ctx_tmp,sec,sec_len,md, NULL); | ||
| 83 | HMAC_Update(&ctx,seed,seed_len); | 136 | HMAC_Update(&ctx,seed,seed_len); |
| 84 | HMAC_Final(&ctx,A1,&A1_len); | 137 | HMAC_Final(&ctx,A1,&A1_len); |
| 85 | 138 | ||
| 86 | n=0; | 139 | n=0; |
| 87 | for (;;) | 140 | for (;;) |
| 88 | { | 141 | { |
| 89 | HMAC_Init(&ctx,NULL,0,NULL); /* re-init */ | 142 | HMAC_Init_ex(&ctx,NULL,0,NULL,NULL); /* re-init */ |
| 143 | HMAC_Init_ex(&ctx_tmp,NULL,0,NULL,NULL); /* re-init */ | ||
| 90 | HMAC_Update(&ctx,A1,A1_len); | 144 | HMAC_Update(&ctx,A1,A1_len); |
| 91 | memcpy(&ctx_tmp,&ctx,sizeof(ctx)); /* Copy for A2 */ /* not needed for last one */ | 145 | HMAC_Update(&ctx_tmp,A1,A1_len); |
| 92 | HMAC_Update(&ctx,seed,seed_len); | 146 | HMAC_Update(&ctx,seed,seed_len); |
| 93 | 147 | ||
| 94 | if (olen > chunk) | 148 | if (olen > chunk) |
| @@ -105,24 +159,18 @@ int olen; | |||
| 105 | break; | 159 | break; |
| 106 | } | 160 | } |
| 107 | } | 161 | } |
| 108 | HMAC_cleanup(&ctx); | 162 | HMAC_CTX_cleanup(&ctx); |
| 109 | HMAC_cleanup(&ctx_tmp); | 163 | HMAC_CTX_cleanup(&ctx_tmp); |
| 110 | memset(A1,0,sizeof(A1)); | 164 | memset(A1,0,sizeof(A1)); |
| 111 | } | 165 | } |
| 112 | 166 | ||
| 113 | static void tls1_PRF(md5,sha1,label,label_len,sec,slen,out1,out2,olen) | 167 | static void tls1_PRF(const EVP_MD *md5, const EVP_MD *sha1, |
| 114 | EVP_MD *md5; | 168 | unsigned char *label, int label_len, |
| 115 | EVP_MD *sha1; | 169 | const unsigned char *sec, int slen, unsigned char *out1, |
| 116 | unsigned char *label; | 170 | unsigned char *out2, int olen) |
| 117 | int label_len; | ||
| 118 | unsigned char *sec; | ||
| 119 | int slen; | ||
| 120 | unsigned char *out1; | ||
| 121 | unsigned char *out2; | ||
| 122 | int olen; | ||
| 123 | { | 171 | { |
| 124 | int len,i; | 172 | int len,i; |
| 125 | unsigned char *S1,*S2; | 173 | const unsigned char *S1,*S2; |
| 126 | 174 | ||
| 127 | len=slen/2; | 175 | len=slen/2; |
| 128 | S1=sec; | 176 | S1=sec; |
| @@ -137,10 +185,8 @@ int olen; | |||
| 137 | out1[i]^=out2[i]; | 185 | out1[i]^=out2[i]; |
| 138 | } | 186 | } |
| 139 | 187 | ||
| 140 | static void tls1_generate_key_block(s,km,tmp,num) | 188 | static void tls1_generate_key_block(SSL *s, unsigned char *km, |
| 141 | SSL *s; | 189 | unsigned char *tmp, int num) |
| 142 | unsigned char *km,*tmp; | ||
| 143 | int num; | ||
| 144 | { | 190 | { |
| 145 | unsigned char *p; | 191 | unsigned char *p; |
| 146 | unsigned char buf[SSL3_RANDOM_SIZE*2+ | 192 | unsigned char buf[SSL3_RANDOM_SIZE*2+ |
| @@ -155,15 +201,25 @@ int num; | |||
| 155 | memcpy(p,s->s3->client_random,SSL3_RANDOM_SIZE); | 201 | memcpy(p,s->s3->client_random,SSL3_RANDOM_SIZE); |
| 156 | p+=SSL3_RANDOM_SIZE; | 202 | p+=SSL3_RANDOM_SIZE; |
| 157 | 203 | ||
| 158 | tls1_PRF(s->ctx->md5,s->ctx->sha1,buf,p-buf, | 204 | tls1_PRF(s->ctx->md5,s->ctx->sha1,buf,(int)(p-buf), |
| 159 | s->session->master_key,s->session->master_key_length, | 205 | s->session->master_key,s->session->master_key_length, |
| 160 | km,tmp,num); | 206 | km,tmp,num); |
| 207 | #ifdef KSSL_DEBUG | ||
| 208 | printf("tls1_generate_key_block() ==> %d byte master_key =\n\t", | ||
| 209 | s->session->master_key_length); | ||
| 210 | { | ||
| 211 | int i; | ||
| 212 | for (i=0; i < s->session->master_key_length; i++) | ||
| 213 | { | ||
| 214 | printf("%02X", s->session->master_key[i]); | ||
| 215 | } | ||
| 216 | printf("\n"); } | ||
| 217 | #endif /* KSSL_DEBUG */ | ||
| 161 | } | 218 | } |
| 162 | 219 | ||
| 163 | int tls1_change_cipher_state(s,which) | 220 | int tls1_change_cipher_state(SSL *s, int which) |
| 164 | SSL *s; | ||
| 165 | int which; | ||
| 166 | { | 221 | { |
| 222 | static const unsigned char empty[]=""; | ||
| 167 | unsigned char *p,*key_block,*mac_secret; | 223 | unsigned char *p,*key_block,*mac_secret; |
| 168 | unsigned char *exp_label,buf[TLS_MD_MAX_CONST_SIZE+ | 224 | unsigned char *exp_label,buf[TLS_MD_MAX_CONST_SIZE+ |
| 169 | SSL3_RANDOM_SIZE*2]; | 225 | SSL3_RANDOM_SIZE*2]; |
| @@ -174,47 +230,103 @@ int which; | |||
| 174 | unsigned char *ms,*key,*iv,*er1,*er2; | 230 | unsigned char *ms,*key,*iv,*er1,*er2; |
| 175 | int client_write; | 231 | int client_write; |
| 176 | EVP_CIPHER_CTX *dd; | 232 | EVP_CIPHER_CTX *dd; |
| 177 | EVP_CIPHER *c; | 233 | const EVP_CIPHER *c; |
| 178 | SSL_COMPRESSION *comp; | 234 | const SSL_COMP *comp; |
| 179 | EVP_MD *m; | 235 | const EVP_MD *m; |
| 180 | int exp,n,i,j,k,exp_label_len; | 236 | int is_export,n,i,j,k,exp_label_len,cl; |
| 237 | int reuse_dd = 0; | ||
| 181 | 238 | ||
| 182 | exp=(s->s3->tmp.new_cipher->algorithms & SSL_EXPORT)?1:0; | 239 | is_export=SSL_C_IS_EXPORT(s->s3->tmp.new_cipher); |
| 183 | c=s->s3->tmp.new_sym_enc; | 240 | c=s->s3->tmp.new_sym_enc; |
| 184 | m=s->s3->tmp.new_hash; | 241 | m=s->s3->tmp.new_hash; |
| 185 | comp=s->s3->tmp.new_compression; | 242 | comp=s->s3->tmp.new_compression; |
| 186 | key_block=s->s3->tmp.key_block; | 243 | key_block=s->s3->tmp.key_block; |
| 187 | 244 | ||
| 245 | #ifdef KSSL_DEBUG | ||
| 246 | printf("tls1_change_cipher_state(which= %d) w/\n", which); | ||
| 247 | printf("\talg= %ld, comp= %p\n", s->s3->tmp.new_cipher->algorithms, | ||
| 248 | comp); | ||
| 249 | printf("\tevp_cipher == %p ==? &d_cbc_ede_cipher3\n", c); | ||
| 250 | printf("\tevp_cipher: nid, blksz= %d, %d, keylen=%d, ivlen=%d\n", | ||
| 251 | c->nid,c->block_size,c->key_len,c->iv_len); | ||
| 252 | printf("\tkey_block: len= %d, data= ", s->s3->tmp.key_block_length); | ||
| 253 | { | ||
| 254 | int i; | ||
| 255 | for (i=0; i<s->s3->tmp.key_block_length; i++) | ||
| 256 | printf("%02x", key_block[i]); printf("\n"); | ||
| 257 | } | ||
| 258 | #endif /* KSSL_DEBUG */ | ||
| 259 | |||
| 188 | if (which & SSL3_CC_READ) | 260 | if (which & SSL3_CC_READ) |
| 189 | { | 261 | { |
| 190 | if ((s->enc_read_ctx == NULL) && | 262 | if (s->enc_read_ctx != NULL) |
| 191 | ((s->enc_read_ctx=(EVP_CIPHER_CTX *) | 263 | reuse_dd = 1; |
| 192 | Malloc(sizeof(EVP_CIPHER_CTX))) == NULL)) | 264 | else if ((s->enc_read_ctx=OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL) |
| 193 | goto err; | 265 | goto err; |
| 194 | dd= s->enc_read_ctx; | 266 | dd= s->enc_read_ctx; |
| 195 | s->read_hash=m; | 267 | s->read_hash=m; |
| 196 | s->read_compression=comp; | 268 | if (s->expand != NULL) |
| 269 | { | ||
| 270 | COMP_CTX_free(s->expand); | ||
| 271 | s->expand=NULL; | ||
| 272 | } | ||
| 273 | if (comp != NULL) | ||
| 274 | { | ||
| 275 | s->expand=COMP_CTX_new(comp->method); | ||
| 276 | if (s->expand == NULL) | ||
| 277 | { | ||
| 278 | SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE,SSL_R_COMPRESSION_LIBRARY_ERROR); | ||
| 279 | goto err2; | ||
| 280 | } | ||
| 281 | if (s->s3->rrec.comp == NULL) | ||
| 282 | s->s3->rrec.comp=(unsigned char *) | ||
| 283 | OPENSSL_malloc(SSL3_RT_MAX_ENCRYPTED_LENGTH); | ||
| 284 | if (s->s3->rrec.comp == NULL) | ||
| 285 | goto err; | ||
| 286 | } | ||
| 197 | memset(&(s->s3->read_sequence[0]),0,8); | 287 | memset(&(s->s3->read_sequence[0]),0,8); |
| 198 | mac_secret= &(s->s3->read_mac_secret[0]); | 288 | mac_secret= &(s->s3->read_mac_secret[0]); |
| 199 | } | 289 | } |
| 200 | else | 290 | else |
| 201 | { | 291 | { |
| 292 | if (s->enc_write_ctx != NULL) | ||
| 293 | reuse_dd = 1; | ||
| 294 | else if ((s->enc_write_ctx=OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL) | ||
| 295 | goto err; | ||
| 202 | if ((s->enc_write_ctx == NULL) && | 296 | if ((s->enc_write_ctx == NULL) && |
| 203 | ((s->enc_write_ctx=(EVP_CIPHER_CTX *) | 297 | ((s->enc_write_ctx=(EVP_CIPHER_CTX *) |
| 204 | Malloc(sizeof(EVP_CIPHER_CTX))) == NULL)) | 298 | OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL)) |
| 205 | goto err; | 299 | goto err; |
| 206 | dd= s->enc_write_ctx; | 300 | dd= s->enc_write_ctx; |
| 207 | s->write_hash=m; | 301 | s->write_hash=m; |
| 208 | s->write_compression=comp; | 302 | if (s->compress != NULL) |
| 303 | { | ||
| 304 | COMP_CTX_free(s->compress); | ||
| 305 | s->compress=NULL; | ||
| 306 | } | ||
| 307 | if (comp != NULL) | ||
| 308 | { | ||
| 309 | s->compress=COMP_CTX_new(comp->method); | ||
| 310 | if (s->compress == NULL) | ||
| 311 | { | ||
| 312 | SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE,SSL_R_COMPRESSION_LIBRARY_ERROR); | ||
| 313 | goto err2; | ||
| 314 | } | ||
| 315 | } | ||
| 209 | memset(&(s->s3->write_sequence[0]),0,8); | 316 | memset(&(s->s3->write_sequence[0]),0,8); |
| 210 | mac_secret= &(s->s3->write_mac_secret[0]); | 317 | mac_secret= &(s->s3->write_mac_secret[0]); |
| 211 | } | 318 | } |
| 212 | 319 | ||
| 320 | if (reuse_dd) | ||
| 321 | EVP_CIPHER_CTX_cleanup(dd); | ||
| 213 | EVP_CIPHER_CTX_init(dd); | 322 | EVP_CIPHER_CTX_init(dd); |
| 214 | 323 | ||
| 215 | p=s->s3->tmp.key_block; | 324 | p=s->s3->tmp.key_block; |
| 216 | i=EVP_MD_size(m); | 325 | i=EVP_MD_size(m); |
| 217 | j=(exp)?5:EVP_CIPHER_key_length(c); | 326 | cl=EVP_CIPHER_key_length(c); |
| 327 | j=is_export ? (cl < SSL_C_EXPORT_KEYLENGTH(s->s3->tmp.new_cipher) ? | ||
| 328 | cl : SSL_C_EXPORT_KEYLENGTH(s->s3->tmp.new_cipher)) : cl; | ||
| 329 | /* Was j=(exp)?5:EVP_CIPHER_key_length(c); */ | ||
| 218 | k=EVP_CIPHER_iv_length(c); | 330 | k=EVP_CIPHER_iv_length(c); |
| 219 | er1= &(s->s3->client_random[0]); | 331 | er1= &(s->s3->client_random[0]); |
| 220 | er2= &(s->s3->server_random[0]); | 332 | er2= &(s->s3->server_random[0]); |
| @@ -241,7 +353,7 @@ int which; | |||
| 241 | 353 | ||
| 242 | if (n > s->s3->tmp.key_block_length) | 354 | if (n > s->s3->tmp.key_block_length) |
| 243 | { | 355 | { |
| 244 | SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE,SSL_R_INTERNAL_ERROR); | 356 | SSLerr(SSL_F_TLS1_CHANGE_CIPHER_STATE,ERR_R_INTERNAL_ERROR); |
| 245 | goto err2; | 357 | goto err2; |
| 246 | } | 358 | } |
| 247 | 359 | ||
| @@ -250,7 +362,7 @@ int which; | |||
| 250 | printf("which = %04X\nmac key=",which); | 362 | printf("which = %04X\nmac key=",which); |
| 251 | { int z; for (z=0; z<i; z++) printf("%02X%c",ms[z],((z+1)%16)?' ':'\n'); } | 363 | { int z; for (z=0; z<i; z++) printf("%02X%c",ms[z],((z+1)%16)?' ':'\n'); } |
| 252 | #endif | 364 | #endif |
| 253 | if (exp) | 365 | if (is_export) |
| 254 | { | 366 | { |
| 255 | /* In here I set both the read and write key/iv to the | 367 | /* In here I set both the read and write key/iv to the |
| 256 | * same value since only the correct one will be used :-). | 368 | * same value since only the correct one will be used :-). |
| @@ -262,8 +374,8 @@ printf("which = %04X\nmac key=",which); | |||
| 262 | p+=SSL3_RANDOM_SIZE; | 374 | p+=SSL3_RANDOM_SIZE; |
| 263 | memcpy(p,s->s3->server_random,SSL3_RANDOM_SIZE); | 375 | memcpy(p,s->s3->server_random,SSL3_RANDOM_SIZE); |
| 264 | p+=SSL3_RANDOM_SIZE; | 376 | p+=SSL3_RANDOM_SIZE; |
| 265 | tls1_PRF(s->ctx->md5,s->ctx->sha1,buf,p-buf,key,j, | 377 | tls1_PRF(s->ctx->md5,s->ctx->sha1,buf,(int)(p-buf),key,j, |
| 266 | tmp1,tmp2,EVP_CIPHER_key_length(c)); | 378 | tmp1,tmp2,EVP_CIPHER_key_length(c)); |
| 267 | key=tmp1; | 379 | key=tmp1; |
| 268 | 380 | ||
| 269 | if (k > 0) | 381 | if (k > 0) |
| @@ -276,8 +388,8 @@ printf("which = %04X\nmac key=",which); | |||
| 276 | p+=SSL3_RANDOM_SIZE; | 388 | p+=SSL3_RANDOM_SIZE; |
| 277 | memcpy(p,s->s3->server_random,SSL3_RANDOM_SIZE); | 389 | memcpy(p,s->s3->server_random,SSL3_RANDOM_SIZE); |
| 278 | p+=SSL3_RANDOM_SIZE; | 390 | p+=SSL3_RANDOM_SIZE; |
| 279 | tls1_PRF(s->ctx->md5,s->ctx->sha1, | 391 | tls1_PRF(s->ctx->md5,s->ctx->sha1,buf,p-buf,empty,0, |
| 280 | buf,p-buf,"",0,iv1,iv2,k*2); | 392 | iv1,iv2,k*2); |
| 281 | if (client_write) | 393 | if (client_write) |
| 282 | iv=iv1; | 394 | iv=iv1; |
| 283 | else | 395 | else |
| @@ -286,8 +398,18 @@ printf("which = %04X\nmac key=",which); | |||
| 286 | } | 398 | } |
| 287 | 399 | ||
| 288 | s->session->key_arg_length=0; | 400 | s->session->key_arg_length=0; |
| 401 | #ifdef KSSL_DEBUG | ||
| 402 | { | ||
| 403 | int i; | ||
| 404 | printf("EVP_CipherInit_ex(dd,c,key=,iv=,which)\n"); | ||
| 405 | printf("\tkey= "); for (i=0; i<c->key_len; i++) printf("%02x", key[i]); | ||
| 406 | printf("\n"); | ||
| 407 | printf("\t iv= "); for (i=0; i<c->iv_len; i++) printf("%02x", iv[i]); | ||
| 408 | printf("\n"); | ||
| 409 | } | ||
| 410 | #endif /* KSSL_DEBUG */ | ||
| 289 | 411 | ||
| 290 | EVP_CipherInit(dd,c,key,iv,(which & SSL3_CC_WRITE)); | 412 | EVP_CipherInit_ex(dd,c,NULL,key,iv,(which & SSL3_CC_WRITE)); |
| 291 | #ifdef TLS_DEBUG | 413 | #ifdef TLS_DEBUG |
| 292 | printf("which = %04X\nkey=",which); | 414 | printf("which = %04X\nkey=",which); |
| 293 | { int z; for (z=0; z<EVP_CIPHER_key_length(c); z++) printf("%02X%c",key[z],((z+1)%16)?' ':'\n'); } | 415 | { int z; for (z=0; z<EVP_CIPHER_key_length(c); z++) printf("%02X%c",key[z],((z+1)%16)?' ':'\n'); } |
| @@ -307,18 +429,22 @@ err2: | |||
| 307 | return(0); | 429 | return(0); |
| 308 | } | 430 | } |
| 309 | 431 | ||
| 310 | int tls1_setup_key_block(s) | 432 | int tls1_setup_key_block(SSL *s) |
| 311 | SSL *s; | ||
| 312 | { | 433 | { |
| 313 | unsigned char *p1,*p2; | 434 | unsigned char *p1,*p2; |
| 314 | EVP_CIPHER *c; | 435 | const EVP_CIPHER *c; |
| 315 | EVP_MD *hash; | 436 | const EVP_MD *hash; |
| 316 | int num,exp; | 437 | int num; |
| 438 | SSL_COMP *comp; | ||
| 439 | |||
| 440 | #ifdef KSSL_DEBUG | ||
| 441 | printf ("tls1_setup_key_block()\n"); | ||
| 442 | #endif /* KSSL_DEBUG */ | ||
| 317 | 443 | ||
| 318 | if (s->s3->tmp.key_block_length != 0) | 444 | if (s->s3->tmp.key_block_length != 0) |
| 319 | return(1); | 445 | return(1); |
| 320 | 446 | ||
| 321 | if (!ssl_cipher_get_evp(s->session->cipher,&c,&hash)) | 447 | if (!ssl_cipher_get_evp(s->session,&c,&hash,&comp)) |
| 322 | { | 448 | { |
| 323 | SSLerr(SSL_F_TLS1_SETUP_KEY_BLOCK,SSL_R_CIPHER_OR_HASH_UNAVAILABLE); | 449 | SSLerr(SSL_F_TLS1_SETUP_KEY_BLOCK,SSL_R_CIPHER_OR_HASH_UNAVAILABLE); |
| 324 | return(0); | 450 | return(0); |
| @@ -327,16 +453,14 @@ SSL *s; | |||
| 327 | s->s3->tmp.new_sym_enc=c; | 453 | s->s3->tmp.new_sym_enc=c; |
| 328 | s->s3->tmp.new_hash=hash; | 454 | s->s3->tmp.new_hash=hash; |
| 329 | 455 | ||
| 330 | exp=(s->session->cipher->algorithms & SSL_EXPORT)?1:0; | ||
| 331 | |||
| 332 | num=EVP_CIPHER_key_length(c)+EVP_MD_size(hash)+EVP_CIPHER_iv_length(c); | 456 | num=EVP_CIPHER_key_length(c)+EVP_MD_size(hash)+EVP_CIPHER_iv_length(c); |
| 333 | num*=2; | 457 | num*=2; |
| 334 | 458 | ||
| 335 | ssl3_cleanup_key_block(s); | 459 | ssl3_cleanup_key_block(s); |
| 336 | 460 | ||
| 337 | if ((p1=(unsigned char *)Malloc(num)) == NULL) | 461 | if ((p1=(unsigned char *)OPENSSL_malloc(num)) == NULL) |
| 338 | goto err; | 462 | goto err; |
| 339 | if ((p2=(unsigned char *)Malloc(num)) == NULL) | 463 | if ((p2=(unsigned char *)OPENSSL_malloc(num)) == NULL) |
| 340 | goto err; | 464 | goto err; |
| 341 | 465 | ||
| 342 | s->s3->tmp.key_block_length=num; | 466 | s->s3->tmp.key_block_length=num; |
| @@ -353,28 +477,33 @@ printf("pre-master\n"); | |||
| 353 | #endif | 477 | #endif |
| 354 | tls1_generate_key_block(s,p1,p2,num); | 478 | tls1_generate_key_block(s,p1,p2,num); |
| 355 | memset(p2,0,num); | 479 | memset(p2,0,num); |
| 356 | Free(p2); | 480 | OPENSSL_free(p2); |
| 357 | #ifdef TLS_DEBUG | 481 | #ifdef TLS_DEBUG |
| 358 | printf("\nkey block\n"); | 482 | printf("\nkey block\n"); |
| 359 | { int z; for (z=0; z<num; z++) printf("%02X%c",p1[z],((z+1)%16)?' ':'\n'); } | 483 | { int z; for (z=0; z<num; z++) printf("%02X%c",p1[z],((z+1)%16)?' ':'\n'); } |
| 360 | #endif | 484 | #endif |
| 361 | 485 | ||
| 486 | /* enable vulnerability countermeasure for CBC ciphers with | ||
| 487 | * known-IV problem (http://www.openssl.org/~bodo/tls-cbc.txt) */ | ||
| 488 | s->s3->need_empty_fragments = 1; | ||
| 489 | #ifndef NO_RC4 | ||
| 490 | if ((s->session->cipher != NULL) && ((s->session->cipher->algorithms & SSL_ENC_MASK) == SSL_RC4)) | ||
| 491 | s->s3->need_empty_fragments = 0; | ||
| 492 | #endif | ||
| 493 | |||
| 362 | return(1); | 494 | return(1); |
| 363 | err: | 495 | err: |
| 364 | SSLerr(SSL_F_TLS1_SETUP_KEY_BLOCK,ERR_R_MALLOC_FAILURE); | 496 | SSLerr(SSL_F_TLS1_SETUP_KEY_BLOCK,ERR_R_MALLOC_FAILURE); |
| 365 | return(0); | 497 | return(0); |
| 366 | } | 498 | } |
| 367 | 499 | ||
| 368 | int tls1_enc(s,send) | 500 | int tls1_enc(SSL *s, int send) |
| 369 | SSL *s; | ||
| 370 | int send; | ||
| 371 | { | 501 | { |
| 372 | SSL3_RECORD *rec; | 502 | SSL3_RECORD *rec; |
| 373 | EVP_CIPHER_CTX *ds; | 503 | EVP_CIPHER_CTX *ds; |
| 374 | unsigned long l; | 504 | unsigned long l; |
| 375 | int bs,i,ii,j,k,n=0; | 505 | int bs,i,ii,j,k,n=0; |
| 376 | EVP_CIPHER *enc; | 506 | const EVP_CIPHER *enc; |
| 377 | SSL_COMPRESSION *comp; | ||
| 378 | 507 | ||
| 379 | if (send) | 508 | if (send) |
| 380 | { | 509 | { |
| @@ -383,12 +512,9 @@ int send; | |||
| 383 | ds=s->enc_write_ctx; | 512 | ds=s->enc_write_ctx; |
| 384 | rec= &(s->s3->wrec); | 513 | rec= &(s->s3->wrec); |
| 385 | if (s->enc_write_ctx == NULL) | 514 | if (s->enc_write_ctx == NULL) |
| 386 | { enc=NULL; comp=NULL; } | 515 | enc=NULL; |
| 387 | else | 516 | else |
| 388 | { | ||
| 389 | enc=EVP_CIPHER_CTX_cipher(s->enc_write_ctx); | 517 | enc=EVP_CIPHER_CTX_cipher(s->enc_write_ctx); |
| 390 | comp=s->write_compression; | ||
| 391 | } | ||
| 392 | } | 518 | } |
| 393 | else | 519 | else |
| 394 | { | 520 | { |
| @@ -397,18 +523,19 @@ int send; | |||
| 397 | ds=s->enc_read_ctx; | 523 | ds=s->enc_read_ctx; |
| 398 | rec= &(s->s3->rrec); | 524 | rec= &(s->s3->rrec); |
| 399 | if (s->enc_read_ctx == NULL) | 525 | if (s->enc_read_ctx == NULL) |
| 400 | { enc=NULL; comp=NULL; } | 526 | enc=NULL; |
| 401 | else | 527 | else |
| 402 | { | ||
| 403 | enc=EVP_CIPHER_CTX_cipher(s->enc_read_ctx); | 528 | enc=EVP_CIPHER_CTX_cipher(s->enc_read_ctx); |
| 404 | comp=s->read_compression; | ||
| 405 | } | ||
| 406 | } | 529 | } |
| 407 | 530 | ||
| 531 | #ifdef KSSL_DEBUG | ||
| 532 | printf("tls1_enc(%d)\n", send); | ||
| 533 | #endif /* KSSL_DEBUG */ | ||
| 534 | |||
| 408 | if ((s->session == NULL) || (ds == NULL) || | 535 | if ((s->session == NULL) || (ds == NULL) || |
| 409 | ((enc == NULL) && (comp == NULL))) | 536 | (enc == NULL)) |
| 410 | { | 537 | { |
| 411 | memcpy(rec->data,rec->input,rec->length); | 538 | memmove(rec->data,rec->input,rec->length); |
| 412 | rec->input=rec->data; | 539 | rec->input=rec->data; |
| 413 | } | 540 | } |
| 414 | else | 541 | else |
| @@ -435,11 +562,48 @@ int send; | |||
| 435 | rec->length+=i; | 562 | rec->length+=i; |
| 436 | } | 563 | } |
| 437 | 564 | ||
| 565 | #ifdef KSSL_DEBUG | ||
| 566 | { | ||
| 567 | unsigned long ui; | ||
| 568 | printf("EVP_Cipher(ds=%p,rec->data=%p,rec->input=%p,l=%ld) ==>\n", | ||
| 569 | ds,rec->data,rec->input,l); | ||
| 570 | printf("\tEVP_CIPHER_CTX: %d buf_len, %d key_len [%d %d], %d iv_len\n", | ||
| 571 | ds->buf_len, ds->cipher->key_len, | ||
| 572 | DES_KEY_SZ, DES_SCHEDULE_SZ, | ||
| 573 | ds->cipher->iv_len); | ||
| 574 | printf("\t\tIV: "); | ||
| 575 | for (i=0; i<ds->cipher->iv_len; i++) printf("%02X", ds->iv[i]); | ||
| 576 | printf("\n"); | ||
| 577 | printf("\trec->input="); | ||
| 578 | for (ui=0; ui<l; ui++) printf(" %02x", rec->input[ui]); | ||
| 579 | printf("\n"); | ||
| 580 | } | ||
| 581 | #endif /* KSSL_DEBUG */ | ||
| 582 | |||
| 583 | if (!send) | ||
| 584 | { | ||
| 585 | if (l == 0 || l%bs != 0) | ||
| 586 | { | ||
| 587 | SSLerr(SSL_F_TLS1_ENC,SSL_R_BLOCK_CIPHER_PAD_IS_WRONG); | ||
| 588 | ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECRYPTION_FAILED); | ||
| 589 | return 0; | ||
| 590 | } | ||
| 591 | } | ||
| 592 | |||
| 438 | EVP_Cipher(ds,rec->data,rec->input,l); | 593 | EVP_Cipher(ds,rec->data,rec->input,l); |
| 439 | 594 | ||
| 595 | #ifdef KSSL_DEBUG | ||
| 596 | { | ||
| 597 | unsigned long i; | ||
| 598 | printf("\trec->data="); | ||
| 599 | for (i=0; i<l; i++) | ||
| 600 | printf(" %02x", rec->data[i]); printf("\n"); | ||
| 601 | } | ||
| 602 | #endif /* KSSL_DEBUG */ | ||
| 603 | |||
| 440 | if ((bs != 1) && !send) | 604 | if ((bs != 1) && !send) |
| 441 | { | 605 | { |
| 442 | ii=i=rec->data[l-1]; | 606 | ii=i=rec->data[l-1]; /* padding_length */ |
| 443 | i++; | 607 | i++; |
| 444 | if (s->options&SSL_OP_TLS_BLOCK_PADDING_BUG) | 608 | if (s->options&SSL_OP_TLS_BLOCK_PADDING_BUG) |
| 445 | { | 609 | { |
| @@ -450,19 +614,22 @@ int send; | |||
| 450 | if (s->s3->flags & TLS1_FLAGS_TLS_PADDING_BUG) | 614 | if (s->s3->flags & TLS1_FLAGS_TLS_PADDING_BUG) |
| 451 | i--; | 615 | i--; |
| 452 | } | 616 | } |
| 617 | /* TLS 1.0 does not bound the number of padding bytes by the block size. | ||
| 618 | * All of them must have value 'padding_length'. */ | ||
| 453 | if (i > (int)rec->length) | 619 | if (i > (int)rec->length) |
| 454 | { | 620 | { |
| 455 | SSLerr(SSL_F_TLS1_ENC,SSL_R_BLOCK_CIPHER_PAD_IS_WRONG); | 621 | /* Incorrect padding. SSLerr() and ssl3_alert are done |
| 456 | ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECRYPTION_FAILED); | 622 | * by caller: we don't want to reveal whether this is |
| 457 | return(0); | 623 | * a decryption error or a MAC verification failure |
| 624 | * (see http://www.openssl.org/~bodo/tls-cbc.txt) */ | ||
| 625 | return -1; | ||
| 458 | } | 626 | } |
| 459 | for (j=(int)(l-i); j<(int)l; j++) | 627 | for (j=(int)(l-i); j<(int)l; j++) |
| 460 | { | 628 | { |
| 461 | if (rec->data[j] != ii) | 629 | if (rec->data[j] != ii) |
| 462 | { | 630 | { |
| 463 | SSLerr(SSL_F_TLS1_ENC,SSL_R_DECRYPTION_FAILED); | 631 | /* Incorrect padding */ |
| 464 | ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECRYPTION_FAILED); | 632 | return -1; |
| 465 | return(0); | ||
| 466 | } | 633 | } |
| 467 | } | 634 | } |
| 468 | rec->length-=i; | 635 | rec->length-=i; |
| @@ -471,25 +638,20 @@ int send; | |||
| 471 | return(1); | 638 | return(1); |
| 472 | } | 639 | } |
| 473 | 640 | ||
| 474 | int tls1_cert_verify_mac(s,in_ctx,out) | 641 | int tls1_cert_verify_mac(SSL *s, EVP_MD_CTX *in_ctx, unsigned char *out) |
| 475 | SSL *s; | ||
| 476 | EVP_MD_CTX *in_ctx; | ||
| 477 | unsigned char *out; | ||
| 478 | { | 642 | { |
| 479 | unsigned int ret; | 643 | unsigned int ret; |
| 480 | EVP_MD_CTX ctx; | 644 | EVP_MD_CTX ctx; |
| 481 | 645 | ||
| 482 | memcpy(&ctx,in_ctx,sizeof(EVP_MD_CTX)); | 646 | EVP_MD_CTX_init(&ctx); |
| 483 | EVP_DigestFinal(&ctx,out,&ret); | 647 | EVP_MD_CTX_copy_ex(&ctx,in_ctx); |
| 648 | EVP_DigestFinal_ex(&ctx,out,&ret); | ||
| 649 | EVP_MD_CTX_cleanup(&ctx); | ||
| 484 | return((int)ret); | 650 | return((int)ret); |
| 485 | } | 651 | } |
| 486 | 652 | ||
| 487 | int tls1_final_finish_mac(s,in1_ctx,in2_ctx,str,slen,out) | 653 | int tls1_final_finish_mac(SSL *s, EVP_MD_CTX *in1_ctx, EVP_MD_CTX *in2_ctx, |
| 488 | SSL *s; | 654 | const char *str, int slen, unsigned char *out) |
| 489 | EVP_MD_CTX *in1_ctx,*in2_ctx; | ||
| 490 | unsigned char *str; | ||
| 491 | int slen; | ||
| 492 | unsigned char *out; | ||
| 493 | { | 655 | { |
| 494 | unsigned int i; | 656 | unsigned int i; |
| 495 | EVP_MD_CTX ctx; | 657 | EVP_MD_CTX ctx; |
| @@ -500,29 +662,27 @@ unsigned char *out; | |||
| 500 | memcpy(q,str,slen); | 662 | memcpy(q,str,slen); |
| 501 | q+=slen; | 663 | q+=slen; |
| 502 | 664 | ||
| 503 | memcpy(&ctx,in1_ctx,sizeof(EVP_MD_CTX)); | 665 | EVP_MD_CTX_init(&ctx); |
| 504 | EVP_DigestFinal(&ctx,q,&i); | 666 | EVP_MD_CTX_copy_ex(&ctx,in1_ctx); |
| 667 | EVP_DigestFinal_ex(&ctx,q,&i); | ||
| 505 | q+=i; | 668 | q+=i; |
| 506 | memcpy(&ctx,in2_ctx,sizeof(EVP_MD_CTX)); | 669 | EVP_MD_CTX_copy_ex(&ctx,in2_ctx); |
| 507 | EVP_DigestFinal(&ctx,q,&i); | 670 | EVP_DigestFinal_ex(&ctx,q,&i); |
| 508 | q+=i; | 671 | q+=i; |
| 509 | 672 | ||
| 510 | tls1_PRF(s->ctx->md5,s->ctx->sha1,buf,q-buf, | 673 | tls1_PRF(s->ctx->md5,s->ctx->sha1,buf,(int)(q-buf), |
| 511 | s->session->master_key,s->session->master_key_length, | 674 | s->session->master_key,s->session->master_key_length, |
| 512 | out,buf2,12); | 675 | out,buf2,12); |
| 513 | memset(&ctx,0,sizeof(EVP_MD_CTX)); | 676 | EVP_MD_CTX_cleanup(&ctx); |
| 514 | 677 | ||
| 515 | return((int)12); | 678 | return((int)12); |
| 516 | } | 679 | } |
| 517 | 680 | ||
| 518 | int tls1_mac(ssl,md,send) | 681 | int tls1_mac(SSL *ssl, unsigned char *md, int send) |
| 519 | SSL *ssl; | ||
| 520 | unsigned char *md; | ||
| 521 | int send; | ||
| 522 | { | 682 | { |
| 523 | SSL3_RECORD *rec; | 683 | SSL3_RECORD *rec; |
| 524 | unsigned char *mac_sec,*seq; | 684 | unsigned char *mac_sec,*seq; |
| 525 | EVP_MD *hash; | 685 | const EVP_MD *hash; |
| 526 | unsigned int md_size; | 686 | unsigned int md_size; |
| 527 | int i; | 687 | int i; |
| 528 | HMAC_CTX hmac; | 688 | HMAC_CTX hmac; |
| @@ -552,41 +712,47 @@ int send; | |||
| 552 | buf[4]=rec->length&0xff; | 712 | buf[4]=rec->length&0xff; |
| 553 | 713 | ||
| 554 | /* I should fix this up TLS TLS TLS TLS TLS XXXXXXXX */ | 714 | /* I should fix this up TLS TLS TLS TLS TLS XXXXXXXX */ |
| 555 | HMAC_Init(&hmac,mac_sec,EVP_MD_size(hash),hash); | 715 | HMAC_CTX_init(&hmac); |
| 716 | HMAC_Init_ex(&hmac,mac_sec,EVP_MD_size(hash),hash,NULL); | ||
| 556 | HMAC_Update(&hmac,seq,8); | 717 | HMAC_Update(&hmac,seq,8); |
| 557 | HMAC_Update(&hmac,buf,5); | 718 | HMAC_Update(&hmac,buf,5); |
| 558 | HMAC_Update(&hmac,rec->input,rec->length); | 719 | HMAC_Update(&hmac,rec->input,rec->length); |
| 559 | HMAC_Final(&hmac,md,&md_size); | 720 | HMAC_Final(&hmac,md,&md_size); |
| 721 | HMAC_CTX_cleanup(&hmac); | ||
| 560 | 722 | ||
| 561 | #ifdef TLS_DEBUG | 723 | #ifdef TLS_DEBUG |
| 562 | printf("sec="); | 724 | printf("sec="); |
| 563 | {int z; for (z=0; z<md_size; z++) printf("%02X ",mac_sec[z]); printf("\n"); } | 725 | {unsigned int z; for (z=0; z<md_size; z++) printf("%02X ",mac_sec[z]); printf("\n"); } |
| 564 | printf("seq="); | 726 | printf("seq="); |
| 565 | {int z; for (z=0; z<8; z++) printf("%02X ",seq[z]); printf("\n"); } | 727 | {int z; for (z=0; z<8; z++) printf("%02X ",seq[z]); printf("\n"); } |
| 566 | printf("buf="); | 728 | printf("buf="); |
| 567 | {int z; for (z=0; z<5; z++) printf("%02X ",buf[z]); printf("\n"); } | 729 | {int z; for (z=0; z<5; z++) printf("%02X ",buf[z]); printf("\n"); } |
| 568 | printf("rec="); | 730 | printf("rec="); |
| 569 | {int z; for (z=0; z<rec->length; z++) printf("%02X ",buf[z]); printf("\n"); } | 731 | {unsigned int z; for (z=0; z<rec->length; z++) printf("%02X ",buf[z]); printf("\n"); } |
| 570 | #endif | 732 | #endif |
| 571 | 733 | ||
| 572 | for (i=7; i>=0; i--) | 734 | for (i=7; i>=0; i--) |
| 573 | if (++seq[i]) break; | 735 | { |
| 736 | ++seq[i]; | ||
| 737 | if (seq[i] != 0) break; | ||
| 738 | } | ||
| 574 | 739 | ||
| 575 | #ifdef TLS_DEBUG | 740 | #ifdef TLS_DEBUG |
| 576 | {int z; for (z=0; z<md_size; z++) printf("%02X ",md[z]); printf("\n"); } | 741 | {unsigned int z; for (z=0; z<md_size; z++) printf("%02X ",md[z]); printf("\n"); } |
| 577 | #endif | 742 | #endif |
| 578 | return(md_size); | 743 | return(md_size); |
| 579 | } | 744 | } |
| 580 | 745 | ||
| 581 | int tls1_generate_master_secret(s,out,p,len) | 746 | int tls1_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p, |
| 582 | SSL *s; | 747 | int len) |
| 583 | unsigned char *out; | ||
| 584 | unsigned char *p; | ||
| 585 | int len; | ||
| 586 | { | 748 | { |
| 587 | unsigned char buf[SSL3_RANDOM_SIZE*2+TLS_MD_MASTER_SECRET_CONST_SIZE]; | 749 | unsigned char buf[SSL3_RANDOM_SIZE*2+TLS_MD_MASTER_SECRET_CONST_SIZE]; |
| 588 | unsigned char buff[SSL_MAX_MASTER_KEY_LENGTH]; | 750 | unsigned char buff[SSL_MAX_MASTER_KEY_LENGTH]; |
| 589 | 751 | ||
| 752 | #ifdef KSSL_DEBUG | ||
| 753 | printf ("tls1_generate_master_secret(%p,%p, %p, %d)\n", s,out, p,len); | ||
| 754 | #endif /* KSSL_DEBUG */ | ||
| 755 | |||
| 590 | /* Setup the stuff to munge */ | 756 | /* Setup the stuff to munge */ |
| 591 | memcpy(buf,TLS_MD_MASTER_SECRET_CONST, | 757 | memcpy(buf,TLS_MD_MASTER_SECRET_CONST, |
| 592 | TLS_MD_MASTER_SECRET_CONST_SIZE); | 758 | TLS_MD_MASTER_SECRET_CONST_SIZE); |
| @@ -597,11 +763,13 @@ int len; | |||
| 597 | tls1_PRF(s->ctx->md5,s->ctx->sha1, | 763 | tls1_PRF(s->ctx->md5,s->ctx->sha1, |
| 598 | buf,TLS_MD_MASTER_SECRET_CONST_SIZE+SSL3_RANDOM_SIZE*2,p,len, | 764 | buf,TLS_MD_MASTER_SECRET_CONST_SIZE+SSL3_RANDOM_SIZE*2,p,len, |
| 599 | s->session->master_key,buff,SSL3_MASTER_SECRET_SIZE); | 765 | s->session->master_key,buff,SSL3_MASTER_SECRET_SIZE); |
| 766 | #ifdef KSSL_DEBUG | ||
| 767 | printf ("tls1_generate_master_secret() complete\n"); | ||
| 768 | #endif /* KSSL_DEBUG */ | ||
| 600 | return(SSL3_MASTER_SECRET_SIZE); | 769 | return(SSL3_MASTER_SECRET_SIZE); |
| 601 | } | 770 | } |
| 602 | 771 | ||
| 603 | int tls1_alert_code(code) | 772 | int tls1_alert_code(int code) |
| 604 | int code; | ||
| 605 | { | 773 | { |
| 606 | switch (code) | 774 | switch (code) |
| 607 | { | 775 | { |
| @@ -623,11 +791,11 @@ int code; | |||
| 623 | case SSL_AD_ACCESS_DENIED: return(TLS1_AD_ACCESS_DENIED); | 791 | case SSL_AD_ACCESS_DENIED: return(TLS1_AD_ACCESS_DENIED); |
| 624 | case SSL_AD_DECODE_ERROR: return(TLS1_AD_DECODE_ERROR); | 792 | case SSL_AD_DECODE_ERROR: return(TLS1_AD_DECODE_ERROR); |
| 625 | case SSL_AD_DECRYPT_ERROR: return(TLS1_AD_DECRYPT_ERROR); | 793 | case SSL_AD_DECRYPT_ERROR: return(TLS1_AD_DECRYPT_ERROR); |
| 626 | case SSL_AD_EXPORT_RESTRICION: return(TLS1_AD_EXPORT_RESTRICION); | 794 | case SSL_AD_EXPORT_RESTRICTION: return(TLS1_AD_EXPORT_RESTRICTION); |
| 627 | case SSL_AD_PROTOCOL_VERSION: return(TLS1_AD_PROTOCOL_VERSION); | 795 | case SSL_AD_PROTOCOL_VERSION: return(TLS1_AD_PROTOCOL_VERSION); |
| 628 | case SSL_AD_INSUFFICIENT_SECURITY:return(TLS1_AD_INSUFFICIENT_SECURITY); | 796 | case SSL_AD_INSUFFICIENT_SECURITY:return(TLS1_AD_INSUFFICIENT_SECURITY); |
| 629 | case SSL_AD_INTERNAL_ERROR: return(TLS1_AD_INTERNAL_ERROR); | 797 | case SSL_AD_INTERNAL_ERROR: return(TLS1_AD_INTERNAL_ERROR); |
| 630 | case SSL_AD_USER_CANCLED: return(TLS1_AD_USER_CANCLED); | 798 | case SSL_AD_USER_CANCELLED: return(TLS1_AD_USER_CANCELLED); |
| 631 | case SSL_AD_NO_RENEGOTIATION: return(TLS1_AD_NO_RENEGOTIATION); | 799 | case SSL_AD_NO_RENEGOTIATION: return(TLS1_AD_NO_RENEGOTIATION); |
| 632 | default: return(-1); | 800 | default: return(-1); |
| 633 | } | 801 | } |
diff --git a/src/lib/libssl/t1_lib.c b/src/lib/libssl/t1_lib.c index f9fbfa414c..ca6c03d5af 100644 --- a/src/lib/libssl/t1_lib.c +++ b/src/lib/libssl/t1_lib.c | |||
| @@ -57,16 +57,12 @@ | |||
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include "objects.h" | 60 | #include <openssl/objects.h> |
| 61 | #include "ssl_locl.h" | 61 | #include "ssl_locl.h" |
| 62 | 62 | ||
| 63 | char *tls1_version_str="TLSv1 part of SSLeay 0.9.0b 29-Jun-1998"; | 63 | const char *tls1_version_str="TLSv1" OPENSSL_VERSION_PTEXT; |
| 64 | 64 | ||
| 65 | #ifndef NO_PROTO | ||
| 66 | static long tls1_default_timeout(void); | 65 | static long tls1_default_timeout(void); |
| 67 | #else | ||
| 68 | static long tls1_default_timeout(); | ||
| 69 | #endif | ||
| 70 | 66 | ||
| 71 | static SSL3_ENC_METHOD TLSv1_enc_data={ | 67 | static SSL3_ENC_METHOD TLSv1_enc_data={ |
| 72 | tls1_enc, | 68 | tls1_enc, |
| @@ -94,6 +90,7 @@ static SSL_METHOD TLSv1_data= { | |||
| 94 | ssl3_write, | 90 | ssl3_write, |
| 95 | ssl3_shutdown, | 91 | ssl3_shutdown, |
| 96 | ssl3_renegotiate, | 92 | ssl3_renegotiate, |
| 93 | ssl3_renegotiate_check, | ||
| 97 | ssl3_ctrl, | 94 | ssl3_ctrl, |
| 98 | ssl3_ctx_ctrl, | 95 | ssl3_ctx_ctrl, |
| 99 | ssl3_get_cipher_by_char, | 96 | ssl3_get_cipher_by_char, |
| @@ -104,47 +101,48 @@ static SSL_METHOD TLSv1_data= { | |||
| 104 | ssl_bad_method, | 101 | ssl_bad_method, |
| 105 | tls1_default_timeout, | 102 | tls1_default_timeout, |
| 106 | &TLSv1_enc_data, | 103 | &TLSv1_enc_data, |
| 104 | ssl_undefined_function, | ||
| 105 | ssl3_callback_ctrl, | ||
| 106 | ssl3_ctx_callback_ctrl, | ||
| 107 | }; | 107 | }; |
| 108 | 108 | ||
| 109 | static long tls1_default_timeout() | 109 | static long tls1_default_timeout(void) |
| 110 | { | 110 | { |
| 111 | /* 2 hours, the 24 hours mentioned in the TLSv1 spec | 111 | /* 2 hours, the 24 hours mentioned in the TLSv1 spec |
| 112 | * is way too long for http, the cache would over fill */ | 112 | * is way too long for http, the cache would over fill */ |
| 113 | return(60*60*2); | 113 | return(60*60*2); |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | SSL_METHOD *tlsv1_base_method() | 116 | SSL_METHOD *tlsv1_base_method(void) |
| 117 | { | 117 | { |
| 118 | return(&TLSv1_data); | 118 | return(&TLSv1_data); |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | int tls1_new(s) | 121 | int tls1_new(SSL *s) |
| 122 | SSL *s; | ||
| 123 | { | 122 | { |
| 124 | if (!ssl3_new(s)) return(0); | 123 | if (!ssl3_new(s)) return(0); |
| 125 | s->method->ssl_clear(s); | 124 | s->method->ssl_clear(s); |
| 126 | return(1); | 125 | return(1); |
| 127 | } | 126 | } |
| 128 | 127 | ||
| 129 | void tls1_free(s) | 128 | void tls1_free(SSL *s) |
| 130 | SSL *s; | ||
| 131 | { | 129 | { |
| 132 | ssl3_free(s); | 130 | ssl3_free(s); |
| 133 | } | 131 | } |
| 134 | 132 | ||
| 135 | void tls1_clear(s) | 133 | void tls1_clear(SSL *s) |
| 136 | SSL *s; | ||
| 137 | { | 134 | { |
| 138 | ssl3_clear(s); | 135 | ssl3_clear(s); |
| 139 | s->version=TLS1_VERSION; | 136 | s->version=TLS1_VERSION; |
| 140 | } | 137 | } |
| 141 | 138 | ||
| 142 | #if 0 | 139 | #if 0 |
| 143 | long tls1_ctrl(s,cmd,larg,parg) | 140 | long tls1_ctrl(SSL *s, int cmd, long larg, char *parg) |
| 144 | SSL *s; | 141 | { |
| 145 | int cmd; | 142 | return(0); |
| 146 | long larg; | 143 | } |
| 147 | char *parg; | 144 | |
| 145 | long tls1_callback_ctrl(SSL *s, int cmd, void *(*fp)()) | ||
| 148 | { | 146 | { |
| 149 | return(0); | 147 | return(0); |
| 150 | } | 148 | } |
diff --git a/src/lib/libssl/t1_meth.c b/src/lib/libssl/t1_meth.c index 512c2078e7..9bb36a7d1c 100644 --- a/src/lib/libssl/t1_meth.c +++ b/src/lib/libssl/t1_meth.c | |||
| @@ -57,11 +57,11 @@ | |||
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include "objects.h" | 60 | #include <openssl/objects.h> |
| 61 | #include "ssl_locl.h" | 61 | #include "ssl_locl.h" |
| 62 | 62 | ||
| 63 | static SSL_METHOD *tls1_get_method(ver) | 63 | static SSL_METHOD *tls1_get_method(int ver); |
| 64 | int ver; | 64 | static SSL_METHOD *tls1_get_method(int ver) |
| 65 | { | 65 | { |
| 66 | if (ver == TLS1_VERSION) | 66 | if (ver == TLS1_VERSION) |
| 67 | return(TLSv1_method()); | 67 | return(TLSv1_method()); |
| @@ -69,19 +69,19 @@ int ver; | |||
| 69 | return(NULL); | 69 | return(NULL); |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | SSL_METHOD *TLSv1_method() | 72 | SSL_METHOD *TLSv1_method(void) |
| 73 | { | 73 | { |
| 74 | static int init=1; | 74 | static int init=1; |
| 75 | static SSL_METHOD TLSv1_data; | 75 | static SSL_METHOD TLSv1_data; |
| 76 | 76 | ||
| 77 | if (init) | 77 | if (init) |
| 78 | { | 78 | { |
| 79 | init=0; | ||
| 80 | memcpy((char *)&TLSv1_data,(char *)tlsv1_base_method(), | 79 | memcpy((char *)&TLSv1_data,(char *)tlsv1_base_method(), |
| 81 | sizeof(SSL_METHOD)); | 80 | sizeof(SSL_METHOD)); |
| 82 | TLSv1_data.ssl_connect=ssl3_connect; | 81 | TLSv1_data.ssl_connect=ssl3_connect; |
| 83 | TLSv1_data.ssl_accept=ssl3_accept; | 82 | TLSv1_data.ssl_accept=ssl3_accept; |
| 84 | TLSv1_data.get_ssl_method=tls1_get_method; | 83 | TLSv1_data.get_ssl_method=tls1_get_method; |
| 84 | init=0; | ||
| 85 | } | 85 | } |
| 86 | return(&TLSv1_data); | 86 | return(&TLSv1_data); |
| 87 | } | 87 | } |
diff --git a/src/lib/libssl/t1_srvr.c b/src/lib/libssl/t1_srvr.c index 8cf0addcd9..996b7ca8e2 100644 --- a/src/lib/libssl/t1_srvr.c +++ b/src/lib/libssl/t1_srvr.c | |||
| @@ -57,15 +57,15 @@ | |||
| 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 "x509.h" | 64 | #include <openssl/x509.h> |
| 65 | #include "ssl_locl.h" | 65 | #include "ssl_locl.h" |
| 66 | 66 | ||
| 67 | static SSL_METHOD *tls1_get_server_method(ver) | 67 | static SSL_METHOD *tls1_get_server_method(int ver); |
| 68 | int ver; | 68 | static SSL_METHOD *tls1_get_server_method(int ver) |
| 69 | { | 69 | { |
| 70 | if (ver == TLS1_VERSION) | 70 | if (ver == TLS1_VERSION) |
| 71 | return(TLSv1_server_method()); | 71 | return(TLSv1_server_method()); |
| @@ -73,18 +73,18 @@ int ver; | |||
| 73 | return(NULL); | 73 | return(NULL); |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | SSL_METHOD *TLSv1_server_method() | 76 | SSL_METHOD *TLSv1_server_method(void) |
| 77 | { | 77 | { |
| 78 | static int init=1; | 78 | static int init=1; |
| 79 | static SSL_METHOD TLSv1_server_data; | 79 | static SSL_METHOD TLSv1_server_data; |
| 80 | 80 | ||
| 81 | if (init) | 81 | if (init) |
| 82 | { | 82 | { |
| 83 | init=0; | ||
| 84 | memcpy((char *)&TLSv1_server_data,(char *)tlsv1_base_method(), | 83 | memcpy((char *)&TLSv1_server_data,(char *)tlsv1_base_method(), |
| 85 | sizeof(SSL_METHOD)); | 84 | sizeof(SSL_METHOD)); |
| 86 | TLSv1_server_data.ssl_accept=ssl3_accept; | 85 | TLSv1_server_data.ssl_accept=ssl3_accept; |
| 87 | TLSv1_server_data.get_ssl_method=tls1_get_server_method; | 86 | TLSv1_server_data.get_ssl_method=tls1_get_server_method; |
| 87 | init=0; | ||
| 88 | } | 88 | } |
| 89 | return(&TLSv1_server_data); | 89 | return(&TLSv1_server_data); |
| 90 | } | 90 | } |
diff --git a/src/lib/libssl/test/methtest.c b/src/lib/libssl/test/methtest.c index 630d29dc91..06ccb3b310 100644 --- a/src/lib/libssl/test/methtest.c +++ b/src/lib/libssl/test/methtest.c | |||
| @@ -58,10 +58,10 @@ | |||
| 58 | 58 | ||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include <stdlib.h> | 60 | #include <stdlib.h> |
| 61 | #include "rsa.h" | 61 | #include <openssl/rsa.h> |
| 62 | #include "x509.h" | 62 | #include <openssl/x509.h> |
| 63 | #include "meth.h" | 63 | #include "meth.h" |
| 64 | #include "err.h" | 64 | #include <openssl/err.h> |
| 65 | 65 | ||
| 66 | int main(argc,argv) | 66 | int main(argc,argv) |
| 67 | int argc; | 67 | int argc; |
diff --git a/src/lib/libssl/test/tcrl b/src/lib/libssl/test/tcrl index 859fba452f..acaf8f3c47 100644 --- a/src/lib/libssl/test/tcrl +++ b/src/lib/libssl/test/tcrl | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | PATH=../apps:$PATH | 3 | PATH=../apps:$PATH |
| 4 | export PATH | 4 | export PATH |
| 5 | 5 | ||
| 6 | cmd='../apps/ssleay crl' | 6 | cmd='../apps/openssl crl' |
| 7 | 7 | ||
| 8 | if [ "$1"x != "x" ]; then | 8 | if [ "$1"x != "x" ]; then |
| 9 | t=$1 | 9 | t=$1 |
diff --git a/src/lib/libssl/test/testca b/src/lib/libssl/test/testca index a28402f9ca..88c186b6ab 100644 --- a/src/lib/libssl/test/testca +++ b/src/lib/libssl/test/testca | |||
| @@ -23,7 +23,7 @@ if [ $? != 0 ]; then | |||
| 23 | fi | 23 | fi |
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | SSLEAY_CONFIG="-config ../apps/ssleay.cnf" | 26 | SSLEAY_CONFIG="-config ../apps/openssl.cnf" |
| 27 | export SSLEAY_CONFIG | 27 | export SSLEAY_CONFIG |
| 28 | $SH ../apps/CA.sh -sign <<EOF | 28 | $SH ../apps/CA.sh -sign <<EOF |
| 29 | y | 29 | y |
diff --git a/src/lib/libssl/test/testenc b/src/lib/libssl/test/testenc index 42db56c2be..0656c7f525 100644 --- a/src/lib/libssl/test/testenc +++ b/src/lib/libssl/test/testenc | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | testsrc=Makefile.ssl | 3 | testsrc=Makefile.ssl |
| 4 | test=./p | 4 | test=./p |
| 5 | cmd=../apps/ssleay | 5 | cmd=../apps/openssl |
| 6 | 6 | ||
| 7 | cat $testsrc >$test; | 7 | cat $testsrc >$test; |
| 8 | 8 | ||
| @@ -27,15 +27,7 @@ else | |||
| 27 | /bin/rm $test.cipher $test.clear | 27 | /bin/rm $test.cipher $test.clear |
| 28 | fi | 28 | fi |
| 29 | 29 | ||
| 30 | for i in rc4 \ | 30 | for i in `$cmd list-cipher-commands` |
| 31 | des-cfb des-ede-cfb des-ede3-cfb \ | ||
| 32 | des-ofb des-ede-ofb des-ede3-ofb \ | ||
| 33 | des-ecb des-ede des-ede3 desx \ | ||
| 34 | des-cbc des-ede-cbc des-ede3-cbc \ | ||
| 35 | idea-ecb idea-cfb idea-ofb idea-cbc \ | ||
| 36 | rc2-ecb rc2-cfb rc2-ofb rc2-cbc \ | ||
| 37 | bf-ecb bf-cfb bf-ofb bf-cbc rc4 \ | ||
| 38 | cast5-ecb cast5-cfb cast5-ofb cast5-cbc | ||
| 39 | do | 31 | do |
| 40 | echo $i | 32 | echo $i |
| 41 | $cmd $i -bufsize 113 -e -k test < $test > $test.$i.cipher | 33 | $cmd $i -bufsize 113 -e -k test < $test > $test.$i.cipher |
diff --git a/src/lib/libssl/test/testgen b/src/lib/libssl/test/testgen index 12a4ca4cea..6a4b6b9221 100644 --- a/src/lib/libssl/test/testgen +++ b/src/lib/libssl/test/testgen | |||
| @@ -11,17 +11,25 @@ export PATH | |||
| 11 | 11 | ||
| 12 | echo "generating certificate request" | 12 | echo "generating certificate request" |
| 13 | 13 | ||
| 14 | echo "There should be a 2 sequences of .'s and some +'s." | 14 | echo "string to make the random number generator think it has entropy" >> ./.rnd |
| 15 | echo "There should not be more that at most 80 per line" | 15 | |
| 16 | if ../apps/openssl no-rsa; then | ||
| 17 | req_new='-newkey dsa:../apps/dsa512.pem' | ||
| 18 | else | ||
| 19 | req_new='-new' | ||
| 20 | echo "There should be a 2 sequences of .'s and some +'s." | ||
| 21 | echo "There should not be more that at most 80 per line" | ||
| 22 | fi | ||
| 23 | |||
| 16 | echo "This could take some time." | 24 | echo "This could take some time." |
| 17 | 25 | ||
| 18 | ../apps/ssleay req -config test.cnf -new -out testreq.pem | 26 | ../apps/openssl req -config test.cnf $req_new -out testreq.pem |
| 19 | if [ $? != 0 ]; then | 27 | if [ $? != 0 ]; then |
| 20 | echo problems creating request | 28 | echo problems creating request |
| 21 | exit 1 | 29 | exit 1 |
| 22 | fi | 30 | fi |
| 23 | 31 | ||
| 24 | ../apps/ssleay req -verify -in testreq.pem -noout | 32 | ../apps/openssl req -config test.cnf -verify -in testreq.pem -noout |
| 25 | if [ $? != 0 ]; then | 33 | if [ $? != 0 ]; then |
| 26 | echo signature on req is wrong | 34 | echo signature on req is wrong |
| 27 | exit 1 | 35 | exit 1 |
diff --git a/src/lib/libssl/test/testp7.pem b/src/lib/libssl/test/testp7.pem index b3b6dba830..e5b7866c31 100644 --- a/src/lib/libssl/test/testp7.pem +++ b/src/lib/libssl/test/testp7.pem | |||
| @@ -1,46 +1,46 @@ | |||
| 1 | -----BEGIN PKCS7----- | 1 | -----BEGIN PKCS7----- |
| 2 | MIAGCSqGSIb3DQEHAqCAMIIIBwIBATEAMIAGCSqGSIb3DQEHAQAAoIIGPDCCBHIw | 2 | MIIIGAYJKoZIhvcNAQcCoIIICTCCCAUCAQExADALBgkqhkiG9w0BBwGgggY8MIIE |
| 3 | ggQcoAMCAQICEHkvjiX1iVGQMenF9HgIjI8wDQYJKoZIhvcNAQEEBQAwYjERMA8G | 3 | cjCCBBygAwIBAgIQeS+OJfWJUZAx6cX0eAiMjzANBgkqhkiG9w0BAQQFADBiMREw |
| 4 | A1UEBxMISW50ZXJuZXQxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTQwMgYDVQQL | 4 | DwYDVQQHEwhJbnRlcm5ldDEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xNDAyBgNV |
| 5 | EytWZXJpU2lnbiBDbGFzcyAxIENBIC0gSW5kaXZpZHVhbCBTdWJzY3JpYmVyMB4X | 5 | BAsTK1ZlcmlTaWduIENsYXNzIDEgQ0EgLSBJbmRpdmlkdWFsIFN1YnNjcmliZXIw |
| 6 | DTk2MDcxOTAwMDAwMFoXDTk3MDMzMDIzNTk1OVowgdUxETAPBgNVBAcTCEludGVy | 6 | HhcNOTYwNzE5MDAwMDAwWhcNOTcwMzMwMjM1OTU5WjCB1TERMA8GA1UEBxMISW50 |
| 7 | bmV0MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE0MDIGA1UECxMrVmVyaVNpZ24g | ||
| 8 | Q2xhc3MgMSBDQSAtIEluZGl2aWR1YWwgU3Vic2NyaWJlcjEoMCYGA1UECxMfRGln | ||
| 9 | aXRhbCBJRCBDbGFzcyAxIC0gU01JTUUgVGVzdDFHMEUGA1UECxM+d3d3LnZlcmlz | ||
| 10 | aWduLmNvbS9yZXBvc2l0b3J5L0NQUy0xLjAgSW5jLiBieSBSZWYuLExJQUIuTFRE | ||
| 11 | KGMpOTYwWzANBgkqhkiG9w0BAQEFAANKADBHAkAOy7xxCAIkOfuIA2LyRpxgKlDO | ||
| 12 | Rl8htdXYhF5iBGUx1GYaK6KF+bK/CCI0l4j2OfWGFBUrwGoWqxTNcWgTfMzRAgMB | ||
| 13 | AAGjggI5MIICNTAJBgNVHRMEAjAAMIICJgYDVR0DBIICHTCCAhkwggIVMIICEQYL | ||
| 14 | YIZIAYb4RQEHAQEwggIAFoIBq1RoaXMgY2VydGlmaWNhdGUgaW5jb3Jwb3JhdGVz | ||
| 15 | IGJ5IHJlZmVyZW5jZSwgYW5kIGl0cyB1c2UgaXMgc3RyaWN0bHkgc3ViamVjdCB0 | ||
| 16 | bywgdGhlIFZlcmlTaWduIENlcnRpZmljYXRpb24gUHJhY3RpY2UgU3RhdGVtZW50 | ||
| 17 | IChDUFMpLCBhdmFpbGFibGUgYXQ6IGh0dHBzOi8vd3d3LnZlcmlzaWduLmNvbS9D | ||
| 18 | UFMtMS4wOyBieSBFLW1haWwgYXQgQ1BTLXJlcXVlc3RzQHZlcmlzaWduLmNvbTsg | ||
| 19 | b3IgYnkgbWFpbCBhdCBWZXJpU2lnbiwgSW5jLiwgMjU5MyBDb2FzdCBBdmUuLCBN | ||
| 20 | b3VudGFpbiBWaWV3LCBDQSA5NDA0MyBVU0EgVGVsLiArMSAoNDE1KSA5NjEtODgz | ||
| 21 | MCBDb3B5cmlnaHQgKGMpIDE5OTYgVmVyaVNpZ24sIEluYy4gIEFsbCBSaWdodHMg | ||
| 22 | UmVzZXJ2ZWQuIENFUlRBSU4gV0FSUkFOVElFUyBESVNDTEFJTUVEIGFuZCBMSUFC | ||
| 23 | SUxJVFkgTElNSVRFRC6gDgYMYIZIAYb4RQEHAQEBoQ4GDGCGSAGG+EUBBwEBAjAv | ||
| 24 | MC0WK2h0dHBzOi8vd3d3LnZlcmlzaWduLmNvbS9yZXBvc2l0b3J5L0NQUy0xLgMw | ||
| 25 | DQYJKoZIhvcNAQEEBQADQQDAmA7km/3iJWEsWN9Z2WU2gmZAknx45WnDKHxMa3Bf | ||
| 26 | gNsh6BLk/ngkJKjNKTDR13XVHqEPUY1flbjATZputw1GMIIBwjCCAWygAwIBAgIQ | ||
| 27 | fAmE6tW5ERSQWDneu3KfSTANBgkqhkiG9w0BAQIFADA+MQswCQYDVQQGEwJVUzEX | ||
| 28 | MBUGA1UEChMOVmVyaVNpZ24sIEluYy4xFjAUBgNVBAsTDVRFU1QgUm9vdCBQQ0Ew | ||
| 29 | HhcNOTYwNzE3MDAwMDAwWhcNOTcwNzE3MjM1OTU5WjBiMREwDwYDVQQHEwhJbnRl | ||
| 30 | cm5ldDEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xNDAyBgNVBAsTK1ZlcmlTaWdu | ||
| 31 | IENsYXNzIDEgQ0EgLSBJbmRpdmlkdWFsIFN1YnNjcmliZXIwXDANBgkqhkiG9w0B | ||
| 32 | AQEFAANLADBIAkEA7Fc6zYJw4WwCWa1ni3fYNbzGSQNluuw990024GusjLfhEk1h | ||
| 33 | MsIUukTT/n8yxoO7rYp4x+LS+tHF2tBtuxg7CwIDAQABoyIwIDALBgNVHQ8EBAMC | ||
| 34 | AQYwEQYJYIZIAYb4QgEBBAQDAgIEMA0GCSqGSIb3DQEBAgUAA0EAFKem0cJGg9nd | ||
| 35 | TAbP5o1HIEyNn11ZlvLU5v1Hejs1MKQt72IMm4jjgOH+pjguXW8lB6yzrK4oVOO2 | ||
| 36 | UNCaNQ1H26GCAa0wgeYwgZEwDQYJKoZIhvcNAQECBQAwYjERMA8GA1UEBxMISW50 | ||
| 37 | ZXJuZXQxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTQwMgYDVQQLEytWZXJpU2ln | 7 | ZXJuZXQxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTQwMgYDVQQLEytWZXJpU2ln |
| 38 | biBDbGFzcyAxIENBIC0gSW5kaXZpZHVhbCBTdWJzY3JpYmVyFw05NjA3MTcxNzU5 | 8 | biBDbGFzcyAxIENBIC0gSW5kaXZpZHVhbCBTdWJzY3JpYmVyMSgwJgYDVQQLEx9E |
| 39 | MjlaFw05NzA3MTgwMDAwMDBaMA0GCSqGSIb3DQEBAgUAA0EAubVWYTsWsQmste9f | 9 | aWdpdGFsIElEIENsYXNzIDEgLSBTTUlNRSBUZXN0MUcwRQYDVQQLEz53d3cudmVy |
| 40 | +UgMw8BkjDlM25fwQLrCfmmnLxjewey10kSROypUaJLb+r4oRALc0fG9XfZsaiiI | 10 | aXNpZ24uY29tL3JlcG9zaXRvcnkvQ1BTLTEuMCBJbmMuIGJ5IFJlZi4sTElBQi5M |
| 41 | gotQHjCBwTBtMA0GCSqGSIb3DQEBAgUAMD4xCzAJBgNVBAYTAlVTMRcwFQYDVQQK | 11 | VEQoYyk5NjBbMA0GCSqGSIb3DQEBAQUAA0oAMEcCQA7LvHEIAiQ5+4gDYvJGnGAq |
| 42 | Ew5WZXJpU2lnbiwgSW5jLjEWMBQGA1UECxMNVEVTVCBSb290IFBDQRcNOTYwNzE3 | 12 | UM5GXyG11diEXmIEZTHUZhorooX5sr8IIjSXiPY59YYUFSvAaharFM1xaBN8zNEC |
| 43 | MTc0NDA5WhcNOTgwNzE3MDAwMDAwWjANBgkqhkiG9w0BAQIFAANBAHitA0/xAukC | 13 | AwEAAaOCAjkwggI1MAkGA1UdEwQCMAAwggImBgNVHQMEggIdMIICGTCCAhUwggIR |
| 44 | jHzeh1AMT/l2oC68N+yFb+aJPHBBMxc6gG2MaKjBNwb5hcXUllMlExONA3ju10f7 | 14 | BgtghkgBhvhFAQcBATCCAgAWggGrVGhpcyBjZXJ0aWZpY2F0ZSBpbmNvcnBvcmF0 |
| 45 | owIq3s3wx10xAAAAAAA= | 15 | ZXMgYnkgcmVmZXJlbmNlLCBhbmQgaXRzIHVzZSBpcyBzdHJpY3RseSBzdWJqZWN0 |
| 16 | IHRvLCB0aGUgVmVyaVNpZ24gQ2VydGlmaWNhdGlvbiBQcmFjdGljZSBTdGF0ZW1l | ||
| 17 | bnQgKENQUyksIGF2YWlsYWJsZSBhdDogaHR0cHM6Ly93d3cudmVyaXNpZ24uY29t | ||
| 18 | L0NQUy0xLjA7IGJ5IEUtbWFpbCBhdCBDUFMtcmVxdWVzdHNAdmVyaXNpZ24uY29t | ||
| 19 | OyBvciBieSBtYWlsIGF0IFZlcmlTaWduLCBJbmMuLCAyNTkzIENvYXN0IEF2ZS4s | ||
| 20 | IE1vdW50YWluIFZpZXcsIENBIDk0MDQzIFVTQSBUZWwuICsxICg0MTUpIDk2MS04 | ||
| 21 | ODMwIENvcHlyaWdodCAoYykgMTk5NiBWZXJpU2lnbiwgSW5jLiAgQWxsIFJpZ2h0 | ||
| 22 | cyBSZXNlcnZlZC4gQ0VSVEFJTiBXQVJSQU5USUVTIERJU0NMQUlNRUQgYW5kIExJ | ||
| 23 | QUJJTElUWSBMSU1JVEVELqAOBgxghkgBhvhFAQcBAQGhDgYMYIZIAYb4RQEHAQEC | ||
| 24 | MC8wLRYraHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JlcG9zaXRvcnkvQ1BTLTEu | ||
| 25 | AzANBgkqhkiG9w0BAQQFAANBAMCYDuSb/eIlYSxY31nZZTaCZkCSfHjlacMofExr | ||
| 26 | cF+A2yHoEuT+eCQkqM0pMNHXddUeoQ9RjV+VuMBNmm63DUYwggHCMIIBbKADAgEC | ||
| 27 | AhB8CYTq1bkRFJBYOd67cp9JMA0GCSqGSIb3DQEBAgUAMD4xCzAJBgNVBAYTAlVT | ||
| 28 | MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjEWMBQGA1UECxMNVEVTVCBSb290IFBD | ||
| 29 | QTAeFw05NjA3MTcwMDAwMDBaFw05NzA3MTcyMzU5NTlaMGIxETAPBgNVBAcTCElu | ||
| 30 | dGVybmV0MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE0MDIGA1UECxMrVmVyaVNp | ||
| 31 | Z24gQ2xhc3MgMSBDQSAtIEluZGl2aWR1YWwgU3Vic2NyaWJlcjBcMA0GCSqGSIb3 | ||
| 32 | DQEBAQUAA0sAMEgCQQDsVzrNgnDhbAJZrWeLd9g1vMZJA2W67D33TTbga6yMt+ES | ||
| 33 | TWEywhS6RNP+fzLGg7utinjH4tL60cXa0G27GDsLAgMBAAGjIjAgMAsGA1UdDwQE | ||
| 34 | AwIBBjARBglghkgBhvhCAQEEBAMCAgQwDQYJKoZIhvcNAQECBQADQQAUp6bRwkaD | ||
| 35 | 2d1MBs/mjUcgTI2fXVmW8tTm/Ud6OzUwpC3vYgybiOOA4f6mOC5dbyUHrLOsrihU | ||
| 36 | 47ZQ0Jo1DUfboYIBrTCBwTBtMA0GCSqGSIb3DQEBAgUAMD4xCzAJBgNVBAYTAlVT | ||
| 37 | MRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjEWMBQGA1UECxMNVEVTVCBSb290IFBD | ||
| 38 | QRcNOTYwNzE3MTc0NDA5WhcNOTgwNzE3MDAwMDAwWjANBgkqhkiG9w0BAQIFAANB | ||
| 39 | AHitA0/xAukCjHzeh1AMT/l2oC68N+yFb+aJPHBBMxc6gG2MaKjBNwb5hcXUllMl | ||
| 40 | ExONA3ju10f7owIq3s3wx10wgeYwgZEwDQYJKoZIhvcNAQECBQAwYjERMA8GA1UE | ||
| 41 | BxMISW50ZXJuZXQxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMTQwMgYDVQQLEytW | ||
| 42 | ZXJpU2lnbiBDbGFzcyAxIENBIC0gSW5kaXZpZHVhbCBTdWJzY3JpYmVyFw05NjA3 | ||
| 43 | MTcxNzU5MjlaFw05NzA3MTgwMDAwMDBaMA0GCSqGSIb3DQEBAgUAA0EAubVWYTsW | ||
| 44 | sQmste9f+UgMw8BkjDlM25fwQLrCfmmnLxjewey10kSROypUaJLb+r4oRALc0fG9 | ||
| 45 | XfZsaiiIgotQHjEA | ||
| 46 | -----END PKCS7----- | 46 | -----END PKCS7----- |
diff --git a/src/lib/libssl/test/testsid.pem b/src/lib/libssl/test/testsid.pem index cd8617be2e..7ffd008f66 100644 --- a/src/lib/libssl/test/testsid.pem +++ b/src/lib/libssl/test/testsid.pem | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | -----BEGIN SSL SESSION PARAMETERS----- | 1 | -----BEGIN SSL SESSION PARAMETERS----- |
| 2 | MIIBxwIBAQIBAgQDAQCABBCi11xa5qkOP8xrr02K/NQCBBBkIYQZM0Bt95W0EHNV | 2 | MIIB1gIBAQIBAgQDAQCABBCi11xa5qkOP8xrr02K/NQCBBBkIYQZM0Bt95W0EHNV |
| 3 | bA58oQYCBDIBr7WiBAICASyjggGGMIIBgjCCASwCAQMwDQYJKoZIhvcNAQEEBQAw | 3 | bA58oQYCBDIBr7WiBAICASyjggGGMIIBgjCCASwCAQMwDQYJKoZIhvcNAQEEBQAw |
| 4 | ODELMAkGA1UEBhMCQVUxDDAKBgNVBAgTA1FMRDEbMBkGA1UEAxMSU1NMZWF5L3Jz | 4 | ODELMAkGA1UEBhMCQVUxDDAKBgNVBAgTA1FMRDEbMBkGA1UEAxMSU1NMZWF5L3Jz |
| 5 | YSB0ZXN0IENBMB4XDTk1MTAwOTIzMzEzNFoXDTk4MDcwNTIzMzEzNFowYDELMAkG | 5 | YSB0ZXN0IENBMB4XDTk1MTAwOTIzMzEzNFoXDTk4MDcwNTIzMzEzNFowYDELMAkG |
| @@ -8,5 +8,5 @@ LjELMAkGA1UECxMCQ1MxGzAZBgNVBAMTElNTTGVheSBkZW1vIGNsaWVudDBcMA0G | |||
| 8 | CSqGSIb3DQEBAQUAA0sAMEgCQQC4pcXEL1lgVA+B5Q3TcuW/O3LZHoA73IYm8oFD | 8 | CSqGSIb3DQEBAQUAA0sAMEgCQQC4pcXEL1lgVA+B5Q3TcuW/O3LZHoA73IYm8oFD |
| 9 | TezgCDhL2RTMn+seKWF36UtJKRIOBU9jZHCVVd0Me5ls6BEjAgMBAAEwDQYJKoZI | 9 | TezgCDhL2RTMn+seKWF36UtJKRIOBU9jZHCVVd0Me5ls6BEjAgMBAAEwDQYJKoZI |
| 10 | hvcNAQEEBQADQQBoIpOcwUY1qlVF7j3ROSGvUsbvByOBFmYWkIBgsCqR+9qo1A7L | 10 | hvcNAQEEBQADQQBoIpOcwUY1qlVF7j3ROSGvUsbvByOBFmYWkIBgsCqR+9qo1A7L |
| 11 | CrWF5i8LWt/vLwAHaxWNx2YuBJMFyuK81fTv | 11 | CrWF5i8LWt/vLwAHaxWNx2YuBJMFyuK81fTvpA0EC3Rlc3Rjb250ZXh0 |
| 12 | -----END SSL SESSION PARAMETERS----- | 12 | -----END SSL SESSION PARAMETERS----- |
diff --git a/src/lib/libssl/test/testss b/src/lib/libssl/test/testss index a5aecf4694..8d3557f356 100644 --- a/src/lib/libssl/test/testss +++ b/src/lib/libssl/test/testss | |||
| @@ -1,9 +1,10 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | 2 | ||
| 3 | digest='-mdc2' | 3 | digest='-md5' |
| 4 | reqcmd="../apps/ssleay req" | 4 | reqcmd="../apps/openssl req" |
| 5 | x509cmd="../apps/ssleay x509 $digest" | 5 | x509cmd="../apps/openssl x509 $digest" |
| 6 | verifycmd="../apps/ssleay verify" | 6 | verifycmd="../apps/openssl verify" |
| 7 | dummycnf="../apps/openssl.cnf" | ||
| 7 | 8 | ||
| 8 | CAkey="keyCA.ss" | 9 | CAkey="keyCA.ss" |
| 9 | CAcert="certCA.ss" | 10 | CAcert="certCA.ss" |
| @@ -18,7 +19,16 @@ Ucert="certU.ss" | |||
| 18 | 19 | ||
| 19 | echo | 20 | echo |
| 20 | echo "make a certificate request using 'req'" | 21 | echo "make a certificate request using 'req'" |
| 21 | $reqcmd -config $CAconf -out $CAreq -keyout $CAkey -new #>err.ss | 22 | |
| 23 | echo "string to make the random number generator think it has entropy" >> ./.rnd | ||
| 24 | |||
| 25 | if ../apps/openssl no-rsa; then | ||
| 26 | req_new='-newkey dsa:../apps/dsa512.pem' | ||
| 27 | else | ||
| 28 | req_new='-new' | ||
| 29 | fi | ||
| 30 | |||
| 31 | $reqcmd -config $CAconf -out $CAreq -keyout $CAkey $req_new #>err.ss | ||
| 22 | if [ $? != 0 ]; then | 32 | if [ $? != 0 ]; then |
| 23 | echo "error using 'req' to generate a certificate request" | 33 | echo "error using 'req' to generate a certificate request" |
| 24 | exit 1 | 34 | exit 1 |
| @@ -39,13 +49,13 @@ if [ $? != 0 ]; then | |||
| 39 | exit 1 | 49 | exit 1 |
| 40 | fi | 50 | fi |
| 41 | 51 | ||
| 42 | $reqcmd -verify -in $CAreq -noout | 52 | $reqcmd -config $dummycnf -verify -in $CAreq -noout |
| 43 | if [ $? != 0 ]; then | 53 | if [ $? != 0 ]; then |
| 44 | echo first generated request is invalid | 54 | echo first generated request is invalid |
| 45 | exit 1 | 55 | exit 1 |
| 46 | fi | 56 | fi |
| 47 | 57 | ||
| 48 | $reqcmd -verify -in $CAreq2 -noout | 58 | $reqcmd -config $dummycnf -verify -in $CAreq2 -noout |
| 49 | if [ $? != 0 ]; then | 59 | if [ $? != 0 ]; then |
| 50 | echo second generated request is invalid | 60 | echo second generated request is invalid |
| 51 | exit 1 | 61 | exit 1 |
| @@ -59,7 +69,7 @@ fi | |||
| 59 | 69 | ||
| 60 | echo | 70 | echo |
| 61 | echo "make another certificate request using 'req'" | 71 | echo "make another certificate request using 'req'" |
| 62 | $reqcmd -config $Uconf -out $Ureq -keyout $Ukey -new >err.ss | 72 | $reqcmd -config $Uconf -out $Ureq -keyout $Ukey $req_new >err.ss |
| 63 | if [ $? != 0 ]; then | 73 | if [ $? != 0 ]; then |
| 64 | echo "error using 'req' to generate a certificate request" | 74 | echo "error using 'req' to generate a certificate request" |
| 65 | exit 1 | 75 | exit 1 |
diff --git a/src/lib/libssl/test/testssl b/src/lib/libssl/test/testssl index f115adb8e1..ba5e41c861 100644 --- a/src/lib/libssl/test/testssl +++ b/src/lib/libssl/test/testssl | |||
| @@ -1,40 +1,137 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | 2 | ||
| 3 | if [ "$1" = "" ]; then | ||
| 4 | key=../apps/server.pem | ||
| 5 | else | ||
| 6 | key="$1" | ||
| 7 | fi | ||
| 8 | if [ "$2" = "" ]; then | ||
| 9 | cert=../apps/server.pem | ||
| 10 | else | ||
| 11 | cert="$2" | ||
| 12 | fi | ||
| 13 | ssltest="./ssltest -key $key -cert $cert -c_key $key -c_cert $cert" | ||
| 14 | |||
| 15 | if ../apps/openssl x509 -in $cert -text -noout | fgrep 'DSA Public Key' >/dev/null; then | ||
| 16 | dsa_cert=YES | ||
| 17 | else | ||
| 18 | dsa_cert=NO | ||
| 19 | fi | ||
| 20 | |||
| 21 | if [ "$3" = "" ]; then | ||
| 22 | CA="-CApath ../certs" | ||
| 23 | else | ||
| 24 | CA="-CAfile $3" | ||
| 25 | fi | ||
| 26 | |||
| 27 | if [ "$4" = "" ]; then | ||
| 28 | extra="" | ||
| 29 | else | ||
| 30 | extra="$4" | ||
| 31 | fi | ||
| 32 | |||
| 33 | ############################################################################# | ||
| 34 | |||
| 3 | echo test sslv2 | 35 | echo test sslv2 |
| 4 | ./ssltest -ssl2 || exit 1 | 36 | $ssltest -ssl2 $extra || exit 1 |
| 5 | 37 | ||
| 6 | echo test sslv2 with server authentication | 38 | echo test sslv2 with server authentication |
| 7 | ./ssltest -ssl2 -server_auth -CApath ../certs || exit 1 | 39 | $ssltest -ssl2 -server_auth $CA $extra || exit 1 |
| 8 | 40 | ||
| 9 | echo test sslv2 with client authentication | 41 | if [ $dsa_cert = NO ]; then |
| 10 | ./ssltest -ssl2 -client_auth -CApath ../certs || exit 1 | 42 | echo test sslv2 with client authentication |
| 43 | $ssltest -ssl2 -client_auth $CA $extra || exit 1 | ||
| 11 | 44 | ||
| 12 | echo test sslv2 with both client and server authentication | 45 | echo test sslv2 with both client and server authentication |
| 13 | ./ssltest -ssl2 -server_auth -client_auth -CApath ../certs || exit 1 | 46 | $ssltest -ssl2 -server_auth -client_auth $CA $extra || exit 1 |
| 47 | fi | ||
| 14 | 48 | ||
| 15 | echo test sslv3 | 49 | echo test sslv3 |
| 16 | ./ssltest -ssl3 || exit 1 | 50 | $ssltest -ssl3 $extra || exit 1 |
| 17 | 51 | ||
| 18 | echo test sslv3 with server authentication | 52 | echo test sslv3 with server authentication |
| 19 | ./ssltest -ssl3 -server_auth -CApath ../certs || exit 1 | 53 | $ssltest -ssl3 -server_auth $CA $extra || exit 1 |
| 20 | 54 | ||
| 21 | echo test sslv3 with client authentication | 55 | echo test sslv3 with client authentication |
| 22 | ./ssltest -ssl3 -client_auth -CApath ../certs || exit 1 | 56 | $ssltest -ssl3 -client_auth $CA $extra || exit 1 |
| 23 | 57 | ||
| 24 | echo test sslv3 with both client and server authentication | 58 | echo test sslv3 with both client and server authentication |
| 25 | ./ssltest -ssl3 -server_auth -client_auth -CApath ../certs || exit 1 | 59 | $ssltest -ssl3 -server_auth -client_auth $CA $extra || exit 1 |
| 26 | 60 | ||
| 27 | echo test sslv2/sslv3 | 61 | echo test sslv2/sslv3 |
| 28 | ./ssltest || exit 1 | 62 | $ssltest $extra || exit 1 |
| 29 | 63 | ||
| 30 | echo test sslv2/sslv3 with server authentication | 64 | echo test sslv2/sslv3 with server authentication |
| 31 | ./ssltest -server_auth -CApath ../certs || exit 1 | 65 | $ssltest -server_auth $CA $extra || exit 1 |
| 32 | 66 | ||
| 33 | echo test sslv2/sslv3 with client authentication | 67 | echo test sslv2/sslv3 with client authentication |
| 34 | ./ssltest -client_auth -CApath ../certs || exit 1 | 68 | $ssltest -client_auth $CA $extra || exit 1 |
| 35 | 69 | ||
| 36 | echo test sslv2/sslv3 with both client and server authentication | 70 | echo test sslv2/sslv3 with both client and server authentication |
| 37 | ./ssltest -server_auth -client_auth -CApath ../certs || exit 1 | 71 | $ssltest -server_auth -client_auth $CA $extra || exit 1 |
| 38 | 72 | ||
| 39 | exit 0 | 73 | echo test sslv2 via BIO pair |
| 74 | $ssltest -bio_pair -ssl2 $extra || exit 1 | ||
| 75 | |||
| 76 | echo test sslv2 with server authentication via BIO pair | ||
| 77 | $ssltest -bio_pair -ssl2 -server_auth $CA $extra || exit 1 | ||
| 78 | |||
| 79 | if [ $dsa_cert = NO ]; then | ||
| 80 | echo test sslv2 with client authentication via BIO pair | ||
| 81 | $ssltest -bio_pair -ssl2 -client_auth $CA $extra || exit 1 | ||
| 82 | |||
| 83 | echo test sslv2 with both client and server authentication via BIO pair | ||
| 84 | $ssltest -bio_pair -ssl2 -server_auth -client_auth $CA $extra || exit 1 | ||
| 85 | fi | ||
| 86 | |||
| 87 | echo test sslv3 via BIO pair | ||
| 88 | $ssltest -bio_pair -ssl3 $extra || exit 1 | ||
| 89 | |||
| 90 | echo test sslv3 with server authentication via BIO pair | ||
| 91 | $ssltest -bio_pair -ssl3 -server_auth $CA $extra || exit 1 | ||
| 92 | |||
| 93 | echo test sslv3 with client authentication via BIO pair | ||
| 94 | $ssltest -bio_pair -ssl3 -client_auth $CA $extra || exit 1 | ||
| 95 | |||
| 96 | echo test sslv3 with both client and server authentication via BIO pair | ||
| 97 | $ssltest -bio_pair -ssl3 -server_auth -client_auth $CA $extra || exit 1 | ||
| 40 | 98 | ||
| 99 | echo test sslv2/sslv3 via BIO pair | ||
| 100 | $ssltest $extra || exit 1 | ||
| 101 | |||
| 102 | if [ $dsa_cert = NO ]; then | ||
| 103 | echo test sslv2/sslv3 w/o DHE via BIO pair | ||
| 104 | $ssltest -bio_pair -no_dhe $extra || exit 1 | ||
| 105 | fi | ||
| 106 | |||
| 107 | echo test sslv2/sslv3 with 1024bit DHE via BIO pair | ||
| 108 | $ssltest -bio_pair -dhe1024dsa -v $extra || exit 1 | ||
| 109 | |||
| 110 | echo test sslv2/sslv3 with server authentication | ||
| 111 | $ssltest -bio_pair -server_auth $CA $extra || exit 1 | ||
| 112 | |||
| 113 | echo test sslv2/sslv3 with client authentication via BIO pair | ||
| 114 | $ssltest -bio_pair -client_auth $CA $extra || exit 1 | ||
| 115 | |||
| 116 | echo test sslv2/sslv3 with both client and server authentication via BIO pair | ||
| 117 | $ssltest -bio_pair -server_auth -client_auth $CA $extra || exit 1 | ||
| 118 | |||
| 119 | echo test sslv2/sslv3 with both client and server authentication via BIO pair and app verify | ||
| 120 | $ssltest -bio_pair -server_auth -client_auth -app_verify $CA $extra || exit 1 | ||
| 121 | |||
| 122 | ############################################################################# | ||
| 123 | |||
| 124 | echo test tls1 with 1024bit anonymous DH, multiple handshakes | ||
| 125 | $ssltest -v -bio_pair -tls1 -cipher ADH -dhe1024dsa -num 10 -f -time $extra || exit 1 | ||
| 126 | |||
| 127 | if ../apps/openssl no-rsa; then | ||
| 128 | echo skipping RSA tests | ||
| 129 | else | ||
| 130 | 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 | ||
| 132 | |||
| 133 | echo test tls1 with 1024bit RSA, 1024bit DHE, multiple handshakes | ||
| 134 | ./ssltest -v -bio_pair -tls1 -cert ../apps/server2.pem -dhe1024dsa -num 10 -f -time $extra || exit 1 | ||
| 135 | fi | ||
| 136 | |||
| 137 | exit 0 | ||
diff --git a/src/lib/libssl/test/tpkcs7 b/src/lib/libssl/test/tpkcs7 index ea1f005dac..15bbba42c0 100644 --- a/src/lib/libssl/test/tpkcs7 +++ b/src/lib/libssl/test/tpkcs7 | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | PATH=../apps:$PATH | 3 | PATH=../apps:$PATH |
| 4 | export PATH | 4 | export PATH |
| 5 | 5 | ||
| 6 | cmd='../apps/ssleay pkcs7' | 6 | cmd='../apps/openssl pkcs7' |
| 7 | 7 | ||
| 8 | if [ "$1"x != "x" ]; then | 8 | if [ "$1"x != "x" ]; then |
| 9 | t=$1 | 9 | t=$1 |
diff --git a/src/lib/libssl/test/tpkcs7d b/src/lib/libssl/test/tpkcs7d index c8f18fb09c..46e5aa2bd6 100644 --- a/src/lib/libssl/test/tpkcs7d +++ b/src/lib/libssl/test/tpkcs7d | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | PATH=../apps:$PATH | 3 | PATH=../apps:$PATH |
| 4 | export PATH | 4 | export PATH |
| 5 | 5 | ||
| 6 | cmd='../apps/ssleay pkcs7' | 6 | cmd='../apps/openssl pkcs7' |
| 7 | 7 | ||
| 8 | if [ "$1"x != "x" ]; then | 8 | if [ "$1"x != "x" ]; then |
| 9 | t=$1 | 9 | t=$1 |
| @@ -11,7 +11,7 @@ else | |||
| 11 | t=pkcs7-1.pem | 11 | t=pkcs7-1.pem |
| 12 | fi | 12 | fi |
| 13 | 13 | ||
| 14 | echo testing pkcs7 conversions | 14 | echo "testing pkcs7 conversions (2)" |
| 15 | cp $t fff.p | 15 | cp $t fff.p |
| 16 | 16 | ||
| 17 | echo "p -> d" | 17 | echo "p -> d" |
diff --git a/src/lib/libssl/test/treq b/src/lib/libssl/test/treq index e5f1d8cc41..9f5eb7eea5 100644 --- a/src/lib/libssl/test/treq +++ b/src/lib/libssl/test/treq | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | PATH=../apps:$PATH | 3 | PATH=../apps:$PATH |
| 4 | export PATH | 4 | export PATH |
| 5 | 5 | ||
| 6 | cmd='../apps/ssleay req' | 6 | cmd='../apps/openssl req -config ../apps/openssl.cnf' |
| 7 | 7 | ||
| 8 | if [ "$1"x != "x" ]; then | 8 | if [ "$1"x != "x" ]; then |
| 9 | t=$1 | 9 | t=$1 |
| @@ -11,6 +11,11 @@ else | |||
| 11 | t=testreq.pem | 11 | t=testreq.pem |
| 12 | fi | 12 | fi |
| 13 | 13 | ||
| 14 | if $cmd -in $t -inform p -noout -text | fgrep 'Unknown Public Key'; then | ||
| 15 | echo "skipping req conversion test for $t" | ||
| 16 | exit 0 | ||
| 17 | fi | ||
| 18 | |||
| 14 | echo testing req conversions | 19 | echo testing req conversions |
| 15 | cp $t fff.p | 20 | cp $t fff.p |
| 16 | 21 | ||
diff --git a/src/lib/libssl/test/trsa b/src/lib/libssl/test/trsa index e5b8fe0448..bd6c07650a 100644 --- a/src/lib/libssl/test/trsa +++ b/src/lib/libssl/test/trsa | |||
| @@ -3,7 +3,12 @@ | |||
| 3 | PATH=../apps:$PATH | 3 | PATH=../apps:$PATH |
| 4 | export PATH | 4 | export PATH |
| 5 | 5 | ||
| 6 | cmd='../apps/ssleay rsa' | 6 | if ../apps/openssl no-rsa; then |
| 7 | echo skipping rsa conversion test | ||
| 8 | exit 0 | ||
| 9 | fi | ||
| 10 | |||
| 11 | cmd='../apps/openssl rsa' | ||
| 7 | 12 | ||
| 8 | if [ "$1"x != "x" ]; then | 13 | if [ "$1"x != "x" ]; then |
| 9 | t=$1 | 14 | t=$1 |
diff --git a/src/lib/libssl/test/tsid b/src/lib/libssl/test/tsid index 8c7e9b1387..9e0854516c 100644 --- a/src/lib/libssl/test/tsid +++ b/src/lib/libssl/test/tsid | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | PATH=../apps:$PATH | 3 | PATH=../apps:$PATH |
| 4 | export PATH | 4 | export PATH |
| 5 | 5 | ||
| 6 | cmd='../apps/ssleay sess_id' | 6 | cmd='../apps/openssl sess_id' |
| 7 | 7 | ||
| 8 | if [ "$1"x != "x" ]; then | 8 | if [ "$1"x != "x" ]; then |
| 9 | t=$1 | 9 | t=$1 |
diff --git a/src/lib/libssl/test/tx509 b/src/lib/libssl/test/tx509 index f8d1f82cdd..35169f3a43 100644 --- a/src/lib/libssl/test/tx509 +++ b/src/lib/libssl/test/tx509 | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | PATH=../apps:$PATH | 3 | PATH=../apps:$PATH |
| 4 | export PATH | 4 | export PATH |
| 5 | 5 | ||
| 6 | cmd='../apps/ssleay x509' | 6 | cmd='../apps/openssl x509' |
| 7 | 7 | ||
| 8 | if [ "$1"x != "x" ]; then | 8 | if [ "$1"x != "x" ]; then |
| 9 | t=$1 | 9 | t=$1 |
diff --git a/src/lib/libssl/tls1.h b/src/lib/libssl/tls1.h index 60978613ef..88ec5fb527 100644 --- a/src/lib/libssl/tls1.h +++ b/src/lib/libssl/tls1.h | |||
| @@ -59,12 +59,14 @@ | |||
| 59 | #ifndef HEADER_TLS1_H | 59 | #ifndef HEADER_TLS1_H |
| 60 | #define HEADER_TLS1_H | 60 | #define HEADER_TLS1_H |
| 61 | 61 | ||
| 62 | #include "buffer.h" | 62 | #include <openssl/buffer.h> |
| 63 | 63 | ||
| 64 | #ifdef __cplusplus | 64 | #ifdef __cplusplus |
| 65 | extern "C" { | 65 | extern "C" { |
| 66 | #endif | 66 | #endif |
| 67 | 67 | ||
| 68 | #define TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES 1 | ||
| 69 | |||
| 68 | #define TLS1_VERSION 0x0301 | 70 | #define TLS1_VERSION 0x0301 |
| 69 | #define TLS1_VERSION_MAJOR 0x03 | 71 | #define TLS1_VERSION_MAJOR 0x03 |
| 70 | #define TLS1_VERSION_MINOR 0x01 | 72 | #define TLS1_VERSION_MINOR 0x01 |
| @@ -75,13 +77,71 @@ extern "C" { | |||
| 75 | #define TLS1_AD_ACCESS_DENIED 49 /* fatal */ | 77 | #define TLS1_AD_ACCESS_DENIED 49 /* fatal */ |
| 76 | #define TLS1_AD_DECODE_ERROR 50 /* fatal */ | 78 | #define TLS1_AD_DECODE_ERROR 50 /* fatal */ |
| 77 | #define TLS1_AD_DECRYPT_ERROR 51 | 79 | #define TLS1_AD_DECRYPT_ERROR 51 |
| 78 | #define TLS1_AD_EXPORT_RESTRICION 60 /* fatal */ | 80 | #define TLS1_AD_EXPORT_RESTRICTION 60 /* fatal */ |
| 79 | #define TLS1_AD_PROTOCOL_VERSION 70 /* fatal */ | 81 | #define TLS1_AD_PROTOCOL_VERSION 70 /* fatal */ |
| 80 | #define TLS1_AD_INSUFFICIENT_SECURITY 71 /* fatal */ | 82 | #define TLS1_AD_INSUFFICIENT_SECURITY 71 /* fatal */ |
| 81 | #define TLS1_AD_INTERNAL_ERROR 80 /* fatal */ | 83 | #define TLS1_AD_INTERNAL_ERROR 80 /* fatal */ |
| 82 | #define TLS1_AD_USER_CANCLED 90 | 84 | #define TLS1_AD_USER_CANCELLED 90 |
| 83 | #define TLS1_AD_NO_RENEGOTIATION 100 | 85 | #define TLS1_AD_NO_RENEGOTIATION 100 |
| 84 | 86 | ||
| 87 | /* Additional TLS ciphersuites from draft-ietf-tls-56-bit-ciphersuites-00.txt | ||
| 88 | * (available if TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES is defined, see | ||
| 89 | * s3_lib.c). We actually treat them like SSL 3.0 ciphers, which we probably | ||
| 90 | * shouldn't. */ | ||
| 91 | #define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_MD5 0x03000060 | ||
| 92 | #define TLS1_CK_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5 0x03000061 | ||
| 93 | #define TLS1_CK_RSA_EXPORT1024_WITH_DES_CBC_SHA 0x03000062 | ||
| 94 | #define TLS1_CK_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA 0x03000063 | ||
| 95 | #define TLS1_CK_RSA_EXPORT1024_WITH_RC4_56_SHA 0x03000064 | ||
| 96 | #define TLS1_CK_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA 0x03000065 | ||
| 97 | #define TLS1_CK_DHE_DSS_WITH_RC4_128_SHA 0x03000066 | ||
| 98 | |||
| 99 | /* AES ciphersuites from draft ietf-tls-ciphersuite-03.txt */ | ||
| 100 | |||
| 101 | #define TLS1_CK_RSA_WITH_AES_128_SHA 0x0300002F | ||
| 102 | #define TLS1_CK_DH_DSS_WITH_AES_128_SHA 0x03000030 | ||
| 103 | #define TLS1_CK_DH_RSA_WITH_AES_128_SHA 0x03000031 | ||
| 104 | #define TLS1_CK_DHE_DSS_WITH_AES_128_SHA 0x03000032 | ||
| 105 | #define TLS1_CK_DHE_RSA_WITH_AES_128_SHA 0x03000033 | ||
| 106 | #define TLS1_CK_ADH_WITH_AES_128_SHA 0x03000034 | ||
| 107 | |||
| 108 | #define TLS1_CK_RSA_WITH_AES_256_SHA 0x03000035 | ||
| 109 | #define TLS1_CK_DH_DSS_WITH_AES_256_SHA 0x03000036 | ||
| 110 | #define TLS1_CK_DH_RSA_WITH_AES_256_SHA 0x03000037 | ||
| 111 | #define TLS1_CK_DHE_DSS_WITH_AES_256_SHA 0x03000038 | ||
| 112 | #define TLS1_CK_DHE_RSA_WITH_AES_256_SHA 0x03000039 | ||
| 113 | #define TLS1_CK_ADH_WITH_AES_256_SHA 0x0300003A | ||
| 114 | |||
| 115 | /* XXX | ||
| 116 | * Inconsistency alert: | ||
| 117 | * The OpenSSL names of ciphers with ephemeral DH here include the string | ||
| 118 | * "DHE", while elsewhere it has always been "EDH". | ||
| 119 | * (The alias for the list of all such ciphers also is "EDH".) | ||
| 120 | * The specifications speak of "EDH"; maybe we should allow both forms | ||
| 121 | * for everything. */ | ||
| 122 | #define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_MD5 "EXP1024-RC4-MD5" | ||
| 123 | #define TLS1_TXT_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5 "EXP1024-RC2-CBC-MD5" | ||
| 124 | #define TLS1_TXT_RSA_EXPORT1024_WITH_DES_CBC_SHA "EXP1024-DES-CBC-SHA" | ||
| 125 | #define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA "EXP1024-DHE-DSS-DES-CBC-SHA" | ||
| 126 | #define TLS1_TXT_RSA_EXPORT1024_WITH_RC4_56_SHA "EXP1024-RC4-SHA" | ||
| 127 | #define TLS1_TXT_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA "EXP1024-DHE-DSS-RC4-SHA" | ||
| 128 | #define TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA "DHE-DSS-RC4-SHA" | ||
| 129 | /* AES ciphersuites from draft-ietf-tls-ciphersuite-06.txt */ | ||
| 130 | #define TLS1_TXT_RSA_WITH_AES_128_SHA "AESdraft128-SHA" | ||
| 131 | #define TLS1_TXT_DH_DSS_WITH_AES_128_SHA "DH-DSS-AESdraft128-SHA" | ||
| 132 | #define TLS1_TXT_DH_RSA_WITH_AES_128_SHA "DH-RSA-AESdraft128-SHA" | ||
| 133 | #define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA "DHE-DSS-AESdraft128-SHA" | ||
| 134 | #define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA "DHE-RSA-AESdraft128-SHA" | ||
| 135 | #define TLS1_TXT_ADH_WITH_AES_128_SHA "ADH-AESdraft128-SHA" | ||
| 136 | |||
| 137 | #define TLS1_TXT_RSA_WITH_AES_256_SHA "AESdraft256-SHA" | ||
| 138 | #define TLS1_TXT_DH_DSS_WITH_AES_256_SHA "DH-DSS-AESdraft256-SHA" | ||
| 139 | #define TLS1_TXT_DH_RSA_WITH_AES_256_SHA "DH-RSA-AESdraft256-SHA" | ||
| 140 | #define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA "DHE-DSS-AESdraft256-SHA" | ||
| 141 | #define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA "DHE-RSA-AESdraft256-SHA" | ||
| 142 | #define TLS1_TXT_ADH_WITH_AES_256_SHA "ADH-AESdraft256-SHA" | ||
| 143 | |||
| 144 | |||
| 85 | #define TLS_CT_RSA_SIGN 1 | 145 | #define TLS_CT_RSA_SIGN 1 |
| 86 | #define TLS_CT_DSS_SIGN 2 | 146 | #define TLS_CT_DSS_SIGN 2 |
| 87 | #define TLS_CT_RSA_FIXED_DH 3 | 147 | #define TLS_CT_RSA_FIXED_DH 3 |
| @@ -108,6 +168,25 @@ extern "C" { | |||
| 108 | #define TLS_MD_MASTER_SECRET_CONST "master secret" | 168 | #define TLS_MD_MASTER_SECRET_CONST "master secret" |
| 109 | #define TLS_MD_MASTER_SECRET_CONST_SIZE 13 | 169 | #define TLS_MD_MASTER_SECRET_CONST_SIZE 13 |
| 110 | 170 | ||
| 171 | #ifdef CHARSET_EBCDIC | ||
| 172 | #undef TLS_MD_CLIENT_FINISH_CONST | ||
| 173 | #define TLS_MD_CLIENT_FINISH_CONST "\x63\x6c\x69\x65\x6e\x74\x20\x66\x69\x6e\x69\x73\x68\x65\x64" /*client finished*/ | ||
| 174 | #undef TLS_MD_SERVER_FINISH_CONST | ||
| 175 | #define TLS_MD_SERVER_FINISH_CONST "\x73\x65\x72\x76\x65\x72\x20\x66\x69\x6e\x69\x73\x68\x65\x64" /*server finished*/ | ||
| 176 | #undef TLS_MD_SERVER_WRITE_KEY_CONST | ||
| 177 | #define TLS_MD_SERVER_WRITE_KEY_CONST "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" /*server write key*/ | ||
| 178 | #undef TLS_MD_KEY_EXPANSION_CONST | ||
| 179 | #define TLS_MD_KEY_EXPANSION_CONST "\x6b\x65\x79\x20\x65\x78\x70\x61\x6e\x73\x69\x6f\x6e" /*key expansion*/ | ||
| 180 | #undef TLS_MD_CLIENT_WRITE_KEY_CONST | ||
| 181 | #define TLS_MD_CLIENT_WRITE_KEY_CONST "\x63\x6c\x69\x65\x6e\x74\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" /*client write key*/ | ||
| 182 | #undef TLS_MD_SERVER_WRITE_KEY_CONST | ||
| 183 | #define TLS_MD_SERVER_WRITE_KEY_CONST "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" /*server write key*/ | ||
| 184 | #undef TLS_MD_IV_BLOCK_CONST | ||
| 185 | #define TLS_MD_IV_BLOCK_CONST "\x49\x56\x20\x62\x6c\x6f\x63\x6b" /*IV block*/ | ||
| 186 | #undef TLS_MD_MASTER_SECRET_CONST | ||
| 187 | #define TLS_MD_MASTER_SECRET_CONST "\x6d\x61\x73\x74\x65\x72\x20\x73\x65\x63\x72\x65\x74" /*master secret*/ | ||
| 188 | #endif | ||
| 189 | |||
| 111 | #ifdef __cplusplus | 190 | #ifdef __cplusplus |
| 112 | } | 191 | } |
| 113 | #endif | 192 | #endif |
