X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=apps%2Fdh.c;h=7465442e49f1c07f8d766029ca8bdfe599c0eb43;hb=c29dbb9562f275485c1266af523cd5d59311d583;hp=bbf445e84568330278402d4bebb900899141f2b9;hpb=7dfb0b774e6592dcbfe47015168a0ac8b44e2a17;p=oweals%2Fopenssl.git diff --git a/apps/dh.c b/apps/dh.c index bbf445e845..7465442e49 100644 --- a/apps/dh.c +++ b/apps/dh.c @@ -1,4 +1,5 @@ /* apps/dh.c */ +/* obsoleted by dhparam.c */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -56,22 +57,23 @@ * [including the GNU Public Licence.] */ +#ifndef NO_DH #include #include #include #include #include "apps.h" -#include "bio.h" -#include "err.h" -#include "bn.h" -#include "dh.h" -#include "x509.h" -#include "pem.h" +#include +#include +#include +#include +#include +#include #undef PROG #define PROG dh_main -/* -inform arg - input format - default PEM (one of DER, TXT or PEM) +/* -inform arg - input format - default PEM (DER or PEM) * -outform arg - output format - default PEM * -in arg - input file - default stdin * -out arg - output file - default stdout @@ -81,9 +83,9 @@ * -C */ -int MAIN(argc, argv) -int argc; -char **argv; +int MAIN(int, char **); + +int MAIN(int argc, char **argv) { DH *dh=NULL; int i,badops=0,text=0; @@ -150,12 +152,12 @@ char **argv; bad: BIO_printf(bio_err,"%s [options] 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; @@ -182,7 +184,15 @@ bad: } } if (outfile == NULL) + { BIO_set_fp(out,stdout,BIO_NOCLOSE); +#ifdef VMS + { + BIO *tmpbio = BIO_new(BIO_f_linebuffer()); + out = BIO_push(tmpbio, out); + } +#endif + } else { if (BIO_write_filename(out,outfile) <= 0) @@ -195,7 +205,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"); @@ -220,7 +230,7 @@ bad: BN_print(stdout,dh->g); printf("\n"); if (dh->length != 0) - printf("recomented private length=%ld\n",dh->length); + printf("recommended private length=%ld\n",dh->length); #endif } @@ -233,8 +243,8 @@ bad: } if (i & DH_CHECK_P_NOT_PRIME) printf("p value is not prime\n"); - if (i & DH_CHECK_P_NOT_STRONG_PRIME) - printf("p value is not a strong prime\n"); + if (i & DH_CHECK_P_NOT_SAFE_PRIME) + printf("p value is not a safe prime\n"); if (i & DH_UNABLE_TO_CHECK_GENERATOR) printf("unable to check the generator value\n"); if (i & DH_NOT_SUITABLE_GENERATOR) @@ -249,10 +259,10 @@ bad: len=BN_num_bytes(dh->p); bits=BN_num_bits(dh->p); - data=(unsigned char *)Malloc(len); + data=(unsigned char *)OPENSSL_malloc(len); if (data == NULL) { - perror("Malloc"); + perror("OPENSSL_malloc"); goto end; } l=BN_bn2bin(dh->p,data); @@ -283,6 +293,7 @@ bad: printf("\tif ((dh->p == NULL) || (dh->g == NULL))\n"); printf("\t\treturn(NULL);\n"); printf("\treturn(dh);\n\t}\n"); + OPENSSL_free(data); } @@ -298,7 +309,7 @@ bad: } if (!i) { - BIO_printf(bio_err,"unable to write DH paramaters\n"); + BIO_printf(bio_err,"unable to write DH parameters\n"); ERR_print_errors(bio_err); goto end; } @@ -306,7 +317,8 @@ bad: ret=0; end: if (in != NULL) BIO_free(in); - if (out != NULL) BIO_free(out); + if (out != NULL) BIO_free_all(out); if (dh != NULL) DH_free(dh); EXIT(ret); } +#endif