Submitted by:
[openssl.git] / apps / genrsa.c
index 973175447f484cf90b1c1c1f741a866c2e482b83..30f1618f18f0d1bb20342b77cd3f65b2452784ab 100644 (file)
@@ -1,5 +1,5 @@
 /* apps/genrsa.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
  * This package is an SSL implementation written
 #include <sys/types.h>
 #include <sys/stat.h>
 #include "apps.h"
-#include "bio.h"
-#include "rand.h"
-#include "err.h"
-#include "bn.h"
-#include "rsa.h"
-#include "evp.h"
-#include "x509.h"
-#include "pem.h"
+#include <openssl/bio.h>
+#include <openssl/rand.h>
+#include <openssl/err.h>
+#include <openssl/bn.h>
+#include <openssl/rsa.h>
+#include <openssl/evp.h>
+#include <openssl/x509.h>
+#include <openssl/pem.h>
 
 #define DEFBITS        512
 #undef PROG
 #define PROG genrsa_main
 
 #ifndef NOPROTO
-static void MS_CALLBACK genrsa_cb(int p, int n);
+static void MS_CALLBACK genrsa_cb(int p, int n, char *arg);
 static long gr_load_rand(char *names);
 #else
 static void MS_CALLBACK genrsa_cb();
 static long gr_load_rand();
 #endif
 
-int MAIN(argc, argv)
-int argc;
-char **argv;
+int MAIN(int argc, char **argv)
        {
        int ret=1;
        char buffer[200];
@@ -101,7 +99,7 @@ char **argv;
 
        if (bio_err == NULL)
                if ((bio_err=BIO_new(BIO_s_file())) != NULL)
-                       BIO_set_fp(bio_err,stderr,BIO_NOCLOSE);
+                       BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
        if ((out=BIO_new(BIO_s_file())) == NULL)
                {
                BIO_printf(bio_err,"unable to creat BIO for output\n");
@@ -201,7 +199,7 @@ bad:
 
        BIO_printf(bio_err,"Generating RSA private key, %d bit long modulus\n",
                num);
-       rsa=RSA_generate_key(num,f4,genrsa_cb);
+       rsa=RSA_generate_key(num,f4,genrsa_cb,(char *)bio_err);
                
        if (randfile == NULL)
                BIO_printf(bio_err,"unable to write 'random state'\n");
@@ -234,9 +232,7 @@ err:
        EXIT(ret);
        }
 
-static void MS_CALLBACK genrsa_cb(p, n)
-int p;
-int n;
+static void MS_CALLBACK genrsa_cb(int p, int n, char *arg)
        {
        char c='*';
 
@@ -244,15 +240,14 @@ int n;
        if (p == 1) c='+';
        if (p == 2) c='*';
        if (p == 3) c='\n';
-       BIO_write(bio_err,&c,1);
-       BIO_flush(bio_err);
+       BIO_write((BIO *)arg,&c,1);
+       BIO_flush((BIO *)arg);
 #ifdef LINT
        p=n;
 #endif
        }
 
-static long gr_load_rand(name)
-char *name;
+static long gr_load_rand(char *name)
        {
        char *p,*n;
        int last;