Manpages for the DH utils and fix for a memory leak in dh program
[openssl.git] / apps / dh.c
index 8a3bcfb88699ef7bb17a6cb9ddae07396b293faf..d68b38808540433543fcf5ed6b1c9db2c184df64 100644 (file)
--- a/apps/dh.c
+++ b/apps/dh.c
@@ -1,5 +1,5 @@
 /* apps/dh.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
  * [including the GNU Public Licence.]
  */
 
+#ifndef NO_DH
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
 #include <string.h>
 #include "apps.h"
-#include "bio.h"
-#include "err.h"
-#include "bn.h"
-#include "dh.h"
-#include "x509.h"
-#include "pem.h"
+#include <openssl/bio.h>
+#include <openssl/err.h>
+#include <openssl/bn.h>
+#include <openssl/dh.h>
+#include <openssl/x509.h>
+#include <openssl/pem.h>
 
 #undef PROG
 #define PROG   dh_main
@@ -81,9 +82,7 @@
  * -C
  */
 
-int MAIN(argc, argv)
-int argc;
-char **argv;
+int MAIN(int argc, char **argv)
        {
        DH *dh=NULL;
        int i,badops=0,text=0;
@@ -95,7 +94,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);
 
        infile=NULL;
        outfile=NULL;
@@ -150,12 +149,12 @@ char **argv;
 bad:
                BIO_printf(bio_err,"%s [options] <infile >outfile\n",prog);
                BIO_printf(bio_err,"where options are\n");
-               BIO_printf(bio_err," -inform arg   input format - one of DER TXT PEM\n");
-               BIO_printf(bio_err," -outform arg  output format - one of DER TXT PEM\n");
-               BIO_printf(bio_err," -in arg       inout file\n");
+               BIO_printf(bio_err," -inform arg   input format - one of DER PEM\n");
+               BIO_printf(bio_err," -outform arg  output format - one of DER PEM\n");
+               BIO_printf(bio_err," -in arg       input file\n");
                BIO_printf(bio_err," -out arg      output file\n");
                BIO_printf(bio_err," -check        check the DH parameters\n");
-               BIO_printf(bio_err," -text         check the DH parameters\n");
+               BIO_printf(bio_err," -text         print a text form of the DH parameters\n");
                BIO_printf(bio_err," -C            Output C code\n");
                BIO_printf(bio_err," -noout        no output\n");
                goto end;
@@ -195,7 +194,7 @@ bad:
        if      (informat == FORMAT_ASN1)
                dh=d2i_DHparams_bio(in,NULL);
        else if (informat == FORMAT_PEM)
-               dh=PEM_read_bio_DHparams(in,NULL,NULL);
+               dh=PEM_read_bio_DHparams(in,NULL,NULL,NULL);
        else
                {
                BIO_printf(bio_err,"bad input format specified\n");
@@ -283,6 +282,7 @@ bad:
                printf("\tif ((dh->p == NULL) || (dh->g == NULL))\n");
                printf("\t\treturn(NULL);\n");
                printf("\treturn(dh);\n\t}\n");
+               Free(data);
                }
 
 
@@ -310,3 +310,4 @@ end:
        if (dh != NULL) DH_free(dh);
        EXIT(ret);
        }
+#endif