]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
digests: Use include file for generated code
authorSimo Sorce <simo@redhat.com>
Thu, 16 Oct 2025 19:48:07 +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/digests/blake2_prov.c [moved from providers/implementations/digests/blake2_prov.c.in with 94% similarity]
providers/implementations/digests/blake2_prov.inc.in [new file with mode: 0644]
providers/implementations/digests/digestcommon.c [moved from providers/implementations/digests/digestcommon.c.in with 76% similarity]
providers/implementations/digests/digestcommon.inc.in [new file with mode: 0644]
providers/implementations/digests/mdc2_prov.c [moved from providers/implementations/digests/mdc2_prov.c.in with 88% similarity]
providers/implementations/digests/mdc2_prov.inc.in [new file with mode: 0644]
providers/implementations/digests/sha3_prov.c [moved from providers/implementations/digests/sha3_prov.c.in with 97% similarity]
providers/implementations/digests/sha3_prov.inc.in [new file with mode: 0644]

index 0932e7780f4569d63baccceffa850395eff779dc..b84c5403ba4302d1bc73d5a84a91ec46220e258e 100644 (file)
@@ -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
index c2748d0702060063da1fcc8f673eba9e162f0226..3109435db0efc9a3b10bc970e277a9aa64a4c7eb 100644 (file)
@@ -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]=\
similarity index 94%
rename from providers/implementations/digests/blake2_prov.c.in
rename to providers/implementations/digests/blake2_prov.c
index 5ec80bf17774dda8d76eb92766f97716b4df1ef9..56e1db18afdb0909db89e3e8ebfbaa957967ff48 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>
@@ -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 (file)
index 0000000..ed223e0
--- /dev/null
@@ -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'],
+                         )); -}
similarity index 76%
rename from providers/implementations/digests/digestcommon.c.in
rename to providers/implementations/digests/digestcommon.c
index ad9cec04be73b1f6b066e4c2c1ccc6e7a41a98f4..eee75be1f253a3ad8ae75744c74a52b485dedf02 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/err.h>
@@ -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 (file)
index 0000000..d33db69
--- /dev/null
@@ -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'],
+                         )); -}
similarity index 88%
rename from providers/implementations/digests/mdc2_prov.c.in
rename to providers/implementations/digests/mdc2_prov.c
index a48ad1f5d11624165b9aba85f57d9efd3d1bd2dd..0e6ed5bd5d66ba780234c1a7c71461d6c00ba955 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);
--}
 
 /*
  * 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 <internal/common.h>
 #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 (file)
index 0000000..740544b
--- /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('mdc2_set_ctx_params',
+                         (['OSSL_DIGEST_PARAM_PAD_TYPE', 'pad', 'uint'],
+                         )); -}
similarity index 97%
rename from providers/implementations/digests/sha3_prov.c.in
rename to providers/implementations/digests/sha3_prov.c
index ef1701ff0ff78389acf1cd3f86d1558ea08d16c8..28e042108f112f1e521982d2c057a56ce7173b24 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/core_names.h>
@@ -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 (file)
index 0000000..c1bdff9
--- /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('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'],
+                         )); -}