version 1.16, 2023/03/05 13:12:53 |
version 1.17, 2023/03/06 14:32:06 |
|
|
int noout; |
int noout; |
char *outfile; |
char *outfile; |
int text; |
int text; |
} pkeyparam_config; |
} cfg; |
|
|
static const struct option pkeyparam_options[] = { |
static const struct option pkeyparam_options[] = { |
{ |
{ |
.name = "check", |
.name = "check", |
.desc = "Check validity of key parameters", |
.desc = "Check validity of key parameters", |
.type = OPTION_FLAG, |
.type = OPTION_FLAG, |
.opt.flag = &pkeyparam_config.check, |
.opt.flag = &cfg.check, |
}, |
}, |
{ |
{ |
.name = "in", |
.name = "in", |
.argname = "file", |
.argname = "file", |
.desc = "Input file (default stdin)", |
.desc = "Input file (default stdin)", |
.type = OPTION_ARG, |
.type = OPTION_ARG, |
.opt.arg = &pkeyparam_config.infile, |
.opt.arg = &cfg.infile, |
}, |
}, |
{ |
{ |
.name = "noout", |
.name = "noout", |
.desc = "Do not print encoded version of the parameters", |
.desc = "Do not print encoded version of the parameters", |
.type = OPTION_FLAG, |
.type = OPTION_FLAG, |
.opt.flag = &pkeyparam_config.noout, |
.opt.flag = &cfg.noout, |
}, |
}, |
{ |
{ |
.name = "out", |
.name = "out", |
.argname = "file", |
.argname = "file", |
.desc = "Output file (default stdout)", |
.desc = "Output file (default stdout)", |
.type = OPTION_ARG, |
.type = OPTION_ARG, |
.opt.arg = &pkeyparam_config.outfile, |
.opt.arg = &cfg.outfile, |
}, |
}, |
{ |
{ |
.name = "text", |
.name = "text", |
.desc = "Print out the parameters in plain text", |
.desc = "Print out the parameters in plain text", |
.type = OPTION_FLAG, |
.type = OPTION_FLAG, |
.opt.flag = &pkeyparam_config.text, |
.opt.flag = &cfg.text, |
}, |
}, |
{ NULL }, |
{ NULL }, |
}; |
}; |
|
|
exit(1); |
exit(1); |
} |
} |
|
|
memset(&pkeyparam_config, 0, sizeof(pkeyparam_config)); |
memset(&cfg, 0, sizeof(cfg)); |
|
|
if (options_parse(argc, argv, pkeyparam_options, NULL, NULL) != 0) { |
if (options_parse(argc, argv, pkeyparam_options, NULL, NULL) != 0) { |
pkeyparam_usage(); |
pkeyparam_usage(); |
return (1); |
return (1); |
} |
} |
|
|
if (pkeyparam_config.infile) { |
if (cfg.infile) { |
if (!(in = BIO_new_file(pkeyparam_config.infile, "r"))) { |
if (!(in = BIO_new_file(cfg.infile, "r"))) { |
BIO_printf(bio_err, "Can't open input file %s\n", |
BIO_printf(bio_err, "Can't open input file %s\n", |
pkeyparam_config.infile); |
cfg.infile); |
goto end; |
goto end; |
} |
} |
} else |
} else |
in = BIO_new_fp(stdin, BIO_NOCLOSE); |
in = BIO_new_fp(stdin, BIO_NOCLOSE); |
|
|
if (pkeyparam_config.outfile) { |
if (cfg.outfile) { |
if (!(out = BIO_new_file(pkeyparam_config.outfile, "w"))) { |
if (!(out = BIO_new_file(cfg.outfile, "w"))) { |
BIO_printf(bio_err, "Can't open output file %s\n", |
BIO_printf(bio_err, "Can't open output file %s\n", |
pkeyparam_config.outfile); |
cfg.outfile); |
goto end; |
goto end; |
} |
} |
} else { |
} else { |
|
|
goto end; |
goto end; |
} |
} |
|
|
if (pkeyparam_config.check) { |
if (cfg.check) { |
if (!pkey_check(out, pkey, EVP_PKEY_param_check, "Parameters")) |
if (!pkey_check(out, pkey, EVP_PKEY_param_check, "Parameters")) |
goto end; |
goto end; |
} |
} |
|
|
if (!pkeyparam_config.noout) |
if (!cfg.noout) |
PEM_write_bio_Parameters(out, pkey); |
PEM_write_bio_Parameters(out, pkey); |
|
|
if (pkeyparam_config.text) |
if (cfg.text) |
EVP_PKEY_print_params(out, pkey, 0, NULL); |
EVP_PKEY_print_params(out, pkey, 0, NULL); |
|
|
ret = 0; |
ret = 0; |