X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=apps%2Fmac.c;h=e84321b83ad0dfb1b5b521228fbaaf9ef5ca6c66;hb=0d96afd28c3bd5af9a57a9def232af2e718bfbf3;hp=205d82f779136144fb1bf6439c7f311f2530a91c;hpb=95214b434fe969e9508b6b9f38d0ea931d7e6415;p=oweals%2Fopenssl.git diff --git a/apps/mac.c b/apps/mac.c index 205d82f779..e84321b83a 100644 --- a/apps/mac.c +++ b/apps/mac.c @@ -1,7 +1,7 @@ /* - * Copyright 2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2018-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 @@ -16,25 +16,37 @@ #include #include +DEFINE_STACK_OF_STRING() + #undef BUFSIZE #define BUFSIZE 1024*8 typedef enum OPTION_choice { OPT_ERR = -1, OPT_EOF = 0, OPT_HELP, - OPT_MACOPT, OPT_BIN, OPT_IN, OPT_OUT + OPT_MACOPT, OPT_BIN, OPT_IN, OPT_OUT, + OPT_PROV_ENUM } OPTION_CHOICE; const OPTIONS mac_options[] = { {OPT_HELP_STR, 1, '-', "Usage: %s [options] mac_name\n"}, - {OPT_HELP_STR, 1, '-', "mac_name\t\t MAC algorithm (See list " - "-mac-algorithms)"}, + + OPT_SECTION("General"), {"help", OPT_HELP, '-', "Display this summary"}, - {"macopt", OPT_MACOPT, 's', "MAC algorithm parameters in n:v form. " - "See 'PARAMETER NAMES' in the EVP_MAC_ docs"}, + {"macopt", OPT_MACOPT, 's', "MAC algorithm parameters in n:v form"}, + {OPT_MORE_STR, 1, '-', "See 'PARAMETER NAMES' in the EVP_MAC_ docs"}, + + OPT_SECTION("Input"), {"in", OPT_IN, '<', "Input file to MAC (default is stdin)"}, + + OPT_SECTION("Output"), {"out", OPT_OUT, '>', "Output to filename rather than stdout"}, - {"binary", OPT_BIN, '-', "Output in binary format (Default is hexadecimal " - "output)"}, + {"binary", OPT_BIN, '-', + "Output in binary format (default is hexadecimal)"}, + + OPT_PROV_OPTIONS, + + OPT_PARAMETERS(), + {"mac_name", 0, 0, "MAC algorithm"}, {NULL} }; @@ -82,6 +94,10 @@ opthelp: if (opts == NULL || !sk_OPENSSL_STRING_push(opts, opt_arg())) goto opthelp; break; + case OPT_PROV_CASES: + if (!opt_provider(o)) + goto err; + break; } } argc = opt_num_rest(); @@ -98,19 +114,19 @@ opthelp: goto opthelp; } - ctx = EVP_MAC_CTX_new(mac); + ctx = EVP_MAC_new_ctx(mac); if (ctx == NULL) goto err; if (opts != NULL) { int ok = 1; OSSL_PARAM *params = - app_params_new_from_opts(opts, EVP_MAC_CTX_settable_params(mac)); + app_params_new_from_opts(opts, EVP_MAC_settable_ctx_params(mac)); if (params == NULL) goto err; - if (!EVP_MAC_CTX_set_params(ctx, params)) { + if (!EVP_MAC_set_ctx_params(ctx, params)) { BIO_printf(bio_err, "MAC parameter error\n"); ERR_print_errors(bio_err); ok = 0; @@ -183,7 +199,7 @@ err: sk_OPENSSL_STRING_free(opts); BIO_free(in); BIO_free(out); - EVP_MAC_CTX_free(ctx); + EVP_MAC_free_ctx(ctx); EVP_MAC_free(mac); return ret; }