]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
asymciphers: Use include file for generated code
authorSimo Sorce <simo@redhat.com>
Thu, 16 Oct 2025 19:48:06 +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/asymciphers/rsa_enc.c [moved from providers/implementations/asymciphers/rsa_enc.c.in with 88% similarity]
providers/implementations/asymciphers/rsa_enc.inc.in [new file with mode: 0644]
providers/implementations/asymciphers/sm2_enc.c [moved from providers/implementations/asymciphers/sm2_enc.c.in with 91% similarity]
providers/implementations/asymciphers/sm2_enc.inc.in [new file with mode: 0644]

index 9c29f7ef2ad09756c986a459390e08e3d3dab03f..33cb09d9b2d9cf3f17786d196649a5f0945ed1a5 100644 (file)
@@ -86,8 +86,8 @@ providers/common/include/prov/der_wrap.h
 providers/common/include/prov/der_sm2.h
 providers/common/include/prov/der_ml_dsa.h
 providers/common/include/prov/der_hkdf.h
-providers/implementations/asymciphers/rsa_enc.c
-providers/implementations/asymciphers/sm2_enc.c
+providers/implementations/asymciphers/rsa_enc.inc
+providers/implementations/asymciphers/sm2_enc.inc
 providers/implementations/exchange/dh_exch.c
 providers/implementations/exchange/ecdh_exch.c
 providers/implementations/exchange/ecx_exch.c
index 27f4866a4e5746750a6259710acbbe8603d7e7ec..061598eedd162d7ecefa99637de27a895a0d08f4 100644 (file)
@@ -48,8 +48,8 @@ DEPEND[]=include/openssl/asn1.h \
          include/openssl/x509_acert.h \
          include/openssl/x509_vfy.h \
          include/crypto/bn_conf.h include/crypto/dso_conf.h \
-         providers/implementations/asymciphers/rsa_enc.c \
-         providers/implementations/asymciphers/sm2_enc.c \
+         providers/implementations/asymciphers/rsa_enc.inc \
+         providers/implementations/asymciphers/sm2_enc.inc \
          providers/implementations/exchange/dh_exch.c \
          providers/implementations/exchange/ecdh_exch.c \
          providers/implementations/exchange/ecx_exch.c \
@@ -166,8 +166,8 @@ GENERATE[include/openssl/x509_vfy.h]=include/openssl/x509_vfy.h.in
 GENERATE[include/crypto/bn_conf.h]=include/crypto/bn_conf.h.in
 GENERATE[include/crypto/dso_conf.h]=include/crypto/dso_conf.h.in
 
