From: Simo Sorce Date: Thu, 16 Oct 2025 19:48:07 +0000 (-0400) Subject: digests: Use include file for generated code X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4739965edddc8a695798648378c14b103e16b383;p=thirdparty%2Fopenssl.git digests: 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 0932e7780f4..b84c5403ba4 100644 --- a/.gitignore +++ b/.gitignore @@ -156,10 +156,10 @@ providers/implementations/ciphers/cipher_null.inc providers/implementations/ciphers/cipher_rc4_hmac_md5.inc providers/implementations/ciphers/cipher_sm2_xts.c providers/implementations/ciphers/cipher_sm4_xts.inc -providers/implementations/digests/blake2_prov.c -providers/implementations/digests/digestcommon.c -providers/implementations/digests/mdc2_prov.c -providers/implementations/digests/sha3_prov.c +providers/implementations/digests/blake2_prov.inc +providers/implementations/digests/digestcommon.inc +providers/implementations/digests/mdc2_prov.inc +providers/implementations/digests/sha3_prov.inc providers/implementations/include/prov/blake2_params.inc providers/implementations/macs/cmac_prov.c providers/implementations/macs/gmac_prov.c diff --git a/build.info b/build.info index c2748d07020..3109435db0e 100644 --- a/build.info +++ b/build.info @@ -114,10 +114,10 @@ DEPEND[]=include/openssl/asn1.h \ providers/implementations/ciphers/cipher_null.inc \ providers/implementations/ciphers/cipher_rc4_hmac_md5.inc \ providers/implementations/ciphers/cipher_sm4_xts.inc \ - providers/implementations/digests/blake2_prov.c \ - providers/implementations/digests/digestcommon.c \ - providers/implementations/digests/mdc2_prov.c \ - providers/implementations/digests/sha3_prov.c \ + providers/implementations/digests/blake2_prov.inc \ + providers/implementations/digests/digestcommon.inc \ + providers/implementations/digests/mdc2_prov.inc \ + providers/implementations/digests/sha3_prov.inc \ providers/implementations/include/prov/blake2_params.inc \ providers/implementations/macs/cmac_prov.c \ providers/implementations/macs/gmac_prov.c \ @@ -232,10 +232,10 @@ DEPEND[providers/implementations/asymciphers/rsa_enc.inc \ providers/implementations/ciphers/cipher_null.inc \ providers/implementations/ciphers/cipher_rc4_hmac_md5.inc \ providers/implementations/ciphers/cipher_sm4_xts.inc \ - providers/implementations/digests/blake2_prov.c \ - providers/implementations/digests/digestcommon.c \ - providers/implementations/digests/mdc2_prov.c \ - providers/implementations/digests/sha3_prov.c \ + providers/implementations/digests/blake2_prov.inc \ + providers/implementations/digests/digestcommon.inc \ + providers/implementations/digests/mdc2_prov.inc \ + providers/implementations/digests/sha3_prov.inc \ providers/implementations/include/prov/blake2_params.inc \ providers/implementations/macs/cmac_prov.c \ providers/implementations/macs/gmac_prov.c \ @@ -383,14 +383,14 @@ GENERATE[providers/implementations/ciphers/cipher_rc4_hmac_md5.inc]=\ providers/implementations/ciphers/cipher_rc4_hmac_md5.inc.in GENERATE[providers/implementations/ciphers/cipher_sm4_xts.inc]=\ providers/implementations/ciphers/cipher_sm4_xts.inc.in -GENERATE[providers/implementations/digests/blake2_prov.c]=\ - providers/implementations/digests/blake2_prov.c.in -GENERATE[providers/implementations/digests/digestcommon.c]=\ - providers/implementations/digests/digestcommon.c.in -GENERATE[providers/implementations/digests/mdc2_prov.c]=\ - providers/implementations/digests/mdc2_prov.c.in -GENERATE[providers/implementations/digests/sha3_prov.c]=\ - providers/implementations/digests/sha3_prov.c.in +GENERATE[providers/implementations/digests/blake2_prov.inc]=\ + providers/implementations/digests/blake2_prov.inc.in +GENERATE[providers/implementations/digests/digestcommon.inc]=\ + providers/implementations/digests/digestcommon.inc.in +GENERATE[providers/implementations/digests/mdc2_prov.inc]=\ + providers/implementations/digests/mdc2_prov.inc.in +GENERATE[providers/implementations/digests/sha3_prov.inc]=\ + providers/implementations/digests/sha3_prov.inc.in GENERATE[providers/implementations/include/prov/blake2_params.inc]=\ providers/implementations/include/prov/blake2_params.inc.in GENERATE[providers/implementations/macs/cmac_prov.c]=\ diff --git a/providers/implementations/digests/blake2_prov.c.in b/providers/implementations/digests/blake2_prov.c similarity index 94% rename from providers/implementations/digests/blake2_prov.c.in rename to providers/implementations/digests/blake2_prov.c index 5ec80bf1777..56e1db18afd 100644 --- a/providers/implementations/digests/blake2_prov.c.in +++ b/providers/implementations/digests/blake2_prov.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 @@ -19,24 +16,17 @@ use OpenSSL::paramnames qw(produce_param_decoder); #include "prov/blake2.h" #include "prov/digestcommon.h" #include "prov/implementations.h" +#include "providers/implementations/digests/blake2_prov.inc" static OSSL_FUNC_digest_gettable_ctx_params_fn blake_gettable_ctx_params; static OSSL_FUNC_digest_settable_ctx_params_fn blake_settable_ctx_params; -{- produce_param_decoder('blake_get_ctx_params', - (['OSSL_DIGEST_PARAM_SIZE', 'size', 'uint'], - )); -} - static const OSSL_PARAM *blake_gettable_ctx_params(ossl_unused void *ctx, ossl_unused void *pctx) { return blake_get_ctx_params_list; } -{- produce_param_decoder('blake_set_ctx_params', - (['OSSL_DIGEST_PARAM_SIZE', 'size', 'uint'], - )); -} - static const OSSL_PARAM *blake_settable_ctx_params(ossl_unused void *ctx, ossl_unused void *pctx) { diff --git a/providers/implementations/digests/blake2_prov.inc.in b/providers/implementations/digests/blake2_prov.inc.in new file mode 100644 index 00000000000..ed223e0980f --- /dev/null +++ b/providers/implementations/digests/blake2_prov.inc.in @@ -0,0 +1,20 @@ +/* + * 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('blake_get_ctx_params', + (['OSSL_DIGEST_PARAM_SIZE', 'size', 'uint'], + )); -} + +{- produce_param_decoder('blake_set_ctx_params', + (['OSSL_DIGEST_PARAM_SIZE', 'size', 'uint'], + )); -} diff --git a/providers/implementations/digests/digestcommon.c.in b/providers/implementations/digests/digestcommon.c similarity index 76% rename from providers/implementations/digests/digestcommon.c.in rename to providers/implementations/digests/digestcommon.c index ad9cec04be7..eee75be1f25 100644 --- a/providers/implementations/digests/digestcommon.c.in +++ b/providers/implementations/digests/digestcommon.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 @@ -16,12 +13,7 @@ use OpenSSL::paramnames qw(produce_param_decoder); #include "prov/digestcommon.h" #include "internal/common.h" -{- produce_param_decoder('digest_default_get_params', - (['OSSL_DIGEST_PARAM_BLOCK_SIZE', 'bsize', 'size_t'], - ['OSSL_DIGEST_PARAM_SIZE', 'size', 'size_t'], - ['OSSL_DIGEST_PARAM_XOF', 'xof', 'int'], - ['OSSL_DIGEST_PARAM_ALGID_ABSENT', 'aldid', 'int'], - )); -} +#include "providers/implementations/digests/digestcommon.inc" int ossl_digest_default_get_params(OSSL_PARAM params[], size_t blksz, size_t paramsz, unsigned long flags) diff --git a/providers/implementations/digests/digestcommon.inc.in b/providers/implementations/digests/digestcommon.inc.in new file mode 100644 index 00000000000..d33db69ffe3 --- /dev/null +++ b/providers/implementations/digests/digestcommon.inc.in @@ -0,0 +1,19 @@ +/* + * 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('digest_default_get_params', + (['OSSL_DIGEST_PARAM_BLOCK_SIZE', 'bsize', 'size_t'], + ['OSSL_DIGEST_PARAM_SIZE', 'size', 'size_t'], + ['OSSL_DIGEST_PARAM_XOF', 'xof', 'int'], + ['OSSL_DIGEST_PARAM_ALGID_ABSENT', 'aldid', 'int'], + )); -} diff --git a/providers/implementations/digests/mdc2_prov.c.in b/providers/implementations/digests/mdc2_prov.c similarity index 88% rename from providers/implementations/digests/mdc2_prov.c.in rename to providers/implementations/digests/mdc2_prov.c index a48ad1f5d11..0e6ed5bd5d6 100644 --- a/providers/implementations/digests/mdc2_prov.c.in +++ b/providers/implementations/digests/mdc2_prov.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); --} /* * MDC2 low level APIs are deprecated for public use, but still ok for @@ -26,14 +23,11 @@ use OpenSSL::paramnames qw(produce_param_decoder); #include #include "prov/digestcommon.h" #include "prov/implementations.h" +#include "providers/implementations/digests/mdc2_prov.inc" static OSSL_FUNC_digest_set_ctx_params_fn mdc2_set_ctx_params; static OSSL_FUNC_digest_settable_ctx_params_fn mdc2_settable_ctx_params; -{- produce_param_decoder('mdc2_set_ctx_params', - (['OSSL_DIGEST_PARAM_PAD_TYPE', 'pad', 'uint'], - )); -} - static const OSSL_PARAM *mdc2_settable_ctx_params(ossl_unused void *ctx, ossl_unused void *provctx) { diff --git a/providers/implementations/digests/mdc2_prov.inc.in b/providers/implementations/digests/mdc2_prov.inc.in new file mode 100644 index 00000000000..740544b3e7f --- /dev/null +++ b/providers/implementations/digests/mdc2_prov.inc.in @@ -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('mdc2_set_ctx_params', + (['OSSL_DIGEST_PARAM_PAD_TYPE', 'pad', 'uint'], + )); -} diff --git a/providers/implementations/digests/sha3_prov.c.in b/providers/implementations/digests/sha3_prov.c similarity index 97% rename from providers/implementations/digests/sha3_prov.c.in rename to providers/implementations/digests/sha3_prov.c index ef1701ff0ff..28e042108f1 100644 --- a/providers/implementations/digests/sha3_prov.c.in +++ b/providers/implementations/digests/sha3_prov.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 @@ -23,6 +20,7 @@ use OpenSSL::paramnames qw(produce_param_decoder); #include "prov/digestcommon.h" #include "prov/implementations.h" #include "internal/common.h" +#include "providers/implementations/digests/sha3_prov.inc" #define SHA3_FLAGS PROV_DIGEST_FLAG_ALGID_ABSENT #define SHAKE_FLAGS (PROV_DIGEST_FLAG_XOF | PROV_DIGEST_FLAG_ALGID_ABSENT) @@ -586,11 +584,6 @@ static void *keccak_dupctx(void *ctx) return ret; } -{- produce_param_decoder('shake_get_ctx_params', - (['OSSL_DIGEST_PARAM_XOFLEN', 'xoflen', 'size_t'], - ['OSSL_DIGEST_PARAM_SIZE', 'size', 'size_t'], - )); -} - static const OSSL_PARAM *shake_gettable_ctx_params(ossl_unused void *ctx, ossl_unused void *provctx) { @@ -617,11 +610,6 @@ static int shake_get_ctx_params(void *vctx, OSSL_PARAM params[]) return 1; } -{- produce_param_decoder('shake_set_ctx_params', - (['OSSL_DIGEST_PARAM_XOFLEN', 'xoflen', 'size_t'], - ['OSSL_DIGEST_PARAM_SIZE', 'xoflen', 'size_t'], - )); -} - static const OSSL_PARAM *shake_settable_ctx_params(ossl_unused void *ctx, ossl_unused void *provctx) { diff --git a/providers/implementations/digests/sha3_prov.inc.in b/providers/implementations/digests/sha3_prov.inc.in new file mode 100644 index 00000000000..c1bdff957b9 --- /dev/null +++ b/providers/implementations/digests/sha3_prov.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('shake_get_ctx_params', + (['OSSL_DIGEST_PARAM_XOFLEN', 'xoflen', 'size_t'], + ['OSSL_DIGEST_PARAM_SIZE', 'size', 'size_t'], + )); -} + +{- produce_param_decoder('shake_set_ctx_params', + (['OSSL_DIGEST_PARAM_XOFLEN', 'xoflen', 'size_t'], + ['OSSL_DIGEST_PARAM_SIZE', 'xoflen', 'size_t'], + )); -}