]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
encode_key2ms: convert to use generated parameter parsing
authorPauli <ppzgs1@gmail.com>
Wed, 30 Jul 2025 02:31:55 +0000 (12:31 +1000)
committerPauli <ppzgs1@gmail.com>
Wed, 13 Aug 2025 02:10:58 +0000 (12:10 +1000)
Reviewed-by: Paul Yang <paulyang.inf@gmail.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28152)

providers/implementations/encode_decode/encode_key2ms.c.in

index 4ed07790b21f8c99c1519cb4f6a021e9d6dfb8f2..4fe9f608d4784a4adf27f20bfd16161895decd5f 100644 (file)
@@ -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.
 #include <openssl/core_names.h>
 #include <openssl/params.h>
 #include <openssl/err.h>
+#include <openssl/proverr.h>
 #include <openssl/pem.h>         /* Functions for writing MSBLOB and PVK */
 #include <openssl/dsa.h>
+#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;
 }