(linenum→info "unix/slp.c:2238")

openssl/0.9.8g/test/ssltest.c

    1: /* ssl/ssltest.c */
    2: /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
    3:  * All rights reserved.
    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
   24:  * modification, are permitted provided that the following conditions
   25:  * are met:
   26:  * 1. Redistributions of source code must retain the copyright
   27:  *    notice, this list of conditions and the following disclaimer.
   28:  * 2. Redistributions in binary form must reproduce the above copyright
   29:  *    notice, this list of conditions and the following disclaimer in the
   30:  *    documentation and/or other materials provided with the distribution.
   31:  * 3. All advertising materials mentioning features or use of this software
   32:  *    must display the following acknowledgement:
   33:  *    "This product includes cryptographic software written by
   34:  *     Eric Young (eay@cryptsoft.com)"
   35:  *    The word 'cryptographic' can be left out if the rouines from the library
   36:  *    being used are not cryptographic related :-).
   37:  * 4. If you include any Windows specific code (or a derivative thereof) from 
   38:  *    the apps directory (application code) you must include an acknowledgement:
   39:  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
   40:  * 
   41:  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
   42:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   43:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   44:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   45:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   46:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   47:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   48:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   49:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   50:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   51:  * SUCH DAMAGE.
   52:  * 
   53:  * The licence and distribution terms for any publically available version or
   54:  * derivative of this code cannot be changed.  i.e. this code cannot simply be
   55:  * copied and put under another distribution licence
   56:  * [including the GNU Public Licence.]
   57:  */
   58: /* ====================================================================
   59:  * Copyright (c) 1998-2000 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 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
  113:  * ECC cipher suite support in OpenSSL originally developed by 
  114:  * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project.
  115:  */
  116: 
  117: #define _BSD_SOURCE 1           /* Or gethostname won't be declared properly
  118:                                    on Linux and GNU platforms. */
  119: 
  120: #include <assert.h>
  121: #include <errno.h>
  122: #include <limits.h>
  123: #include <stdio.h>
  124: #include <stdlib.h>
  125: #include <string.h>
  126: #include <time.h>
  127: 
  128: #define USE_SOCKETS
  129: #include "e_os.h"
  130: 
  131: #define _XOPEN_SOURCE 500       /* Or isascii won't be declared properly on
  132:                                    VMS (at least with DECompHP C).  */
  133: #include <ctype.h>
  134: 
  135: #include <openssl/bio.h>
  136: #include <openssl/crypto.h>
  137: #include <openssl/evp.h>
  138: #include <openssl/x509.h>
  139: #include <openssl/x509v3.h>
  140: #include <openssl/ssl.h>
  141: #ifndef OPENSSL_NO_ENGINE
  142: #include <openssl/engine.h>
  143: #endif
  144: #include <openssl/err.h>
  145: #include <openssl/rand.h>
  146: #ifndef OPENSSL_NO_RSA
  147: #include <openssl/rsa.h>
  148: #endif
  149: #ifndef OPENSSL_NO_DSA
  150: #include <openssl/dsa.h>
  151: #endif
  152: #ifndef OPENSSL_NO_DH
  153: #include <openssl/dh.h>
  154: #endif
  155: #include <openssl/bn.h>
  156: 
  157: #define _XOPEN_SOURCE_EXTENDED  1 /* Or gethostname won't be declared properly
  158:                                      on Compaq platforms (at least with DEC C).
  159:                                      Do not try to put it earlier, or IPv6 includes
  160:                                      get screwed...
  161:                                   */
  162: 
  163: #ifdef OPENSSL_SYS_WINDOWS
  164: #include <winsock.h>
  165: #else
  166: #include OPENSSL_UNISTD
  167: #endif
  168: 
  169: #ifdef OPENSSL_SYS_VMS
  170: #  define TEST_SERVER_CERT "SYS$DISK:[-.APPS]SERVER.PEM"
  171: #  define TEST_CLIENT_CERT "SYS$DISK:[-.APPS]CLIENT.PEM"
  172: #elif defined(OPENSSL_SYS_WINCE)
  173: #  define TEST_SERVER_CERT "\\OpenSSL\\server.pem"
  174: #  define TEST_CLIENT_CERT "\\OpenSSL\\client.pem"
  175: #elif defined(OPENSSL_SYS_NETWARE)
  176: #  define TEST_SERVER_CERT "\\openssl\\apps\\server.pem"
  177: #  define TEST_CLIENT_CERT "\\openssl\\apps\\client.pem"
  178: #else
  179: #  define TEST_SERVER_CERT "../apps/server.pem"
  180: #  define TEST_CLIENT_CERT "../apps/client.pem"
  181: #endif
  182: 
  183: /* There is really no standard for this, so let's assign some tentative
  184:    numbers.  In any case, these numbers are only for this test */
  185: #define COMP_RLE        255
  186: #define COMP_ZLIB       1
  187: 
  188: static int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx);
  189: #ifndef OPENSSL_NO_RSA
  190: static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export,int keylength);
  191: static void free_tmp_rsa(void);
  192: #endif
  193: static int MS_CALLBACK app_verify_callback(X509_STORE_CTX *ctx, void *arg);
  194: #define APP_CALLBACK_STRING "Test Callback Argument"
  195: struct app_verify_arg
  196:         {
  197:         char *string;
  198:         int app_verify;
  199:         int allow_proxy_certs;
  200:         char *proxy_auth;
  201:         char *proxy_cond;
  202:         };
  203: 
  204: #ifndef OPENSSL_NO_DH
  205: static DH *get_dh512(void);
  206: static DH *get_dh1024(void);
  207: static DH *get_dh1024dsa(void);
  208: #endif
  209: 
  210: static BIO *bio_err=NULL;
  211: static BIO *bio_stdout=NULL;
  212: 
  213: static char *cipher=NULL;
  214: static int verbose=0;
  215: static int debug=0;
  216: #if 0
  217: /* Not used yet. */
  218: #ifdef FIONBIO
  219: static int s_nbio=0;
  220: #endif
  221: #endif
  222: 
  223: static const char rnd_seed[] = "string to make the random number generator think it has entropy";
  224: 
  225: int doit_biopair(SSL *s_ssl,SSL *c_ssl,long bytes,clock_t *s_time,clock_t *c_time);
  226: int doit(SSL *s_ssl,SSL *c_ssl,long bytes);
  227: static int do_test_cipherlist(void);
  228: static void sv_usage(void)
  229:         {
  230:         fprintf(stderr,"usage: ssltest [args ...]\n");
  231:         fprintf(stderr,"\n");
  232:         fprintf(stderr," -server_auth  - check server certificate\n");
  233:         fprintf(stderr," -client_auth  - do client authentication\n");
  234:         fprintf(stderr," -proxy        - allow proxy certificates\n");
  235:         fprintf(stderr," -proxy_auth <val> - set proxy policy rights\n");
  236:         fprintf(stderr," -proxy_cond <val> - experssion to test proxy policy rights\n");
  237:         fprintf(stderr," -v            - more output\n");
  238:         fprintf(stderr," -d            - debug output\n");
  239:         fprintf(stderr," -reuse        - use session-id reuse\n");
  240:         fprintf(stderr," -num <val>    - number of connections to perform\n");
  241:         fprintf(stderr," -bytes <val>  - number of bytes to swap between client/server\n");
  242: #ifndef OPENSSL_NO_DH
  243:         fprintf(stderr," -dhe1024      - use 1024 bit key (safe prime) for DHE\n");
  244:         fprintf(stderr," -dhe1024dsa   - use 1024 bit key (with 160-bit subprime) for DHE\n");
  245:         fprintf(stderr," -no_dhe       - disable DHE\n");
  246: #endif
  247: #ifndef OPENSSL_NO_ECDH
  248:         fprintf(stderr," -no_ecdhe     - disable ECDHE\n");
  249: #endif
  250: #ifndef OPENSSL_NO_SSL2
  251:         fprintf(stderr," -ssl2         - use SSLv2\n");
  252: #endif
  253: #ifndef OPENSSL_NO_SSL3
  254:         fprintf(stderr," -ssl3         - use SSLv3\n");
  255: #endif
  256: #ifndef OPENSSL_NO_TLS1
  257:         fprintf(stderr," -tls1         - use TLSv1\n");
  258: #endif
  259:         fprintf(stderr," -CApath arg   - PEM format directory of CA's\n");
  260:         fprintf(stderr," -CAfile arg   - PEM format file of CA's\n");
  261:         fprintf(stderr," -cert arg     - Server certificate file\n");
  262:         fprintf(stderr," -key arg      - Server key file (default: same as -cert)\n");
  263:         fprintf(stderr," -c_cert arg   - Client certificate file\n");
  264:         fprintf(stderr," -c_key arg    - Client key file (default: same as -c_cert)\n");
  265:         fprintf(stderr," -cipher arg   - The cipher list\n");
  266:         fprintf(stderr," -bio_pair     - Use BIO pairs\n");
  267:         fprintf(stderr," -f            - Test even cases that can't work\n");
  268:         fprintf(stderr," -time         - measure processor time used by client and server\n");
  269:         fprintf(stderr," -zlib         - use zlib compression\n");
  270:         fprintf(stderr," -rle          - use rle compression\n");
  271: #ifndef OPENSSL_NO_ECDH
  272:         fprintf(stderr," -named_curve arg  - Elliptic curve name to use for ephemeral ECDH keys.\n" \
  273:                        "                 Use \"openssl ecparam -list_curves\" for all names\n"  \
  274:                        "                 (default is sect163r2).\n");
  275: #endif
  276:         fprintf(stderr," -test_cipherlist - verifies the order of the ssl cipher lists\n");
  277:         }
  278: 
  279: static void print_details(SSL *c_ssl, const char *prefix)
  280:         {
  281:         SSL_CIPHER *ciph;
  282:         X509 *cert;
  283:                 
  284:         ciph=SSL_get_current_cipher(c_ssl);
  285:         BIO_printf(bio_stdout,"%s%s, cipher %s %s",
  286:                 prefix,
  287:                 SSL_get_version(c_ssl),
  288:                 SSL_CIPHER_get_version(ciph),
  289:                 SSL_CIPHER_get_name(ciph));
  290:         cert=SSL_get_peer_certificate(c_ssl);
  291:         if (cert != NULL)
  292:                 {
  293:                 EVP_PKEY *pkey = X509_get_pubkey(cert);
  294:                 if (pkey != NULL)
  295:                         {
  296:                         if (0) 
  297:                                 ;
  298: #ifndef OPENSSL_NO_RSA
  299:                         else if (pkey->type == EVP_PKEY_RSA && pkey->pkey.rsa != NULL
  300:                                 && pkey->pkey.rsa->n != NULL)
  301:                                 {
  302:                                 BIO_printf(bio_stdout, ", %d bit RSA",
  303:                                         BN_num_bits(pkey->pkey.rsa->n));
  304:                                 }
  305: #endif
  306: #ifndef OPENSSL_NO_DSA
  307:                         else if (pkey->type == EVP_PKEY_DSA && pkey->pkey.dsa != NULL
  308:                                 && pkey->pkey.dsa->p != NULL)
  309:                                 {
  310:                                 BIO_printf(bio_stdout, ", %d bit DSA",
  311:                                         BN_num_bits(pkey->pkey.dsa->p));
  312:                                 }
  313: #endif
  314:                         EVP_PKEY_free(pkey);
  315:                         }
  316:                 X509_free(cert);
  317:                 }
  318:         /* The SSL API does not allow us to look at temporary RSA/DH keys,
  319:          * otherwise we should print their lengths too */
  320:         BIO_printf(bio_stdout,"\n");
  321:         }
  322: 
  323: static void lock_dbg_cb(int mode, int type, const char *file, int line)
  324:         {
  325:         static int modes[CRYPTO_NUM_LOCKS]; /* = {0, 0, ... } */
  326:         const char *errstr = NULL;
  327:         int rw;
  328:         
  329:         rw = mode & (CRYPTO_READ|CRYPTO_WRITE);
  330:         if (!((rw == CRYPTO_READ) || (rw == CRYPTO_WRITE)))
  331:                 {
  332:                 errstr = "invalid mode";
  333:                 goto err;
  334:                 }
  335: 
  336:         if (type < 0 || type >= CRYPTO_NUM_LOCKS)
  337:                 {
  338:                 errstr = "type out of bounds";
  339:                 goto err;
  340:                 }
  341: 
  342:         if (mode & CRYPTO_LOCK)
  343:                 {
  344:                 if (modes[type])
  345:                         {
  346:                         errstr = "already locked";
  347:                         /* must not happen in a single-threaded program
  348:                          * (would deadlock) */
  349:                         goto err;
  350:                         }
  351: 
  352:                 modes[type] = rw;
  353:                 }
  354:         else if (mode & CRYPTO_UNLOCK)
  355:                 {
  356:                 if (!modes[type])
  357:                         {
  358:                         errstr = "not locked";
  359:                         goto err;
  360:                         }
  361:                 
  362:                 if (modes[type] != rw)
  363:                         {
  364:                         errstr = (rw == CRYPTO_READ) ?
  365:                                 "CRYPTO_r_unlock on write lock" :
  366:                                 "CRYPTO_w_unlock on read lock";
  367:                         }
  368: 
  369:                 modes[type] = 0;
  370:                 }
  371:         else
  372:                 {
  373:                 errstr = "invalid mode";
  374:                 goto err;
  375:                 }
  376: 
  377:  err:
  378:         if (errstr)
  379:                 {
  380:                 /* we cannot use bio_err here */
  381:                 fprintf(stderr, "openssl (lock_dbg_cb): %s (mode=%d, type=%d) at %s:%d\n",
  382:                         errstr, mode, type, file, line);
  383:                 }
  384:         }
  385: 
  386: 
  387: int main(int argc, char *argv[])
  388:         {
  389:         char *CApath=NULL,*CAfile=NULL;
  390:         int badop=0;
  391:         int bio_pair=0;
  392:         int force=0;
  393:         int tls1=0,ssl2=0,ssl3=0,ret=1;
  394:         int client_auth=0;
  395:         int server_auth=0,i;
  396:         struct app_verify_arg app_verify_arg =
  397:                 { APP_CALLBACK_STRING, 0, 0, NULL, NULL };
  398:         char *server_cert=TEST_SERVER_CERT;
  399:         char *server_key=NULL;
  400:         char *client_cert=TEST_CLIENT_CERT;
  401:         char *client_key=NULL;
  402: #ifndef OPENSSL_NO_ECDH
  403:         char *named_curve = NULL;
  404: #endif
  405:         SSL_CTX *s_ctx=NULL;
  406:         SSL_CTX *c_ctx=NULL;
  407:         SSL_METHOD *meth=NULL;
  408:         SSL *c_ssl,*s_ssl;
  409:         int number=1,reuse=0;
  410:         long bytes=256L;
  411: #ifndef OPENSSL_NO_DH
  412:         DH *dh;
  413:         int dhe1024 = 0, dhe1024dsa = 0;
  414: #endif
  415: #ifndef OPENSSL_NO_ECDH
  416:         EC_KEY *ecdh = NULL;
  417: #endif
  418:         int no_dhe = 0;
  419:         int no_ecdhe = 0;
  420:         int print_time = 0;
  421:         clock_t s_time = 0, c_time = 0;
  422:         int comp = 0;
  423: #ifndef OPENSSL_NO_COMP
  424:         COMP_METHOD *cm = NULL;
  425: #endif
  426:         STACK_OF(SSL_COMP) *ssl_comp_methods = NULL;
  427:         int test_cipherlist = 0;
  428: 
  429:         verbose = 0;
  430:         debug = 0;
  431:         cipher = 0;
  432: 
  433:         bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);        
  434: 
  435:         CRYPTO_set_locking_callback(lock_dbg_cb);
  436: 
  437:         /* enable memory leak checking unless explicitly disabled */
  438:         if (!((getenv("OPENSSL_DEBUG_MEMORY") != NULL) && (0 == strcmp(getenv("OPENSSL_DEBUG_MEMORY"), "off"))))
  439:                 {
  440:                 CRYPTO_malloc_debug_init();
  441:                 CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
  442:                 }
  443:         else
  444:                 {
  445:                 /* OPENSSL_DEBUG_MEMORY=off */
  446:                 CRYPTO_set_mem_debug_functions(0, 0, 0, 0, 0);
  447:                 }
  448:         CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
  449: 
  450:         RAND_seed(rnd_seed, sizeof rnd_seed);
  451: 
  452:         bio_stdout=BIO_new_fp(stdout,BIO_NOCLOSE);
  453: 
  454:         argc--;
  455:         argv++;
  456: 
  457:         while (argc >= 1)
  458:                 {
  459:                 if    (strcmp(*argv,"-server_auth") == 0)
  460:                         server_auth=1;
  461:                 else if       (strcmp(*argv,"-client_auth") == 0)
  462:                         client_auth=1;
  463:                 else if (strcmp(*argv,"-proxy_auth") == 0)
  464:                         {
  465:                         if (--argc < 1) goto bad;
  466:                         app_verify_arg.proxy_auth= *(++argv);
  467:                         }
  468:                 else if (strcmp(*argv,"-proxy_cond") == 0)
  469:                         {
  470:                         if (--argc < 1) goto bad;
  471:                         app_verify_arg.proxy_cond= *(++argv);
  472:                         }
  473:                 else if       (strcmp(*argv,"-v") == 0)
  474:                         verbose=1;
  475:                 else if       (strcmp(*argv,"-d") == 0)
  476:                         debug=1;
  477:                 else if       (strcmp(*argv,"-reuse") == 0)
  478:                         reuse=1;
  479:                 else if       (strcmp(*argv,"-dhe1024") == 0)
  480:                         {
  481: #ifndef OPENSSL_NO_DH
  482:                         dhe1024=1;
  483: #else
  484:                         fprintf(stderr,"ignoring -dhe1024, since I'm compiled without DH\n");
  485: #endif
  486:                         }
  487:                 else if       (strcmp(*argv,"-dhe1024dsa") == 0)
  488:                         {
  489: #ifndef OPENSSL_NO_DH
  490:                         dhe1024dsa=1;
  491: #else
  492:                         fprintf(stderr,"ignoring -dhe1024, since I'm compiled without DH\n");
  493: #endif
  494:                         }
  495:                 else if       (strcmp(*argv,"-no_dhe") == 0)
  496:                         no_dhe=1;
  497:                 else if       (strcmp(*argv,"-no_ecdhe") == 0)
  498:                         no_ecdhe=1;
  499:                 else if       (strcmp(*argv,"-ssl2") == 0)
  500:                         ssl2=1;
  501:                 else if       (strcmp(*argv,"-tls1") == 0)
  502:                         tls1=1;
  503:                 else if       (strcmp(*argv,"-ssl3") == 0)
  504:                         ssl3=1;
  505:                 else if       (strncmp(*argv,"-num",4) == 0)
  506:                         {
  507:                         if (--argc < 1) goto bad;
  508:                         number= atoi(*(++argv));
  509:                         if (number == 0) number=1;
  510:                         }
  511:                 else if       (strcmp(*argv,"-bytes") == 0)
  512:                         {
  513:                         if (--argc < 1) goto bad;
  514:                         bytes= atol(*(++argv));
  515:                         if (bytes == 0L) bytes=1L;
  516:                         i=strlen(argv[0]);
  517:                         if (argv[0][i-1] == 'k') bytes*=1024L;
  518:                         if (argv[0][i-1] == 'm') bytes*=1024L*1024L;
  519:                         }
  520:                 else if       (strcmp(*argv,"-cert") == 0)
  521:                         {
  522:                         if (--argc < 1) goto bad;
  523:                         server_cert= *(++argv);
  524:                         }
  525:                 else if       (strcmp(*argv,"-s_cert") == 0)
  526:                         {
  527:                         if (--argc < 1) goto bad;
  528:                         server_cert= *(++argv);