X-Git-Url: https://git.openssl.org/gitweb/?a=blobdiff_plain;f=apps%2Fgenpkey.c;h=389f0e620c6737d4b76533ec693d8e1571def691;hb=914f97eecc9166fbfdb50c2d04e2b9f9d0c52198;hp=3ae508c1c83b2c4a184bfc793f43f65a9d28ac6b;hpb=5388f9862d9aaf3c7cf7a70c1e36e7e983c26cfc;p=openssl.git diff --git a/apps/genpkey.c b/apps/genpkey.c index 3ae508c1c8..389f0e620c 100644 --- a/apps/genpkey.c +++ b/apps/genpkey.c @@ -1,5 +1,5 @@ /* - * Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -7,6 +7,9 @@ * https://www.openssl.org/source/license.html */ +/* We need to use some engine deprecated APIs */ +#define OPENSSL_SUPPRESS_DEPRECATED + #include #include #include "apps.h" @@ -24,7 +27,8 @@ static int genpkey_cb(EVP_PKEY_CTX *ctx); typedef enum OPTION_choice { OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_ENGINE, OPT_OUTFORM, OPT_OUT, OPT_PASS, OPT_PARAMFILE, - OPT_ALGORITHM, OPT_PKEYOPT, OPT_GENPARAM, OPT_TEXT, OPT_CIPHER + OPT_ALGORITHM, OPT_PKEYOPT, OPT_GENPARAM, OPT_TEXT, OPT_CIPHER, + OPT_PROV_ENUM } OPTION_CHOICE; const OPTIONS genpkey_options[] = { @@ -46,6 +50,8 @@ const OPTIONS genpkey_options[] = { {"text", OPT_TEXT, '-', "Print the in text"}, {"", OPT_CIPHER, '-', "Cipher to use to encrypt the key"}, + OPT_PROV_OPTIONS, + /* This is deliberately last. */ {OPT_HELP_STR, 1, 1, "Order of options may be important! See the documentation.\n"}, @@ -131,6 +137,11 @@ int genpkey_main(int argc, char **argv) BIO_printf(bio_err, "%s: cipher mode not supported\n", prog); goto end; } + break; + case OPT_PROV_CASES: + if (!opt_provider(o)) + goto end; + break; } } argc = opt_num_rest(); @@ -181,9 +192,12 @@ int genpkey_main(int argc, char **argv) goto end; } + ret = 0; + if (rv <= 0) { BIO_puts(bio_err, "Error writing key\n"); ERR_print_errors(bio_err); + ret = 1; } if (text) { @@ -195,11 +209,10 @@ int genpkey_main(int argc, char **argv) if (rv <= 0) { BIO_puts(bio_err, "Error printing key\n"); ERR_print_errors(bio_err); + ret = 1; } } - ret = 0; - end: EVP_PKEY_free(pkey); EVP_PKEY_CTX_free(ctx); @@ -267,7 +280,7 @@ int init_gen_str(EVP_PKEY_CTX **pctx, ameth = EVP_PKEY_asn1_find_str(&tmpeng, algname, -1); -#ifndef OPENSSL_NO_ENGINE +#if !defined(OPENSSL_NO_ENGINE) && !defined(OPENSSL_NO_DEPRECATED_3_0) if (!ameth && e) ameth = ENGINE_get_pkey_asn1_meth_str(e, algname, -1); #endif @@ -280,7 +293,7 @@ int init_gen_str(EVP_PKEY_CTX **pctx, ERR_clear_error(); EVP_PKEY_asn1_get0_info(&pkey_id, NULL, NULL, NULL, NULL, ameth); -#ifndef OPENSSL_NO_ENGINE +#if !defined(OPENSSL_NO_ENGINE) && !defined(OPENSSL_NO_DEPRECATED_3_0) ENGINE_finish(tmpeng); #endif ctx = EVP_PKEY_CTX_new_id(pkey_id, e);