From ca95d136d238e5ead679df8a7573ecccef37cc0e Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 16 Oct 2025 15:48:09 -0400 Subject: [PATCH] signature: 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) --- .gitignore | 14 ++-- build.info | 56 +++++++-------- .../signature/{dsa_sig.c.in => dsa_sig.c} | 58 +++++---------- .../implementations/signature/dsa_sig.inc.in | 36 ++++++++++ .../signature/{ecdsa_sig.c.in => ecdsa_sig.c} | 71 ++++++------------- .../signature/ecdsa_sig.inc.in | 41 +++++++++++ .../signature/{eddsa_sig.c.in => eddsa_sig.c} | 22 ++---- .../signature/eddsa_sig.inc.in | 25 +++++++ .../{ml_dsa_sig.c.in => ml_dsa_sig.c} | 31 ++------ .../signature/ml_dsa_sig.inc.in | 33 +++++++++ .../signature/{rsa_sig.c.in => rsa_sig.c} | 53 ++------------ .../implementations/signature/rsa_sig.inc.in | 56 +++++++++++++++ .../{slh_dsa_sig.c.in => slh_dsa_sig.c} | 15 +--- .../signature/slh_dsa_sig.inc.in | 23 ++++++ .../signature/{sm2_sig.c.in => sm2_sig.c} | 17 +---- .../implementations/signature/sm2_sig.inc.in | 24 +++++++ 16 files changed, 324 insertions(+), 251 deletions(-) rename providers/implementations/signature/{dsa_sig.c.in => dsa_sig.c} (95%) create mode 100644 providers/implementations/signature/dsa_sig.inc.in rename providers/implementations/signature/{ecdsa_sig.c.in => ecdsa_sig.c} (94%) create mode 100644 providers/implementations/signature/ecdsa_sig.inc.in rename providers/implementations/signature/{eddsa_sig.c.in => eddsa_sig.c} (98%) create mode 100644 providers/implementations/signature/eddsa_sig.inc.in rename providers/implementations/signature/{ml_dsa_sig.c.in => ml_dsa_sig.c} (92%) create mode 100644 providers/implementations/signature/ml_dsa_sig.inc.in rename providers/implementations/signature/{rsa_sig.c.in => rsa_sig.c} (95%) create mode 100644 providers/implementations/signature/rsa_sig.inc.in rename providers/implementations/signature/{slh_dsa_sig.c.in => slh_dsa_sig.c} (95%) create mode 100644 providers/implementations/signature/slh_dsa_sig.inc.in rename providers/implementations/signature/{sm2_sig.c.in => sm2_sig.c} (95%) create mode 100644 providers/implementations/signature/sm2_sig.inc.in diff --git a/.gitignore b/.gitignore index 918ecc7da44..129335aa443 100644 --- a/.gitignore +++ b/.gitignore @@ -119,8 +119,8 @@ providers/implementations/kem/rsa_kem.inc providers/implementations/keymgmt/ml_dsa_kmgmt.inc providers/implementations/keymgmt/ml_kem_kmgmt.inc providers/implementations/keymgmt/mlx_kmgmt.inc -providers/implementations/signature/dsa_sig.c -providers/implementations/signature/ecdsa_sig.c +providers/implementations/signature/dsa_sig.inc +providers/implementations/signature/ecdsa_sig.inc providers/implementations/keymgmt/dh_kmgmt.inc providers/implementations/keymgmt/dsa_kmgmt.inc providers/implementations/keymgmt/ecx_kmgmt.inc @@ -131,11 +131,11 @@ providers/implementations/keymgmt/ml_kem_kmgmt.inc providers/implementations/keymgmt/mlx_kmgmt.inc providers/implementations/keymgmt/slh_dsa_kmgmt.inc providers/implementations/keymgmt/template_kmgmt.inc -providers/implementations/signature/eddsa_sig.c -providers/implementations/signature/ml_dsa_sig.c -providers/implementations/signature/rsa_sig.c -providers/implementations/signature/slh_dsa_sig.c -providers/implementations/signature/sm2_sig.c +providers/implementations/signature/eddsa_sig.inc +providers/implementations/signature/ml_dsa_sig.inc +providers/implementations/signature/rsa_sig.inc +providers/implementations/signature/slh_dsa_sig.inc +providers/implementations/signature/sm2_sig.inc providers/implementations/skeymgmt/generic.inc providers/implementations/storemgmt/file_store_any2obj.inc providers/implementations/storemgmt/file_store.inc diff --git a/build.info b/build.info index 149e3c46f20..92b698ab138 100644 --- a/build.info +++ b/build.info @@ -88,13 +88,13 @@ DEPEND[]=include/openssl/asn1.h \ providers/implementations/keymgmt/mlx_kmgmt.inc \ providers/implementations/keymgmt/slh_dsa_kmgmt.inc \ providers/implementations/keymgmt/template_kmgmt.inc \ - providers/implementations/signature/dsa_sig.c \ - providers/implementations/signature/ecdsa_sig.c \ - providers/implementations/signature/eddsa_sig.c \ - providers/implementations/signature/ml_dsa_sig.c \ - providers/implementations/signature/rsa_sig.c \ - providers/implementations/signature/slh_dsa_sig.c \ - providers/implementations/signature/sm2_sig.c \ + providers/implementations/signature/dsa_sig.inc \ + providers/implementations/signature/ecdsa_sig.inc \ + providers/implementations/signature/eddsa_sig.inc \ + providers/implementations/signature/ml_dsa_sig.inc \ + providers/implementations/signature/rsa_sig.inc \ + providers/implementations/signature/slh_dsa_sig.inc \ + providers/implementations/signature/sm2_sig.inc \ providers/implementations/skeymgmt/generic.inc \ providers/implementations/storemgmt/file_store_any2obj.inc \ providers/implementations/storemgmt/file_store.inc \ @@ -206,13 +206,13 @@ DEPEND[providers/implementations/asymciphers/rsa_enc.inc \ providers/implementations/keymgmt/mlx_kmgmt.inc \ providers/implementations/keymgmt/slh_dsa_kmgmt.inc \ providers/implementations/keymgmt/template_kmgmt.inc \ - providers/implementations/signature/dsa_sig.c \ - providers/implementations/signature/ecdsa_sig.c \ - providers/implementations/signature/eddsa_sig.c \ - providers/implementations/signature/ml_dsa_sig.c \ - providers/implementations/signature/rsa_sig.c \ - providers/implementations/signature/slh_dsa_sig.c \ - providers/implementations/signature/sm2_sig.c \ + providers/implementations/signature/dsa_sig.inc \ + providers/implementations/signature/ecdsa_sig.inc \ + providers/implementations/signature/eddsa_sig.inc \ + providers/implementations/signature/ml_dsa_sig.inc \ + providers/implementations/signature/rsa_sig.inc \ + providers/implementations/signature/slh_dsa_sig.inc \ + providers/implementations/signature/sm2_sig.inc \ providers/implementations/skeymgmt/generic.inc \ providers/implementations/storemgmt/file_store_any2obj.inc \ providers/implementations/storemgmt/file_store.inc \ @@ -331,20 +331,20 @@ GENERATE[providers/implementations/keymgmt/slh_dsa_kmgmt.inc]=\ providers/implementations/keymgmt/slh_dsa_kmgmt.inc.in GENERATE[providers/implementations/keymgmt/template_kmgmt.inc]=\ providers/implementations/keymgmt/template_kmgmt.inc.in -GENERATE[providers/implementations/signature/dsa_sig.c]=\ - providers/implementations/signature/dsa_sig.c.in -GENERATE[providers/implementations/signature/ecdsa_sig.c]=\ - providers/implementations/signature/ecdsa_sig.c.in -GENERATE[providers/implementations/signature/eddsa_sig.c]=\ - providers/implementations/signature/eddsa_sig.c.in -GENERATE[providers/implementations/signature/ml_dsa_sig.c]=\ - providers/implementations/signature/ml_dsa_sig.c.in -GENERATE[providers/implementations/signature/rsa_sig.c]=\ - providers/implementations/signature/rsa_sig.c.in -GENERATE[providers/implementations/signature/slh_dsa_sig.c]=\ - providers/implementations/signature/slh_dsa_sig.c.in -GENERATE[providers/implementations/signature/sm2_sig.c]=\ - providers/implementations/signature/sm2_sig.c.in +GENERATE[providers/implementations/signature/dsa_sig.inc]=\ + providers/implementations/signature/dsa_sig.inc.in +GENERATE[providers/implementations/signature/ecdsa_sig.inc]=\ + providers/implementations/signature/ecdsa_sig.inc.in +GENERATE[providers/implementations/signature/eddsa_sig.inc]=\ + providers/implementations/signature/eddsa_sig.inc.in +GENERATE[providers/implementations/signature/ml_dsa_sig.inc]=\ + providers/implementations/signature/ml_dsa_sig.inc.in +GENERATE[providers/implementations/signature/rsa_sig.inc]=\ + providers/implementations/signature/rsa_sig.inc.in +GENERATE[providers/implementations/signature/slh_dsa_sig.inc]=\ + providers/implementations/signature/slh_dsa_sig.inc.in +GENERATE[providers/implementations/signature/sm2_sig.inc]=\ + providers/implementations/signature/sm2_sig.inc.in GENERATE[providers/implementations/skeymgmt/generic.inc]=\ providers/implementations/skeymgmt/generic.inc.in GENERATE[providers/implementations/storemgmt/file_store_any2obj.inc]=\ diff --git a/providers/implementations/signature/dsa_sig.c.in b/providers/implementations/signature/dsa_sig.c similarity index 95% rename from providers/implementations/signature/dsa_sig.c.in rename to providers/implementations/signature/dsa_sig.c index b208992ee19..ab76bbe5dba 100644 --- a/providers/implementations/signature/dsa_sig.c.in +++ b/providers/implementations/signature/dsa_sig.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); --} /* * DSA low level APIs are deprecated for public use, but still ok for @@ -672,12 +669,22 @@ static void *dsa_dupctx(void *vpdsactx) return NULL; } -{- produce_param_decoder('dsa_get_ctx_params', - (['OSSL_SIGNATURE_PARAM_ALGORITHM_ID', 'algid', 'octet_string'], - ['OSSL_SIGNATURE_PARAM_DIGEST', 'digest', 'utf8_string'], - ['OSSL_SIGNATURE_PARAM_NONCE_TYPE', 'nonce', 'uint'], - ['OSSL_SIGNATURE_PARAM_FIPS_APPROVED_INDICATOR', 'ind', 'int', 'fips'], - )); -} +struct dsa_all_set_ctx_params_st { + OSSL_PARAM *digest; /* dsa_set_ctx_params */ + OSSL_PARAM *propq; /* dsa_set_ctx_params */ +#ifdef FIPS_MODULE + OSSL_PARAM *ind_d; + OSSL_PARAM *ind_k; + OSSL_PARAM *ind_sign; +#endif + OSSL_PARAM *nonce; + OSSL_PARAM *sig; /* dsa_sigalg_set_ctx_params */ +}; + +#define dsa_set_ctx_params_st dsa_all_set_ctx_params_st +#define dsa_sigalg_set_ctx_params_st dsa_all_set_ctx_params_st + +#include "providers/implementations/signature/dsa_sig.inc" static int dsa_get_ctx_params(void *vpdsactx, OSSL_PARAM *params) { @@ -711,18 +718,6 @@ static const OSSL_PARAM *dsa_gettable_ctx_params(ossl_unused void *ctx, return dsa_get_ctx_params_list; } -struct dsa_all_set_ctx_params_st { - OSSL_PARAM *digest; /* dsa_set_ctx_params */ - OSSL_PARAM *propq; /* dsa_set_ctx_params */ -#ifdef FIPS_MODULE - OSSL_PARAM *ind_d; - OSSL_PARAM *ind_k; - OSSL_PARAM *ind_sign; -#endif - OSSL_PARAM *nonce; - OSSL_PARAM *sig; /* dsa_sigalg_set_ctx_params */ -}; - /** * @brief Setup common params for dsa_set_ctx_params and dsa_sigalg_set_ctx_params * The caller is responsible for checking |vpdsactx| is not NULL and |params| @@ -747,17 +742,6 @@ static int dsa_common_set_ctx_params(PROV_DSA_CTX *pdsactx, return 1; } -#define dsa_set_ctx_params_st dsa_all_set_ctx_params_st - -{- produce_param_decoder('dsa_set_ctx_params', - (['OSSL_SIGNATURE_PARAM_DIGEST', 'digest', 'utf8_string'], - ['OSSL_SIGNATURE_PARAM_PROPERTIES', 'propq', 'utf8_string'], - ['OSSL_SIGNATURE_PARAM_NONCE_TYPE', 'nonce', 'uint'], - ['OSSL_SIGNATURE_PARAM_FIPS_KEY_CHECK', 'ind_k', 'int', 'fips'], - ['OSSL_SIGNATURE_PARAM_FIPS_DIGEST_CHECK', 'ind_d', 'int', 'fips'], - ['OSSL_SIGNATURE_PARAM_FIPS_SIGN_CHECK', 'ind_sign', 'int', 'fips'], - )); -} - static int dsa_set_ctx_params(void *vpdsactx, const OSSL_PARAM params[]) { PROV_DSA_CTX *pdsactx = (PROV_DSA_CTX *)vpdsactx; @@ -936,16 +920,6 @@ static const char **dsa_sigalg_query_key_types(void) return keytypes; } -#define dsa_sigalg_set_ctx_params_st dsa_all_set_ctx_params_st - -{- produce_param_decoder('dsa_sigalg_set_ctx_params', - (['OSSL_SIGNATURE_PARAM_SIGNATURE', 'sig', 'octet_string'], - ['OSSL_SIGNATURE_PARAM_NONCE_TYPE', 'nonce', 'uint'], - ['OSSL_SIGNATURE_PARAM_FIPS_KEY_CHECK', 'ind_k', 'int', 'fips'], - ['OSSL_SIGNATURE_PARAM_FIPS_DIGEST_CHECK', 'ind_d', 'int', 'fips'], - ['OSSL_SIGNATURE_PARAM_FIPS_SIGN_CHECK', 'ind_sign', 'int', 'fips'], - )); -} - static const OSSL_PARAM *dsa_sigalg_settable_ctx_params(void *vpdsactx, ossl_unused void *provctx) { diff --git a/providers/implementations/signature/dsa_sig.inc.in b/providers/implementations/signature/dsa_sig.inc.in new file mode 100644 index 00000000000..af329e9415b --- /dev/null +++ b/providers/implementations/signature/dsa_sig.inc.in @@ -0,0 +1,36 @@ +/* + * 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('dsa_get_ctx_params', + (['OSSL_SIGNATURE_PARAM_ALGORITHM_ID', 'algid', 'octet_string'], + ['OSSL_SIGNATURE_PARAM_DIGEST', 'digest', 'utf8_string'], + ['OSSL_SIGNATURE_PARAM_NONCE_TYPE', 'nonce', 'uint'], + ['OSSL_SIGNATURE_PARAM_FIPS_APPROVED_INDICATOR', 'ind', 'int', 'fips'], + )); -} + +{- produce_param_decoder('dsa_set_ctx_params', + (['OSSL_SIGNATURE_PARAM_DIGEST', 'digest', 'utf8_string'], + ['OSSL_SIGNATURE_PARAM_PROPERTIES', 'propq', 'utf8_string'], + ['OSSL_SIGNATURE_PARAM_NONCE_TYPE', 'nonce', 'uint'], + ['OSSL_SIGNATURE_PARAM_FIPS_KEY_CHECK', 'ind_k', 'int', 'fips'], + ['OSSL_SIGNATURE_PARAM_FIPS_DIGEST_CHECK', 'ind_d', 'int', 'fips'], + ['OSSL_SIGNATURE_PARAM_FIPS_SIGN_CHECK', 'ind_sign', 'int', 'fips'], + )); -} + +{- produce_param_decoder('dsa_sigalg_set_ctx_params', + (['OSSL_SIGNATURE_PARAM_SIGNATURE', 'sig', 'octet_string'], + ['OSSL_SIGNATURE_PARAM_NONCE_TYPE', 'nonce', 'uint'], + ['OSSL_SIGNATURE_PARAM_FIPS_KEY_CHECK', 'ind_k', 'int', 'fips'], + ['OSSL_SIGNATURE_PARAM_FIPS_DIGEST_CHECK', 'ind_d', 'int', 'fips'], + ['OSSL_SIGNATURE_PARAM_FIPS_SIGN_CHECK', 'ind_sign', 'int', 'fips'], + )); -} diff --git a/providers/implementations/signature/ecdsa_sig.c.in b/providers/implementations/signature/ecdsa_sig.c similarity index 94% rename from providers/implementations/signature/ecdsa_sig.c.in rename to providers/implementations/signature/ecdsa_sig.c index d2e954b1af6..7f1428fbb00 100644 --- a/providers/implementations/signature/ecdsa_sig.c.in +++ b/providers/implementations/signature/ecdsa_sig.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); --} /* * ECDSA low level APIs are deprecated for public use, but still ok for @@ -36,6 +33,26 @@ use OpenSSL::paramnames qw(produce_param_decoder); #include "prov/der_ec.h" #include "crypto/ec.h" +struct ecdsa_all_set_ctx_params_st { + OSSL_PARAM *digest; /* ecdsa_set_ctx_params */ + OSSL_PARAM *propq; /* ecdsa_set_ctx_params */ + OSSL_PARAM *size; /* ecdsa_set_ctx_params */ +#ifdef FIPS_MODULE + OSSL_PARAM *ind_d; + OSSL_PARAM *ind_k; +#endif +#if !defined(OPENSSL_NO_ACVP_TESTS) + OSSL_PARAM *kat; +#endif + OSSL_PARAM *nonce; + OSSL_PARAM *sig; /* ecdsa_sigalg_set_ctx_params */ +}; + +#define ecdsa_set_ctx_params_st ecdsa_all_set_ctx_params_st +#define ecdsa_sigalg_set_ctx_params_st ecdsa_all_set_ctx_params_st + +#include "providers/implementations/signature/ecdsa_sig.inc" + static OSSL_FUNC_signature_newctx_fn ecdsa_newctx; static OSSL_FUNC_signature_sign_init_fn ecdsa_sign_init; static OSSL_FUNC_signature_verify_init_fn ecdsa_verify_init; @@ -675,15 +692,6 @@ static void *ecdsa_dupctx(void *vctx) return NULL; } -{- produce_param_decoder('ecdsa_get_ctx_params', - (['OSSL_SIGNATURE_PARAM_ALGORITHM_ID', 'algid', 'octet_string'], - ['OSSL_SIGNATURE_PARAM_DIGEST_SIZE', 'size', 'size_t'], - ['OSSL_SIGNATURE_PARAM_DIGEST', 'digest', 'utf8_string'], - ['OSSL_SIGNATURE_PARAM_NONCE_TYPE', 'nonce', 'uint'], - ['OSSL_SIGNATURE_PARAM_FIPS_VERIFY_MESSAGE', 'verify', 'uint', 'fips'], - ['OSSL_SIGNATURE_PARAM_FIPS_APPROVED_INDICATOR', 'ind', 'int', 'fips'], - )); -} - static int ecdsa_get_ctx_params(void *vctx, OSSL_PARAM *params) { PROV_ECDSA_CTX *ctx = (PROV_ECDSA_CTX *)vctx; @@ -726,21 +734,6 @@ static const OSSL_PARAM *ecdsa_gettable_ctx_params(ossl_unused void *vctx, return ecdsa_get_ctx_params_list; } -struct ecdsa_all_set_ctx_params_st { - OSSL_PARAM *digest; /* ecdsa_set_ctx_params */ - OSSL_PARAM *propq; /* ecdsa_set_ctx_params */ - OSSL_PARAM *size; /* ecdsa_set_ctx_params */ -#ifdef FIPS_MODULE - OSSL_PARAM *ind_d; - OSSL_PARAM *ind_k; -#endif -#if !defined(OPENSSL_NO_ACVP_TESTS) - OSSL_PARAM *kat; -#endif - OSSL_PARAM *nonce; - OSSL_PARAM *sig; /* ecdsa_sigalg_set_ctx_params */ -}; - /** * @brief Set up common params for ecdsa_set_ctx_params and * ecdsa_sigalg_set_ctx_params. The caller is responsible for checking |vctx| is @@ -766,19 +759,6 @@ static int ecdsa_common_set_ctx_params(PROV_ECDSA_CTX *ctx, return 1; } -#define ecdsa_set_ctx_params_st ecdsa_all_set_ctx_params_st - -{- produce_param_decoder('ecdsa_set_ctx_params', - (['OSSL_SIGNATURE_PARAM_DIGEST', 'digest', 'utf8_string'], - ['OSSL_SIGNATURE_PARAM_PROPERTIES', 'propq', 'utf8_string'], - ['OSSL_SIGNATURE_PARAM_DIGEST_SIZE', 'size', 'size_t'], - ['OSSL_SIGNATURE_PARAM_KAT', 'kat', 'uint', - "#if !defined(OPENSSL_NO_ACVP_TESTS)"], - ['OSSL_SIGNATURE_PARAM_NONCE_TYPE', 'nonce', 'uint'], - ['OSSL_SIGNATURE_PARAM_FIPS_KEY_CHECK', 'ind_k', 'int', 'fips'], - ['OSSL_SIGNATURE_PARAM_FIPS_DIGEST_CHECK', 'ind_d', 'int', 'fips'], - )); -} - static int ecdsa_set_ctx_params(void *vctx, const OSSL_PARAM params[]) { PROV_ECDSA_CTX *ctx = (PROV_ECDSA_CTX *)vctx; @@ -957,17 +937,6 @@ static const char **ecdsa_sigalg_query_key_types(void) return keytypes; } -#define ecdsa_sigalg_set_ctx_params_st ecdsa_all_set_ctx_params_st - -{- produce_param_decoder('ecdsa_sigalg_set_ctx_params', - (['OSSL_SIGNATURE_PARAM_SIGNATURE', 'sig', 'octet_string'], - ['OSSL_SIGNATURE_PARAM_KAT', 'kat', 'uint', - "#if !defined(OPENSSL_NO_ACVP_TESTS)"], - ['OSSL_SIGNATURE_PARAM_NONCE_TYPE', 'nonce', 'uint'], - ['OSSL_SIGNATURE_PARAM_FIPS_KEY_CHECK', 'ind_k', 'int', 'fips'], - ['OSSL_SIGNATURE_PARAM_FIPS_DIGEST_CHECK', 'ind_d', 'int', 'fips'], - )); -} - static const OSSL_PARAM *ecdsa_sigalg_settable_ctx_params(void *vctx, ossl_unused void *provctx) { diff --git a/providers/implementations/signature/ecdsa_sig.inc.in b/providers/implementations/signature/ecdsa_sig.inc.in new file mode 100644 index 00000000000..4907b8db48d --- /dev/null +++ b/providers/implementations/signature/ecdsa_sig.inc.in @@ -0,0 +1,41 @@ +/* + * 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('ecdsa_get_ctx_params', + (['OSSL_SIGNATURE_PARAM_ALGORITHM_ID', 'algid', 'octet_string'], + ['OSSL_SIGNATURE_PARAM_DIGEST_SIZE', 'size', 'size_t'], + ['OSSL_SIGNATURE_PARAM_DIGEST', 'digest', 'utf8_string'], + ['OSSL_SIGNATURE_PARAM_NONCE_TYPE', 'nonce', 'uint'], + ['OSSL_SIGNATURE_PARAM_FIPS_VERIFY_MESSAGE', 'verify', 'uint', 'fips'], + ['OSSL_SIGNATURE_PARAM_FIPS_APPROVED_INDICATOR', 'ind', 'int', 'fips'], + )); -} + +{- produce_param_decoder('ecdsa_set_ctx_params', + (['OSSL_SIGNATURE_PARAM_DIGEST', 'digest', 'utf8_string'], + ['OSSL_SIGNATURE_PARAM_PROPERTIES', 'propq', 'utf8_string'], + ['OSSL_SIGNATURE_PARAM_DIGEST_SIZE', 'size', 'size_t'], + ['OSSL_SIGNATURE_PARAM_KAT', 'kat', 'uint', + "#if !defined(OPENSSL_NO_ACVP_TESTS)"], + ['OSSL_SIGNATURE_PARAM_NONCE_TYPE', 'nonce', 'uint'], + ['OSSL_SIGNATURE_PARAM_FIPS_KEY_CHECK', 'ind_k', 'int', 'fips'], + ['OSSL_SIGNATURE_PARAM_FIPS_DIGEST_CHECK', 'ind_d', 'int', 'fips'], + )); -} + +{- produce_param_decoder('ecdsa_sigalg_set_ctx_params', + (['OSSL_SIGNATURE_PARAM_SIGNATURE', 'sig', 'octet_string'], + ['OSSL_SIGNATURE_PARAM_KAT', 'kat', 'uint', + "#if !defined(OPENSSL_NO_ACVP_TESTS)"], + ['OSSL_SIGNATURE_PARAM_NONCE_TYPE', 'nonce', 'uint'], + ['OSSL_SIGNATURE_PARAM_FIPS_KEY_CHECK', 'ind_k', 'int', 'fips'], + ['OSSL_SIGNATURE_PARAM_FIPS_DIGEST_CHECK', 'ind_d', 'int', 'fips'], + )); -} diff --git a/providers/implementations/signature/eddsa_sig.c.in b/providers/implementations/signature/eddsa_sig.c similarity index 98% rename from providers/implementations/signature/eddsa_sig.c.in rename to providers/implementations/signature/eddsa_sig.c index 1ef925253d6..2c069cf3c12 100644 --- a/providers/implementations/signature/eddsa_sig.c.in +++ b/providers/implementations/signature/eddsa_sig.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 #include @@ -27,6 +24,10 @@ use OpenSSL::paramnames qw(produce_param_decoder); #include "prov/der_ecx.h" #include "crypto/ecx.h" +#define eddsa_set_variant_ctx_params_st eddsa_set_ctx_params_st + +#include "providers/implementations/signature/eddsa_sig.inc" + #ifdef S390X_EC_ASM # include "s390x_arch.h" @@ -792,10 +793,6 @@ static const char **ed448_sigalg_query_key_types(void) return keytypes; } -{- produce_param_decoder('eddsa_get_ctx_params', - (['OSSL_SIGNATURE_PARAM_ALGORITHM_ID', 'id', 'octet_string'], - )); -} - static int eddsa_get_ctx_params(void *vpeddsactx, OSSL_PARAM *params) { PROV_EDDSA_CTX *peddsactx = (PROV_EDDSA_CTX *)vpeddsactx; @@ -819,11 +816,6 @@ static const OSSL_PARAM *eddsa_gettable_ctx_params(ossl_unused void *vpeddsactx, return eddsa_get_ctx_params_list; } -{- produce_param_decoder('eddsa_set_ctx_params', - (['OSSL_SIGNATURE_PARAM_INSTANCE', 'inst', 'utf8_string'], - ['OSSL_SIGNATURE_PARAM_CONTEXT_STRING', 'ctx', 'octet_string'], - )); -} - static int eddsa_set_ctx_params_internal (PROV_EDDSA_CTX *peddsactx, const struct eddsa_set_ctx_params_st *p) { @@ -891,7 +883,6 @@ static const OSSL_PARAM *eddsa_settable_ctx_params(ossl_unused void *vpeddsactx, return eddsa_set_ctx_params_list; } - static int eddsa_set_ctx_params(void *vpeddsactx, const OSSL_PARAM params[]) { PROV_EDDSA_CTX *peddsactx = (PROV_EDDSA_CTX *)vpeddsactx; @@ -902,11 +893,6 @@ static int eddsa_set_ctx_params(void *vpeddsactx, const OSSL_PARAM params[]) return eddsa_set_ctx_params_internal(peddsactx, &p); } -#define eddsa_set_variant_ctx_params_st eddsa_set_ctx_params_st -{- produce_param_decoder('eddsa_set_variant_ctx_params', - (['OSSL_SIGNATURE_PARAM_CONTEXT_STRING', 'ctx', 'octet_string'], - )); -} - static const OSSL_PARAM * eddsa_settable_variant_ctx_params(ossl_unused void *vpeddsactx, ossl_unused void *provctx) diff --git a/providers/implementations/signature/eddsa_sig.inc.in b/providers/implementations/signature/eddsa_sig.inc.in new file mode 100644 index 00000000000..ec1ba2388f5 --- /dev/null +++ b/providers/implementations/signature/eddsa_sig.inc.in @@ -0,0 +1,25 @@ +/* + * 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('eddsa_get_ctx_params', + (['OSSL_SIGNATURE_PARAM_ALGORITHM_ID', 'id', 'octet_string'], + )); -} + +{- produce_param_decoder('eddsa_set_ctx_params', + (['OSSL_SIGNATURE_PARAM_INSTANCE', 'inst', 'utf8_string'], + ['OSSL_SIGNATURE_PARAM_CONTEXT_STRING', 'ctx', 'octet_string'], + )); -} + +{- produce_param_decoder('eddsa_set_variant_ctx_params', + (['OSSL_SIGNATURE_PARAM_CONTEXT_STRING', 'ctx', 'octet_string'], + )); -} diff --git a/providers/implementations/signature/ml_dsa_sig.c.in b/providers/implementations/signature/ml_dsa_sig.c similarity index 92% rename from providers/implementations/signature/ml_dsa_sig.c.in rename to providers/implementations/signature/ml_dsa_sig.c index a12618ac715..b4397c0974f 100644 --- a/providers/implementations/signature/ml_dsa_sig.c.in +++ b/providers/implementations/signature/ml_dsa_sig.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" @@ -27,6 +24,11 @@ use OpenSSL::paramnames qw(produce_param_decoder); #include "internal/packet.h" #include "internal/sizes.h" +#define ml_dsa_set_ctx_params_st ml_dsa_verifymsg_set_ctx_params_st +#define ml_dsa_set_ctx_params_decoder ml_dsa_verifymsg_set_ctx_params_decoder + +#include "providers/implementations/signature/ml_dsa_sig.inc" + #define ML_DSA_MESSAGE_ENCODE_RAW 0 #define ML_DSA_MESSAGE_ENCODE_PURE 1 @@ -365,25 +367,6 @@ static int ml_dsa_digest_verify(void *vctx, * Only need the param list for the signing case. The decoder and structure * are shared between the sign and verify cases. */ -#define ml_dsa_set_ctx_params_st ml_dsa_verifymsg_set_ctx_params_st -#define ml_dsa_set_ctx_params_decoder ml_dsa_verifymsg_set_ctx_params_decoder - -{- produce_param_decoder('ml_dsa_set_ctx_params', - (['OSSL_SIGNATURE_PARAM_CONTEXT_STRING', 'ctx', 'octet_string'], - ['OSSL_SIGNATURE_PARAM_TEST_ENTROPY', 'ent', 'octet_string'], - ['OSSL_SIGNATURE_PARAM_DETERMINISTIC', 'det', 'int'], - ['OSSL_SIGNATURE_PARAM_MESSAGE_ENCODING', 'msgenc', 'int'], - ['OSSL_SIGNATURE_PARAM_MU', 'mu', 'int'], - )); -} - -{- produce_param_decoder('ml_dsa_verifymsg_set_ctx_params', - (['OSSL_SIGNATURE_PARAM_CONTEXT_STRING', 'ctx', 'octet_string'], - ['OSSL_SIGNATURE_PARAM_TEST_ENTROPY', 'ent', 'octet_string'], - ['OSSL_SIGNATURE_PARAM_DETERMINISTIC', 'det', 'int'], - ['OSSL_SIGNATURE_PARAM_MESSAGE_ENCODING', 'msgenc', 'int'], - ['OSSL_SIGNATURE_PARAM_MU', 'mu', 'int'], - ['OSSL_SIGNATURE_PARAM_SIGNATURE', 'sig', 'octet_string'], - )); -} static int ml_dsa_set_ctx_params(void *vctx, const OSSL_PARAM params[]) { @@ -449,10 +432,6 @@ static const OSSL_PARAM *ml_dsa_settable_ctx_params(void *vctx, return ml_dsa_set_ctx_params_list; } -{- produce_param_decoder('ml_dsa_get_ctx_params', - (['OSSL_SIGNATURE_PARAM_ALGORITHM_ID', 'id', 'octet_string'], - )); -} - static const OSSL_PARAM *ml_dsa_gettable_ctx_params(ossl_unused void *vctx, ossl_unused void *provctx) { diff --git a/providers/implementations/signature/ml_dsa_sig.inc.in b/providers/implementations/signature/ml_dsa_sig.inc.in new file mode 100644 index 00000000000..4cf58161d90 --- /dev/null +++ b/providers/implementations/signature/ml_dsa_sig.inc.in @@ -0,0 +1,33 @@ +/* + * 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_dsa_set_ctx_params', + (['OSSL_SIGNATURE_PARAM_CONTEXT_STRING', 'ctx', 'octet_string'], + ['OSSL_SIGNATURE_PARAM_TEST_ENTROPY', 'ent', 'octet_string'], + ['OSSL_SIGNATURE_PARAM_DETERMINISTIC', 'det', 'int'], + ['OSSL_SIGNATURE_PARAM_MESSAGE_ENCODING', 'msgenc', 'int'], + ['OSSL_SIGNATURE_PARAM_MU', 'mu', 'int'], + )); -} + +{- produce_param_decoder('ml_dsa_verifymsg_set_ctx_params', + (['OSSL_SIGNATURE_PARAM_CONTEXT_STRING', 'ctx', 'octet_string'], + ['OSSL_SIGNATURE_PARAM_TEST_ENTROPY', 'ent', 'octet_string'], + ['OSSL_SIGNATURE_PARAM_DETERMINISTIC', 'det', 'int'], + ['OSSL_SIGNATURE_PARAM_MESSAGE_ENCODING', 'msgenc', 'int'], + ['OSSL_SIGNATURE_PARAM_MU', 'mu', 'int'], + ['OSSL_SIGNATURE_PARAM_SIGNATURE', 'sig', 'octet_string'], + )); -} + +{- produce_param_decoder('ml_dsa_get_ctx_params', + (['OSSL_SIGNATURE_PARAM_ALGORITHM_ID', 'id', 'octet_string'], + )); -} diff --git a/providers/implementations/signature/rsa_sig.c.in b/providers/implementations/signature/rsa_sig.c similarity index 95% rename from providers/implementations/signature/rsa_sig.c.in rename to providers/implementations/signature/rsa_sig.c index cb0c7366194..7ad55468e80 100644 --- a/providers/implementations/signature/rsa_sig.c.in +++ b/providers/implementations/signature/rsa_sig.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 @@ -36,6 +33,10 @@ use OpenSSL::paramnames qw(produce_param_decoder); #include "prov/der_rsa.h" #include "prov/securitycheck.h" +#define rsa_set_ctx_params_no_digest_st rsa_set_ctx_params_st + +#include "providers/implementations/signature/rsa_sig.inc" + #define RSA_DEFAULT_DIGEST_NAME OSSL_DIGEST_NAME_SHA1 static OSSL_FUNC_signature_newctx_fn rsa_newctx; @@ -1385,18 +1386,6 @@ static void *rsa_dupctx(void *vprsactx) return NULL; } -{- produce_param_decoder('rsa_get_ctx_params', - (['OSSL_SIGNATURE_PARAM_ALGORITHM_ID', 'algid', 'octet_string'], - ['OSSL_SIGNATURE_PARAM_PAD_MODE', 'pad', 'utf8_string'], - ['OSSL_SIGNATURE_PARAM_PAD_MODE', 'pad', 'int'], - ['OSSL_SIGNATURE_PARAM_DIGEST', 'digest', 'utf8_string'], - ['OSSL_SIGNATURE_PARAM_MGF1_DIGEST', 'mgf1', 'utf8_string'], - ['OSSL_SIGNATURE_PARAM_PSS_SALTLEN', 'slen', 'utf8_string'], - ['OSSL_SIGNATURE_PARAM_PSS_SALTLEN', 'slen', 'int'], - ['OSSL_SIGNATURE_PARAM_FIPS_VERIFY_MESSAGE', 'verify', 'uint', 'fips'], - ['OSSL_SIGNATURE_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; @@ -1519,36 +1508,6 @@ static int rsa_x931_padding_allowed(PROV_RSA_CTX *ctx) } #endif -{- produce_param_decoder('rsa_set_ctx_params', - (['OSSL_SIGNATURE_PARAM_DIGEST', 'digest', 'utf8_string'], - ['OSSL_SIGNATURE_PARAM_PROPERTIES', 'propq', 'utf8_string'], - ['OSSL_SIGNATURE_PARAM_PAD_MODE', 'pad', 'utf8_string'], - ['OSSL_SIGNATURE_PARAM_PAD_MODE', 'pad', 'int'], - ['OSSL_SIGNATURE_PARAM_MGF1_DIGEST', 'mgf1', 'utf8_string'], - ['OSSL_SIGNATURE_PARAM_MGF1_PROPERTIES', 'mgf1pq', 'utf8_string'], - ['OSSL_SIGNATURE_PARAM_PSS_SALTLEN', 'slen', 'utf8_string'], - ['OSSL_SIGNATURE_PARAM_PSS_SALTLEN', 'slen', 'int'], - ['OSSL_SIGNATURE_PARAM_FIPS_KEY_CHECK', 'ind_k', 'int', 'fips'], - ['OSSL_SIGNATURE_PARAM_FIPS_DIGEST_CHECK', 'ind_d', 'int', 'fips'], - ['OSSL_SIGNATURE_PARAM_FIPS_RSA_PSS_SALTLEN_CHECK', 'ind_slen', 'int', 'fips'], - ['OSSL_SIGNATURE_PARAM_FIPS_SIGN_X931_PAD_CHECK', 'ind_xpad', 'int', 'fips'], - )); -} - -#define rsa_set_ctx_params_no_digest_st rsa_set_ctx_params_st - -{- produce_param_decoder('rsa_set_ctx_params_no_digest', - (['OSSL_SIGNATURE_PARAM_PAD_MODE', 'pad', 'utf8_string'], - ['OSSL_SIGNATURE_PARAM_PAD_MODE', 'pad', 'int'], - ['OSSL_SIGNATURE_PARAM_MGF1_DIGEST', 'mgf1', 'utf8_string'], - ['OSSL_SIGNATURE_PARAM_MGF1_PROPERTIES', 'mgf1pq', 'utf8_string'], - ['OSSL_SIGNATURE_PARAM_PSS_SALTLEN', 'slen', 'utf8_string'], - ['OSSL_SIGNATURE_PARAM_PSS_SALTLEN', 'slen', 'int'], - ['OSSL_SIGNATURE_PARAM_FIPS_KEY_CHECK', 'ind_k', 'int', 'fips'], - ['OSSL_SIGNATURE_PARAM_FIPS_DIGEST_CHECK', 'ind_d', 'int', 'fips'], - ['OSSL_SIGNATURE_PARAM_FIPS_RSA_PSS_SALTLEN_CHECK', 'ind_slen', 'int', 'fips'], - ['OSSL_SIGNATURE_PARAM_FIPS_SIGN_X931_PAD_CHECK', 'ind_xpad', 'int', 'fips'], - )); -} - static int rsa_set_ctx_params(void *vprsactx, const OSSL_PARAM params[]) { PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx; @@ -1949,10 +1908,6 @@ static const char **rsa_sigalg_query_key_types(void) return keytypes; } -{- produce_param_decoder('rsa_sigalg_set_ctx_params', - (['OSSL_SIGNATURE_PARAM_SIGNATURE', 'sig', 'octet_string'], - )); -} - static const OSSL_PARAM *rsa_sigalg_settable_ctx_params(void *vprsactx, ossl_unused void *provctx) { diff --git a/providers/implementations/signature/rsa_sig.inc.in b/providers/implementations/signature/rsa_sig.inc.in new file mode 100644 index 00000000000..e73e26d8194 --- /dev/null +++ b/providers/implementations/signature/rsa_sig.inc.in @@ -0,0 +1,56 @@ +/* + * 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_SIGNATURE_PARAM_ALGORITHM_ID', 'algid', 'octet_string'], + ['OSSL_SIGNATURE_PARAM_PAD_MODE', 'pad', 'utf8_string'], + ['OSSL_SIGNATURE_PARAM_PAD_MODE', 'pad', 'int'], + ['OSSL_SIGNATURE_PARAM_DIGEST', 'digest', 'utf8_string'], + ['OSSL_SIGNATURE_PARAM_MGF1_DIGEST', 'mgf1', 'utf8_string'], + ['OSSL_SIGNATURE_PARAM_PSS_SALTLEN', 'slen', 'utf8_string'], + ['OSSL_SIGNATURE_PARAM_PSS_SALTLEN', 'slen', 'int'], + ['OSSL_SIGNATURE_PARAM_FIPS_VERIFY_MESSAGE', 'verify', 'uint', 'fips'], + ['OSSL_SIGNATURE_PARAM_FIPS_APPROVED_INDICATOR', 'ind', 'int', 'fips'], + )); -} + +{- produce_param_decoder('rsa_set_ctx_params', + (['OSSL_SIGNATURE_PARAM_DIGEST', 'digest', 'utf8_string'], + ['OSSL_SIGNATURE_PARAM_PROPERTIES', 'propq', 'utf8_string'], + ['OSSL_SIGNATURE_PARAM_PAD_MODE', 'pad', 'utf8_string'], + ['OSSL_SIGNATURE_PARAM_PAD_MODE', 'pad', 'int'], + ['OSSL_SIGNATURE_PARAM_MGF1_DIGEST', 'mgf1', 'utf8_string'], + ['OSSL_SIGNATURE_PARAM_MGF1_PROPERTIES', 'mgf1pq', 'utf8_string'], + ['OSSL_SIGNATURE_PARAM_PSS_SALTLEN', 'slen', 'utf8_string'], + ['OSSL_SIGNATURE_PARAM_PSS_SALTLEN', 'slen', 'int'], + ['OSSL_SIGNATURE_PARAM_FIPS_KEY_CHECK', 'ind_k', 'int', 'fips'], + ['OSSL_SIGNATURE_PARAM_FIPS_DIGEST_CHECK', 'ind_d', 'int', 'fips'], + ['OSSL_SIGNATURE_PARAM_FIPS_RSA_PSS_SALTLEN_CHECK', 'ind_slen', 'int', 'fips'], + ['OSSL_SIGNATURE_PARAM_FIPS_SIGN_X931_PAD_CHECK', 'ind_xpad', 'int', 'fips'], + )); -} + +{- produce_param_decoder('rsa_set_ctx_params_no_digest', + (['OSSL_SIGNATURE_PARAM_PAD_MODE', 'pad', 'utf8_string'], + ['OSSL_SIGNATURE_PARAM_PAD_MODE', 'pad', 'int'], + ['OSSL_SIGNATURE_PARAM_MGF1_DIGEST', 'mgf1', 'utf8_string'], + ['OSSL_SIGNATURE_PARAM_MGF1_PROPERTIES', 'mgf1pq', 'utf8_string'], + ['OSSL_SIGNATURE_PARAM_PSS_SALTLEN', 'slen', 'utf8_string'], + ['OSSL_SIGNATURE_PARAM_PSS_SALTLEN', 'slen', 'int'], + ['OSSL_SIGNATURE_PARAM_FIPS_KEY_CHECK', 'ind_k', 'int', 'fips'], + ['OSSL_SIGNATURE_PARAM_FIPS_DIGEST_CHECK', 'ind_d', 'int', 'fips'], + ['OSSL_SIGNATURE_PARAM_FIPS_RSA_PSS_SALTLEN_CHECK', 'ind_slen', 'int', 'fips'], + ['OSSL_SIGNATURE_PARAM_FIPS_SIGN_X931_PAD_CHECK', 'ind_xpad', 'int', 'fips'], + )); -} + +{- produce_param_decoder('rsa_sigalg_set_ctx_params', + (['OSSL_SIGNATURE_PARAM_SIGNATURE', 'sig', 'octet_string'], + )); -} diff --git a/providers/implementations/signature/slh_dsa_sig.c.in b/providers/implementations/signature/slh_dsa_sig.c similarity index 95% rename from providers/implementations/signature/slh_dsa_sig.c.in rename to providers/implementations/signature/slh_dsa_sig.c index 909691637c9..23b27f2def8 100644 --- a/providers/implementations/signature/slh_dsa_sig.c.in +++ b/providers/implementations/signature/slh_dsa_sig.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 #include @@ -21,6 +18,7 @@ use OpenSSL::paramnames qw(produce_param_decoder); #include "crypto/slh_dsa.h" #include "internal/cryptlib.h" #include "internal/sizes.h" +#include "providers/implementations/signature/slh_dsa_sig.inc" #define SLH_DSA_MAX_ADD_RANDOM_LEN 32 @@ -260,13 +258,6 @@ static int slh_dsa_digest_verify(void *vctx, const uint8_t *sig, size_t siglen, return slh_dsa_verify(vctx, sig, siglen, tbs, tbslen); } -{- produce_param_decoder('slh_dsa_set_ctx_params', - (['OSSL_SIGNATURE_PARAM_CONTEXT_STRING', 'context', 'octet_string'], - ['OSSL_SIGNATURE_PARAM_TEST_ENTROPY', 'entropy', 'octet_string'], - ['OSSL_SIGNATURE_PARAM_DETERMINISTIC', 'det', 'int'], - ['OSSL_SIGNATURE_PARAM_MESSAGE_ENCODING', 'msgenc', 'int'], - )); -} - static int slh_dsa_set_ctx_params(void *vctx, const OSSL_PARAM params[]) { PROV_SLH_DSA_CTX *pctx = (PROV_SLH_DSA_CTX *)vctx; @@ -311,10 +302,6 @@ static const OSSL_PARAM *slh_dsa_settable_ctx_params(void *vctx, return slh_dsa_set_ctx_params_list; } -{- produce_param_decoder('slh_dsa_get_ctx_params', - (['OSSL_SIGNATURE_PARAM_ALGORITHM_ID', 'algid', 'octet_string'], - )); -} - static const OSSL_PARAM *slh_dsa_gettable_ctx_params(ossl_unused void *vctx, ossl_unused void *provctx) { diff --git a/providers/implementations/signature/slh_dsa_sig.inc.in b/providers/implementations/signature/slh_dsa_sig.inc.in new file mode 100644 index 00000000000..a636ef841ba --- /dev/null +++ b/providers/implementations/signature/slh_dsa_sig.inc.in @@ -0,0 +1,23 @@ +/* + * 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('slh_dsa_set_ctx_params', + (['OSSL_SIGNATURE_PARAM_CONTEXT_STRING', 'context', 'octet_string'], + ['OSSL_SIGNATURE_PARAM_TEST_ENTROPY', 'entropy', 'octet_string'], + ['OSSL_SIGNATURE_PARAM_DETERMINISTIC', 'det', 'int'], + ['OSSL_SIGNATURE_PARAM_MESSAGE_ENCODING', 'msgenc', 'int'], + )); -} + +{- produce_param_decoder('slh_dsa_get_ctx_params', + (['OSSL_SIGNATURE_PARAM_ALGORITHM_ID', 'algid', 'octet_string'], + )); -} diff --git a/providers/implementations/signature/sm2_sig.c.in b/providers/implementations/signature/sm2_sig.c similarity index 95% rename from providers/implementations/signature/sm2_sig.c.in rename to providers/implementations/signature/sm2_sig.c index 0ce7f752e77..5a5f3d91261 100644 --- a/providers/implementations/signature/sm2_sig.c.in +++ b/providers/implementations/signature/sm2_sig.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); --} /* * ECDSA low level APIs are deprecated for public use, but still ok for @@ -35,6 +32,7 @@ use OpenSSL::paramnames qw(produce_param_decoder); #include "crypto/ec.h" #include "crypto/sm2.h" #include "prov/der_sm2.h" +#include "providers/implementations/signature/sm2_sig.inc" static OSSL_FUNC_signature_newctx_fn sm2sig_newctx; static OSSL_FUNC_signature_sign_init_fn sm2sig_signature_init; @@ -314,7 +312,6 @@ int sm2sig_digest_sign_final(void *vpsm2ctx, unsigned char *sig, size_t *siglen, return sm2sig_sign(vpsm2ctx, sig, siglen, sigsize, digest, (size_t)dlen); } - int sm2sig_digest_verify_final(void *vpsm2ctx, const unsigned char *sig, size_t siglen) { @@ -399,12 +396,6 @@ static void *sm2sig_dupctx(void *vpsm2ctx) return NULL; } -{- produce_param_decoder('sm2sig_get_ctx_params', - (['OSSL_SIGNATURE_PARAM_ALGORITHM_ID', 'algid', 'octet_string'], - ['OSSL_SIGNATURE_PARAM_DIGEST_SIZE', 'size', 'size_t'], - ['OSSL_SIGNATURE_PARAM_DIGEST', 'digest', 'utf8_string'], - )); -} - static int sm2sig_get_ctx_params(void *vpsm2ctx, OSSL_PARAM *params) { PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx; @@ -437,12 +428,6 @@ static const OSSL_PARAM *sm2sig_gettable_ctx_params(ossl_unused void *vpsm2ctx, return sm2sig_get_ctx_params_list; } -{- produce_param_decoder('sm2sig_set_ctx_params', - (['OSSL_SIGNATURE_PARAM_DIGEST_SIZE', 'size', 'size_t'], - ['OSSL_SIGNATURE_PARAM_DIGEST', 'digest', 'utf8_string'], - ['OSSL_PKEY_PARAM_DIST_ID', 'distid', 'octet_string'], - )); -} - static int sm2sig_set_ctx_params(void *vpsm2ctx, const OSSL_PARAM params[]) { PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx; diff --git a/providers/implementations/signature/sm2_sig.inc.in b/providers/implementations/signature/sm2_sig.inc.in new file mode 100644 index 00000000000..f410d74a47d --- /dev/null +++ b/providers/implementations/signature/sm2_sig.inc.in @@ -0,0 +1,24 @@ +/* + * 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('sm2sig_get_ctx_params', + (['OSSL_SIGNATURE_PARAM_ALGORITHM_ID', 'algid', 'octet_string'], + ['OSSL_SIGNATURE_PARAM_DIGEST_SIZE', 'size', 'size_t'], + ['OSSL_SIGNATURE_PARAM_DIGEST', 'digest', 'utf8_string'], + )); -} + +{- produce_param_decoder('sm2sig_set_ctx_params', + (['OSSL_SIGNATURE_PARAM_DIGEST_SIZE', 'size', 'size_t'], + ['OSSL_SIGNATURE_PARAM_DIGEST', 'digest', 'utf8_string'], + ['OSSL_PKEY_PARAM_DIST_ID', 'distid', 'octet_string'], + )); -} -- 2.47.3