-DEPEND[providers/implementations/asymciphers/rsa_enc.c \
-       providers/implementations/asymciphers/sm2_enc.c \
+DEPEND[providers/implementations/asymciphers/rsa_enc.inc \
+       providers/implementations/asymciphers/sm2_enc.inc \
        providers/implementations/exchange/dh_exch.c \
        providers/implementations/exchange/ecdh_exch.c \
        providers/implementations/exchange/ecx_exch.c \
@@ -251,10 +251,10 @@ DEPEND[providers/implementations/asymciphers/rsa_enc.c \
        providers/implementations/rands/seed_src_jitter.c \
        providers/implementations/rands/test_rng.c \
        include/openssl/core_names.h]=util/perl|OpenSSL/paramnames.pm
-GENERATE[providers/implementations/asymciphers/rsa_enc.c]=\
-    providers/implementations/asymciphers/rsa_enc.c.in
-GENERATE[providers/implementations/asymciphers/sm2_enc.c]=\
-    providers/implementations/asymciphers/sm2_enc.c.in
+GENERATE[providers/implementations/asymciphers/rsa_enc.inc]=\
+    providers/implementations/asymciphers/rsa_enc.inc.in
+GENERATE[providers/implementations/asymciphers/sm2_enc.inc]=\
+    providers/implementations/asymciphers/sm2_enc.inc.in
 GENERATE[providers/implementations/exchange/dh_exch.c]=\
     providers/implementations/exchange/dh_exch.c.in
 GENERATE[providers/implementations/exchange/ecdh_exch.c]=\
similarity index 88%
rename from providers/implementations/asymciphers/rsa_enc.c.in
rename to providers/implementations/asymciphers/rsa_enc.c
index 6fcb6f74f5956ead3adf635027b40eaede1a9b07..0060020aa2eb7a83836191e7cbc5804be717332f 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
@@ -35,6 +32,7 @@ use OpenSSL::paramnames qw(produce_param_decoder);
 #include "prov/providercommon.h"
 #include "prov/securitycheck.h"
 #include <stdlib.h>
+#include "providers/implementations/asymciphers/rsa_enc.inc"
 
 static OSSL_FUNC_asym_cipher_newctx_fn rsa_newctx;
 static OSSL_FUNC_asym_cipher_encrypt_init_fn rsa_encrypt_init;
@@ -368,18 +366,6 @@ static void *rsa_dupctx(void *vprsactx)
     return dstctx;
 }
 
-{- produce_param_decoder('rsa_get_ctx_params',
-                         (['OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST',             'oaep',   'utf8_string'],
-                          ['OSSL_ASYM_CIPHER_PARAM_PAD_MODE',                'pad',    'utf8_string'],
-                          ['OSSL_ASYM_CIPHER_PARAM_PAD_MODE',                'pad',    'int'],
-                          ['OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST',             'mgf1',   'utf8_string'],
-                          ['OSSL_ASYM_CIPHER_PARAM_OAEP_LABEL',              'label',  'octet_ptr'],
-                          ['OSSL_ASYM_CIPHER_PARAM_TLS_CLIENT_VERSION',      'tlsver', 'uint'],
-                          ['OSSL_ASYM_CIPHER_PARAM_TLS_NEGOTIATED_VERSION',  'negver', 'uint'],
-                          ['OSSL_ASYM_CIPHER_PARAM_IMPLICIT_REJECTION',      'imrej',  'uint'],
-                          ['OSSL_ASYM_CIPHER_PARAM_FIPS_APPROVED_INDICATOR', 'ind',    'int', 'fips'],
-                         )); -}
-
 static int rsa_get_ctx_params(void *vprsactx, OSSL_PARAM *params)
 {
     PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
@@ -451,28 +437,12 @@ static int rsa_get_ctx_params(void *vprsactx, OSSL_PARAM *params)
     return 1;
 }
 
-
 static const OSSL_PARAM *rsa_gettable_ctx_params(ossl_unused void *vprsactx,
                                                  ossl_unused void *provctx)
 {
     return rsa_get_ctx_params_list;
 }
 
-{- produce_param_decoder('rsa_set_ctx_params',
-                         (['OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST',                  'oaep',    'utf8_string'],
-                          ['OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST_PROPS',            'oaep_pq', 'utf8_string'],
-                          ['OSSL_ASYM_CIPHER_PARAM_PAD_MODE',                     'pad',     'utf8_string'],
-                          ['OSSL_ASYM_CIPHER_PARAM_PAD_MODE',                     'pad',     'int'],
-                          ['OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST',                  'mgf1',    'utf8_string'],
-                          ['OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST_PROPS',            'mgf1_pq', 'utf8_string'],
-                          ['OSSL_ASYM_CIPHER_PARAM_OAEP_LABEL',                   'label',   'octet_string'],
-                          ['OSSL_ASYM_CIPHER_PARAM_TLS_CLIENT_VERSION',           'tlsver',  'uint'],
-                          ['OSSL_ASYM_CIPHER_PARAM_TLS_NEGOTIATED_VERSION',       'negver',  'uint'],
-                          ['OSSL_ASYM_CIPHER_PARAM_IMPLICIT_REJECTION',           'imrej',   'uint'],
-                          ['OSSL_ASYM_CIPHER_PARAM_FIPS_KEY_CHECK',               'ind_k',   'int', 'fips'],
-                          ['OSSL_ASYM_CIPHER_PARAM_FIPS_RSA_PKCS15_PAD_DISABLED', 'ind_pad', 'int', 'fips'],
-                         )); -}
-
 static int rsa_set_ctx_params(void *vprsactx, const OSSL_PARAM params[])
 {
     PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
diff --git a/providers/implementations/asymciphers/rsa_enc.inc.in b/providers/implementations/asymciphers/rsa_enc.inc.in
new file mode 100644 (file)
index 0000000..baa9bdc
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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('rsa_get_ctx_params',
+                         (['OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST',             'oaep',   'utf8_string'],
+                          ['OSSL_ASYM_CIPHER_PARAM_PAD_MODE',                'pad',    'utf8_string'],
+                          ['OSSL_ASYM_CIPHER_PARAM_PAD_MODE',                'pad',    'int'],
+                          ['OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST',             'mgf1',   'utf8_string'],
+                          ['OSSL_ASYM_CIPHER_PARAM_OAEP_LABEL',              'label',  'octet_ptr'],
+                          ['OSSL_ASYM_CIPHER_PARAM_TLS_CLIENT_VERSION',      'tlsver', 'uint'],
+                          ['OSSL_ASYM_CIPHER_PARAM_TLS_NEGOTIATED_VERSION',  'negver', 'uint'],
+                          ['OSSL_ASYM_CIPHER_PARAM_IMPLICIT_REJECTION',      'imrej',  'uint'],
+                          ['OSSL_ASYM_CIPHER_PARAM_FIPS_APPROVED_INDICATOR', 'ind',    'int', 'fips'],
+                         )); -}
+
+{- produce_param_decoder('rsa_set_ctx_params',
+                         (['OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST',                  'oaep',    'utf8_string'],
+                          ['OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST_PROPS',            'oaep_pq', 'utf8_string'],
+                          ['OSSL_ASYM_CIPHER_PARAM_PAD_MODE',                     'pad',     'utf8_string'],
+                          ['OSSL_ASYM_CIPHER_PARAM_PAD_MODE',                     'pad',     'int'],
+                          ['OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST',                  'mgf1',    'utf8_string'],
+                          ['OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST_PROPS',            'mgf1_pq', 'utf8_string'],
+                          ['OSSL_ASYM_CIPHER_PARAM_OAEP_LABEL',                   'label',   'octet_string'],
+                          ['OSSL_ASYM_CIPHER_PARAM_TLS_CLIENT_VERSION',           'tlsver',  'uint'],
+                          ['OSSL_ASYM_CIPHER_PARAM_TLS_NEGOTIATED_VERSION',       'negver',  'uint'],
+                          ['OSSL_ASYM_CIPHER_PARAM_IMPLICIT_REJECTION',           'imrej',   'uint'],
+                          ['OSSL_ASYM_CIPHER_PARAM_FIPS_KEY_CHECK',               'ind_k',   'int', 'fips'],
+                          ['OSSL_ASYM_CIPHER_PARAM_FIPS_RSA_PKCS15_PAD_DISABLED', 'ind_pad', 'int', 'fips'],
+                         )); -}
similarity index 91%
rename from providers/implementations/asymciphers/sm2_enc.c.in
rename to providers/implementations/asymciphers/sm2_enc.c
index a8271a834193a2923c3772b00e68718c318bf16b..b8d991c1c3c3f18e8d3a5aac594aeed961e2a30c 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 "internal/deprecated.h"
 
@@ -25,6 +22,7 @@ use OpenSSL::paramnames qw(produce_param_decoder);
 #include "prov/implementations.h"
 #include "prov/providercommon.h"
 #include "prov/provider_util.h"
+#include "providers/implementations/asymciphers/sm2_enc.inc"
 
 static OSSL_FUNC_asym_cipher_newctx_fn sm2_newctx;
 static OSSL_FUNC_asym_cipher_encrypt_init_fn sm2_init;
@@ -158,10 +156,6 @@ static void *sm2_dupctx(void *vpsm2ctx)
     return dstctx;
 }
 
