There have been a number of complaints from a number of sources that names
[openssl.git] / ssl / ssltest.c
index 2548c8abc5b1a19e070674d280ab9f891ccaadce..2ef8a50785b77775f84e074349dc76e36b4e9940 100644 (file)
@@ -88,6 +88,7 @@
 static int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx);
 #ifndef NO_RSA
 static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export,int keylength);
+static void free_tmp_rsa(void);
 #endif
 #ifndef NO_DH
 static DH *get_dh512(void);
@@ -139,10 +140,10 @@ static void sv_usage(void)
 #endif
        fprintf(stderr," -CApath arg   - PEM format directory of CA's\n");
        fprintf(stderr," -CAfile arg   - PEM format file of CA's\n");
-       fprintf(stderr," -cert arg     - Certificate file\n");
-       fprintf(stderr," -key arg      - Key file\n");
-       fprintf(stderr," -s_cert arg   - Just the server certificate file\n");
-       fprintf(stderr," -c_cert arg   - Just the client certificate file\n");
+       fprintf(stderr," -cert arg     - Server certificate file\n");
+       fprintf(stderr," -key arg      - Server key file (default: same as -cert)\n");
+       fprintf(stderr," -c_cert arg   - Client certificate file\n");
+       fprintf(stderr," -c_key arg    - Client key file (default: same as -c_cert)\n");
        fprintf(stderr," -cipher arg   - The cipher list\n");
        fprintf(stderr," -bio_pair     - Use BIO pairs\n");
        fprintf(stderr," -f            - Test even cases that can't work\n");
@@ -499,10 +500,24 @@ bad:
                BIO_printf(bio_stdout, "%d handshakes of %ld bytes done\n",number,bytes);
        if (print_time)
                {
+#ifdef CLOCKS_PER_SEC
+               /* "To determine the time in seconds, the value returned
+                * by the clock function should be divided by the value
+                * of the macro CLOCKS_PER_SEC."
+                *                                       -- ISO/IEC 9899 */
                BIO_printf(bio_stdout, "Approximate total server time: %6.2f s\n"
                        "Approximate total client time: %6.2f s\n",
                        (double)s_time/CLOCKS_PER_SEC,
                        (double)c_time/CLOCKS_PER_SEC);
+#else
+               /* "`CLOCKS_PER_SEC' undeclared (first use this function)"
+                *                            -- cc on NeXTstep/OpenStep */
+               BIO_printf(bio_stdout,
+                       "Approximate total server time: %6.2f units\n"
+                       "Approximate total client time: %6.2f units\n",
+                       (double)s_time,
+                       (double)c_time);
+#endif
                }
 
        SSL_free(s_ssl);
@@ -514,6 +529,9 @@ end:
 
        if (bio_stdout != NULL) BIO_free(bio_stdout);
 
+#ifndef NO_RSA
+       free_tmp_rsa();
+#endif
        ERR_free_strings();
        ERR_remove_state(0);
        EVP_cleanup();
@@ -1175,7 +1193,7 @@ int doit(SSL *s_ssl, SSL *c_ssl, long count)
        ret=0;
 err:
        /* We have to set the BIO's to NULL otherwise they will be
-        * Free()ed twice.  Once when th s_ssl is SSL_free()ed and
+        * OPENSSL_free()ed twice.  Once when th s_ssl is SSL_free()ed and
         * again when c_ssl is SSL_free()ed.
         * This is a hack required because s_ssl and c_ssl are sharing the same
         * BIO structure and SSL_set_bio() and SSL_free() automatically
@@ -1228,10 +1246,10 @@ static int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx)
        }
 
 #ifndef NO_RSA
+static RSA *rsa_tmp=NULL;
+
 static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export, int keylength)
        {
-       static RSA *rsa_tmp=NULL;
-
        if (rsa_tmp == NULL)
                {
                BIO_printf(bio_err,"Generating temp (%d bit) RSA key...",keylength);
@@ -1242,6 +1260,15 @@ static RSA MS_CALLBACK *tmp_rsa_cb(SSL *s, int is_export, int keylength)
                }
        return(rsa_tmp);
        }
+
+static void free_tmp_rsa(void)
+       {
+       if (rsa_tmp != NULL)
+               {
+               RSA_free(rsa_tmp);
+               rsa_tmp = NULL;
+               }
+       }
 #endif
 
 #ifndef NO_DH