Rework how our providers are built
authorRichard Levitte <levitte@openssl.org>
Thu, 3 Oct 2019 23:38:17 +0000 (01:38 +0200)
committerRichard Levitte <levitte@openssl.org>
Thu, 10 Oct 2019 12:12:15 +0000 (14:12 +0200)
We put almost everything in these internal static libraries:

libcommon               Block building code that can be used by all
                        our implementations, legacy and non-legacy
                        alike.
libimplementations      All non-legacy algorithm implementations and
                        only them.  All the code that ends up here is
                        agnostic to the definitions of FIPS_MODE.
liblegacy               All legacy implementations.

libnonfips              Support code for the algorithm implementations.
                        Built with FIPS_MODE undefined.  Any code that
                        checks that FIPS_MODE isn't defined must end
                        up in this library.
libfips                 Support code for the algorithm implementations.
                        Built with FIPS_MODE defined.  Any code that
                        checks that FIPS_MODE is defined must end up
                        in this library.

The FIPS provider module is built from providers/fips/*.c and linked
with libimplementations, libcommon and libfips.

The Legacy provider module is built from providers/legacy/*.c and
linked with liblegacy, libcommon and libcrypto.
If module building is disabled, the object files from liblegacy and
libcommon are added to libcrypto and the Legacy provider becomes a
built-in provider.

The Default provider module is built-in, so it ends up being linked
with libimplementations, libcommon and libnonfips.  For libcrypto in
form of static library, the object files from those other libraries
are simply being added to libcrypto.

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/10088)

37 files changed:
crypto/aes/build.info
crypto/bn/build.info
crypto/buffer/build.info
crypto/build.info
crypto/cmac/build.info
crypto/des/build.info
crypto/ec/build.info
crypto/evp/build.info
crypto/hmac/build.info
crypto/lhash/build.info
crypto/modes/build.info
crypto/property/build.info
crypto/rand/build.info
crypto/sha/build.info
crypto/stack/build.info
providers/build.info
providers/common/build.info
providers/common/ciphers/build.info
providers/common/ciphers/cipher_aes_xts.c
providers/common/ciphers/cipher_aes_xts.h
providers/common/ciphers/cipher_fips.c [new file with mode: 0644]
providers/common/digests/build.info
providers/common/exchange/build.info
providers/common/kdfs/build.info
providers/common/kdfs/pbkdf2.c
providers/common/kdfs/pbkdf2.h [new file with mode: 0644]
providers/common/kdfs/pbkdf2_fips.c [new file with mode: 0644]
providers/common/keymgmt/build.info
providers/common/macs/build.info
providers/common/signature/build.info
providers/default/build.info
providers/default/ciphers/build.info
providers/default/digests/build.info
providers/default/kdfs/build.info
providers/default/macs/build.info
providers/fips/build.info
providers/legacy/digests/build.info

index aac88012b4c28e875ec53c1d32253ab060aad434..59c009761ebd7d9c812a7284bc191ad0a701efcc 100644 (file)
@@ -62,8 +62,8 @@ ENDIF
 $COMMON=aes_misc.c aes_ecb.c $AESASM
 SOURCE[../../libcrypto]=$COMMON aes_cfb.c aes_ofb.c aes_ige.c aes_wrap.c
 DEFINE[../../libcrypto]=$AESDEF
-SOURCE[../../providers/fips]=$COMMON
-DEFINE[../../providers/fips]=$AESDEF
+SOURCE[../../providers/libfips.a]=$COMMON
+DEFINE[../../providers/libfips.a]=$AESDEF
 
 GENERATE[aes-ia64.s]=asm/aes-ia64.S
 
index 18b5950f6d6b337d3a83e7c0a73063a4441bc9c7..75b84d0df6aa6ab0fc3710bf24854bd5fdf63f13 100644 (file)
@@ -109,8 +109,8 @@ $COMMON=bn_add.c bn_div.c bn_exp.c bn_lib.c bn_ctx.c bn_mul.c \
         bn_rsa_fips186_4.c $BNASM
 SOURCE[../../libcrypto]=$COMMON bn_print.c bn_err.c bn_depr.c bn_srp.c
 DEFINE[../../libcrypto]=$BNDEF
-SOURCE[../../providers/fips]=$COMMON
-DEFINE[../../providers/fips]=$BNDEF
+SOURCE[../../providers/libfips.a]=$COMMON
+DEFINE[../../providers/libfips.a]=$BNDEF
 
 INCLUDE[../../libcrypto]=../../crypto/include
 
index 63de1a570fa77eb89130ed548218e496f521c6f4..6f31397be722f100ab195505efa812cd78a0eb9c 100644 (file)
@@ -1,3 +1,3 @@
 LIBS=../../libcrypto
 SOURCE[../../libcrypto]=buffer.c buf_err.c
-SOURCE[../../providers/fips]=buffer.c
+SOURCE[../../providers/libfips.a]=buffer.c
index 5d3b123d69479d4934fe607b60aa8361219c4d64..f41ecf448f32302548f99b6f278ff89fe850beaa 100644 (file)
@@ -63,7 +63,7 @@ $CORE_COMMON=provider_core.c provider_predefined.c \
         core_fetch.c core_algorithm.c core_namemap.c
 
 SOURCE[../libcrypto]=$CORE_COMMON provider_conf.c
-SOURCE[../providers/fips]=$CORE_COMMON
+SOURCE[../providers/libfips.a]=$CORE_COMMON
 
 # Central utilities
 $UTIL_COMMON=\
@@ -78,8 +78,8 @@ SOURCE[../libcrypto]=$UTIL_COMMON \
         o_fopen.c getenv.c o_init.c o_fips.c init.c trace.c provider.c \
         $UPLINKSRC
 DEFINE[../libcrypto]=$UTIL_DEFINE $UPLINKDEF
-SOURCE[../providers/fips]=$UTIL_COMMON
-DEFINE[../providers/fips]=$UTIL_DEFINE
+SOURCE[../providers/libfips.a]=$UTIL_COMMON
+DEFINE[../providers/libfips.a]=$UTIL_DEFINE
 
 
 DEPEND[info.o]=buildinf.h
index f6c8bfabbcc11173333dc0dc550376d0ceec5425..a2f6f218c269ee3ccba3f63e8f4584318300f578 100644 (file)
@@ -3,4 +3,4 @@ LIBS=../../libcrypto
 $COMMON=cmac.c
 
 SOURCE[../../libcrypto]=$COMMON cm_ameth.c
-SOURCE[../../providers/fips]=$COMMON
+SOURCE[../../providers/libfips.a]=$COMMON
index 774bad754b01b6bd5a8779087488a3d40b0d79df..b1c1e624c2c9159e186e75d8ea85aac79c391f9b 100644 (file)
@@ -20,7 +20,7 @@ SOURCE[../../libcrypto]=$COMMON\
         ofb64ede.c ofb64enc.c ofb_enc.c \
         str2key.c  pcbc_enc.c qud_cksm.c rand_key.c \
         fcrypt.c xcbc_enc.c cbc_cksm.c
-SOURCE[../../providers/fips]=$COMMON
+SOURCE[../../providers/libfips.a]=$COMMON
 
 GENERATE[des_enc-sparc.S]=asm/des_enc.m4
 GENERATE[dest4-sparcv9.S]=asm/dest4-sparcv9.pl
index d140b5d64b87781fa577f8e8987b534bc3497244..40aef3679857dfcb55deea9ce22ddcbe65fadb6c 100644 (file)
@@ -57,8 +57,8 @@ $COMMON=ec_lib.c ecp_smpl.c ecp_mont.c ecp_nist.c ec_cvt.c ec_mult.c \
 SOURCE[../../libcrypto]=$COMMON ec_ameth.c ec_pmeth.c ecx_meth.c ec_err.c \
                         ecdh_kdf.c eck_prn.c
 DEFINE[../../libcrypto]=$ECDEF
-SOURCE[../../providers/fips]=$COMMON
-DEFINE[../../providers/fips]=$ECDEF
+SOURCE[../../providers/libfips.a]=$COMMON
+DEFINE[../../providers/libfips.a]=$ECDEF
 
 GENERATE[ecp_nistz256-x86.s]=asm/ecp_nistz256-x86.pl
 
index 9c71930c05acc379f200902363ed14157f7b87ab..94f033bbc189a8aa7b7ea4d88171bc0749958e40 100644 (file)
@@ -18,7 +18,7 @@ SOURCE[../../libcrypto]=$COMMON\
         e_chacha20_poly1305.c \
         pkey_mac.c exchange.c \
         legacy_sha.c legacy_md5_sha1.c
-SOURCE[../../providers/fips]=$COMMON
+SOURCE[../../providers/libfips.a]=$COMMON
 
 INCLUDE[e_aes.o]=.. ../modes
 INCLUDE[e_aes_cbc_hmac_sha1.o]=../modes
index 56ad67ef8f0ec1b4258be40e5a96c164309a03cf..4ed90c09f496fd524b024cc3b1e55d09258a911c 100644 (file)
@@ -3,4 +3,4 @@ LIBS=../../libcrypto
 $COMMON=hmac.c
 
 SOURCE[../../libcrypto]=$COMMON hm_ameth.c
-SOURCE[../../providers/fips]=$COMMON
+SOURCE[../../providers/libfips.a]=$COMMON
index 0aa12a1eb3eb1b70e13626592dfe74e56c61ccd1..b3176b8358d4cc5a729f62b706b9dd99382a3e41 100644 (file)
@@ -1,5 +1,5 @@
 LIBS=../../libcrypto
 SOURCE[../../libcrypto]=\
         lhash.c lh_stats.c
-SOURCE[../../providers/fips]=\
+SOURCE[../../providers/libfips.a]=\
         lhash.c
index 8a8aead651fe0d7eab8b5b2db67836477260995e..4ae0d8b01127e0f2fa6a2df2605f48553c1cf359 100644 (file)
@@ -54,8 +54,8 @@ SOURCE[../../libcrypto]=$COMMON \
         cts128.c ocb128.c siv128.c
 
 DEFINE[../../libcrypto]=$MODESDEF
-SOURCE[../../providers/fips]=$COMMON
-DEFINE[../../providers/fips]=$MODESDEF
+SOURCE[../../providers/libfips.a]=$COMMON
+DEFINE[../../providers/libfips.a]=$MODESDEF
 
 INCLUDE[gcm128.o]=..
 
index db3c9444986e70f5cbc412b2c9299674424b7574..bfa1f0602f92a8fcd593c935c9540b6747983ad7 100644 (file)
@@ -1,4 +1,4 @@
 LIBS=../../libcrypto
 $COMMON=property_string.c property_parse.c property.c defn_cache.c
 SOURCE[../../libcrypto]=$COMMON property_err.c
-SOURCE[../../providers/fips]=$COMMON
+SOURCE[../../providers/libfips.a]=$COMMON
index 3e0a9c7432086cd2a7f39ec0da9720371687c506..0925c4b2de9e6c5a833692305eaafe50a0b9c3fb 100644 (file)
@@ -4,4 +4,4 @@ $COMMON=rand_lib.c rand_crng_test.c rand_win.c rand_unix.c  rand_vms.c \
         drbg_lib.c drbg_ctr.c rand_vxworks.c drbg_hash.c drbg_hmac.c
 
 SOURCE[../../libcrypto]=$COMMON randfile.c rand_err.c rand_egd.c
-SOURCE[../../providers/fips]=$COMMON
+SOURCE[../../providers/libfips.a]=$COMMON
index 67d9fd4723f3c57ea5b6d105bb11bb304a67630d..25c64a0e2c5e58b6960a9692172c323abb0cdb23 100644 (file)
@@ -76,8 +76,8 @@ ENDIF
 $COMMON=sha1dgst.c sha256.c sha512.c sha3.c $SHA1ASM $KECCAK1600ASM
 SOURCE[../../libcrypto]=$COMMON sha1_one.c
 DEFINE[../../libcrypto]=$SHA1DEF $KECCAK1600DEF
-SOURCE[../../providers/fips]= $COMMON
-DEFINE[../../providers/fips]= $SHA1DEF $KECCAK1600DEF
+SOURCE[../../providers/libfips.a]= $COMMON
+DEFINE[../../providers/libfips.a]= $SHA1DEF $KECCAK1600DEF
 
 GENERATE[sha1-586.s]=asm/sha1-586.pl
 DEPEND[sha1-586.s]=../perlasm/x86asm.pl
index e4183e089c9e142d34dde1895c90d323a0704f70..23d83a6f111b512208b52b29b473780bcc430c6e 100644 (file)
@@ -1,3 +1,3 @@
 LIBS=../../libcrypto
 SOURCE[../../libcrypto]=stack.c
-SOURCE[../../providers/fips]=stack.c
+SOURCE[../../providers/libfips.a]=stack.c
index 80b2952494a1850952a7582e6064afb5d4aef59d..e951c6229db65fe2f23d0a99fda3d7fef75b3545 100644 (file)
+# We place all implementations in static libraries, and then let the
+# provider mains pilfer what they want through symbol resolution when
+# linking.
+#
+# The non-legacy implementations (libimplementations) must be made FIPS
+# agnostic as much as possible, as well as the common building blocks
+# (libcommon).  The legacy implementations (liblegacy) will never be
+# part of the FIPS provider.
+#
+# If there is anything that isn't FIPS agnostic, it should be set aside
+# in its own source file, which is then included directly into other
+# static libraries geared for FIPS and non-FIPS providers, and built
+# separately.
+#
+# libcommon.a           Contains common building blocks, potentially
+#                       needed both by non-legacy and legacy code.
+#
+# libimplementations.a  Contains all non-legacy implementations.
+# liblegacy.a           Contains all legacy implementaions.
+#
+# libfips.a             Contains all things needed to support
+#                       FIPS implementations, such as code from
+#                       crypto/ and object files that contain
+#                       FIPS-specific code.  FIPS_MODE is defined
+#                       for this library.  The FIPS module uses
+#                       this.
+# libnonfips.a          Corresponds to libfips.a, but built with
+#                       FIPS_MODE undefined.  The default and legacy
+#                       providers use this.
+
 SUBDIRS=common default
 
 INCLUDE[../libcrypto]=common/include
 
+# Libraries we're dealing with
+$LIBCOMMON=libcommon.a
+$LIBIMPLEMENTATIONS=libimplementations.a
+$LIBLEGACY=liblegacy.a
+$LIBNONFIPS=libnonfips.a
+$LIBFIPS=libfips.a
+
+# Enough of our implementations include prov/ciphercommon.h (present in
+# providers/common/include), which includes crypto/ciphermode_platform.h
+# (present in include), which in turn may include very internal header
+# files in crypto/, so let's have a common include list for them all.
+$COMMON_INCLUDES=../crypto ../include common/include
+
+INCLUDE[$LIBCOMMON]=$COMMON_INCLUDES
+INCLUDE[$LIBIMPLEMENTATIONS]=.. $COMMON_INCLUDES default/include
+INCLUDE[$LIBLEGACY]=$COMMON_INCLUDES
+INCLUDE[$LIBNONFIPS]=$COMMON_INCLUDES
+INCLUDE[$LIBFIPS]=.. $COMMON_INCLUDES
+DEFINE[$LIBFIPS]=FIPS_MODE
+
+# Weak dependencies to provide library order information.
+# We make it weak so they aren't both used always; what is
+# actually used is determined by non-weak dependencies.
+DEPEND[$LIBIMPLEMENTATIONS]{weak}=$LIBFIPS $LIBNONFIPS
+DEPEND[$LIBCOMMON]{weak}=$LIBFIPS
+
+# Strong dependencies.  This ensures that any time libimplementations
+# is used, libcommon gets included as well.
+DEPEND[$LIBIMPLEMENTATIONS]=$LIBCOMMON
+DEPEND[$LIBNONFIPS]=../libcrypto
+# It's tempting to make libcommon depend on ../libcrypto.  However,
+# since the FIPS provider module must NOT depend on ../libcrypto, we
+# need to set that dependency up specifically for the final products
+# that use $LIBCOMMON or anything that depends on it.
+
+# Libraries common to all providers, must be built regardless
+LIBS{noinst}=$LIBCOMMON
+# Libraries that are common for all non-FIPS providers, must be built regardless
+LIBS{noinst}=$LIBNONFIPS $LIBIMPLEMENTATIONS
+
+#
+# Default provider stuff
+#
+# Because the default provider is built in, it means that libcrypto must
+# include all the object files that are needed (we do that indirectly,
+# by using the appropriate libraries as source).  Note that for shared
+# libraries, SOURCEd libraries are considered as if the where specified
+# with DEPEND.
+$DEFAULTGOAL=../libcrypto
+SOURCE[$DEFAULTGOAL]=$LIBIMPLEMENTATIONS $LIBNONFIPS
+
+LIBS=$DEFAULTGOAL
+
+#
+# FIPS provider stuff
+#
+# We define it this way to ensure that configdata.pm will have all the
+# necessary information even if we don't build the module.  This will allow
+# us to make all kinds of checks on the source, based on what we specify in
+# diverse build.info files.  libfips.a, fips.so and their sources aren't
+# built unless the proper LIBS or MODULES statement has been seen, so we
+# have those and only those within a condition.
+SUBDIRS=fips
+$FIPSGOAL=fips
+DEPEND[$FIPSGOAL]=$LIBIMPLEMENTATIONS $LIBFIPS
+INCLUDE[$FIPSGOAL]=../include
+IF[{- defined $target{shared_defflag} -}]
+  SOURCE[$FIPSGOAL]=fips.ld
+  GENERATE[fips.ld]=../util/providers.num
+ENDIF
+
 IF[{- !$disabled{fips} -}]
-  SUBDIRS=fips
-  MODULES=fips
-  IF[{- defined $target{shared_defflag} -}]
-    SOURCE[fips]=fips.ld
-    GENERATE[fips.ld]=../util/providers.num
-  ENDIF
-  INCLUDE[fips]=.. ../include common/include
-  DEFINE[fips]=FIPS_MODE
+  # This is the trigger to actually build the FIPS module.  Without these
+  # statements, the final build file will not have a trace of it.
+  MODULES=$FIPSGOAL
+  LIBS{noinst}=$LIBFIPS
 ENDIF
 
+#
+# Legacy provider stuff
+#
 IF[{- !$disabled{legacy} -}]
+  # The legacy implementation library
   SUBDIRS=legacy
+  LIBS{noinst}=$LIBLEGACY
+  DEPEND[$LIBLEGACY]=$LIBCOMMON $LIBNONFIPS
+
+  # The Legacy provider
   IF[{- $disabled{module} -}]
-    LIBS=../libcrypto
-    DEFINE[../libcrypto]=STATIC_LEGACY
+    # Become built in
+    # In this case, we need to do the same thing a for the default provider,
+    # and make the liblegacy object files end up in libcrypto.  We could also
+    # just say that for the built-in legacy, we put the source directly in
+    # libcrypto instead of going via liblegacy, but that makes writing the
+    # implementation specific build.info files harder to write, so we don't.
+    $LEGACYGOAL=../libcrypto
+    SOURCE[$LEGACYGOAL]=$LIBLEGACY
+    DEFINE[$LIBLEGACY]=STATIC_LEGACY
+    DEFINE[$LEGACYGOAL]=STATIC_LEGACY
   ELSE
-    MODULES=legacy
+    # Become a module
+    # In this case, we can work with dependencies
+    $LEGACYGOAL=legacy
+    MODULES=$LEGACYGOAL
+    DEPEND[$LEGACYGOAL]=$LIBLEGACY
     IF[{- defined $target{shared_defflag} -}]
       SOURCE[legacy]=legacy.ld
       GENERATE[legacy.ld]=../util/providers.num
     ENDIF
-    DEPEND[legacy]=../libcrypto
-    INCLUDE[legacy]=.. ../include common/include
   ENDIF
+
+  # Common things that are valid no matter what form the Legacy provider
+  # takes.
+  INCLUDE[$LEGACYGOAL]=../include common/include
 ENDIF
+
index 916cc3e4eafaee45375c0545e7ac565d1c966d1c..95c2fd107e22e301c65d0dc5912f3daef55486f5 100644 (file)
@@ -1,5 +1,6 @@
 SUBDIRS=digests ciphers macs kdfs exchange keymgmt signature
-$COMMON=provider_util.c
 
-SOURCE[../../libcrypto]=$COMMON provider_err.c provlib.c
-SOURCE[../fips]=$COMMON
+SOURCE[../libcommon.a]=provider_err.c provlib.c
+$FIPSCOMMON=provider_util.c
+SOURCE[../libnonfips.a]=$FIPSCOMMON
+SOURCE[../libfips.a]=$FIPSCOMMON
index 0969e6d3786935c6ec14709f945f239d25d5dd02..77376cce1e4d8632116cecd7463a66a1ec4d0fde 100644 (file)
@@ -1,21 +1,26 @@
-LIBS=../../../libcrypto
+# This source is common building blockss for all ciphers in all our providers.
+SOURCE[../../libcommon.a]=\
+        cipher_common.c cipher_common_hw.c block.c \
+        cipher_gcm.c cipher_gcm_hw.c \
+        cipher_ccm.c cipher_ccm_hw.c
+
+# These are our implementations
+$GOAL=../../libimplementations.a
 
 IF[{- !$disabled{des} -}]
   $COMMON_DES=cipher_tdes.c cipher_tdes_hw.c
 ENDIF
 
-$COMMON=cipher_common.c cipher_common_hw.c block.c \
+SOURCE[$GOAL]=\
         cipher_aes.c cipher_aes_hw.c \
         cipher_aes_xts.c cipher_aes_xts_hw.c \
-        cipher_gcm.c cipher_gcm_hw.c \
         cipher_aes_gcm.c cipher_aes_gcm_hw.c \
-        cipher_ccm.c cipher_ccm_hw.c \
         cipher_aes_ccm.c cipher_aes_ccm_hw.c \
         cipher_aes_wrp.c \
         $COMMON_DES
-        
-SOURCE[../../../libcrypto]=$COMMON
-INCLUDE[../../../libcrypto]=. ../../../crypto
+# Because some default ciphers need it
+INCLUDE[$GOAL]=.
 
-SOURCE[../../fips]=$COMMON
-INCLUDE[../../fips]=. ../../../crypto
+# Finally, we have a few things that aren't FIPS agnostic
+SOURCE[../../libfips.a]=cipher_fips.c
+SOURCE[../../libnonfips.a]=cipher_fips.c
index fdda733d24124906ed59002c2ad9ba943d0dafb5..d0b999081e993185a440ac67041b82174c5e5c25 100644 (file)
 #define AES_XTS_IV_BITS 128
 #define AES_XTS_BLOCK_BITS 8
 
-#ifdef FIPS_MODE
-static const int allow_insecure_decrypt = 0;
-#else
-static const int allow_insecure_decrypt = 1;
-#endif /* FIPS_MODE */
-
 /* forward declarations */
 static OSSL_OP_cipher_encrypt_init_fn aes_xts_einit;
 static OSSL_OP_cipher_decrypt_init_fn aes_xts_dinit;
