Workaround for some CMS signature formats.
[openssl.git] / apps / gendh.c
index b90087493a53b765c5818926ef5b3c8989e74a84..4ec776ba9399a8f3a0b3aeb80b9a78d71410d2c2 100644 (file)
@@ -57,6 +57,7 @@
  * [including the GNU Public Licence.]
  */
 
+#include <openssl/opensslconf.h>
 /* Until the key-gen callbacks are modified to use newer prototypes, we allow
  * deprecated functions for openssl-internal code */
 #ifdef OPENSSL_NO_DEPRECATED
 #undef PROG
 #define PROG gendh_main
 
-static void MS_CALLBACK dh_cb(int p, int n, void *arg);
+static int MS_CALLBACK dh_cb(int p, int n, BN_GENCB *cb);
 
 int MAIN(int, char **);
 
 int MAIN(int argc, char **argv)
        {
-#ifndef OPENSSL_NO_ENGINE
-       ENGINE *e = NULL;
-#endif
+       BN_GENCB cb;
        DH *dh=NULL;
        int ret=1,num=DEFBITS;
        int g=2;
@@ -102,6 +101,7 @@ int MAIN(int argc, char **argv)
 
        apps_startup();
 
+       BN_GENCB_set(&cb, dh_cb, bio_err);
        if (bio_err == NULL)
                if ((bio_err=BIO_new(BIO_s_file())) != NULL)
                        BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
@@ -160,7 +160,7 @@ bad:
                }
                
 #ifndef OPENSSL_NO_ENGINE
-        e = setup_engine(bio_err, engine, 0);
+        setup_engine(bio_err, engine, 0);
 #endif
 
        out=BIO_new(BIO_s_file());
@@ -199,10 +199,10 @@ bad:
 
        BIO_printf(bio_err,"Generating DH parameters, %d bit long safe prime, generator %d\n",num,g);
        BIO_printf(bio_err,"This is going to take a long time\n");
-       dh=DH_generate_parameters(num,g,dh_cb,bio_err);
-               
-       if (dh == NULL) goto end;
 
+       if(((dh = DH_new()) == NULL) || !DH_generate_parameters_ex(dh, num, g, &cb))
+               goto end;
+               
        app_RAND_write_file(NULL, bio_err);
 
        if (!PEM_write_bio_DHparams(out,dh))
@@ -217,7 +217,7 @@ end:
        OPENSSL_EXIT(ret);
        }
 
-static void MS_CALLBACK dh_cb(int p, int n, void *arg)
+static int MS_CALLBACK dh_cb(int p, int n, BN_GENCB *cb)
        {
        char c='*';
 
@@ -225,10 +225,17 @@ static void MS_CALLBACK dh_cb(int p, int n, void *arg)
        if (p == 1) c='+';
        if (p == 2) c='*';
        if (p == 3) c='\n';
-       BIO_write((BIO *)arg,&c,1);
-       (void)BIO_flush((BIO *)arg);
+       BIO_write(cb->arg,&c,1);
+       (void)BIO_flush(cb->arg);
 #ifdef LINT
        p=n;
 #endif
+       return 1;
        }
+#else /* !OPENSSL_NO_DH */
+
+# if PEDANTIC
+static void *dummy=&dummy;
+# endif
+
 #endif