]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
kem: Use include file for generated code
authorSimo Sorce <simo@redhat.com>
Thu, 16 Oct 2025 19:48:08 +0000 (15:48 -0400)
committerDmitry Belyavskiy <beldmit@gmail.com>
Mon, 20 Oct 2025 07:45:53 +0000 (09:45 +0200)
Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/28838)

.gitignore
build.info
providers/implementations/kem/ec_kem.c [moved from providers/implementations/kem/ec_kem.c.in with 98% similarity]
providers/implementations/kem/ec_kem.inc.in [new file with mode: 0644]
providers/implementations/kem/ecx_kem.c [moved from providers/implementations/kem/ecx_kem.c.in with 98% similarity]
providers/implementations/kem/ecx_kem.inc.in [new file with mode: 0644]
providers/implementations/kem/ml_kem_kem.c [moved from providers/implementations/kem/ml_kem_kem.c.in with 97% similarity]
providers/implementations/kem/ml_kem_kem.inc.in [new file with mode: 0644]
providers/implementations/kem/rsa_kem.c [moved from providers/implementations/kem/rsa_kem.c.in with 96% similarity]
providers/implementations/kem/rsa_kem.inc.in [new file with mode: 0644]

index 6934a9d96e4a9a5d7dd5c49bb2712ff1d8b3f98f..f5fd9e77aa1aaf6ce9b9c9d5961a57d257351aec 100644 (file)
@@ -112,10 +112,10 @@ providers/implementations/kdfs/sshkdf.inc
 providers/implementations/kdfs/sskdf.inc
 providers/implementations/kdfs/tls1_prf.inc
 providers/implementations/kdfs/x942kdf.inc
-providers/implementations/kem/ec_kem.c
-providers/implementations/kem/ecx_kem.c
-providers/implementations/kem/ml_kem_kem.c
-providers/implementations/kem/rsa_kem.c
+providers/implementations/kem/ec_kem.inc
+providers/implementations/kem/ecx_kem.inc
+providers/implementations/kem/ml_kem_kem.inc
+providers/implementations/kem/rsa_kem.inc
 providers/implementations/keymgmt/ml_dsa_kmgmt.c
 providers/implementations/keymgmt/ml_kem_kmgmt.c
 providers/implementations/keymgmt/mlx_kmgmt.c
index fbea823d9054ca4ca9bab9ff59b1b31ca252341a..be9fb3a5298ea980ca31786203ad4f147fffad64 100644 (file)
@@ -74,10 +74,10 @@ DEPEND[]=include/openssl/asn1.h \
          providers/implementations/kdfs/sskdf.inc \
          providers/implementations/kdfs/tls1_prf.inc \
          providers/implementations/kdfs/x942kdf.inc \
-         providers/implementations/kem/ec_kem.c \
-         providers/implementations/kem/ecx_kem.c \
-         providers/implementations/kem/ml_kem_kem.c \
-         providers/implementations/kem/rsa_kem.c \
+         providers/implementations/kem/ec_kem.inc \
+         providers/implementations/kem/ecx_kem.inc \
+         providers/implementations/kem/ml_kem_kem.inc \
+         providers/implementations/kem/rsa_kem.inc \
          providers/implementations/keymgmt/dh_kmgmt.c \
          providers/implementations/keymgmt/dsa_kmgmt.c \
          providers/implementations/keymgmt/ecx_kmgmt.c \
