diff options
Diffstat (limited to 'src/lib/libssl/src/apps/s_server.c')
| -rw-r--r-- | src/lib/libssl/src/apps/s_server.c | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/src/lib/libssl/src/apps/s_server.c b/src/lib/libssl/src/apps/s_server.c index af19b89227..61a77dff11 100644 --- a/src/lib/libssl/src/apps/s_server.c +++ b/src/lib/libssl/src/apps/s_server.c | |||
| @@ -83,6 +83,7 @@ typedef unsigned int u_int; | |||
| 83 | #include <openssl/pem.h> | 83 | #include <openssl/pem.h> |
| 84 | #include <openssl/x509.h> | 84 | #include <openssl/x509.h> |
| 85 | #include <openssl/ssl.h> | 85 | #include <openssl/ssl.h> |
| 86 | #include <openssl/engine.h> | ||
| 86 | #include "s_apps.h" | 87 | #include "s_apps.h" |
| 87 | 88 | ||
| 88 | #ifdef WINDOWS | 89 | #ifdef WINDOWS |
| @@ -176,6 +177,7 @@ static int s_debug=0; | |||
| 176 | static int s_quiet=0; | 177 | static int s_quiet=0; |
| 177 | 178 | ||
| 178 | static int hack=0; | 179 | static int hack=0; |
| 180 | static char *engine_id=NULL; | ||
| 179 | 181 | ||
| 180 | #ifdef MONOLITH | 182 | #ifdef MONOLITH |
| 181 | static void s_server_init(void) | 183 | static void s_server_init(void) |
| @@ -198,6 +200,7 @@ static void s_server_init(void) | |||
| 198 | s_debug=0; | 200 | s_debug=0; |
| 199 | s_quiet=0; | 201 | s_quiet=0; |
| 200 | hack=0; | 202 | hack=0; |
| 203 | engine_id=NULL; | ||
| 201 | } | 204 | } |
| 202 | #endif | 205 | #endif |
| 203 | 206 | ||
| @@ -242,6 +245,7 @@ static void sv_usage(void) | |||
| 242 | BIO_printf(bio_err," -bugs - Turn on SSL bug compatibility\n"); | 245 | BIO_printf(bio_err," -bugs - Turn on SSL bug compatibility\n"); |
| 243 | BIO_printf(bio_err," -www - Respond to a 'GET /' with a status page\n"); | 246 | BIO_printf(bio_err," -www - Respond to a 'GET /' with a status page\n"); |
| 244 | BIO_printf(bio_err," -WWW - Respond to a 'GET /<path> HTTP/1.0' with file ./<path>\n"); | 247 | BIO_printf(bio_err," -WWW - Respond to a 'GET /<path> HTTP/1.0' with file ./<path>\n"); |
| 248 | BIO_printf(bio_err," -engine id - Initialise and use the specified engine\n"); | ||
| 245 | } | 249 | } |
| 246 | 250 | ||
| 247 | static int local_argc=0; | 251 | static int local_argc=0; |
| @@ -285,7 +289,7 @@ static int ebcdic_new(BIO *bi) | |||
| 285 | { | 289 | { |
| 286 | EBCDIC_OUTBUFF *wbuf; | 290 | EBCDIC_OUTBUFF *wbuf; |
| 287 | 291 | ||
| 288 | wbuf = (EBCDIC_OUTBUFF *)Malloc(sizeof(EBCDIC_OUTBUFF) + 1024); | 292 | wbuf = (EBCDIC_OUTBUFF *)OPENSSL_malloc(sizeof(EBCDIC_OUTBUFF) + 1024); |
| 289 | wbuf->alloced = 1024; | 293 | wbuf->alloced = 1024; |
| 290 | wbuf->buff[0] = '\0'; | 294 | wbuf->buff[0] = '\0'; |
| 291 | 295 | ||
| @@ -299,7 +303,7 @@ static int ebcdic_free(BIO *a) | |||
| 299 | { | 303 | { |
| 300 | if (a == NULL) return(0); | 304 | if (a == NULL) return(0); |
| 301 | if (a->ptr != NULL) | 305 | if (a->ptr != NULL) |
| 302 | Free(a->ptr); | 306 | OPENSSL_free(a->ptr); |
| 303 | a->ptr=NULL; | 307 | a->ptr=NULL; |
| 304 | a->init=0; | 308 | a->init=0; |
| 305 | a->flags=0; | 309 | a->flags=0; |
| @@ -336,8 +340,8 @@ static int ebcdic_write(BIO *b, char *in, int inl) | |||
| 336 | num = num + num; /* double the size */ | 340 | num = num + num; /* double the size */ |
| 337 | if (num < inl) | 341 | if (num < inl) |
| 338 | num = inl; | 342 | num = inl; |
| 339 | Free(wbuf); | 343 | OPENSSL_free(wbuf); |
| 340 | wbuf=(EBCDIC_OUTBUFF *)Malloc(sizeof(EBCDIC_OUTBUFF) + num); | 344 | wbuf=(EBCDIC_OUTBUFF *)OPENSSL_malloc(sizeof(EBCDIC_OUTBUFF) + num); |
| 341 | 345 | ||
| 342 | wbuf->alloced = num; | 346 | wbuf->alloced = num; |
| 343 | wbuf->buff[0] = '\0'; | 347 | wbuf->buff[0] = '\0'; |
| @@ -411,6 +415,7 @@ int MAIN(int argc, char *argv[]) | |||
| 411 | int no_tmp_rsa=0,no_dhe=0,nocert=0; | 415 | int no_tmp_rsa=0,no_dhe=0,nocert=0; |
| 412 | int state=0; | 416 | int state=0; |
| 413 | SSL_METHOD *meth=NULL; | 417 | SSL_METHOD *meth=NULL; |
| 418 | ENGINE *e=NULL; | ||
| 414 | #ifndef NO_DH | 419 | #ifndef NO_DH |
| 415 | DH *dh=NULL; | 420 | DH *dh=NULL; |
| 416 | #endif | 421 | #endif |
| @@ -565,6 +570,11 @@ int MAIN(int argc, char *argv[]) | |||
| 565 | else if (strcmp(*argv,"-tls1") == 0) | 570 | else if (strcmp(*argv,"-tls1") == 0) |
| 566 | { meth=TLSv1_server_method(); } | 571 | { meth=TLSv1_server_method(); } |
| 567 | #endif | 572 | #endif |
| 573 | else if (strcmp(*argv,"-engine") == 0) | ||
| 574 | { | ||
| 575 | if (--argc < 1) goto bad; | ||
| 576 | engine_id= *(++argv); | ||
| 577 | } | ||
| 568 | else | 578 | else |
| 569 | { | 579 | { |
| 570 | BIO_printf(bio_err,"unknown option %s\n",*argv); | 580 | BIO_printf(bio_err,"unknown option %s\n",*argv); |
| @@ -609,6 +619,29 @@ bad: | |||
| 609 | SSL_load_error_strings(); | 619 | SSL_load_error_strings(); |
| 610 | OpenSSL_add_ssl_algorithms(); | 620 | OpenSSL_add_ssl_algorithms(); |
| 611 | 621 | ||
| 622 | if (engine_id != NULL) | ||
| 623 | { | ||
| 624 | if((e = ENGINE_by_id(engine_id)) == NULL) | ||
| 625 | { | ||
| 626 | BIO_printf(bio_err,"invalid engine\n"); | ||
| 627 | ERR_print_errors(bio_err); | ||
| 628 | goto end; | ||
| 629 | } | ||
| 630 | if (s_debug) | ||
| 631 | { | ||
| 632 | ENGINE_ctrl(e, ENGINE_CTRL_SET_LOGSTREAM, | ||
| 633 | 0, bio_err, 0); | ||
| 634 | } | ||
| 635 | if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) | ||
| 636 | { | ||
| 637 | BIO_printf(bio_err,"can't use that engine\n"); | ||
| 638 | ERR_print_errors(bio_err); | ||
| 639 | goto end; | ||
| 640 | } | ||
| 641 | BIO_printf(bio_err,"engine \"%s\" set.\n", engine_id); | ||
| 642 | ENGINE_free(e); | ||
| 643 | } | ||
| 644 | |||
| 612 | ctx=SSL_CTX_new(meth); | 645 | ctx=SSL_CTX_new(meth); |
| 613 | if (ctx == NULL) | 646 | if (ctx == NULL) |
| 614 | { | 647 | { |
| @@ -766,7 +799,7 @@ static int sv_body(char *hostname, int s, unsigned char *context) | |||
| 766 | struct timeval tv; | 799 | struct timeval tv; |
| 767 | #endif | 800 | #endif |
| 768 | 801 | ||
| 769 | if ((buf=Malloc(bufsize)) == NULL) | 802 | if ((buf=OPENSSL_malloc(bufsize)) == NULL) |
| 770 | { | 803 | { |
| 771 | BIO_printf(bio_err,"out of memory\n"); | 804 | BIO_printf(bio_err,"out of memory\n"); |
| 772 | goto err; | 805 | goto err; |
| @@ -1028,7 +1061,7 @@ err: | |||
| 1028 | if (buf != NULL) | 1061 | if (buf != NULL) |
| 1029 | { | 1062 | { |
| 1030 | memset(buf,0,bufsize); | 1063 | memset(buf,0,bufsize); |
| 1031 | Free(buf); | 1064 | OPENSSL_free(buf); |
| 1032 | } | 1065 | } |
| 1033 | if (ret >= 0) | 1066 | if (ret >= 0) |
| 1034 | BIO_printf(bio_s_out,"ACCEPT\n"); | 1067 | BIO_printf(bio_s_out,"ACCEPT\n"); |
| @@ -1145,7 +1178,7 @@ static int www_body(char *hostname, int s, unsigned char *context) | |||
| 1145 | BIO *io,*ssl_bio,*sbio; | 1178 | BIO *io,*ssl_bio,*sbio; |
| 1146 | long total_bytes; | 1179 | long total_bytes; |
| 1147 | 1180 | ||
| 1148 | buf=Malloc(bufsize); | 1181 | buf=OPENSSL_malloc(bufsize); |
| 1149 | if (buf == NULL) return(0); | 1182 | if (buf == NULL) return(0); |
| 1150 | io=BIO_new(BIO_f_buffer()); | 1183 | io=BIO_new(BIO_f_buffer()); |
| 1151 | ssl_bio=BIO_new(BIO_f_ssl()); | 1184 | ssl_bio=BIO_new(BIO_f_ssl()); |
| @@ -1474,7 +1507,7 @@ err: | |||
| 1474 | if (ret >= 0) | 1507 | if (ret >= 0) |
| 1475 | BIO_printf(bio_s_out,"ACCEPT\n"); | 1508 | BIO_printf(bio_s_out,"ACCEPT\n"); |
| 1476 | 1509 | ||
| 1477 | if (buf != NULL) Free(buf); | 1510 | if (buf != NULL) OPENSSL_free(buf); |
| 1478 | if (io != NULL) BIO_free_all(io); | 1511 | if (io != NULL) BIO_free_all(io); |
| 1479 | /* if (ssl_bio != NULL) BIO_free(ssl_bio);*/ | 1512 | /* if (ssl_bio != NULL) BIO_free(ssl_bio);*/ |
| 1480 | return(ret); | 1513 | return(ret); |
