X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=apps%2Fgenpkey.c;h=6dfda08b9e09f2d7ca3e4bea10f3ce27e8ffebeb;hp=96801c7045373e0c896fa2b724418573b04464d1;hb=2cc5142fb13e00e4c11179b156fdcec7cd4cde77;hpb=105f6a6323cd1a9ac7fab68d575bf0382324a3bc diff --git a/apps/genpkey.c b/apps/genpkey.c index 96801c7045..6dfda08b9e 100644 --- a/apps/genpkey.c +++ b/apps/genpkey.c @@ -1,5 +1,5 @@ /* apps/genpkey.c */ -/* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL +/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006 */ /* ==================================================================== @@ -67,8 +67,6 @@ static int init_keygen_file(BIO *err, EVP_PKEY_CTX **pctx, const char *file, ENGINE *e); -static int init_gen_str(BIO *err, EVP_PKEY_CTX **pctx, - const char *algname, ENGINE *e, int do_param); static int genpkey_cb(EVP_PKEY_CTX *ctx); #define PROG genpkey_main @@ -362,8 +360,8 @@ static int init_keygen_file(BIO *err, EVP_PKEY_CTX **pctx, } -static int init_gen_str(BIO *err, EVP_PKEY_CTX **pctx, - const char *algname, ENGINE *e, int do_param) +int init_gen_str(BIO *err, EVP_PKEY_CTX **pctx, + const char *algname, ENGINE *e, int do_param) { EVP_PKEY_CTX *ctx = NULL; const EVP_PKEY_ASN1_METHOD *ameth; @@ -375,14 +373,22 @@ static int init_gen_str(BIO *err, EVP_PKEY_CTX **pctx, BIO_puts(err, "Algorithm already set!\n"); return 0; } + ameth = EVP_PKEY_asn1_find_str(&tmpeng, algname, -1); +#ifndef OPENSSL_NO_ENGINE + if (!ameth && e) + ameth = ENGINE_get_pkey_asn1_meth_str(e, algname, -1); +#endif + if (!ameth) { BIO_printf(bio_err, "Algorithm %s not found\n", algname); return 0; } + ERR_clear_error(); + EVP_PKEY_asn1_get0_info(&pkey_id, NULL, NULL, NULL, NULL, ameth); #ifndef OPENSSL_NO_ENGINE if (tmpeng)