From 7c214f1092f7622a1c2fdc5cfe70ddc94918daa3 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Fri, 4 Oct 2019 12:30:33 +0200 Subject: [PATCH] Providers: move all digests From providers/{common,default,legacy}/ to providers/implementations/ However, providers/common/digests/digest_common.c stays where it is, because it's support code rather than an implementation. To better support all kinds of implementations with common code, we add the library providers/libcommon.a. Code that ends up in this library must be FIPS agnostic. While we're moving things around, though, we move digestscommon.h from providers/common/include/internal to providers/common/include/prov, thereby starting on a provider specific include structure, which follows the line of thoughts of the recent header file reorganization. We modify the affected '#include "internal/something.h"' to '#include "prov/something.h"'. Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/10088) --- crypto/blake2/m_blake2b.c | 2 +- crypto/blake2/m_blake2s.c | 2 +- crypto/evp/legacy_md5_sha1.c | 2 +- crypto/md5/md5_sha1.c | 2 +- providers/build.info | 6 ++- providers/common/digests/build.info | 5 -- providers/common/digests/digest_common.c | 2 +- .../include/{internal => prov}/digestcommon.h | 0 providers/default/build.info | 2 +- providers/default/digests/build.info | 16 ------ providers/implementations/build.info | 2 +- .../digests/blake2_impl.h | 0 .../digests/blake2_prov.c | 4 +- .../digests/blake2b_prov.c | 2 +- .../digests/blake2s_prov.c | 2 +- providers/implementations/digests/build.info | 52 +++++++++++++++++++ .../digests/md2_prov.c | 2 +- .../digests/md4_prov.c | 2 +- .../digests/md5_prov.c | 2 +- .../digests/md5_sha1_prov.c | 4 +- .../digests/mdc2_prov.c | 2 +- .../digests/ripemd_prov.c | 2 +- .../digests/sha2_prov.c | 2 +- .../digests/sha3_prov.c | 2 +- .../digests/sm3_prov.c | 2 +- .../digests/wp_prov.c | 2 +- .../include/prov}/blake2.h | 0 .../include/prov}/md5_sha1.h | 0 .../implementations/macs/blake2_mac_impl.c | 2 +- providers/legacy/build.info | 1 - providers/legacy/digests/build.info | 21 -------- 31 files changed, 79 insertions(+), 68 deletions(-) rename providers/common/include/{internal => prov}/digestcommon.h (100%) delete mode 100644 providers/default/digests/build.info rename providers/{default => implementations}/digests/blake2_impl.h (100%) rename providers/{default => implementations}/digests/blake2_prov.c (94%) rename providers/{default => implementations}/digests/blake2b_prov.c (99%) rename providers/{default => implementations}/digests/blake2s_prov.c (99%) create mode 100644 providers/implementations/digests/build.info rename providers/{legacy => implementations}/digests/md2_prov.c (94%) rename providers/{legacy => implementations}/digests/md4_prov.c (94%) rename providers/{default => implementations}/digests/md5_prov.c (94%) rename providers/{default => implementations}/digests/md5_sha1_prov.c (96%) rename providers/{legacy => implementations}/digests/mdc2_prov.c (97%) rename providers/{legacy => implementations}/digests/ripemd_prov.c (94%) rename providers/{common => implementations}/digests/sha2_prov.c (98%) rename providers/{common => implementations}/digests/sha3_prov.c (99%) rename providers/{default => implementations}/digests/sm3_prov.c (94%) rename providers/{legacy => implementations}/digests/wp_prov.c (94%) rename providers/{default/include/internal => implementations/include/prov}/blake2.h (100%) rename providers/{default/include/internal => implementations/include/prov}/md5_sha1.h (100%) delete mode 100644 providers/legacy/digests/build.info diff --git a/crypto/blake2/m_blake2b.c b/crypto/blake2/m_blake2b.c index 816dd06b6c..bb3f145abd 100644 --- a/crypto/blake2/m_blake2b.c +++ b/crypto/blake2/m_blake2b.c @@ -12,7 +12,7 @@ # include # include # include "crypto/evp.h" -# include "internal/blake2.h" +# include "prov/blake2.h" static int init(EVP_MD_CTX *ctx) { diff --git a/crypto/blake2/m_blake2s.c b/crypto/blake2/m_blake2s.c index caf8a6657a..b04d63ec38 100644 --- a/crypto/blake2/m_blake2s.c +++ b/crypto/blake2/m_blake2s.c @@ -12,7 +12,7 @@ # include # include # include "crypto/evp.h" -# include "internal/blake2.h" +# include "prov/blake2.h" static int init(EVP_MD_CTX *ctx) { diff --git a/crypto/evp/legacy_md5_sha1.c b/crypto/evp/legacy_md5_sha1.c index cba37bacd8..a23febfd53 100644 --- a/crypto/evp/legacy_md5_sha1.c +++ b/crypto/evp/legacy_md5_sha1.c @@ -9,7 +9,7 @@ #include -#include "internal/md5_sha1.h" /* diverse MD5_SHA1 macros */ +#include "prov/md5_sha1.h" /* diverse MD5_SHA1 macros */ #ifndef OPENSSL_NO_MD5 diff --git a/crypto/md5/md5_sha1.c b/crypto/md5/md5_sha1.c index 5d5fac95bd..32bf9a13fc 100644 --- a/crypto/md5/md5_sha1.c +++ b/crypto/md5/md5_sha1.c @@ -7,7 +7,7 @@ * https://www.openssl.org/source/license.html */ #include -#include "internal/md5_sha1.h" +#include "prov/md5_sha1.h" #include int md5_sha1_init(MD5_SHA1_CTX *mctx) diff --git a/providers/build.info b/providers/build.info index 973adac5c7..42b9c0aa9c 100644 --- a/providers/build.info +++ b/providers/build.info @@ -46,8 +46,8 @@ $LIBFIPS=libfips.a $COMMON_INCLUDES=../crypto ../include common/include INCLUDE[$LIBCOMMON]=$COMMON_INCLUDES -INCLUDE[$LIBIMPLEMENTATIONS]=.. $COMMON_INCLUDES default/include -INCLUDE[$LIBLEGACY]=$COMMON_INCLUDES +INCLUDE[$LIBIMPLEMENTATIONS]=.. $COMMON_INCLUDES implementations/include +INCLUDE[$LIBLEGACY]=$COMMON_INCLUDES implementations/include INCLUDE[$LIBNONFIPS]=$COMMON_INCLUDES INCLUDE[$LIBFIPS]=.. $COMMON_INCLUDES DEFINE[$LIBFIPS]=FIPS_MODE @@ -82,6 +82,8 @@ LIBS{noinst}=$LIBNONFIPS $LIBIMPLEMENTATIONS # with DEPEND. $DEFAULTGOAL=../libcrypto SOURCE[$DEFAULTGOAL]=$LIBIMPLEMENTATIONS $LIBNONFIPS +# Some legacy implementations depend on provider header files +INCLUDE[../libcrypto]=implementations/include LIBS=$DEFAULTGOAL diff --git a/providers/common/digests/build.info b/providers/common/digests/build.info index 2a8e8aa397..730046d670 100644 --- a/providers/common/digests/build.info +++ b/providers/common/digests/build.info @@ -1,7 +1,2 @@ # This source is common for all digests in all our providers. SOURCE[../../libcommon.a]=digest_common.c - -# These are our implementations -$GOAL=../../libimplementations.a - -SOURCE[$GOAL]=sha2_prov.c sha3_prov.c diff --git a/providers/common/digests/digest_common.c b/providers/common/digests/digest_common.c index 062209f329..92610a1524 100644 --- a/providers/common/digests/digest_common.c +++ b/providers/common/digests/digest_common.c @@ -8,7 +8,7 @@ */ #include "openssl/err.h" -#include "internal/digestcommon.h" +#include "prov/digestcommon.h" #include "internal/providercommonerr.h" int digest_default_get_params(OSSL_PARAM params[], size_t blksz, size_t paramsz, diff --git a/providers/common/include/internal/digestcommon.h b/providers/common/include/prov/digestcommon.h similarity index 100% rename from providers/common/include/internal/digestcommon.h rename to providers/common/include/prov/digestcommon.h diff --git a/providers/default/build.info b/providers/default/build.info index 67b4d3a977..9a9760b799 100644 --- a/providers/default/build.info +++ b/providers/default/build.info @@ -1,4 +1,4 @@ -SUBDIRS=digests ciphers +SUBDIRS=ciphers $GOAL=../../libcrypto SOURCE[$GOAL]=defltprov.c INCLUDE[$GOAL]=include diff --git a/providers/default/digests/build.info b/providers/default/digests/build.info deleted file mode 100644 index 6869657ec9..0000000000 --- a/providers/default/digests/build.info +++ /dev/null @@ -1,16 +0,0 @@ -$GOAL=../../libimplementations.a - -IF[{- !$disabled{blake2} -}] - SOURCE[$GOAL]=\ - blake2_prov.c blake2b_prov.c blake2s_prov.c -ENDIF - -IF[{- !$disabled{sm3} -}] - SOURCE[$GOAL]=\ - sm3_prov.c -ENDIF - -IF[{- !$disabled{md5} -}] - SOURCE[$GOAL]=\ - md5_prov.c md5_sha1_prov.c -ENDIF diff --git a/providers/implementations/build.info b/providers/implementations/build.info index 1170ef96b3..86c581d7f7 100644 --- a/providers/implementations/build.info +++ b/providers/implementations/build.info @@ -1 +1 @@ -SUBDIRS=macs kdfs exchange keymgmt signature +SUBDIRS=digests macs kdfs exchange keymgmt signature diff --git a/providers/default/digests/blake2_impl.h b/providers/implementations/digests/blake2_impl.h similarity index 100% rename from providers/default/digests/blake2_impl.h rename to providers/implementations/digests/blake2_impl.h diff --git a/providers/default/digests/blake2_prov.c b/providers/implementations/digests/blake2_prov.c similarity index 94% rename from providers/default/digests/blake2_prov.c rename to providers/implementations/digests/blake2_prov.c index f299fb289d..16f301b177 100644 --- a/providers/default/digests/blake2_prov.c +++ b/providers/implementations/digests/blake2_prov.c @@ -8,8 +8,8 @@ */ #include -#include "internal/blake2.h" -#include "internal/digestcommon.h" +#include "prov/blake2.h" +#include "prov/digestcommon.h" #include "internal/provider_algs.h" OSSL_OP_digest_init_fn blake2s256_init; diff --git a/providers/default/digests/blake2b_prov.c b/providers/implementations/digests/blake2b_prov.c similarity index 99% rename from providers/default/digests/blake2b_prov.c rename to providers/implementations/digests/blake2b_prov.c index 2f8081268e..baa33e922f 100644 --- a/providers/default/digests/blake2b_prov.c +++ b/providers/implementations/digests/blake2b_prov.c @@ -18,7 +18,7 @@ #include #include #include "blake2_impl.h" -#include "internal/blake2.h" +#include "prov/blake2.h" static const uint64_t blake2b_IV[8] = { diff --git a/providers/default/digests/blake2s_prov.c b/providers/implementations/digests/blake2s_prov.c similarity index 99% rename from providers/default/digests/blake2s_prov.c rename to providers/implementations/digests/blake2s_prov.c index a9c757ea62..703d8a8fab 100644 --- a/providers/default/digests/blake2s_prov.c +++ b/providers/implementations/digests/blake2s_prov.c @@ -18,7 +18,7 @@ #include #include #include "blake2_impl.h" -#include "internal/blake2.h" +#include "prov/blake2.h" static const uint32_t blake2s_IV[8] = { diff --git a/providers/implementations/digests/build.info b/providers/implementations/digests/build.info new file mode 100644 index 0000000000..2026de95d7 --- /dev/null +++ b/providers/implementations/digests/build.info @@ -0,0 +1,52 @@ +# We make separate GOAL variables for each algorithm, to make it easy to +# switch each to the Legacy provider when needed. + +$SHA1_GOAL=../../libimplementations.a +$SHA2_GOAL=../../libimplementations.a +$SHA3_GOAL=../../libimplementations.a +$BLAKE2_GOAL=../../libimplementations.a +$SM3_GOAL=../../libimplementations.a +$MD5_GOAL=../../libimplementations.a + +$MD2_GOAL=../../liblegacy.a +$MD4_GOAL=../../liblegacy.a +$MDC2_GOAL=../../liblegacy.a +$WHIRLPOOL_GOAL=../../liblegacy.a +$RIPEMD_GOAL=../../liblegacy.a + +SOURCE[$SHA2_GOAL]=sha2_prov.c +SOURCE[$SHA3_GOAL]=sha3_prov.c + +$GOAL=../../libimplementations.a + +IF[{- !$disabled{blake2} -}] + SOURCE[$BLAKE2_GOAL]=blake2_prov.c blake2b_prov.c blake2s_prov.c +ENDIF + +IF[{- !$disabled{sm3} -}] + SOURCE[$SM3_GOAL]=sm3_prov.c +ENDIF + +IF[{- !$disabled{md5} -}] + SOURCE[$MD5_GOAL]=md5_prov.c md5_sha1_prov.c +ENDIF + +IF[{- !$disabled{md2} -}] + SOURCE[$MD2_GOAL]=md2_prov.c +ENDIF + +IF[{- !$disabled{md4} -}] + SOURCE[$MD4_GOAL]=md4_prov.c +ENDIF + +IF[{- !$disabled{mdc2} -}] + SOURCE[$MDC2_GOAL]=mdc2_prov.c +ENDIF + +IF[{- !$disabled{whirlpool} -}] + SOURCE[$WHIRLPOOL_GOAL]=wp_prov.c +ENDIF + +IF[{- !$disabled{rmd160} -}] + SOURCE[$RIPEMD_GOAL]=ripemd_prov.c +ENDIF diff --git a/providers/legacy/digests/md2_prov.c b/providers/implementations/digests/md2_prov.c similarity index 94% rename from providers/legacy/digests/md2_prov.c rename to providers/implementations/digests/md2_prov.c index 2a4439d26c..ab1d605218 100644 --- a/providers/legacy/digests/md2_prov.c +++ b/providers/implementations/digests/md2_prov.c @@ -9,7 +9,7 @@ #include #include -#include "internal/digestcommon.h" +#include "prov/digestcommon.h" #include "internal/provider_algs.h" /* md2_functions */ diff --git a/providers/legacy/digests/md4_prov.c b/providers/implementations/digests/md4_prov.c similarity index 94% rename from providers/legacy/digests/md4_prov.c rename to providers/implementations/digests/md4_prov.c index 8486b7b48d..6b311c075d 100644 --- a/providers/legacy/digests/md4_prov.c +++ b/providers/implementations/digests/md4_prov.c @@ -9,7 +9,7 @@ #include #include -#include "internal/digestcommon.h" +#include "prov/digestcommon.h" #include "internal/provider_algs.h" /* md4_functions */ diff --git a/providers/default/digests/md5_prov.c b/providers/implementations/digests/md5_prov.c similarity index 94% rename from providers/default/digests/md5_prov.c rename to providers/implementations/digests/md5_prov.c index c688bebac0..1205888ff9 100644 --- a/providers/default/digests/md5_prov.c +++ b/providers/implementations/digests/md5_prov.c @@ -9,7 +9,7 @@ #include #include -#include "internal/digestcommon.h" +#include "prov/digestcommon.h" #include "internal/provider_algs.h" /* md5_functions */ diff --git a/providers/default/digests/md5_sha1_prov.c b/providers/implementations/digests/md5_sha1_prov.c similarity index 96% rename from providers/default/digests/md5_sha1_prov.c rename to providers/implementations/digests/md5_sha1_prov.c index 7f224cba4f..ff6e2ed121 100644 --- a/providers/default/digests/md5_sha1_prov.c +++ b/providers/implementations/digests/md5_sha1_prov.c @@ -12,8 +12,8 @@ #include #include #include -#include "internal/md5_sha1.h" -#include "internal/digestcommon.h" +#include "prov/md5_sha1.h" +#include "prov/digestcommon.h" #include "internal/provider_algs.h" static OSSL_OP_digest_set_ctx_params_fn md5_sha1_set_ctx_params; diff --git a/providers/legacy/digests/mdc2_prov.c b/providers/implementations/digests/mdc2_prov.c similarity index 97% rename from providers/legacy/digests/mdc2_prov.c rename to providers/implementations/digests/mdc2_prov.c index cf37b528e7..f0ae8b3742 100644 --- a/providers/legacy/digests/mdc2_prov.c +++ b/providers/implementations/digests/mdc2_prov.c @@ -12,7 +12,7 @@ #include #include #include -#include "internal/digestcommon.h" +#include "prov/digestcommon.h" #include "internal/provider_algs.h" #include "internal/providercommonerr.h" diff --git a/providers/legacy/digests/ripemd_prov.c b/providers/implementations/digests/ripemd_prov.c similarity index 94% rename from providers/legacy/digests/ripemd_prov.c rename to providers/implementations/digests/ripemd_prov.c index 314b69a3fb..4f11f79e4c 100644 --- a/providers/legacy/digests/ripemd_prov.c +++ b/providers/implementations/digests/ripemd_prov.c @@ -9,7 +9,7 @@ #include #include -#include "internal/digestcommon.h" +#include "prov/digestcommon.h" #include "internal/provider_algs.h" /* ripemd160_functions */ diff --git a/providers/common/digests/sha2_prov.c b/providers/implementations/digests/sha2_prov.c similarity index 98% rename from providers/common/digests/sha2_prov.c rename to providers/implementations/digests/sha2_prov.c index d2c7df2ee6..3c07e784cf 100644 --- a/providers/common/digests/sha2_prov.c +++ b/providers/implementations/digests/sha2_prov.c @@ -14,7 +14,7 @@ #include #include #include -#include "internal/digestcommon.h" +#include "prov/digestcommon.h" #include "internal/provider_algs.h" #include "crypto/sha.h" diff --git a/providers/common/digests/sha3_prov.c b/providers/implementations/digests/sha3_prov.c similarity index 99% rename from providers/common/digests/sha3_prov.c rename to providers/implementations/digests/sha3_prov.c index 0563d0cfc1..5adc7b2976 100644 --- a/providers/common/digests/sha3_prov.c +++ b/providers/implementations/digests/sha3_prov.c @@ -14,7 +14,7 @@ #include #include #include "internal/sha3.h" -#include "internal/digestcommon.h" +#include "prov/digestcommon.h" #include "internal/provider_algs.h" #include "internal/providercommonerr.h" diff --git a/providers/default/digests/sm3_prov.c b/providers/implementations/digests/sm3_prov.c similarity index 94% rename from providers/default/digests/sm3_prov.c rename to providers/implementations/digests/sm3_prov.c index 512e3cb1c1..bd9d833184 100644 --- a/providers/default/digests/sm3_prov.c +++ b/providers/implementations/digests/sm3_prov.c @@ -9,7 +9,7 @@ #include #include "internal/sm3.h" -#include "internal/digestcommon.h" +#include "prov/digestcommon.h" #include "internal/provider_algs.h" /* sm3_functions */ diff --git a/providers/legacy/digests/wp_prov.c b/providers/implementations/digests/wp_prov.c similarity index 94% rename from providers/legacy/digests/wp_prov.c rename to providers/implementations/digests/wp_prov.c index eaa41b0af1..1dd5aa36e4 100644 --- a/providers/legacy/digests/wp_prov.c +++ b/providers/implementations/digests/wp_prov.c @@ -9,7 +9,7 @@ #include #include -#include "internal/digestcommon.h" +#include "prov/digestcommon.h" #include "internal/provider_algs.h" /* wp_functions */ diff --git a/providers/default/include/internal/blake2.h b/providers/implementations/include/prov/blake2.h similarity index 100% rename from providers/default/include/internal/blake2.h rename to providers/implementations/include/prov/blake2.h diff --git a/providers/default/include/internal/md5_sha1.h b/providers/implementations/include/prov/md5_sha1.h similarity index 100% rename from providers/default/include/internal/md5_sha1.h rename to providers/implementations/include/prov/md5_sha1.h diff --git a/providers/implementations/macs/blake2_mac_impl.c b/providers/implementations/macs/blake2_mac_impl.c index a190b91b98..a191e78def 100644 --- a/providers/implementations/macs/blake2_mac_impl.c +++ b/providers/implementations/macs/blake2_mac_impl.c @@ -11,7 +11,7 @@ #include #include -#include "internal/blake2.h" +#include "prov/blake2.h" #include "internal/cryptlib.h" #include "internal/providercommonerr.h" #include "internal/provider_algs.h" diff --git a/providers/legacy/build.info b/providers/legacy/build.info index 713c48dbe6..1236f15818 100644 --- a/providers/legacy/build.info +++ b/providers/legacy/build.info @@ -1,4 +1,3 @@ -SUBDIRS=digests IF[{- $disabled{module} -}] $GOAL=../../libcrypto ELSE diff --git a/providers/legacy/digests/build.info b/providers/legacy/digests/build.info deleted file mode 100644 index 4e1aeb6ddd..0000000000 --- a/providers/legacy/digests/build.info +++ /dev/null @@ -1,21 +0,0 @@ -$GOAL=../../liblegacy.a - -IF[{- !$disabled{md2} -}] - SOURCE[$GOAL]=md2_prov.c -ENDIF - -IF[{- !$disabled{md4} -}] - SOURCE[$GOAL]=md4_prov.c -ENDIF - -IF[{- !$disabled{mdc2} -}] - SOURCE[$GOAL]=mdc2_prov.c -ENDIF - -IF[{- !$disabled{whirlpool} -}] - SOURCE[$GOAL]=wp_prov.c -ENDIF - -IF[{- !$disabled{rmd160} -}] - SOURCE[$GOAL]=ripemd_prov.c -ENDIF -- 2.34.1