The compression method may be undefined for some reason that has
[openssl.git] / ssl / ssltest.c
index 2ef8a50785b77775f84e074349dc76e36b4e9940..b44a5ec48f847ca34396537574d867c6b8189c21 100644 (file)
 #  define TEST_CLIENT_CERT "../apps/client.pem"
 #endif
 
+/* 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
+
 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);
@@ -148,6 +153,8 @@ static void sv_usage(void)
        fprintf(stderr," -bio_pair     - Use BIO pairs\n");
        fprintf(stderr," -f            - Test even cases that can't work\n");
        fprintf(stderr," -time         - measure processor time used by client and server\n");
+       fprintf(stderr," -zlib         - use zlib compression\n");
+       fprintf(stderr," -time         - use rle compression\n");
        }
 
 static void print_details(SSL *c_ssl, const char *prefix)
@@ -220,6 +227,8 @@ int main(int argc, char *argv[])
        int no_dhe = 0;
        int print_time = 0;
        clock_t s_time = 0, c_time = 0;
+       int comp = 0;
+       COMP_METHOD *cm;
 
        verbose = 0;
        debug = 0;
@@ -333,6 +342,14 @@ int main(int argc, char *argv[])
                        {
                        print_time = 1;
                        }
+               else if (strcmp(*argv,"-zlib") == 0)
+                       {
+                       comp = COMP_ZLIB;
+                       }
+               else if (strcmp(*argv,"-rle") == 0)
+                       {
+                       comp = COMP_RLE;
+                       }
                else
                        {
                        fprintf(stderr,"unknown option %s\n",*argv);
@@ -374,6 +391,23 @@ bad:
        SSL_library_init();
        SSL_load_error_strings();
 
+       if (comp == COMP_ZLIB) cm = COMP_zlib();
+       if (comp == COMP_RLE) cm = COMP_rle();
+       if (cm != NULL)
+               {
+               if (cm->type != NID_undef)
+                       SSL_COMP_add_compression_method(comp, cm);
+               else
+                       {
+                       fprintf(stderr,
+                               "Warning: %s compression not supported\n",
+                               (comp == COMP_RLE ? "rle" :
+                                       (comp == COMP_ZLIB ? "zlib" :
+                                               "unknown")));
+                       ERR_print_errors_fp(stderr);
+                       }
+               }
+
 #if !defined(NO_SSL2) && !defined(NO_SSL3)
        if (ssl2)
                meth=SSLv2_method();
@@ -1278,7 +1312,7 @@ static void free_tmp_rsa(void)
  *    $ openssl dhparam -C -noout -dsaparam 1024
  * (The third function has been renamed to avoid name conflicts.)
  */
-DH *get_dh512()
+static DH *get_dh512()
        {
        static unsigned char dh512_p[]={
                0xCB,0xC8,0xE1,0x86,0xD0,0x1F,0x94,0x17,0xA6,0x99,0xF0,0xC6,
@@ -1301,7 +1335,7 @@ DH *get_dh512()
        return(dh);
        }
 
-DH *get_dh1024()
+static DH *get_dh1024()
        {
        static unsigned char dh1024_p[]={
                0xF8,0x81,0x89,0x7D,0x14,0x24,0xC5,0xD1,0xE6,0xF7,0xBF,0x3A,
@@ -1329,7 +1363,7 @@ DH *get_dh1024()
        return(dh);
        }
 
-DH *get_dh1024dsa()
+static DH *get_dh1024dsa()
        {
        static unsigned char dh1024_p[]={
                0xC8,0x00,0xF7,0x08,0x07,0x89,0x4D,0x90,0x53,0xF3,0xD5,0x00,