]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
ecx: convert key exchange to using generated param decoder
authorPauli <ppzgs1@gmail.com>
Thu, 24 Jul 2025 02:01:03 +0000 (12:01 +1000)
committerPauli <ppzgs1@gmail.com>
Wed, 13 Aug 2025 02:04:52 +0000 (12:04 +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/28148)

providers/implementations/exchange/ecx_exch.c.in

index 28e2ff61c7cc30027da063a9b5938a7be40c4cf5..a1efcf7253e86968560ff66bae488e402656fae5 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);
+-}
 
 #include <openssl/crypto.h>
 #include <openssl/core_dispatch.h>
@@ -177,24 +180,34 @@ static void *ecx_dupctx(void *vecxctx)
     return dstctx;
 }
 
+#ifdef FIPS_MODULE
+{- produce_param_decoder('ecx_get_ctx_params',
+                         (['ALG_PARAM_FIPS_APPROVED_INDICATOR', 'ind', 'int'],
+                         )); -}
+#endif
+
 static const OSSL_PARAM *ecx_gettable_ctx_params(ossl_unused void *vctx,
                                                  ossl_unused void *provctx)
 {
-    static const OSSL_PARAM known_gettable_ctx_params[] = {
-        OSSL_FIPS_IND_GETTABLE_CTX_PARAM()
-        OSSL_PARAM_END
-    };
-    return known_gettable_ctx_params;
+#ifdef FIPS_MODULE
+    return ecx_get_ctx_params_list;
+#else
+    static OSSL_PARAM params[] = { OSSL_PARAM_END };
+
+    return params;
+#endif
 }
 
 static int ecx_get_ctx_params(ossl_unused void *vctx, OSSL_PARAM params[])
 {
 #ifdef FIPS_MODULE
     int approved = 0;
-    OSSL_PARAM *p = OSSL_PARAM_locate(params,
-                                      OSSL_ALG_PARAM_FIPS_APPROVED_INDICATOR);
+    struct ecx_get_ctx_params_st p;
+
+    if (vctx == NULL || !ecx_get_ctx_params_decoder(params, &p))
+        return 0;
 
-    if (p != NULL && !OSSL_PARAM_set_int(p, approved))
+    if (p.ind != NULL && !OSSL_PARAM_set_int(p.ind, approved))
         return 0;
 #endif
     return 1;