@@ -192,10 +192,10 @@ DEPEND[providers/implementations/asymciphers/rsa_enc.inc \
        providers/implementations/kdfs/sskdf.inc \
        providers/implementations/kdfs/tls1_prf.inc \
        providers/implementations/kdfs/x942kdf.inc \
-       providers/implementations/kem/ec_kem.c \
-       providers/implementations/kem/ecx_kem.c \
-       providers/implementations/kem/ml_kem_kem.c \
-       providers/implementations/kem/rsa_kem.c \
+       providers/implementations/kem/ec_kem.inc \
+       providers/implementations/kem/ecx_kem.inc \
+       providers/implementations/kem/ml_kem_kem.inc \
+       providers/implementations/kem/rsa_kem.inc \
        providers/implementations/keymgmt/dh_kmgmt.c \
        providers/implementations/keymgmt/dsa_kmgmt.c \
        providers/implementations/keymgmt/ecx_kmgmt.c \
@@ -303,14 +303,14 @@ GENERATE[providers/implementations/kdfs/tls1_prf.inc]=\
     providers/implementations/kdfs/tls1_prf.inc.in
 GENERATE[providers/implementations/kdfs/x942kdf.inc]=\
     providers/implementations/kdfs/x942kdf.inc.in
-GENERATE[providers/implementations/kem/ec_kem.c]=\
-    providers/implementations/kem/ec_kem.c.in
-GENERATE[providers/implementations/kem/ecx_kem.c]=\
-    providers/implementations/kem/ecx_kem.c.in
-GENERATE[providers/implementations/kem/ml_kem_kem.c]=\
-    providers/implementations/kem/ml_kem_kem.c.in
-GENERATE[providers/implementations/kem/rsa_kem.c]=\
-    providers/implementations/kem/rsa_kem.c.in
+GENERATE[providers/implementations/kem/ec_kem.inc]=\
+    providers/implementations/kem/ec_kem.inc.in
+GENERATE[providers/implementations/kem/ecx_kem.inc]=\
+    providers/implementations/kem/ecx_kem.inc.in
+GENERATE[providers/implementations/kem/ml_kem_kem.inc]=\
+    providers/implementations/kem/ml_kem_kem.inc.in
+GENERATE[providers/implementations/kem/rsa_kem.inc]=\
+    providers/implementations/kem/rsa_kem.inc.in
 GENERATE[providers/implementations/keymgmt/dh_kmgmt.c]=\
     providers/implementations/keymgmt/dh_kmgmt.c.in
 GENERATE[providers/implementations/keymgmt/dsa_kmgmt.c]=\
similarity index 98%
rename from providers/implementations/kem/ec_kem.c.in
rename to providers/implementations/kem/ec_kem.c
index 370ef833ada57818113d301eb3cd7567cad32d4a..20442b0fc805c0c6844f941f5b846be61d03c562 100644 (file)
@@ -6,9 +6,6 @@
  * in the file LICENSE in the source distribution or at
  * https://www.openssl.org/source/license.html
  */
-{-
-use OpenSSL::paramnames qw(produce_param_decoder);
--}
 
 /*
  * The following implementation is part of RFC 9180 related to DHKEM using
@@ -39,6 +36,7 @@ use OpenSSL::paramnames qw(produce_param_decoder);
 #include "crypto/ec.h"
 #include "prov/ecx.h"
 #include "prov/eckem.h"
+#include "providers/implementations/kem/ec_kem.inc"
 
 typedef struct {
     EC_KEY *recipient_key;
@@ -288,12 +286,6 @@ static int eckem_auth_decapsulate_init(void *vctx, void *vecx, void *vauthpub,
     return eckem_init(vctx, EVP_PKEY_OP_DECAPSULATE, vecx, vauthpub, params);
 }
 
-
-{- produce_param_decoder('eckem_set_ctx_params',
-                         (['OSSL_KEM_PARAM_OPERATION',   'op',   'utf8_string'],
-                          ['OSSL_KEM_PARAM_IKME',        'ikme', 'octet_string'],
-                         )); -}
-
 static int eckem_set_ctx_params(void *vctx, const OSSL_PARAM params[])
 {
     PROV_EC_CTX *ctx = (PROV_EC_CTX *)vctx;
diff --git a/providers/implementations/kem/ec_kem.inc.in b/providers/implementations/kem/ec_kem.inc.in
new file mode 100644 (file)
index 0000000..ae6cd7a
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2025 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * 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
+ */
+
+{-
+use OpenSSL::paramnames qw(produce_param_decoder);
+-}
+
+{- produce_param_decoder('eckem_set_ctx_params',
+                         (['OSSL_KEM_PARAM_OPERATION',   'op',   'utf8_string'],
+                          ['OSSL_KEM_PARAM_IKME',        'ikme', 'octet_string'],
+                         )); -}
similarity index 98%
rename from providers/implementations/kem/ecx_kem.c.in
rename to providers/implementations/kem/ecx_kem.c
index bb9037dc4db877def22877837083ef683026fa85..b772a45fb4372dff0a9c6f64ef164daabba897d9 100644 (file)
@@ -6,9 +6,6 @@
  * in the file LICENSE in the source distribution or at
  * https://www.openssl.org/source/license.html
  */
-{-
-use OpenSSL::paramnames qw(produce_param_decoder);
--}
 
 /*
  * The following implementation is part of RFC 9180 related to DHKEM using
@@ -39,6 +36,7 @@ use OpenSSL::paramnames qw(produce_param_decoder);
 #include <openssl/hpke.h>
 #include "internal/hpke_util.h"
 #include "prov/eckem.h"
+#include "providers/implementations/kem/ecx_kem.inc"
 
 #define MAX_ECX_KEYLEN X448_KEYLEN
 
@@ -244,11 +242,6 @@ static int ecxkem_auth_decapsulate_init(void *vctx, void *vecx, void *vauthpub,
     return ecxkem_init(vctx, EVP_PKEY_OP_DECAPSULATE, vecx, vauthpub, params);
 }
 
-{- produce_param_decoder('ecxkem_set_ctx_params',
-                         (['OSSL_KEM_PARAM_OPERATION',   'op',   'utf8_string'],
-                          ['OSSL_KEM_PARAM_IKME',        'ikme', 'octet_string'],
-                         )); -}
-
 static int ecxkem_set_ctx_params(void *vctx, const OSSL_PARAM params[])
 {
     PROV_ECX_CTX *ctx = (PROV_ECX_CTX *)vctx;
diff --git a/providers/implementations/kem/ecx_kem.inc.in b/providers/implementations/kem/ecx_kem.inc.in
new file mode 100644 (file)
index 0000000..5cd2dda
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2025 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * 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
+ */
+
+{-
+use OpenSSL::paramnames qw(produce_param_decoder);
+-}
+
+{- produce_param_decoder('ecxkem_set_ctx_params',
+                         (['OSSL_KEM_PARAM_OPERATION',   'op',   'utf8_string'],
+                          ['OSSL_KEM_PARAM_IKME',        'ikme', 'octet_string'],
+                         )); -}
similarity index 97%
rename from providers/implementations/kem/ml_kem_kem.c.in
rename to providers/implementations/kem/ml_kem_kem.c
index 1c9a816e02c321ad3ec75db4a5b227f857341d96..bb27c9626668af8609abae2a29d5ae3dcb37bed4 100644 (file)
@@ -6,9 +6,6 @@
  * 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 <string.h>
 #include <openssl/crypto.h>
@@ -24,6 +21,7 @@ use OpenSSL::paramnames qw(produce_param_decoder);
 #include "prov/implementations.h"
 #include "prov/securitycheck.h"
 #include "prov/providercommon.h"
+#include "providers/implementations/kem/ml_kem_kem.inc"
 
 static OSSL_FUNC_kem_newctx_fn ml_kem_newctx;
 static OSSL_FUNC_kem_freectx_fn ml_kem_freectx;
@@ -99,10 +97,6 @@ static int ml_kem_decapsulate_init(void *vctx, void *vkey,
     return ml_kem_init(vctx, EVP_PKEY_OP_DECAPSULATE, key, params);
 }
 
-{- produce_param_decoder('ml_kem_set_ctx_params',
-                         (['OSSL_KEM_PARAM_IKME', 'ikme', 'octet_string'],
-                         )); -}
-
 static int ml_kem_set_ctx_params(void *vctx, const OSSL_PARAM params[])
 {
     PROV_ML_KEM_CTX *ctx = vctx;
diff --git a/providers/implementations/kem/ml_kem_kem.inc.in b/providers/implementations/kem/ml_kem_kem.inc.in
new file mode 100644 (file)
index 0000000..201b154
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright 2025 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * 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
+ */
+
+{-
+use OpenSSL::paramnames qw(produce_param_decoder);
+-}
+
+{- produce_param_decoder('ml_kem_set_ctx_params',
+                         (['OSSL_KEM_PARAM_IKME', 'ikme', 'octet_string'],
+                         )); -}
similarity index 96%
rename from providers/implementations/kem/rsa_kem.c.in
rename to providers/implementations/kem/rsa_kem.c
index 0806cdd43e6ee3374987864c83ada822102a9c57..a75460bded74c473dbca139897e5c8d072e5dd1e 100644 (file)
@@ -6,9 +6,6 @@
  * in the file LICENSE in the source distribution or at
  * https://www.openssl.org/source/license.html
  */
-{-
-use OpenSSL::paramnames qw(produce_param_decoder);
--}
 
 /*
  * RSA low level APIs are deprecated for public use, but still ok for
@@ -30,6 +27,7 @@ use OpenSSL::paramnames qw(produce_param_decoder);
 #include "prov/providercommon.h"
 #include "prov/implementations.h"
 #include "prov/securitycheck.h"
+#include "providers/implementations/kem/rsa_kem.inc"
 
 static OSSL_FUNC_kem_newctx_fn rsakem_newctx;
 static OSSL_FUNC_kem_encapsulate_init_fn rsakem_encapsulate_init;
@@ -176,10 +174,6 @@ static int rsakem_decapsulate_init(void *vprsactx, void *vrsa,
                        "RSA Decapsulate Init");
 }
 
-{- produce_param_decoder('rsakem_get_ctx_params',
-                         (['OSSL_KEM_PARAM_FIPS_APPROVED_INDICATOR', 'ind', 'int', 'fips'],
-                         )); -}
-
 static int rsakem_get_ctx_params(void *vprsactx, OSSL_PARAM *params)
 {
     PROV_RSA_CTX *ctx = (PROV_RSA_CTX *)vprsactx;
@@ -199,11 +193,6 @@ static const OSSL_PARAM *rsakem_gettable_ctx_params(ossl_unused void *vprsactx,
     return rsakem_get_ctx_params_list;
 }
 
-{- produce_param_decoder('rsakem_set_ctx_params',
-                         (['OSSL_KEM_PARAM_OPERATION',       'op',    'utf8_string'],
-                          ['OSSL_KEM_PARAM_FIPS_KEY_CHECK',  'ind_k', 'int', 'fips'],
-                         )); -}
-
 static int rsakem_set_ctx_params(void *vprsactx, const OSSL_PARAM params[])
 {
     PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
diff --git a/providers/implementations/kem/rsa_kem.inc.in b/providers/implementations/kem/rsa_kem.inc.in
new file mode 100644 (file)
index 0000000..0588758
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2025 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * 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
+ */
+
+{-
+use OpenSSL::paramnames qw(produce_param_decoder);
+-}
+
+{- produce_param_decoder('rsakem_get_ctx_params',
+                         (['OSSL_KEM_PARAM_FIPS_APPROVED_INDICATOR', 'ind', 'int', 'fips'],
+                         )); -}
+
+{- produce_param_decoder('rsakem_set_ctx_params',
+                         (['OSSL_KEM_PARAM_OPERATION',       'op',    'utf8_string'],
+                          ['OSSL_KEM_PARAM_FIPS_KEY_CHECK',  'ind_k', 'int', 'fips'],
+                         )); -}