X-Git-Url: https://git.openssl.org/gitweb/?a=blobdiff_plain;f=apps%2Fdh.c;h=dee9c01fcec1e10419cccc6549f70b467666c6a5;hb=2f1dffa88e1b120add4f0b3a794fbca65aa7768d;hp=7465442e49f1c07f8d766029ca8bdfe599c0eb43;hpb=645749ef98612340b11c4bf2ba856e1fa469912b;p=openssl.git diff --git a/apps/dh.c b/apps/dh.c index 7465442e49..dee9c01fce 100644 --- a/apps/dh.c +++ b/apps/dh.c @@ -57,7 +57,8 @@ * [including the GNU Public Licence.] */ -#ifndef NO_DH +#include /* for OPENSSL_NO_DH */ +#ifndef OPENSSL_NO_DH #include #include #include @@ -92,6 +93,9 @@ int MAIN(int argc, char **argv) BIO *in=NULL,*out=NULL; int informat,outformat,check=0,noout=0,C=0,ret=1; char *infile,*outfile,*prog; +#ifndef OPENSSL_NO_ENGINE + char *engine; +#endif apps_startup(); @@ -99,6 +103,12 @@ int MAIN(int argc, char **argv) if ((bio_err=BIO_new(BIO_s_file())) != NULL) BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); + if (!load_config(bio_err, NULL)) + goto end; + +#ifndef OPENSSL_NO_ENGINE + engine=NULL; +#endif infile=NULL; outfile=NULL; informat=FORMAT_PEM; @@ -129,6 +139,13 @@ int MAIN(int argc, char **argv) if (--argc < 1) goto bad; outfile= *(++argv); } +#ifndef OPENSSL_NO_ENGINE + else if (strcmp(*argv,"-engine") == 0) + { + if (--argc < 1) goto bad; + engine= *(++argv); + } +#endif else if (strcmp(*argv,"-check") == 0) check=1; else if (strcmp(*argv,"-text") == 0) @@ -160,11 +177,18 @@ bad: 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"); +#ifndef OPENSSL_NO_ENGINE + BIO_printf(bio_err," -engine e use engine e, possibly a hardware device.\n"); +#endif goto end; } ERR_load_crypto_strings(); +#ifndef OPENSSL_NO_ENGINE + setup_engine(bio_err, engine, 0); +#endif + in=BIO_new(BIO_s_file()); out=BIO_new(BIO_s_file()); if ((in == NULL) || (out == NULL)) @@ -186,7 +210,7 @@ bad: if (outfile == NULL) { BIO_set_fp(out,stdout,BIO_NOCLOSE); -#ifdef VMS +#ifdef OPENSSL_SYS_VMS { BIO *tmpbio = BIO_new(BIO_f_linebuffer()); out = BIO_push(tmpbio, out); @@ -319,6 +343,13 @@ end: if (in != NULL) BIO_free(in); if (out != NULL) BIO_free_all(out); if (dh != NULL) DH_free(dh); - EXIT(ret); + apps_shutdown(); + OPENSSL_EXIT(ret); } +#else /* !OPENSSL_NO_DH */ + +# if PEDANTIC +static void *dummy=&dummy; +# endif + #endif