From: Simo Sorce Date: Thu, 16 Oct 2025 19:48:06 +0000 (-0400) Subject: asymciphers: Use include file for generated code X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d6e9de921c87a2d878b350373f6438145d1ee107;p=thirdparty%2Fopenssl.git asymciphers: Use include file for generated code Signed-off-by: Simo Sorce Reviewed-by: Matt Caswell Reviewed-by: Tomas Mraz Reviewed-by: Dmitry Belyavskiy (Merged from https://github.com/openssl/openssl/pull/28838) --- diff --git a/.gitignore b/.gitignore index 9c29f7ef2ad..33cb09d9b2d 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/build.info b/build.info index 27f4866a4e5..061598eedd1 100644 --- a/build.info +++ b/build.info @@ -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]=\ diff --git a/providers/implementations/asymciphers/rsa_enc.c.in b/providers/implementations/asymciphers/rsa_enc.c similarity index 88% rename from providers/implementations/asymciphers/rsa_enc.c.in rename to providers/implementations/asymciphers/rsa_enc.c index 6fcb6f74f59..0060020aa2e 100644 --- a/providers/implementations/asymciphers/rsa_enc.c.in +++ b/providers/implementations/asymciphers/rsa_enc.c @@ -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 +#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 index 00000000000..baa9bdc8c63 --- /dev/null +++ b/providers/implementations/asymciphers/rsa_enc.inc.in @@ -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'], + )); -} diff --git a/providers/implementations/asymciphers/sm2_enc.c.in b/providers/implementations/asymciphers/sm2_enc.c similarity index 91% rename from providers/implementations/asymciphers/sm2_enc.c.in rename to providers/implementations/asymciphers/sm2_enc.c index a8271a83419..b8d991c1c3c 100644 --- a/providers/implementations/asymciphers/sm2_enc.c.in +++ b/providers/implementations/asymciphers/sm2_enc.c @@ -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 index 00000000000..f545a6ab35f --- /dev/null +++ b/providers/implementations/asymciphers/sm2_enc.inc.in @@ -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'], + )); -}