-{- produce_param_decoder('sm2_get_ctx_params',
-                         (['OSSL_ASYM_CIPHER_PARAM_DIGEST',  'digest',   'utf8_string'],
-                         )); -}
-
 static int sm2_get_ctx_params(void *vpsm2ctx, OSSL_PARAM *params)
 {
     PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx;
@@ -187,12 +181,6 @@ static const OSSL_PARAM *sm2_gettable_ctx_params(ossl_unused void *vpsm2ctx,
     return sm2_get_ctx_params_list;
 }
 
-{- produce_param_decoder('sm2_set_ctx_params',
-                         (['OSSL_ASYM_CIPHER_PARAM_DIGEST',     'digest', 'utf8_string'],
-                          ['OSSL_ASYM_CIPHER_PARAM_PROPERTIES', 'propq',  'utf8_string'],
-                          ['OSSL_ASYM_CIPHER_PARAM_ENGINE',     'engine', 'utf8_string', 'hidden'],
-                         )); -}
-
 static int sm2_set_ctx_params(void *vpsm2ctx, const OSSL_PARAM params[])
 {
     PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx;
diff --git a/providers/implementations/asymciphers/sm2_enc.inc.in b/providers/implementations/asymciphers/sm2_enc.inc.in
new file mode 100644 (file)
index 0000000..f545a6a
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * 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('sm2_get_ctx_params',
+                         (['OSSL_ASYM_CIPHER_PARAM_DIGEST',  'digest',   'utf8_string'],
+                         )); -}
+
+{- produce_param_decoder('sm2_set_ctx_params',
+                         (['OSSL_ASYM_CIPHER_PARAM_DIGEST',     'digest', 'utf8_string'],
+                          ['OSSL_ASYM_CIPHER_PARAM_PROPERTIES', 'propq',  'utf8_string'],
+                          ['OSSL_ASYM_CIPHER_PARAM_ENGINE',     'engine', 'utf8_string', 'hidden'],
+                         )); -}