version 1.15, 2019/07/14 03:30:46 |
version 1.16, 2022/01/10 12:17:49 |
|
|
#include <openssl/pem.h> |
#include <openssl/pem.h> |
|
|
static struct { |
static struct { |
|
int check; |
const EVP_CIPHER *cipher; |
const EVP_CIPHER *cipher; |
char *infile; |
char *infile; |
int informat; |
int informat; |
|
|
int outformat; |
int outformat; |
char *passargin; |
char *passargin; |
char *passargout; |
char *passargout; |
|
int pubcheck; |
int pubin; |
int pubin; |
int pubout; |
int pubout; |
int pubtext; |
int pubtext; |
|
|
|
|
static const struct option pkey_options[] = { |
static const struct option pkey_options[] = { |
{ |
{ |
|
.name = "check", |
|
.desc = "Check validity of key", |
|
.type = OPTION_FLAG, |
|
.opt.flag = &pkey_config.check, |
|
}, |
|
{ |
.name = "in", |
.name = "in", |
.argname = "file", |
.argname = "file", |
.desc = "Input file (default stdin)", |
.desc = "Input file (default stdin)", |
|
|
.opt.arg = &pkey_config.passargout, |
.opt.arg = &pkey_config.passargout, |
}, |
}, |
{ |
{ |
|
.name = "pubcheck", |
|
.desc = "Check validity of public key", |
|
.type = OPTION_FLAG, |
|
.opt.flag = &pkey_config.pubcheck, |
|
}, |
|
{ |
.name = "pubin", |
.name = "pubin", |
.desc = "Expect a public key (default private key)", |
.desc = "Expect a public key (default private key)", |
.type = OPTION_VALUE, |
.type = OPTION_VALUE, |
|
|
int n = 0; |
int n = 0; |
|
|
fprintf(stderr, |
fprintf(stderr, |
"usage: pkey [-ciphername] [-in file] [-inform fmt] [-noout] " |
"usage: pkey [-check] [-ciphername] [-in file] [-inform fmt] " |
"[-out file]\n" |
"[-noout] [-out file]\n" |
" [-outform fmt] [-passin src] [-passout src] [-pubin] " |
" [-outform fmt] [-passin src] [-passout src] [-pubcheck] " |
"[-pubout] [-text]\n" |
"[-pubin] [-pubout]\n" |
" [-text_pub]\n\n"); |
" [-text] [-text_pub]\n\n"); |
options_usage(pkey_options); |
options_usage(pkey_options); |
fprintf(stderr, "\n"); |
fprintf(stderr, "\n"); |
|
|
|
|
pkey_config.informat, 1, passin, "key"); |
pkey_config.informat, 1, passin, "key"); |
if (!pkey) |
if (!pkey) |
goto end; |
goto end; |
|
|
|
#if notyet |
|
if (pkey_config.check) { |
|
if (!pkey_check(out, pkey, EVP_PKEY_check, "Key pair")) |
|
goto end; |
|
} else if (pkey_config.pubcheck) { |
|
if (!pkey_check(out, pkey, EVP_PKEY_public_check, "Public key")) |
|
goto end; |
|
} |
|
#endif |
|
|
if (!pkey_config.noout) { |
if (!pkey_config.noout) { |
if (pkey_config.outformat == FORMAT_PEM) { |
if (pkey_config.outformat == FORMAT_PEM) { |