Fix s_server -ssl2. Previously this reported "Error setting EC curve"
[oweals/openssl.git] / apps / dhparam.c
index b47097cbb223e035fc85c970de34687967aa1fad..606365e1805d255433e9b248d82eb1d42439a258 100644 (file)
 #undef PROG
 #define PROG   dhparam_main
 
-#define DEFBITS        512
+#define DEFBITS        2048
 
 /* -inform arg - input format - default PEM (DER or PEM)
  * -outform arg - output format - default PEM
@@ -253,7 +253,7 @@ bad:
                BIO_printf(bio_err," -C            Output C code\n");
                BIO_printf(bio_err," -2            generate parameters using  2 as the generator value\n");
                BIO_printf(bio_err," -5            generate parameters using  5 as the generator value\n");
-               BIO_printf(bio_err," numbits       number of bits in to generate (default 512)\n");
+               BIO_printf(bio_err," numbits       number of bits in to generate (default 2048)\n");
 #ifndef OPENSSL_NO_ENGINE
                BIO_printf(bio_err," -engine e     use engine e, possibly a hardware device.\n");
 #endif
@@ -332,7 +332,6 @@ bad:
                        BIO_printf(bio_err,"This is going to take a long time\n");
                        if(!dh || !DH_generate_parameters_ex(dh, num, g, &cb))
                                {
-                               if(dh) DH_free(dh);
                                ERR_print_errors(bio_err);
                                goto end;
                                }
@@ -513,7 +512,12 @@ bad:
                if      (outformat == FORMAT_ASN1)
                        i=i2d_DHparams_bio(out,dh);
                else if (outformat == FORMAT_PEM)
-                       i=PEM_write_bio_DHparams(out,dh);
+                       {
+                       if (dh->q)
+                               i=PEM_write_bio_DHxparams(out,dh);
+                       else
+                               i=PEM_write_bio_DHparams(out,dh);
+                       }
                else    {
                        BIO_printf(bio_err,"bad output format specified for outfile\n");
                        goto end;