diff options
Diffstat (limited to 'src/lib/libssl/src/demos/tunala/tunala.c')
-rw-r--r-- | src/lib/libssl/src/demos/tunala/tunala.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/lib/libssl/src/demos/tunala/tunala.c b/src/lib/libssl/src/demos/tunala/tunala.c index e802a6209f..e918cba2ce 100644 --- a/src/lib/libssl/src/demos/tunala/tunala.c +++ b/src/lib/libssl/src/demos/tunala/tunala.c | |||
@@ -69,8 +69,8 @@ typedef struct _tunala_world_t { | |||
69 | static SSL_CTX *initialise_ssl_ctx(int server_mode, const char *engine_id, | 69 | static SSL_CTX *initialise_ssl_ctx(int server_mode, const char *engine_id, |
70 | const char *CAfile, const char *cert, const char *key, | 70 | const char *CAfile, const char *cert, const char *key, |
71 | const char *dcert, const char *dkey, const char *cipher_list, | 71 | const char *dcert, const char *dkey, const char *cipher_list, |
72 | const char *dh_file, const char *dh_special, int ctx_options, | 72 | const char *dh_file, const char *dh_special, int tmp_rsa, |
73 | int out_state, int out_verify, int verify_mode, | 73 | int ctx_options, int out_state, int out_verify, int verify_mode, |
74 | unsigned int verify_depth); | 74 | unsigned int verify_depth); |
75 | static void selector_init(tunala_selector_t *selector); | 75 | static void selector_init(tunala_selector_t *selector); |
76 | static void selector_add_listener(tunala_selector_t *selector, int fd); | 76 | static void selector_add_listener(tunala_selector_t *selector, int fd); |
@@ -102,6 +102,7 @@ static int def_flipped = 0; | |||
102 | static const char *def_cipher_list = NULL; | 102 | static const char *def_cipher_list = NULL; |
103 | static const char *def_dh_file = NULL; | 103 | static const char *def_dh_file = NULL; |
104 | static const char *def_dh_special = NULL; | 104 | static const char *def_dh_special = NULL; |
105 | static int def_tmp_rsa = 1; | ||
105 | static int def_ctx_options = 0; | 106 | static int def_ctx_options = 0; |
106 | static int def_verify_mode = 0; | 107 | static int def_verify_mode = 0; |
107 | static unsigned int def_verify_depth = 10; | 108 | static unsigned int def_verify_depth = 10; |
@@ -127,6 +128,7 @@ static const char *helpstring = | |||
127 | " -cipher <list> (specifies cipher list to use)\n" | 128 | " -cipher <list> (specifies cipher list to use)\n" |
128 | " -dh_file <path> (a PEM file containing DH parameters to use)\n" | 129 | " -dh_file <path> (a PEM file containing DH parameters to use)\n" |
129 | " -dh_special <NULL|generate|standard> (see below: def=NULL)\n" | 130 | " -dh_special <NULL|generate|standard> (see below: def=NULL)\n" |
131 | " -no_tmp_rsa (don't generate temporary RSA keys)\n" | ||
130 | " -no_ssl2 (disable SSLv2)\n" | 132 | " -no_ssl2 (disable SSLv2)\n" |
131 | " -no_ssl3 (disable SSLv3)\n" | 133 | " -no_ssl3 (disable SSLv3)\n" |
132 | " -no_tls1 (disable TLSv1)\n" | 134 | " -no_tls1 (disable TLSv1)\n" |
@@ -306,6 +308,7 @@ int main(int argc, char *argv[]) | |||
306 | const char *cipher_list = def_cipher_list; | 308 | const char *cipher_list = def_cipher_list; |
307 | const char *dh_file = def_dh_file; | 309 | const char *dh_file = def_dh_file; |
308 | const char *dh_special = def_dh_special; | 310 | const char *dh_special = def_dh_special; |
311 | int tmp_rsa = def_tmp_rsa; | ||
309 | int ctx_options = def_ctx_options; | 312 | int ctx_options = def_ctx_options; |
310 | int verify_mode = def_verify_mode; | 313 | int verify_mode = def_verify_mode; |
311 | unsigned int verify_depth = def_verify_depth; | 314 | unsigned int verify_depth = def_verify_depth; |
@@ -427,6 +430,9 @@ next_arg: | |||
427 | if(!parse_dh_special(*argv, &dh_special)) | 430 | if(!parse_dh_special(*argv, &dh_special)) |
428 | return 1; | 431 | return 1; |
429 | goto next_arg; | 432 | goto next_arg; |
433 | } else if(strcmp(*argv, "-no_tmp_rsa") == 0) { | ||
434 | tmp_rsa = 0; | ||
435 | goto next_arg; | ||
430 | } else if(strcmp(*argv, "-no_ssl2") == 0) { | 436 | } else if(strcmp(*argv, "-no_ssl2") == 0) { |
431 | ctx_options |= SSL_OP_NO_SSLv2; | 437 | ctx_options |= SSL_OP_NO_SSLv2; |
432 | goto next_arg; | 438 | goto next_arg; |
@@ -487,7 +493,7 @@ next_arg: | |||
487 | /* Create the SSL_CTX */ | 493 | /* Create the SSL_CTX */ |
488 | if((world.ssl_ctx = initialise_ssl_ctx(server_mode, engine_id, | 494 | if((world.ssl_ctx = initialise_ssl_ctx(server_mode, engine_id, |
489 | cacert, cert, key, dcert, dkey, cipher_list, dh_file, | 495 | cacert, cert, key, dcert, dkey, cipher_list, dh_file, |
490 | dh_special, ctx_options, out_state, out_verify, | 496 | dh_special, tmp_rsa, ctx_options, out_state, out_verify, |
491 | verify_mode, verify_depth)) == NULL) | 497 | verify_mode, verify_depth)) == NULL) |
492 | return err_str1("initialise_ssl_ctx(engine_id=%s) failed", | 498 | return err_str1("initialise_ssl_ctx(engine_id=%s) failed", |
493 | (engine_id == NULL) ? "NULL" : engine_id); | 499 | (engine_id == NULL) ? "NULL" : engine_id); |
@@ -522,8 +528,13 @@ main_loop: | |||
522 | /* Now do the select */ | 528 | /* Now do the select */ |
523 | switch(selector_select(&world.selector)) { | 529 | switch(selector_select(&world.selector)) { |
524 | case -1: | 530 | case -1: |
525 | fprintf(stderr, "selector_select returned a badness error.\n"); | 531 | if(errno != EINTR) { |
526 | goto shouldnt_happen; | 532 | fprintf(stderr, "selector_select returned a " |
533 | "badness error.\n"); | ||
534 | goto shouldnt_happen; | ||
535 | } | ||
536 | fprintf(stderr, "Warn, selector interrupted by a signal\n"); | ||
537 | goto main_loop; | ||
527 | case 0: | 538 | case 0: |
528 | fprintf(stderr, "Warn, selector_select returned 0 - signal?""?\n"); | 539 | fprintf(stderr, "Warn, selector_select returned 0 - signal?""?\n"); |
529 | goto main_loop; | 540 | goto main_loop; |
@@ -717,8 +728,8 @@ do_it: | |||
717 | static SSL_CTX *initialise_ssl_ctx(int server_mode, const char *engine_id, | 728 | static SSL_CTX *initialise_ssl_ctx(int server_mode, const char *engine_id, |
718 | const char *CAfile, const char *cert, const char *key, | 729 | const char *CAfile, const char *cert, const char *key, |
719 | const char *dcert, const char *dkey, const char *cipher_list, | 730 | const char *dcert, const char *dkey, const char *cipher_list, |
720 | const char *dh_file, const char *dh_special, int ctx_options, | 731 | const char *dh_file, const char *dh_special, int tmp_rsa, |
721 | int out_state, int out_verify, int verify_mode, | 732 | int ctx_options, int out_state, int out_verify, int verify_mode, |
722 | unsigned int verify_depth) | 733 | unsigned int verify_depth) |
723 | { | 734 | { |
724 | SSL_CTX *ctx = NULL, *ret = NULL; | 735 | SSL_CTX *ctx = NULL, *ret = NULL; |
@@ -770,6 +781,9 @@ static SSL_CTX *initialise_ssl_ctx(int server_mode, const char *engine_id, | |||
770 | /* dcert and dkey */ | 781 | /* dcert and dkey */ |
771 | if((dcert || dkey) && !ctx_set_cert(ctx, dcert, dkey)) | 782 | if((dcert || dkey) && !ctx_set_cert(ctx, dcert, dkey)) |
772 | goto err; | 783 | goto err; |
784 | /* temporary RSA key generation */ | ||
785 | if(tmp_rsa) | ||
786 | SSL_CTX_set_tmp_rsa_callback(ctx, cb_generate_tmp_rsa); | ||
773 | 787 | ||
774 | /* cipher_list */ | 788 | /* cipher_list */ |
775 | if(cipher_list) { | 789 | if(cipher_list) { |