index 4f8a8f874f27795980440e3739fb0ba7c1c886a5..16fb8c34cde4ee5fb2b9bed625b7c8dbfc818463 100644 (file)
 #include <openssl/aes.h>
 #include "internal/ciphers/ciphercommon.h"
 
+/*
+ * Available in cipher_fips.c, and compiled with different values depending
+ * on we're in the FIPS module or not.
+ */
+extern const int allow_insecure_decrypt;
+
 PROV_CIPHER_FUNC(void, xts_stream,
                  (const unsigned char *in, unsigned char *out, size_t len,
                   const AES_KEY *key1, const AES_KEY *key2,
diff --git a/providers/common/ciphers/cipher_fips.c b/providers/common/ciphers/cipher_fips.c
new file mode 100644 (file)
index 0000000..c99d6ed
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright 2019 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
+ */
+
+#include "cipher_aes_xts.h"
+
+#ifdef FIPS_MODE
+const int allow_insecure_decrypt = 0;
+#else
+const int allow_insecure_decrypt = 1;
+#endif /* FIPS_MODE */
index fbbce36e875aedacec733a735174fda2a4ab1d4a..2a8e8aa3975d3039e55aa53386897c9f3b8f2e75 100644 (file)
@@ -1,5 +1,7 @@
-$COMMON=sha2_prov.c sha3_prov.c digest_common.c
+# This source is common for all digests in all our providers.
+SOURCE[../../libcommon.a]=digest_common.c
 
-SOURCE[../../../libcrypto]=$COMMON
-SOURCE[../../fips]=$COMMON
-SOURCE[../../legacy]= digest_common.c
+# These are our implementations
+$GOAL=../../libimplementations.a
+
+SOURCE[$GOAL]=sha2_prov.c sha3_prov.c
index c99c9d81b52c6d5ac8324cbe7af6f0ef7544d1c9..90ea0c9a026db19482cf23d0dbcd06626f28bce6 100644 (file)
@@ -1,7 +1,5 @@
-LIBS=../../../libcrypto
+$GOAL=../../libimplementations.a
+
 IF[{- !$disabled{dh} -}]
-  SOURCE[../../../libcrypto]=\
-          dh_exch.c
+  SOURCE[$GOAL]=dh_exch.c
 ENDIF
-
-
index 8a723d488d2f0d9e40d8bb6043e41f27a50aaa7b..b2b354dc34102c200deb00d9d63b59d5897d5c91 100644 (file)
@@ -1,13 +1,5 @@
-$COMMON=tls1_prf.c hkdf.c kbkdf.c pbkdf2.c sskdf.c
+$GOAL=../../libimplementations.a
 
-LIBS=../../../libcrypto
-SOURCE[../../../libcrypto]=$COMMON
-INCLUDE[../../../libcrypto]=. ../../../crypto
-
-IF[{- !$disabled{fips} -}]
-  MODULES=../../fips
-  SOURCE[../../fips]=$COMMON
-  INCLUDE[../../fips]=. ../../../crypto
-ENDIF
-
-        
+SOURCE[$GOAL]=tls1_prf.c hkdf.c kbkdf.c pbkdf2.c sskdf.c
+SOURCE[../../libfips.a]=pbkdf2_fips.c
+SOURCE[../../libnonfips.a]=pbkdf2_fips.c
index b98123b8729cadc26f1c637c66df3ffd6b7eb1dd..68aa0aa7c42779bcfe59fcfffa8a66532dce8d2d 100644 (file)
 #include "internal/providercommonerr.h"
 #include "internal/provider_algs.h"
 #include "internal/provider_util.h"
+#include "pbkdf2.h"
 
 /* Constants specified in SP800-132 */
 #define KDF_PBKDF2_MIN_KEY_LEN_BITS  112
 #define KDF_PBKDF2_MAX_KEY_LEN_DIGEST_RATIO 0xFFFFFFFF
 #define KDF_PBKDF2_MIN_ITERATIONS 1000
 #define KDF_PBKDF2_MIN_SALT_LEN   (128 / 8)
-/*
- * For backwards compatibility reasons,
- * Extra checks are done by default in fips mode only.
- */
-#ifdef FIPS_MODE
-# define KDF_PBKDF2_DEFAULT_CHECKS 1
-#else
-# define KDF_PBKDF2_DEFAULT_CHECKS 0
-#endif /* FIPS_MODE */
 
 static OSSL_OP_kdf_newctx_fn kdf_pbkdf2_new;
 static OSSL_OP_kdf_freectx_fn kdf_pbkdf2_free;
@@ -111,7 +103,7 @@ static void kdf_pbkdf2_init(KDF_PBKDF2 *ctx)
         /* This is an error, but there is no way to indicate such directly */
         ossl_prov_digest_reset(&ctx->digest);
     ctx->iter = PKCS5_DEFAULT_ITER;
-    ctx->lower_bound_checks = KDF_PBKDF2_DEFAULT_CHECKS;
+    ctx->lower_bound_checks = kdf_pbkdf2_default_checks;
 }
 
 static int pbkdf2_set_membuf(unsigned char **buffer, size_t *buflen,
diff --git a/providers/common/kdfs/pbkdf2.h b/providers/common/kdfs/pbkdf2.h
new file mode 100644 (file)
index 0000000..c8c2e5b
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * Copyright 2019 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
+ */
+
+/*
+ * Available in pbkdfe_fips.c, and compiled with different values depending
+ * on we're in the FIPS module or not.
+ */
+extern const int kdf_pbkdf2_default_checks;
diff --git a/providers/common/kdfs/pbkdf2_fips.c b/providers/common/kdfs/pbkdf2_fips.c
new file mode 100644 (file)
index 0000000..d33782b
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2019 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
+ */
+
+#include "pbkdf2.h"
+
+/*
+ * For backwards compatibility reasons,
+ * Extra checks are done by default in fips mode only.
+ */
+#ifdef FIPS_MODE
+const int kdf_pbkdf2_default_checks = 1;
+#else
+const int kdf_pbkdf2_default_checks = 0;
+#endif /* FIPS_MODE */
index e66190c401cd2e18e270857a3eb4b893b785fcd0..533c4890777813bdbb0f7ea265a6d3d3e7a0b447 100644 (file)
@@ -1,9 +1,8 @@
-LIBS=../../../libcrypto
+$GOAL=../../libimplementations.a
+
 IF[{- !$disabled{dh} -}]
-  SOURCE[../../../libcrypto]=\
-          dh_kmgmt.c
+  SOURCE[$GOAL]=dh_kmgmt.c
 ENDIF
 IF[{- !$disabled{dsa} -}]
-  SOURCE[../../../libcrypto]=\
-          dsa_kmgmt.c
+  SOURCE[$GOAL]=dsa_kmgmt.c
 ENDIF
index 832a1e76ecfc5051c17b2889055b12f0079644de..1eafe70604361d260e03b996498e1823a252847d 100644 (file)
@@ -1,15 +1,9 @@
+$GOAL=../../libimplementations.a
+
 $COMMON=gmac_prov.c hmac_prov.c kmac_prov.c
 
 IF[{- !$disabled{cmac} -}]
   $COMMON=$COMMON cmac_prov.c
 ENDIF
 
-LIBS=../../../libcrypto
-SOURCE[../../../libcrypto]=$COMMON
-INCLUDE[../../../libcrypto]=. ../../../crypto
-
-IF[{- !$disabled{fips} -}]
-  MODULES=../../fips
-  SOURCE[../../fips]=$COMMON
-  INCLUDE[../../fips]=. ../../../crypto
-ENDIF
+SOURCE[$GOAL]=$COMMON
index 5b64229dfc5d0b9de9f513f65e0fc5ce11b16b14..496fb7d7d866c5766775d69bad1af7d83733714c 100644 (file)
@@ -1,7 +1,7 @@
-LIBS=../../../libcrypto
+$GOAL=../../libimplementations.a
+
 IF[{- !$disabled{dsa} -}]
-  SOURCE[../../../libcrypto]=\
-          dsa.c
+  SOURCE[$GOAL]=dsa.c
 ENDIF
 
 
index ca78cce0a827d374f7c26bc35a8b489044b02abb..31ae5079653c12a7832d6bf05a306576ce6fa73f 100644 (file)
@@ -1,6 +1,4 @@
-SUBDIRS=digests macs ciphers
 SUBDIRS=digests kdfs macs ciphers
-LIBS=../../libcrypto
-SOURCE[../../libcrypto]=\
-        defltprov.c
-INCLUDE[../../libcrypto]=include
+$GOAL=../../libcrypto
+SOURCE[$GOAL]=defltprov.c
+INCLUDE[$GOAL]=include
index 5142357c7eccd344a82a659fe4d986196b50e203..044078957323026c4896a1641a7ee4a4e7f35e54 100644 (file)
@@ -1,7 +1,7 @@
-LIBS=../../../libcrypto
+$GOAL=../../libimplementations.a
 
 IF[{- !$disabled{des} -}]
-  SOURCE[../../../libcrypto]=\
+  SOURCE[$GOAL]=\
       cipher_tdes_default.c cipher_tdes_default_hw.c \
       cipher_tdes_wrap.c cipher_tdes_wrap_hw.c \
       cipher_desx.c cipher_desx_hw.c \
@@ -9,59 +9,59 @@ IF[{- !$disabled{des} -}]
 ENDIF
 
 IF[{- !$disabled{aria} -}]
-  SOURCE[../../../libcrypto]=\
+  SOURCE[$GOAL]=\
       cipher_aria.c cipher_aria_hw.c \
       cipher_aria_gcm.c cipher_aria_gcm_hw.c \
       cipher_aria_ccm.c cipher_aria_ccm_hw.c
 ENDIF
 
 IF[{- !$disabled{camellia} -}]
-  SOURCE[../../../libcrypto]=\
+  SOURCE[$GOAL]=\
       cipher_camellia.c cipher_camellia_hw.c
 ENDIF
 
 IF[{- !$disabled{bf} -}]
-  SOURCE[../../../libcrypto]=\
+  SOURCE[$GOAL]=\
       cipher_blowfish.c cipher_blowfish_hw.c
 ENDIF
 
 IF[{- !$disabled{idea} -}]
-  SOURCE[../../../libcrypto]=\
+  SOURCE[$GOAL]=\
       cipher_idea.c cipher_idea_hw.c
 ENDIF
 
 IF[{- !$disabled{cast} -}]
-  SOURCE[../../../libcrypto]=\
+  SOURCE[$GOAL]=\
       cipher_cast5.c cipher_cast5_hw.c
 ENDIF
 
 IF[{- !$disabled{seed} -}]
-  SOURCE[../../../libcrypto]=\
+  SOURCE[$GOAL]=\
       cipher_seed.c cipher_seed_hw.c
 ENDIF
 
 IF[{- !$disabled{sm4} -}]
-  SOURCE[../../../libcrypto]=\
+  SOURCE[$GOAL]=\
       cipher_sm4.c cipher_sm4_hw.c
 ENDIF
 
 IF[{- !$disabled{ocb} -}]
-  SOURCE[../../../libcrypto]=\
+  SOURCE[$GOAL]=\
        cipher_aes_ocb.c cipher_aes_ocb_hw.c
 ENDIF
 
 IF[{- !$disabled{rc4} -}]
-  SOURCE[../../../libcrypto]=\
+  SOURCE[$GOAL]=\
       cipher_rc4.c cipher_rc4_hw.c
 ENDIF
 
 IF[{- !$disabled{rc5} -}]
-  SOURCE[../../../libcrypto]=\
+  SOURCE[$GOAL]=\
       cipher_rc5.c cipher_rc5_hw.c
 ENDIF
 
 IF[{- !$disabled{rc2} -}]
-  SOURCE[../../../libcrypto]=\
+  SOURCE[$GOAL]=\
       cipher_rc2.c cipher_rc2_hw.c
 ENDIF
 
index 9d61229ae7d38fda1ca85e0f50b44dc526fd9fe7..6869657ec96804d997e5ff7a2a7ef4e21b6840f5 100644 (file)
@@ -1,15 +1,16 @@
+$GOAL=../../libimplementations.a
 
 IF[{- !$disabled{blake2} -}]
-  SOURCE[../../../libcrypto]=\
+  SOURCE[$GOAL]=\
           blake2_prov.c blake2b_prov.c blake2s_prov.c
 ENDIF
 
 IF[{- !$disabled{sm3} -}]
-  SOURCE[../../../libcrypto]=\
+  SOURCE[$GOAL]=\
           sm3_prov.c
 ENDIF
 
 IF[{- !$disabled{md5} -}]
-  SOURCE[../../../libcrypto]=\
+  SOURCE[$GOAL]=\
           md5_prov.c md5_sha1_prov.c
 ENDIF
index 27047c5286119020dfdb0f37f4d3ec8d7dac32db..90b127d73126ad025981f88d69e970a41ad4b0ae 100644 (file)
@@ -1,3 +1,2 @@
-LIBS=../../../libcrypto
-SOURCE[../../../libcrypto]=scrypt.c sshkdf.c x942kdf.c
-INCLUDE[../../../libcrypto]=. ../../../crypto
+$GOAL=../../libimplementations.a
+SOURCE[$GOAL]=scrypt.c sshkdf.c x942kdf.c
index fa7f5e479a791574331f79c49a4b6aed99ef6148..821a3d467bf8bb2b198bd53eb1e64ed8adffd26b 100644 (file)
@@ -1,15 +1,13 @@
-LIBS=../../../libcrypto
+$GOAL=../../libimplementations.a
 
 IF[{- !$disabled{blake2} -}]
-  SOURCE[../../../libcrypto]=blake2b_mac.c blake2s_mac.c
+  SOURCE[$GOAL]=blake2b_mac.c blake2s_mac.c
 ENDIF
 
 IF[{- !$disabled{siphash} -}]
-  SOURCE[../../../libcrypto]=siphash_prov.c
+  SOURCE[$GOAL]=siphash_prov.c
 ENDIF
 
 IF[{- !$disabled{poly1305} -}]
-  SOURCE[../../../libcrypto]=poly1305_prov.c
+  SOURCE[$GOAL]=poly1305_prov.c
 ENDIF
-
-INCLUDE[../../../libcrypto]=. ../../../crypto
index 9b8effa85c4299ef5187a8922cde198658287799..829d8ef3eafec237c453e6fb3a47ffb450e1cb23 100644 (file)
@@ -1,2 +1,3 @@
 
 SOURCE[../fips]=fipsprov.c selftest.c
+INCLUDE[../fips]=../common/include
\ No newline at end of file
index 2c85970ddec11d33a3f70504a3184e56d5449cfe..4e1aeb6dddc747c899f757f68ac40b8d486bf945 100644 (file)
@@ -1,30 +1,21 @@
-IF[{- $disabled{module} -}]
-  $GOAL=../../../libcrypto
-ELSE
-  $GOAL=../../legacy
-ENDIF
+$GOAL=../../liblegacy.a
 
 IF[{- !$disabled{md2} -}]
-  SOURCE[$GOAL]=\
-          md2_prov.c
+  SOURCE[$GOAL]=md2_prov.c
 ENDIF
 
 IF[{- !$disabled{md4} -}]
-  SOURCE[$GOAL]=\
-          md4_prov.c
+  SOURCE[$GOAL]=md4_prov.c
 ENDIF
 
 IF[{- !$disabled{mdc2} -}]
-  SOURCE[$GOAL]=\
-          mdc2_prov.c
+  SOURCE[$GOAL]=mdc2_prov.c
 ENDIF
 
 IF[{- !$disabled{whirlpool} -}]
-  SOURCE[$GOAL]=\
-          wp_prov.c
+  SOURCE[$GOAL]=wp_prov.c
 ENDIF
 
 IF[{- !$disabled{rmd160} -}]
-  SOURCE[$GOAL]=\
-          ripemd_prov.c
-ENDIF
\ No newline at end of file
+  SOURCE[$GOAL]=ripemd_prov.c
+ENDIF