Avoid including cryptlib.h, it's not really needed.
[openssl.git] / ssl / ssltest.c
index 7bb4152000cf4bb5c24409c1b9af4e917243bdc2..63641df6c3d20113bf9a5c21079143c4e7323173 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
+#include <inttypes.h>
 
 #define USE_SOCKETS
 #include "e_os.h"
 #elif defined(OPENSSL_SYS_WINCE)
 #  define TEST_SERVER_CERT "\\OpenSSL\\server.pem"
 #  define TEST_CLIENT_CERT "\\OpenSSL\\client.pem"
+#elif defined(OPENSSL_SYS_NETWARE)
+#  define TEST_SERVER_CERT "\\openssl\\apps\\server.pem"
+#  define TEST_CLIENT_CERT "\\openssl\\apps\\client.pem"
 #else
 #  define TEST_SERVER_CERT "../apps/server.pem"
 #  define TEST_CLIENT_CERT "../apps/client.pem"
 
 /* There is really no standard for this, so let's assign some tentative
    numbers.  In any case, these numbers are only for this test */
-#define COMP_RLE       1
-#define COMP_ZLIB      2
+#define COMP_RLE       255
+#define COMP_ZLIB      1
 
 static int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx);
 #ifndef OPENSSL_NO_RSA
@@ -373,7 +377,7 @@ int main(int argc, char *argv[])
        SSL_METHOD *meth=NULL;
        SSL *c_ssl,*s_ssl;
        int number=1,reuse=0;
-       long bytes=1L;
+       long bytes=256L;
 #ifndef OPENSSL_NO_DH
        DH *dh;
        int dhe1024 = 0, dhe1024dsa = 0;
@@ -387,6 +391,7 @@ int main(int argc, char *argv[])
        clock_t s_time = 0, c_time = 0;
        int comp = 0;
        COMP_METHOD *cm = NULL;
+       STACK_OF(SSL_COMP) *ssl_comp_methods = NULL;
 
        verbose = 0;
        debug = 0;
@@ -594,7 +599,14 @@ bad:
        if (cm != NULL)
                {
                if (cm->type != NID_undef)
-                       SSL_COMP_add_compression_method(comp, cm);
+                       {
+                       if (SSL_COMP_add_compression_method(comp, cm) != 0)
+                               {
+                               fprintf(stderr,
+                                       "Failed to add compression method\n");
+                               ERR_print_errors_fp(stderr);
+                               }
+                       }
                else
                        {
                        fprintf(stderr,
@@ -605,6 +617,19 @@ bad:
                        ERR_print_errors_fp(stderr);
                        }
                }
+       ssl_comp_methods = SSL_COMP_get_compression_methods();
+       fprintf(stderr, "Available compression methods:\n");
+       {
+       int j, n = sk_SSL_COMP_num(ssl_comp_methods);
+       if (n == 0)
+               fprintf(stderr, "  NONE\n");
+       else
+               for (j = 0; j < n; j++)
+                       {
+                       SSL_COMP *c = sk_SSL_COMP_value(ssl_comp_methods, j);
+                       fprintf(stderr, "  %d: %s\n", c->id, c->name);
+                       }
+       }
 
 #if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)
        if (ssl2)
@@ -1329,8 +1354,8 @@ int doit(SSL *s_ssl, SSL *c_ssl, long count)
                        {
                        if (c_write)
                                {
-                               j=(cw_num > (long)sizeof(cbuf))
-                                       ?sizeof(cbuf):(int)cw_num;
+                               j = (cw_num > (long)sizeof(cbuf)) ?
+                                       (int)sizeof(cbuf) : (int)cw_num;
                                i=BIO_write(c_bio,cbuf,j);
                                if (i < 0)
                                        {
@@ -1460,8 +1485,8 @@ int doit(SSL *s_ssl, SSL *c_ssl, long count)
                                }
                        else
                                {
-                               j=(sw_num > (long)sizeof(sbuf))?
-                                       sizeof(sbuf):(int)sw_num;
+                               j = (sw_num > (long)sizeof(sbuf)) ?
+                                       (int)sizeof(sbuf) : (int)sw_num;
                                i=BIO_write(s_bio,sbuf,j);
                                if (i < 0)
                                        {
@@ -1569,7 +1594,7 @@ static int MS_CALLBACK app_verify_callback(X509_STORE_CTX *ctx, void *arg)
        fprintf(stderr, "In app_verify_callback, allowing cert. ");
        fprintf(stderr, "Arg is: %s\n", (char *)arg);
        fprintf(stderr, "Finished printing do we have a context? 0x%x a cert? 0x%x\n",
-                       (unsigned int)ctx, (unsigned int)ctx->cert);
+                       (uintptr_t)ctx, (uintptr_t)ctx->cert);
        if (ctx->cert)
                s=X509_NAME_oneline(X509_get_subject_name(ctx->cert),buf,256);
        if (s != NULL)