| OLD | NEW |
| 1 /* apps/s_time.c */ | 1 /* apps/s_time.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 * |
| 5 * This package is an SSL implementation written | 5 * This package is an SSL implementation written |
| 6 * by Eric Young (eay@cryptsoft.com). | 6 * by Eric Young (eay@cryptsoft.com). |
| 7 * The implementation was written so as to conform with Netscapes SSL. | 7 * The implementation was written so as to conform with Netscapes SSL. |
| 8 * | 8 * |
| 9 * This library is free for commercial and non-commercial use as long as | 9 * This library is free for commercial and non-commercial use as long as |
| 10 * the following conditions are aheared to. The following conditions | 10 * the following conditions are aheared to. The following conditions |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 #include "s_apps.h" | 78 #include "s_apps.h" |
| 79 #include <openssl/err.h> | 79 #include <openssl/err.h> |
| 80 #ifdef WIN32_STUFF | 80 #ifdef WIN32_STUFF |
| 81 #include "winmain.h" | 81 #include "winmain.h" |
| 82 #include "wintext.h" | 82 #include "wintext.h" |
| 83 #endif | 83 #endif |
| 84 #if !defined(OPENSSL_SYS_MSDOS) | 84 #if !defined(OPENSSL_SYS_MSDOS) |
| 85 #include OPENSSL_UNISTD | 85 #include OPENSSL_UNISTD |
| 86 #endif | 86 #endif |
| 87 | 87 |
| 88 #if !defined(OPENSSL_SYS_NETWARE) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPE
NSSL_SYS_VXWORKS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) | |
| 89 #define TIMES | |
| 90 #endif | |
| 91 | |
| 92 #ifndef _IRIX | |
| 93 #include <time.h> | |
| 94 #endif | |
| 95 #ifdef TIMES | |
| 96 #include <sys/types.h> | |
| 97 #include <sys/times.h> | |
| 98 #endif | |
| 99 | |
| 100 /* Depending on the VMS version, the tms structure is perhaps defined. | |
| 101 The __TMS macro will show if it was. If it wasn't defined, we should | |
| 102 undefine TIMES, since that tells the rest of the program how things | |
| 103 should be handled. -- Richard Levitte */ | |
| 104 #if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS) | |
| 105 #undef TIMES | |
| 106 #endif | |
| 107 | |
| 108 #if !defined(TIMES) && !defined(OPENSSL_SYS_VXWORKS) && !defined(OPENSSL_SYS_NET
WARE) | |
| 109 #include <sys/timeb.h> | |
| 110 #endif | |
| 111 | |
| 112 #if defined(sun) || defined(__ultrix) | |
| 113 #define _POSIX_SOURCE | |
| 114 #include <limits.h> | |
| 115 #include <sys/param.h> | |
| 116 #endif | |
| 117 | |
| 118 /* The following if from times(3) man page. It may need to be changed | |
| 119 */ | |
| 120 #ifndef HZ | |
| 121 # ifdef _SC_CLK_TCK | |
| 122 # define HZ ((double)sysconf(_SC_CLK_TCK)) | |
| 123 # else | |
| 124 # ifndef CLK_TCK | |
| 125 # ifndef _BSD_CLK_TCK_ /* FreeBSD hack */ | |
| 126 # define HZ 100.0 | |
| 127 # else /* _BSD_CLK_TCK_ */ | |
| 128 # define HZ ((double)_BSD_CLK_TCK_) | |
| 129 # endif | |
| 130 # else /* CLK_TCK */ | |
| 131 # define HZ ((double)CLK_TCK) | |
| 132 # endif | |
| 133 # endif | |
| 134 #endif | |
| 135 | |
| 136 #undef PROG | 88 #undef PROG |
| 137 #define PROG s_time_main | 89 #define PROG s_time_main |
| 138 | 90 |
| 139 #undef ioctl | 91 #undef ioctl |
| 140 #define ioctl ioctlsocket | 92 #define ioctl ioctlsocket |
| 141 | 93 |
| 142 #define SSL_CONNECT_NAME "localhost:4433" | 94 #define SSL_CONNECT_NAME "localhost:4433" |
| 143 | 95 |
| 144 /*#define TEST_CERT "client.pem" */ /* no default cert. */ | 96 /*#define TEST_CERT "client.pem" */ /* no default cert. */ |
| 145 | 97 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 170 /* static char *port=PORT_STR;*/ | 122 /* static char *port=PORT_STR;*/ |
| 171 static char *host=SSL_CONNECT_NAME; | 123 static char *host=SSL_CONNECT_NAME; |
| 172 static char *t_cert_file=NULL; | 124 static char *t_cert_file=NULL; |
| 173 static char *t_key_file=NULL; | 125 static char *t_key_file=NULL; |
| 174 static char *CApath=NULL; | 126 static char *CApath=NULL; |
| 175 static char *CAfile=NULL; | 127 static char *CAfile=NULL; |
| 176 static char *tm_cipher=NULL; | 128 static char *tm_cipher=NULL; |
| 177 static int tm_verify = SSL_VERIFY_NONE; | 129 static int tm_verify = SSL_VERIFY_NONE; |
| 178 static int maxTime = SECONDS; | 130 static int maxTime = SECONDS; |
| 179 static SSL_CTX *tm_ctx=NULL; | 131 static SSL_CTX *tm_ctx=NULL; |
| 180 static SSL_METHOD *s_time_meth=NULL; | 132 static const SSL_METHOD *s_time_meth=NULL; |
| 181 static char *s_www_path=NULL; | 133 static char *s_www_path=NULL; |
| 182 static long bytes_read=0; | 134 static long bytes_read=0; |
| 183 static int st_bugs=0; | 135 static int st_bugs=0; |
| 184 static int perform=0; | 136 static int perform=0; |
| 185 #ifdef FIONBIO | 137 #ifdef FIONBIO |
| 186 static int t_nbio=0; | 138 static int t_nbio=0; |
| 187 #endif | 139 #endif |
| 188 #ifdef OPENSSL_SYS_WIN32 | 140 #ifdef OPENSSL_SYS_WIN32 |
| 189 static int exitNow = 0; /* Set when it's time to exit main */ | 141 static int exitNow = 0; /* Set when it's time to exit main */ |
| 190 #endif | 142 #endif |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 } | 317 } |
| 366 | 318 |
| 367 /*********************************************************************** | 319 /*********************************************************************** |
| 368 * TIME - time functions | 320 * TIME - time functions |
| 369 */ | 321 */ |
| 370 #define START 0 | 322 #define START 0 |
| 371 #define STOP 1 | 323 #define STOP 1 |
| 372 | 324 |
| 373 static double tm_Time_F(int s) | 325 static double tm_Time_F(int s) |
| 374 { | 326 { |
| 375 » static double ret; | 327 » return app_tminterval(s,1); |
| 376 #ifdef TIMES | |
| 377 » static struct tms tstart,tend; | |
| 378 | |
| 379 » if(s == START) { | |
| 380 » » times(&tstart); | |
| 381 » » return(0); | |
| 382 » } else { | |
| 383 » » times(&tend); | |
| 384 » » ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ; | |
| 385 » » return((ret == 0.0)?1e-6:ret); | |
| 386 } | 328 } |
| 387 #elif defined(OPENSSL_SYS_NETWARE) | |
| 388 static clock_t tstart,tend; | |
| 389 | |
| 390 if (s == START) | |
| 391 { | |
| 392 tstart=clock(); | |
| 393 return(0); | |
| 394 } | |
| 395 else | |
| 396 { | |
| 397 tend=clock(); | |
| 398 ret=(double)((double)(tend)-(double)(tstart)); | |
| 399 return((ret < 0.001)?0.001:ret); | |
| 400 } | |
| 401 #elif defined(OPENSSL_SYS_VXWORKS) | |
| 402 { | |
| 403 static unsigned long tick_start, tick_end; | |
| 404 | |
| 405 if( s == START ) | |
| 406 { | |
| 407 tick_start = tickGet(); | |
| 408 return 0; | |
| 409 } | |
| 410 else | |
| 411 { | |
| 412 tick_end = tickGet(); | |
| 413 ret = (double)(tick_end - tick_start) / (double)sysClkRateGet(); | |
| 414 return((ret == 0.0)?1e-6:ret); | |
| 415 } | |
| 416 } | |
| 417 #else /* !times() */ | |
| 418 static struct timeb tstart,tend; | |
| 419 long i; | |
| 420 | |
| 421 if(s == START) { | |
| 422 ftime(&tstart); | |
| 423 return(0); | |
| 424 } else { | |
| 425 ftime(&tend); | |
| 426 i=(long)tend.millitm-(long)tstart.millitm; | |
| 427 ret=((double)(tend.time-tstart.time))+((double)i)/1000.0; | |
| 428 return((ret == 0.0)?1e-6:ret); | |
| 429 } | |
| 430 #endif | |
| 431 } | |
| 432 | 329 |
| 433 /*********************************************************************** | 330 /*********************************************************************** |
| 434 * MAIN - main processing area for client | 331 * MAIN - main processing area for client |
| 435 * real name depends on MONOLITH | 332 * real name depends on MONOLITH |
| 436 */ | 333 */ |
| 437 int MAIN(int, char **); | 334 int MAIN(int, char **); |
| 438 | 335 |
| 439 int MAIN(int argc, char **argv) | 336 int MAIN(int argc, char **argv) |
| 440 { | 337 { |
| 441 double totalTime = 0.0; | 338 double totalTime = 0.0; |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 /* ok, lets connect */ | 594 /* ok, lets connect */ |
| 698 for(;;) { | 595 for(;;) { |
| 699 i=SSL_connect(serverCon); | 596 i=SSL_connect(serverCon); |
| 700 if (BIO_sock_should_retry(i)) | 597 if (BIO_sock_should_retry(i)) |
| 701 { | 598 { |
| 702 BIO_printf(bio_err,"DELAY\n"); | 599 BIO_printf(bio_err,"DELAY\n"); |
| 703 | 600 |
| 704 i=SSL_get_fd(serverCon); | 601 i=SSL_get_fd(serverCon); |
| 705 width=i+1; | 602 width=i+1; |
| 706 FD_ZERO(&readfds); | 603 FD_ZERO(&readfds); |
| 707 » » » FD_SET(i,&readfds); | 604 » » » openssl_fdset(i,&readfds); |
| 708 /* Note: under VMS with SOCKETSHR the 2nd parameter | 605 /* Note: under VMS with SOCKETSHR the 2nd parameter |
| 709 * is currently of type (int *) whereas under other | 606 * is currently of type (int *) whereas under other |
| 710 * systems it is (void *) if you don't have a cast it | 607 * systems it is (void *) if you don't have a cast it |
| 711 * will choke the compiler: if you do have a cast then | 608 * will choke the compiler: if you do have a cast then |
| 712 * you can either go for (int *) or (void *). | 609 * you can either go for (int *) or (void *). |
| 713 */ | 610 */ |
| 714 select(width,(void *)&readfds,NULL,NULL,NULL); | 611 select(width,(void *)&readfds,NULL,NULL,NULL); |
| 715 continue; | 612 continue; |
| 716 } | 613 } |
| 717 break; | 614 break; |
| 718 } | 615 } |
| 719 if(i <= 0) | 616 if(i <= 0) |
| 720 { | 617 { |
| 721 BIO_printf(bio_err,"ERROR\n"); | 618 BIO_printf(bio_err,"ERROR\n"); |
| 722 if (verify_error != X509_V_OK) | 619 if (verify_error != X509_V_OK) |
| 723 BIO_printf(bio_err,"verify error:%s\n", | 620 BIO_printf(bio_err,"verify error:%s\n", |
| 724 X509_verify_cert_error_string(verify_error)); | 621 X509_verify_cert_error_string(verify_error)); |
| 725 else | 622 else |
| 726 ERR_print_errors(bio_err); | 623 ERR_print_errors(bio_err); |
| 727 if (scon == NULL) | 624 if (scon == NULL) |
| 728 SSL_free(serverCon); | 625 SSL_free(serverCon); |
| 729 return NULL; | 626 return NULL; |
| 730 } | 627 } |
| 731 | 628 |
| 732 return serverCon; | 629 return serverCon; |
| 733 } | 630 } |
| 734 | 631 |
| 735 | 632 |
| OLD | NEW |