mirror of
https://github.com/QuasarApp/openssl.git
synced 2025-04-29 19:24:37 +00:00
Restore support for ENGINE format keys in apps.
RT#4207 Reviewed-by: Tim Hudson <tjh@openssl.org>
This commit is contained in:
parent
48c16012e7
commit
d18ba3cc36
@ -83,7 +83,7 @@ typedef enum OPTION_choice {
|
|||||||
|
|
||||||
OPTIONS dsa_options[] = {
|
OPTIONS dsa_options[] = {
|
||||||
{"help", OPT_HELP, '-', "Display this summary"},
|
{"help", OPT_HELP, '-', "Display this summary"},
|
||||||
{"inform", OPT_INFORM, 'F', "Input format, DER PEM PVK"},
|
{"inform", OPT_INFORM, 'f', "Input format, DER PEM PVK"},
|
||||||
{"outform", OPT_OUTFORM, 'F', "Output format, DER PEM PVK"},
|
{"outform", OPT_OUTFORM, 'F', "Output format, DER PEM PVK"},
|
||||||
{"in", OPT_IN, 's', "Input key"},
|
{"in", OPT_IN, 's', "Input key"},
|
||||||
{"out", OPT_OUT, '>', "Output file"},
|
{"out", OPT_OUT, '>', "Output file"},
|
||||||
|
21
apps/ec.c
21
apps/ec.c
@ -92,8 +92,8 @@ typedef enum OPTION_choice {
|
|||||||
|
|
||||||
OPTIONS ec_options[] = {
|
OPTIONS ec_options[] = {
|
||||||
{"help", OPT_HELP, '-', "Display this summary"},
|
{"help", OPT_HELP, '-', "Display this summary"},
|
||||||
{"in", OPT_IN, '<', "Input file"},
|
{"in", OPT_IN, 's', "Input file"},
|
||||||
{"inform", OPT_INFORM, 'F', "Input format - DER or PEM"},
|
{"inform", OPT_INFORM, 'f', "Input format - DER or PEM"},
|
||||||
{"out", OPT_OUT, '>', "Output file"},
|
{"out", OPT_OUT, '>', "Output file"},
|
||||||
{"outform", OPT_OUTFORM, 'F', "Output format - DER or PEM"},
|
{"outform", OPT_OUTFORM, 'F', "Output format - DER or PEM"},
|
||||||
{"noout", OPT_NOOUT, '-', "Don't print key out"},
|
{"noout", OPT_NOOUT, '-', "Don't print key out"},
|
||||||
@ -118,6 +118,7 @@ OPTIONS ec_options[] = {
|
|||||||
int ec_main(int argc, char **argv)
|
int ec_main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
BIO *in = NULL, *out = NULL;
|
BIO *in = NULL, *out = NULL;
|
||||||
|
ENGINE *e;
|
||||||
EC_KEY *eckey = NULL;
|
EC_KEY *eckey = NULL;
|
||||||
const EC_GROUP *group;
|
const EC_GROUP *group;
|
||||||
const EVP_CIPHER *enc = NULL;
|
const EVP_CIPHER *enc = NULL;
|
||||||
@ -143,7 +144,7 @@ int ec_main(int argc, char **argv)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
goto end;
|
goto end;
|
||||||
case OPT_INFORM:
|
case OPT_INFORM:
|
||||||
if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &informat))
|
if (!opt_format(opt_arg(), OPT_FMT_ANY, &informat))
|
||||||
goto opthelp;
|
goto opthelp;
|
||||||
break;
|
break;
|
||||||
case OPT_IN:
|
case OPT_IN:
|
||||||
@ -178,7 +179,7 @@ int ec_main(int argc, char **argv)
|
|||||||
passoutarg = opt_arg();
|
passoutarg = opt_arg();
|
||||||
break;
|
break;
|
||||||
case OPT_ENGINE:
|
case OPT_ENGINE:
|
||||||
(void)setup_engine(opt_arg(), 0);
|
e = setup_engine(opt_arg(), 0);
|
||||||
break;
|
break;
|
||||||
case OPT_CIPHER:
|
case OPT_CIPHER:
|
||||||
if (!opt_cipher(opt_unknown(), &enc))
|
if (!opt_cipher(opt_unknown(), &enc))
|
||||||
@ -217,9 +218,11 @@ int ec_main(int argc, char **argv)
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (informat != FORMAT_ENGINE) {
|
||||||
in = bio_open_default(infile, 'r', informat);
|
in = bio_open_default(infile, 'r', informat);
|
||||||
if (in == NULL)
|
if (in == NULL)
|
||||||
goto end;
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
BIO_printf(bio_err, "read EC key\n");
|
BIO_printf(bio_err, "read EC key\n");
|
||||||
if (informat == FORMAT_ASN1) {
|
if (informat == FORMAT_ASN1) {
|
||||||
@ -227,6 +230,16 @@ int ec_main(int argc, char **argv)
|
|||||||
eckey = d2i_EC_PUBKEY_bio(in, NULL);
|
eckey = d2i_EC_PUBKEY_bio(in, NULL);
|
||||||
else
|
else
|
||||||
eckey = d2i_ECPrivateKey_bio(in, NULL);
|
eckey = d2i_ECPrivateKey_bio(in, NULL);
|
||||||
|
} else if (informat == FORMAT_ENGINE) {
|
||||||
|
EVP_PKEY *pkey;
|
||||||
|
if (pubin)
|
||||||
|
pkey = load_pubkey(infile, informat , 1, passin, e, "Public Key");
|
||||||
|
else
|
||||||
|
pkey = load_key(infile, informat, 1, passin, e, "Private Key");
|
||||||
|
if (pkey != NULL) {
|
||||||
|
eckey = EVP_PKEY_get1_EC_KEY(pkey);
|
||||||
|
EVP_PKEY_free(pkey);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (pubin)
|
if (pubin)
|
||||||
eckey = PEM_read_bio_EC_PUBKEY(in, NULL, NULL, NULL);
|
eckey = PEM_read_bio_EC_PUBKEY(in, NULL, NULL, NULL);
|
||||||
|
@ -71,7 +71,7 @@ typedef enum OPTION_choice {
|
|||||||
|
|
||||||
OPTIONS pkey_options[] = {
|
OPTIONS pkey_options[] = {
|
||||||
{"help", OPT_HELP, '-', "Display this summary"},
|
{"help", OPT_HELP, '-', "Display this summary"},
|
||||||
{"inform", OPT_INFORM, 'F', "Input format (DER or PEM)"},
|
{"inform", OPT_INFORM, 'f', "Input format (DER or PEM)"},
|
||||||
{"outform", OPT_OUTFORM, 'F', "Output format (DER or PEM)"},
|
{"outform", OPT_OUTFORM, 'F', "Output format (DER or PEM)"},
|
||||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||||
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
|
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user