RT3548: Remove unsupported platforms
[openssl.git] / apps / gendh.c
index 47497864b0024d8c774598a4bdf01a1cdc4f1151..ec6842528a5517c6d8b9538bb3a862aaf69dfaa7 100644 (file)
  */
 
 #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 OPENSSL_NO_DEPRECATED
-#endif
 
 #ifndef OPENSSL_NO_DH
 #include <stdio.h>
 #include <openssl/x509.h>
 #include <openssl/pem.h>
 
-#define DEFBITS        512
+#define DEFBITS        2048
 #undef PROG
 #define PROG gendh_main
 
-static int MS_CALLBACK dh_cb(int p, int n, BN_GENCB *cb);
+static int dh_cb(int p, int n, BN_GENCB *cb);
 
 int MAIN(int, char **);
 
 int MAIN(int argc, char **argv)
        {
-       BN_GENCB cb;
-#ifndef OPENSSL_NO_ENGINE
-       ENGINE *e = NULL;
-#endif
+       BN_GENCB *cb=NULL;
        DH *dh=NULL;
        int ret=1,num=DEFBITS;
        int g=2;
@@ -104,11 +96,16 @@ 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);
 
+       cb = BN_GENCB_new();
+       if(!cb)
+               goto end;
+
+       BN_GENCB_set(cb, dh_cb, bio_err);
+
        if (!load_config(bio_err, NULL))
                goto end;
 
@@ -163,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());
@@ -203,7 +200,7 @@ 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");
 
-       if(((dh = DH_new()) == NULL) || !DH_generate_parameters_ex(dh, num, g, &cb))
+       if(((dh = DH_new()) == NULL) || !DH_generate_parameters_ex(dh, num, g, cb))
                goto end;
                
        app_RAND_write_file(NULL, bio_err);
@@ -216,11 +213,12 @@ end:
                ERR_print_errors(bio_err);
        if (out != NULL) BIO_free_all(out);
        if (dh != NULL) DH_free(dh);
+       if (cb != NULL) BN_GENCB_free(cb);
        apps_shutdown();
        OPENSSL_EXIT(ret);
        }
 
-static int MS_CALLBACK dh_cb(int p, int n, BN_GENCB *cb)
+static int dh_cb(int p, int n, BN_GENCB *cb)
        {
        char c='*';
 
@@ -228,11 +226,14 @@ static int MS_CALLBACK dh_cb(int p, int n, BN_GENCB *cb)
        if (p == 1) c='+';
        if (p == 2) c='*';
        if (p == 3) c='\n';
-       BIO_write(cb->arg,&c,1);
-       (void)BIO_flush(cb->arg);
-#ifdef LINT
-       p=n;
-#endif
+       BIO_write(BN_GENCB_get_arg(cb),&c,1);
+       (void)BIO_flush(BN_GENCB_get_arg(cb));
        return 1;
        }
+#else /* !OPENSSL_NO_DH */
+
+# if PEDANTIC
+static void *dummy=&dummy;
+# endif
+
 #endif