From: Pauli Date: Wed, 30 Jul 2025 02:31:55 +0000 (+1000) Subject: encode_key2ms: convert to use generated parameter parsing X-Git-Tag: openssl-3.6.0-alpha1~130 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f4de265c0f197726d8279b9930d02c1e21fa7537;p=thirdparty%2Fopenssl.git encode_key2ms: convert to use generated parameter parsing Reviewed-by: Paul Yang Reviewed-by: Shane Lontis Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/28152) --- diff --git a/providers/implementations/encode_decode/encode_key2ms.c.in b/providers/implementations/encode_decode/encode_key2ms.c.in index 4ed07790b21..4fe9f608d47 100644 --- a/providers/implementations/encode_decode/encode_key2ms.c.in +++ b/providers/implementations/encode_decode/encode_key2ms.c.in @@ -6,6 +6,9 @@ * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */ +{- +use OpenSSL::paramnames qw(produce_param_decoder); +-} /* * Low level APIs are deprecated for public use, but still ok for internal use. @@ -18,8 +21,10 @@ #include #include #include +#include #include /* Functions for writing MSBLOB and PVK */ #include +#include "internal/cryptlib.h" #include "internal/passphrase.h" #include "crypto/rsa.h" #include "prov/implementations.h" @@ -88,23 +93,24 @@ static void key2ms_freectx(void *vctx) OPENSSL_free(ctx); } +{- produce_param_decoder('key2pvk_set_ctx_params', + (['ENCODER_PARAM_ENCRYPT_LEVEL', 'enclvl', 'int'], + )); -} + static const OSSL_PARAM *key2pvk_settable_ctx_params(ossl_unused void *provctx) { - static const OSSL_PARAM settables[] = { - OSSL_PARAM_int(OSSL_ENCODER_PARAM_ENCRYPT_LEVEL, NULL), - OSSL_PARAM_END, - }; - - return settables; + return key2pvk_set_ctx_params_list; } static int key2pvk_set_ctx_params(void *vctx, const OSSL_PARAM params[]) { struct key2ms_ctx_st *ctx = vctx; - const OSSL_PARAM *p; + struct key2pvk_set_ctx_params_st p; + + if (ctx == NULL || !key2pvk_set_ctx_params_decoder(params, &p)) + return 0; - p = OSSL_PARAM_locate_const(params, OSSL_ENCODER_PARAM_ENCRYPT_LEVEL); - if (p != NULL && !OSSL_PARAM_get_int(p, &ctx->pvk_encr_level)) + if (p.enclvl != NULL && !OSSL_PARAM_get_int(p.enclvl, &ctx->pvk_encr_level)) return 0; return 1; }