=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/openssl/genpkey.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- src/usr.bin/openssl/genpkey.c 2015/08/22 16:36:05 1.4 +++ src/usr.bin/openssl/genpkey.c 2015/09/11 14:30:23 1.5 @@ -1,4 +1,4 @@ -/* $OpenBSD: genpkey.c,v 1.4 2015/08/22 16:36:05 jsing Exp $ */ +/* $OpenBSD: genpkey.c,v 1.5 2015/09/11 14:30:23 bcook Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006 */ @@ -65,19 +65,13 @@ #include #include -#ifndef OPENSSL_NO_ENGINE -#include -#endif - static int -init_keygen_file(BIO * err, EVP_PKEY_CTX ** pctx, const char *file, - ENGINE * e); +init_keygen_file(BIO * err, EVP_PKEY_CTX ** pctx, const char *file); static int genpkey_cb(EVP_PKEY_CTX * ctx); int genpkey_main(int argc, char **argv) { - ENGINE *e = NULL; char **args, *outfile = NULL; char *passarg = NULL; BIO *in = NULL, *out = NULL; @@ -107,20 +101,13 @@ goto bad; passarg = *(++args); } -#ifndef OPENSSL_NO_ENGINE - else if (strcmp(*args, "-engine") == 0) { - if (!args[1]) - goto bad; - e = setup_engine(bio_err, *(++args), 0); - } -#endif else if (!strcmp(*args, "-paramfile")) { if (!args[1]) goto bad; args++; if (do_param == 1) goto bad; - if (!init_keygen_file(bio_err, &ctx, *args, e)) + if (!init_keygen_file(bio_err, &ctx, *args)) goto end; } else if (!strcmp(*args, "-out")) { if (args[1]) { @@ -131,7 +118,7 @@ } else if (strcmp(*args, "-algorithm") == 0) { if (!args[1]) goto bad; - if (!init_gen_str(bio_err, &ctx, *(++args), e, do_param)) + if (!init_gen_str(bio_err, &ctx, *(++args), do_param)) goto end; } else if (strcmp(*args, "-pkeyopt") == 0) { if (!args[1]) @@ -174,9 +161,6 @@ BIO_printf(bio_err, "-outform X output format (DER or PEM)\n"); BIO_printf(bio_err, "-pass arg output file pass phrase source\n"); BIO_printf(bio_err, "- use cipher to encrypt the key\n"); -#ifndef OPENSSL_NO_ENGINE - BIO_printf(bio_err, "-engine e use engine e, possibly a hardware device.\n"); -#endif BIO_printf(bio_err, "-paramfile file parameters file\n"); BIO_printf(bio_err, "-algorithm alg the public key algorithm\n"); BIO_printf(bio_err, "-pkeyopt opt:value set the public key algorithm option \n" @@ -261,7 +245,7 @@ static int init_keygen_file(BIO * err, EVP_PKEY_CTX ** pctx, - const char *file, ENGINE * e) + const char *file) { BIO *pbio; EVP_PKEY *pkey = NULL; @@ -282,7 +266,7 @@ BIO_printf(bio_err, "Error reading parameter file %s\n", file); return 0; } - ctx = EVP_PKEY_CTX_new(pkey, e); + ctx = EVP_PKEY_CTX_new(pkey, NULL); if (!ctx) goto err; if (EVP_PKEY_keygen_init(ctx) <= 0) @@ -304,24 +288,18 @@ int init_gen_str(BIO * err, EVP_PKEY_CTX ** pctx, - const char *algname, ENGINE * e, int do_param) + const char *algname, int do_param) { EVP_PKEY_CTX *ctx = NULL; const EVP_PKEY_ASN1_METHOD *ameth; - ENGINE *tmpeng = NULL; int pkey_id; if (*pctx) { BIO_puts(err, "Algorithm already set!\n"); return 0; } - ameth = EVP_PKEY_asn1_find_str(&tmpeng, algname, -1); + ameth = EVP_PKEY_asn1_find_str(NULL, 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; @@ -329,11 +307,7 @@ ERR_clear_error(); EVP_PKEY_asn1_get0_info(&pkey_id, NULL, NULL, NULL, NULL, ameth); -#ifndef OPENSSL_NO_ENGINE - if (tmpeng) - ENGINE_finish(tmpeng); -#endif - ctx = EVP_PKEY_CTX_new_id(pkey_id, e); + ctx = EVP_PKEY_CTX_new_id(pkey_id, NULL); if (!ctx) goto err;