diff options
author | markus <> | 2003-05-11 21:36:59 +0000 |
---|---|---|
committer | markus <> | 2003-05-11 21:36:59 +0000 |
commit | 9cea7b85baecb1a02a3ea617de73d9693a9792eb (patch) | |
tree | b0ca83a03e35572831c5818cd2011868d462a5d1 /src/lib/libssl/src/ssl/ssltest.c | |
parent | f8f1d7fabf136ce9810602509c477d2c42bf6d1c (diff) | |
download | openbsd-9cea7b85baecb1a02a3ea617de73d9693a9792eb.tar.gz openbsd-9cea7b85baecb1a02a3ea617de73d9693a9792eb.tar.bz2 openbsd-9cea7b85baecb1a02a3ea617de73d9693a9792eb.zip |
import 0.9.7b (without idea and rc5)
Diffstat (limited to 'src/lib/libssl/src/ssl/ssltest.c')
-rw-r--r-- | src/lib/libssl/src/ssl/ssltest.c | 52 |
1 files changed, 39 insertions, 13 deletions
diff --git a/src/lib/libssl/src/ssl/ssltest.c b/src/lib/libssl/src/ssl/ssltest.c index 4f6379e160..47c383200a 100644 --- a/src/lib/libssl/src/ssl/ssltest.c +++ b/src/lib/libssl/src/ssl/ssltest.c | |||
@@ -109,11 +109,8 @@ | |||
109 | * | 109 | * |
110 | */ | 110 | */ |
111 | 111 | ||
112 | #define _XOPEN_SOURCE 600 /* Or gethostname won't be declared properly | 112 | #define _BSD_SOURCE 1 /* Or gethostname won't be declared properly |
113 | on Linux and GNU platforms. */ | 113 | on Linux and GNU platforms. */ |
114 | #define _XOPEN_SOURCE_EXTENDED 1 /* Or gethostname won't be declared properly | ||
115 | on Compaq platforms (at least with DEC C). | ||
116 | */ | ||
117 | 114 | ||
118 | #include <assert.h> | 115 | #include <assert.h> |
119 | #include <errno.h> | 116 | #include <errno.h> |
@@ -123,6 +120,7 @@ | |||
123 | #include <string.h> | 120 | #include <string.h> |
124 | #include <time.h> | 121 | #include <time.h> |
125 | 122 | ||
123 | #define USE_SOCKETS | ||
126 | #include "e_os.h" | 124 | #include "e_os.h" |
127 | 125 | ||
128 | #include <openssl/bio.h> | 126 | #include <openssl/bio.h> |
@@ -130,12 +128,20 @@ | |||
130 | #include <openssl/evp.h> | 128 | #include <openssl/evp.h> |
131 | #include <openssl/x509.h> | 129 | #include <openssl/x509.h> |
132 | #include <openssl/ssl.h> | 130 | #include <openssl/ssl.h> |
131 | #ifndef OPENSSL_NO_ENGINE | ||
133 | #include <openssl/engine.h> | 132 | #include <openssl/engine.h> |
133 | #endif | ||
134 | #include <openssl/err.h> | 134 | #include <openssl/err.h> |
135 | #include <openssl/rand.h> | 135 | #include <openssl/rand.h> |
136 | |||
137 | #define _XOPEN_SOURCE_EXTENDED 1 /* Or gethostname won't be declared properly | ||
138 | on Compaq platforms (at least with DEC C). | ||
139 | Do not try to put it earlier, or IPv6 includes | ||
140 | get screwed... | ||
141 | */ | ||
142 | |||
136 | #ifdef OPENSSL_SYS_WINDOWS | 143 | #ifdef OPENSSL_SYS_WINDOWS |
137 | #include <winsock.h> | 144 | #include <winsock.h> |
138 | #include "../crypto/bio/bss_file.c" | ||
139 | #else | 145 | #else |
140 | #include OPENSSL_UNISTD | 146 | #include OPENSSL_UNISTD |
141 | #endif | 147 | #endif |
@@ -143,6 +149,9 @@ | |||
143 | #ifdef OPENSSL_SYS_VMS | 149 | #ifdef OPENSSL_SYS_VMS |
144 | # define TEST_SERVER_CERT "SYS$DISK:[-.APPS]SERVER.PEM" | 150 | # define TEST_SERVER_CERT "SYS$DISK:[-.APPS]SERVER.PEM" |
145 | # define TEST_CLIENT_CERT "SYS$DISK:[-.APPS]CLIENT.PEM" | 151 | # define TEST_CLIENT_CERT "SYS$DISK:[-.APPS]CLIENT.PEM" |
152 | #elif defined(OPENSSL_SYS_WINCE) | ||
153 | # define TEST_SERVER_CERT "\\OpenSSL\\server.pem" | ||
154 | # define TEST_CLIENT_CERT "\\OpenSSL\\client.pem" | ||
146 | #else | 155 | #else |
147 | # define TEST_SERVER_CERT "../apps/server.pem" | 156 | # define TEST_SERVER_CERT "../apps/server.pem" |
148 | # define TEST_CLIENT_CERT "../apps/client.pem" | 157 | # define TEST_CLIENT_CERT "../apps/client.pem" |
@@ -364,7 +373,9 @@ int main(int argc, char *argv[]) | |||
364 | verbose = 0; | 373 | verbose = 0; |
365 | debug = 0; | 374 | debug = 0; |
366 | cipher = 0; | 375 | cipher = 0; |
367 | 376 | ||
377 | bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); | ||
378 | |||
368 | CRYPTO_set_locking_callback(lock_dbg_cb); | 379 | CRYPTO_set_locking_callback(lock_dbg_cb); |
369 | 380 | ||
370 | /* enable memory leak checking unless explicitly disabled */ | 381 | /* enable memory leak checking unless explicitly disabled */ |
@@ -382,7 +393,6 @@ int main(int argc, char *argv[]) | |||
382 | 393 | ||
383 | RAND_seed(rnd_seed, sizeof rnd_seed); | 394 | RAND_seed(rnd_seed, sizeof rnd_seed); |
384 | 395 | ||
385 | bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); | ||
386 | bio_stdout=BIO_new_fp(stdout,BIO_NOCLOSE); | 396 | bio_stdout=BIO_new_fp(stdout,BIO_NOCLOSE); |
387 | 397 | ||
388 | argc--; | 398 | argc--; |
@@ -405,7 +415,7 @@ int main(int argc, char *argv[]) | |||
405 | #ifndef OPENSSL_NO_DH | 415 | #ifndef OPENSSL_NO_DH |
406 | dhe1024=1; | 416 | dhe1024=1; |
407 | #else | 417 | #else |
408 | fprintf(stderr,"ignoring -dhe1024, since I'm compiled without DH\n"; | 418 | fprintf(stderr,"ignoring -dhe1024, since I'm compiled without DH\n"); |
409 | #endif | 419 | #endif |
410 | } | 420 | } |
411 | else if (strcmp(*argv,"-dhe1024dsa") == 0) | 421 | else if (strcmp(*argv,"-dhe1024dsa") == 0) |
@@ -413,7 +423,7 @@ int main(int argc, char *argv[]) | |||
413 | #ifndef OPENSSL_NO_DH | 423 | #ifndef OPENSSL_NO_DH |
414 | dhe1024dsa=1; | 424 | dhe1024dsa=1; |
415 | #else | 425 | #else |
416 | fprintf(stderr,"ignoring -dhe1024, since I'm compiled without DH\n"; | 426 | fprintf(stderr,"ignoring -dhe1024, since I'm compiled without DH\n"); |
417 | #endif | 427 | #endif |
418 | } | 428 | } |
419 | else if (strcmp(*argv,"-no_dhe") == 0) | 429 | else if (strcmp(*argv,"-no_dhe") == 0) |
@@ -530,7 +540,7 @@ bad: | |||
530 | "the test anyway (and\n-d to see what happens), " | 540 | "the test anyway (and\n-d to see what happens), " |
531 | "or add one of -ssl2, -ssl3, -tls1, -reuse\n" | 541 | "or add one of -ssl2, -ssl3, -tls1, -reuse\n" |
532 | "to avoid protocol mismatch.\n"); | 542 | "to avoid protocol mismatch.\n"); |
533 | exit(1); | 543 | EXIT(1); |
534 | } | 544 | } |
535 | 545 | ||
536 | if (print_time) | 546 | if (print_time) |
@@ -686,10 +696,16 @@ bad: | |||
686 | #ifndef OPENSSL_NO_KRB5 | 696 | #ifndef OPENSSL_NO_KRB5 |
687 | if (c_ssl && c_ssl->kssl_ctx) | 697 | if (c_ssl && c_ssl->kssl_ctx) |
688 | { | 698 | { |
689 | char localhost[257]; | 699 | char localhost[MAXHOSTNAMELEN+2]; |
690 | 700 | ||
691 | if (gethostname(localhost, 256) == 0) | 701 | if (gethostname(localhost, sizeof localhost-1) == 0) |
692 | { | 702 | { |
703 | localhost[sizeof localhost-1]='\0'; | ||
704 | if(strlen(localhost) == sizeof localhost-1) | ||
705 | { | ||
706 | BIO_printf(bio_err,"localhost name too long\n"); | ||
707 | goto end; | ||
708 | } | ||
693 | kssl_ctx_setstring(c_ssl->kssl_ctx, KSSL_SERVER, | 709 | kssl_ctx_setstring(c_ssl->kssl_ctx, KSSL_SERVER, |
694 | localhost); | 710 | localhost); |
695 | } | 711 | } |
@@ -745,7 +761,9 @@ end: | |||
745 | #ifndef OPENSSL_NO_RSA | 761 | #ifndef OPENSSL_NO_RSA |
746 | free_tmp_rsa(); | 762 | free_tmp_rsa(); |
747 | #endif | 763 | #endif |
764 | #ifndef OPENSSL_NO_ENGINE | ||
748 | ENGINE_cleanup(); | 765 | ENGINE_cleanup(); |
766 | #endif | ||
749 | CRYPTO_cleanup_all_ex_data(); | 767 | CRYPTO_cleanup_all_ex_data(); |
750 | ERR_free_strings(); | 768 | ERR_free_strings(); |
751 | ERR_remove_state(0); | 769 | ERR_remove_state(0); |
@@ -835,6 +853,8 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count, | |||
835 | int i, r; | 853 | int i, r; |
836 | clock_t c_clock = clock(); | 854 | clock_t c_clock = clock(); |
837 | 855 | ||
856 | memset(cbuf, 0, sizeof(cbuf)); | ||
857 | |||
838 | if (debug) | 858 | if (debug) |
839 | if (SSL_in_init(c_ssl)) | 859 | if (SSL_in_init(c_ssl)) |
840 | printf("client waiting in SSL_connect - %s\n", | 860 | printf("client waiting in SSL_connect - %s\n", |
@@ -919,6 +939,8 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count, | |||
919 | int i, r; | 939 | int i, r; |
920 | clock_t s_clock = clock(); | 940 | clock_t s_clock = clock(); |
921 | 941 | ||
942 | memset(sbuf, 0, sizeof(sbuf)); | ||
943 | |||
922 | if (debug) | 944 | if (debug) |
923 | if (SSL_in_init(s_ssl)) | 945 | if (SSL_in_init(s_ssl)) |
924 | printf("server waiting in SSL_accept - %s\n", | 946 | printf("server waiting in SSL_accept - %s\n", |
@@ -1162,6 +1184,9 @@ int doit(SSL *s_ssl, SSL *c_ssl, long count) | |||
1162 | int c_write,s_write; | 1184 | int c_write,s_write; |
1163 | int do_server=0,do_client=0; | 1185 | int do_server=0,do_client=0; |
1164 | 1186 | ||
1187 | memset(cbuf,0,sizeof(cbuf)); | ||
1188 | memset(sbuf,0,sizeof(sbuf)); | ||
1189 | |||
1165 | c_to_s=BIO_new(BIO_s_mem()); | 1190 | c_to_s=BIO_new(BIO_s_mem()); |
1166 | s_to_c=BIO_new(BIO_s_mem()); | 1191 | s_to_c=BIO_new(BIO_s_mem()); |
1167 | if ((s_to_c == NULL) || (c_to_s == NULL)) | 1192 | if ((s_to_c == NULL) || (c_to_s == NULL)) |
@@ -1443,7 +1468,8 @@ static int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx) | |||
1443 | { | 1468 | { |
1444 | char *s,buf[256]; | 1469 | char *s,buf[256]; |
1445 | 1470 | ||
1446 | s=X509_NAME_oneline(X509_get_subject_name(ctx->current_cert),buf,256); | 1471 | s=X509_NAME_oneline(X509_get_subject_name(ctx->current_cert),buf, |
1472 | sizeof buf); | ||
1447 | if (s != NULL) | 1473 | if (s != NULL) |
1448 | { | 1474 | { |
1449 | if (ok) | 1475 | if (ok) |