X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=apps%2Fpkeyparam.c;h=df95f76f42c5d7fdc209104caef14d345daea728;hb=0c9fcfebf1b68a1736277c333dd6d59f35eb24f5;hp=35cdd8dc928c865ae42adba5f7ffb1cb064c1bde;hpb=b0004708730f300a2e5c6a11c887caab50b6c42a;p=oweals%2Fopenssl.git diff --git a/apps/pkeyparam.c b/apps/pkeyparam.c index 35cdd8dc92..df95f76f42 100644 --- a/apps/pkeyparam.c +++ b/apps/pkeyparam.c @@ -1,7 +1,7 @@ /* - * Copyright 2006-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved. * - * Licensed under the OpenSSL license (the "License"). You may not use + * 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 * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html @@ -9,7 +9,9 @@ #include #include +#include #include "apps.h" +#include "progs.h" #include #include #include @@ -17,19 +19,27 @@ typedef enum OPTION_choice { OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, OPT_IN, OPT_OUT, OPT_TEXT, OPT_NOOUT, - OPT_ENGINE, OPT_CHECK + OPT_ENGINE, OPT_CHECK, + OPT_PROV_ENUM } OPTION_CHOICE; const OPTIONS pkeyparam_options[] = { + OPT_SECTION("General"), {"help", OPT_HELP, '-', "Display this summary"}, - {"in", OPT_IN, '<', "Input file"}, - {"out", OPT_OUT, '>', "Output file"}, - {"text", OPT_TEXT, '-', "Print parameters as text"}, - {"noout", OPT_NOOUT, '-', "Don't output encoded parameters"}, #ifndef OPENSSL_NO_ENGINE {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"}, #endif {"check", OPT_CHECK, '-', "Check key param consistency"}, + + OPT_SECTION("Input"), + {"in", OPT_IN, '<', "Input file"}, + + OPT_SECTION("Output"), + {"out", OPT_OUT, '>', "Output file"}, + {"text", OPT_TEXT, '-', "Print parameters as text"}, + {"noout", OPT_NOOUT, '-', "Don't output encoded parameters"}, + + OPT_PROV_OPTIONS, {NULL} }; @@ -38,9 +48,11 @@ int pkeyparam_main(int argc, char **argv) ENGINE *e = NULL; BIO *in = NULL, *out = NULL; EVP_PKEY *pkey = NULL; - int text = 0, noout = 0, ret = 1, check = 0; + EVP_PKEY_CTX *ctx = NULL; + int text = 0, noout = 0, ret = EXIT_FAILURE, check = 0, r; OPTION_CHOICE o; char *infile = NULL, *outfile = NULL, *prog; + unsigned long err; prog = opt_init(argc, argv, pkeyparam_options); while ((o = opt_next()) != OPT_EOF) { @@ -72,6 +84,10 @@ int pkeyparam_main(int argc, char **argv) case OPT_CHECK: check = 1; break; + case OPT_PROV_CASES: + if (!opt_provider(o)) + goto end; + break; } } argc = opt_num_rest(); @@ -92,9 +108,6 @@ int pkeyparam_main(int argc, char **argv) } if (check) { - int r; - EVP_PKEY_CTX *ctx; - ctx = EVP_PKEY_CTX_new(pkey, e); if (ctx == NULL) { ERR_print_errors(bio_err); @@ -110,8 +123,6 @@ int pkeyparam_main(int argc, char **argv) * Note: at least for RSA keys if this function returns * -1, there will be no error reasons. */ - unsigned long err; - BIO_printf(out, "Parameters are invalid\n"); while ((err = ERR_peek_error()) != 0) { @@ -119,8 +130,8 @@ int pkeyparam_main(int argc, char **argv) ERR_reason_error_string(err)); ERR_get_error(); /* remove err from error stack */ } + goto end; } - EVP_PKEY_CTX_free(ctx); } if (!noout) @@ -129,9 +140,10 @@ int pkeyparam_main(int argc, char **argv) if (text) EVP_PKEY_print_params(out, pkey, 0, NULL); - ret = 0; + ret = EXIT_SUCCESS; end: + EVP_PKEY_CTX_free(ctx); EVP_PKEY_free(pkey); release_engine(e); BIO_free_all(out);