{"C", OPT_C, '-', "Print C code"},
{"2", OPT_2, '-', "Generate parameters using 2 as the generator value"},
{"5", OPT_5, '-', "Generate parameters using 5 as the generator value"},
-# ifndef OPENSSL_NO_ENGINE
- {"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"},
-# endif
# ifndef OPENSSL_NO_DSA
{"dsaparam", OPT_DSAPARAM, '-',
"Read or generate DSA parameters, convert to DH"},
+# endif
+# ifndef OPENSSL_NO_ENGINE
+ {"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"},
# endif
{NULL}
};
{
BIO *in = NULL, *out = NULL;
DH *dh = NULL;
- char *engine = NULL, *infile = NULL, *outfile = NULL, *prog, *inrand =
- NULL;
+ char *infile = NULL, *outfile = NULL, *prog, *inrand = NULL;
int dsaparam = 0, i, text = 0, C = 0, ret = 1, num = 0, g = 0;
int informat = FORMAT_PEM, outformat = FORMAT_PEM, check = 0, noout = 0;
OPTION_CHOICE o;
outfile = opt_arg();
break;
case OPT_ENGINE:
- engine = opt_arg();
+ (void)setup_engine(opt_arg(), 0);
break;
case OPT_CHECK:
check = 1;
argc = opt_num_rest();
argv = opt_rest();
- if (argv[0] && (!opt_int(argv[0], &num) || num <= 0))
+ if (!app_load_modules(NULL))
goto end;
-# ifndef OPENSSL_NO_ENGINE
- setup_engine(engine, 0);
-# endif
+ if (argv[0] && (!opt_int(argv[0], &num) || num <= 0))
+ goto end;
if (g && !num)
num = DEFBITS;
app_RAND_write_file(NULL);
} else {
- in = bio_open_default(infile, RB(informat));
+ in = bio_open_default(infile, 'r', informat);
if (in == NULL)
goto end;
/* dh != NULL */
}
- out = bio_open_default(outfile, "w");
+ out = bio_open_default(outfile, 'w', outformat);
if (out == NULL)
goto end;
len = BN_num_bytes(dh->p);
bits = BN_num_bits(dh->p);
- data = (unsigned char *)OPENSSL_malloc(len);
- if (data == NULL) {
- perror("OPENSSL_malloc");
- goto end;
- }
+ data = app_malloc(len, "print a BN");
BIO_printf(out, "#ifndef HEADER_DH_H\n"
"# include <openssl/dh.h>\n"
"#endif\n"