version 1.11, 2018/02/07 05:47:55 |
version 1.12, 2018/08/24 20:09:56 |
|
|
int nocrypt; |
int nocrypt; |
char *outfile; |
char *outfile; |
int outformat; |
int outformat; |
int p8_broken; |
|
char *passargin; |
char *passargin; |
char *passargout; |
char *passargout; |
int pbe_nid; |
int pbe_nid; |
|
|
|
|
static struct option pkcs8_options[] = { |
static struct option pkcs8_options[] = { |
{ |
{ |
.name = "embed", |
|
.desc = "Generate DSA keys in a broken format", |
|
.type = OPTION_VALUE, |
|
.value = PKCS8_EMBEDDED_PARAM, |
|
.opt.value = &pkcs8_config.p8_broken, |
|
}, |
|
{ |
|
.name = "in", |
.name = "in", |
.argname = "file", |
.argname = "file", |
.desc = "Input file (default stdin)", |
.desc = "Input file (default stdin)", |
|
|
.opt.value = &pkcs8_config.iter, |
.opt.value = &pkcs8_config.iter, |
}, |
}, |
{ |
{ |
.name = "nooct", |
|
.desc = "Generate RSA keys in a broken format (no octet)", |
|
.type = OPTION_VALUE, |
|
.value = PKCS8_NO_OCTET, |
|
.opt.value = &pkcs8_config.p8_broken, |
|
}, |
|
{ |
|
.name = "nsdb", |
|
.desc = "Generate DSA keys in the broken Netscape DB format", |
|
.type = OPTION_VALUE, |
|
.value = PKCS8_NS_DB, |
|
.opt.value = &pkcs8_config.p8_broken, |
|
}, |
|
{ |
|
.name = "out", |
.name = "out", |
.argname = "file", |
.argname = "file", |
.desc = "Output file (default stdout)", |
.desc = "Output file (default stdout)", |
|
|
pkcs8_config.iter = PKCS12_DEFAULT_ITER; |
pkcs8_config.iter = PKCS12_DEFAULT_ITER; |
pkcs8_config.informat = FORMAT_PEM; |
pkcs8_config.informat = FORMAT_PEM; |
pkcs8_config.outformat = FORMAT_PEM; |
pkcs8_config.outformat = FORMAT_PEM; |
pkcs8_config.p8_broken = PKCS8_OK; |
|
pkcs8_config.pbe_nid = -1; |
pkcs8_config.pbe_nid = -1; |
|
|
if (options_parse(argc, argv, pkcs8_options, NULL, NULL) != 0) { |
if (options_parse(argc, argv, pkcs8_options, NULL, NULL) != 0) { |
|
|
pkcs8_config.informat, 1, passin, "key"); |
pkcs8_config.informat, 1, passin, "key"); |
if (!pkey) |
if (!pkey) |
goto end; |
goto end; |
if (!(p8inf = EVP_PKEY2PKCS8_broken(pkey, |
if (!(p8inf = EVP_PKEY2PKCS8(pkey))) { |
pkcs8_config.p8_broken))) { |
|
BIO_printf(bio_err, "Error converting key\n"); |
BIO_printf(bio_err, "Error converting key\n"); |
ERR_print_errors(bio_err); |
ERR_print_errors(bio_err); |
goto end; |
goto end; |
|
|
BIO_printf(bio_err, "Error converting key\n"); |
BIO_printf(bio_err, "Error converting key\n"); |
ERR_print_errors(bio_err); |
ERR_print_errors(bio_err); |
goto end; |
goto end; |
} |
|
if (p8inf->broken) { |
|
BIO_printf(bio_err, "Warning: broken key encoding: "); |
|
switch (p8inf->broken) { |
|
case PKCS8_NO_OCTET: |
|
BIO_printf(bio_err, "No Octet String in PrivateKey\n"); |
|
break; |
|
|
|
case PKCS8_EMBEDDED_PARAM: |
|
BIO_printf(bio_err, |
|
"DSA parameters included in PrivateKey\n"); |
|
break; |
|
|
|
case PKCS8_NS_DB: |
|
BIO_printf(bio_err, |
|
"DSA public key include in PrivateKey\n"); |
|
break; |
|
|
|
case PKCS8_NEG_PRIVKEY: |
|
BIO_printf(bio_err, "DSA private key value is negative\n"); |
|
break; |
|
|
|
default: |
|
BIO_printf(bio_err, "Unknown broken type\n"); |
|
break; |
|
} |
|
} |
} |
if (pkcs8_config.outformat == FORMAT_PEM) |
if (pkcs8_config.outformat == FORMAT_PEM) |
PEM_write_bio_PrivateKey(out, pkey, NULL, NULL, 0, NULL, |
PEM_write_bio_PrivateKey(out, pkey, NULL, NULL, 0, NULL, |