]> git.saurik.com Git - apple/xnu.git/blobdiff - EXTERNAL_HEADERS/corecrypto/cc_config.h
xnu-7195.101.1.tar.gz
[apple/xnu.git] / EXTERNAL_HEADERS / corecrypto / cc_config.h
index 464f32b1822165134661e837cd057e94e6bb6f95..2ce76e2bd454c73b393ee443a34d651276b99dee 100644 (file)
@@ -1,20 +1,21 @@
-/*
- *  cc_config.h
- *  corecrypto
- *
- *  Created on 11/16/2010
- *
- *  Copyright (c) 2010,2011,2012,2013,2014,2015 Apple Inc. All rights reserved.
+/* Copyright (c) (2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020) Apple Inc. All rights reserved.
  *
+ * corecrypto is licensed under Apple Inc.’s Internal Use License Agreement (which
+ * is contained in the License.txt file distributed with corecrypto) and only to 
+ * people who accept that license. IMPORTANT:  Any license rights granted to you by 
+ * Apple Inc. (if any) are limited to internal use within your organization only on 
+ * devices and computers you own or control, for the sole purpose of verifying the 
+ * security characteristics and correct functioning of the Apple Software.  You may 
+ * not, directly or indirectly, redistribute the Apple Software or any portions thereof.
  */
 
 #ifndef _CORECRYPTO_CC_CONFIG_H_
 #define _CORECRYPTO_CC_CONFIG_H_
 
 /* A word about configuration macros:
+
     Conditional configuration macros specific to corecrypto should be named CORECRYPTO_xxx
-    or CCxx_yyy and be defined to be either 0 or 1 in this file. You can add an 
+    or CCxx_yyy and be defined to be either 0 or 1 in this file. You can add an
     #ifndef #error construct at the end of this file to make sure it's always defined.
 
     They should always be tested using the #if directive, never the #ifdef directive.
 
     Configuration Macros that are defined outside of corecrypto (eg: KERNEL, DEBUG, ...)
     shall only be used in this file to define CCxxx macros.
+
     External macros should be assumed to be either undefined, defined with no value,
     or defined as true or false. We shall strive to build with -Wundef whenever possible,
     so the following construct should be used to test external macros in this file:
-  
+
          #if defined(DEBUG) && (DEBUG)
          #define CORECRYPTO_DEBUG 1
          #else
          #define CORECRYPTO_DEBUG 0
          #endif
-  
+
 
     It is acceptable to define a conditional CC_xxxx macro in an implementation file,
     to be used only in this file.
+
     The current code is not guaranteed to follow those rules, but should be fixed to.
+
     Corecrypto requires GNU and C99 compatibility.
     Typically enabled by passing --gnu --c99 to the compiler (eg. armcc)
 
 */
 
-//Do not set these macros to 1, unless you are developing/testing for Windows
-#define CORECRYPTO_SIMULATE_WINDOWS_ENVIRONMENT 0
-#define CORECRYPTO_HACK_FOR_WINDOWS_DEVELOPMENT 0 //to be removed after <rdar://problem/26585938> port corecrypto to Windows
+//Do not set this macros to 1, unless you are developing/testing for Linux under macOS
+#define CORECRYPTO_SIMULATE_POSIX_ENVIRONMENT    0
 
-//this macro is used to turn on/off usage of transparent union in corecrypto
-//it should be commented out in corecrypto and be used only by the software that use corecrypto
-//#define CORECRYPTO_DONOT_USE_TRANSPARENT_UNION
-#ifdef CORECRYPTO_DONOT_USE_TRANSPARENT_UNION
- #define CORECRYPTO_USE_TRANSPARENT_UNION 0
-#else
- #define CORECRYPTO_USE_TRANSPARENT_UNION 1
-#endif
+//Do not set these macros to 1, unless you are developing/testing for Windows under macOS
+#define CORECRYPTO_SIMULATE_WINDOWS_ENVIRONMENT 0
+#define CORECRYPTO_HACK_FOR_WINDOWS_DEVELOPMENT 0
 
 #if (defined(DEBUG) && (DEBUG)) || defined(_DEBUG) //MSVC defines _DEBUG
 /* CC_DEBUG is already used in CommonCrypto */
  #define CC_KERNEL 0
 #endif
 
-// LINUX_BUILD_TEST is for sanity check of the configuration
-// > xcodebuild -scheme "corecrypto_test" OTHER_CFLAGS="$(values) -DLINUX_BUILD_TEST"
-#if defined(__linux__) || defined(LINUX_BUILD_TEST)
+#if defined(LINUX_SGX) && (LINUX_SGX)
+ #define CC_SGX 1
+#else
+ #define CC_SGX 0
+#endif
+
+#if (defined(__linux__) && !(CC_SGX)) || CORECRYPTO_SIMULATE_POSIX_ENVIRONMENT
  #define CC_LINUX 1
 #else
  #define CC_LINUX 0
 #endif
 
+#if defined(__ANDROID__) && (__ANDROID__)
+ #define CC_ANDROID 1
+#else
+ #define CC_ANDROID 0
+#endif
+
 #if defined(USE_L4) && (USE_L4)
  #define CC_USE_L4 1
 #else
  #define CC_USE_L4 0
 #endif
 
+#if defined(RTKIT) && (RTKIT)
+ #define CC_RTKIT 1
+#else
+ #define CC_RTKIT 0
+#endif
+
+#if defined(RTKITROM) && (RTKITROM)
+#define CC_RTKITROM 1
+#else
+#define CC_RTKITROM 0
+#endif
+
 #if defined(USE_SEPROM) && (USE_SEPROM)
  #define CC_USE_SEPROM 1
 #else
  #define CC_IBOOT 0
 #endif
 
-// BB configuration
+#if defined(TARGET_OS_BRIDGE)
+ #define CC_BRIDGE TARGET_OS_BRIDGE
+#else
+ #define CC_BRIDGE 0
+#endif
+
+// Check if we're running on a generic, userspace platform, i.e., not in the kernel, SEP, etc.
+#ifndef CC_GENERIC_PLATFORM
+  #define CC_GENERIC_PLATFORM \
+            (!CC_RTKIT && !CC_KERNEL && !CC_USE_L4 && \
+             !CC_RTKITROM && !CC_EFI && !CC_IBOOT &&  \
+             !CC_USE_SEPROM && !CC_ANDROID && !CC_LINUX && \
+             !CC_BRIDGE)
+#endif
+
+// Check for availability of internal Darwin SPIs.
+#ifndef CC_DARWIN_SPIS_AVAILABLE
+  #if defined(__has_include)
+    #define CC_DARWIN_SPIS_AVAILABLE __has_include(<os/log_private.h>)
+  #else
+    #define CC_DARWIN_SPIS_AVAILABLE 0
+  #endif
+#endif
+
+// Check for open source builds
+
+// ccringbuffer availability
+// Only enable the ccringbuffer data structure in generic, userspace builds where memory allocation is not an issue.
+#ifndef CC_RINGBUFFER_AVAILABLE
+  #define CC_RINGBUFFER_AVAILABLE (CC_GENERIC_PLATFORM && CC_DARWIN_SPIS_AVAILABLE && !CC_OPEN_SOURCE)
+#endif
+
+// os_log integration
+// Only enable logging support in generic, userspace builds with the desired Darwin SPIs.
+#ifndef CC_LOGGING_AVAILABLE
+  #define CC_LOGGING_AVAILABLE (CC_GENERIC_PLATFORM && CC_DARWIN_SPIS_AVAILABLE && !CC_OPEN_SOURCE)
+#endif
+
+// FeatureFlag integration
+// Only enable feature flag support in generic, userspace builds with the desired Darwin SPIs.
+// This requires linking against libsystem_featureflags to function correctly.
+#ifndef CC_FEATURE_FLAGS_AVAILABLE
+  #if defined(__has_include)
+    #define CC_FEATURE_FLAGS_AVAILABLE __has_include(<os/feature_private.h>)
+  #else
+    #define CC_FEATURE_FLAGS_AVAILABLE 0
+  #endif
+#endif
+
+// Macro to determine if a specific feature is available.
+// Turn off all features at compile time if desired and avoid the runtime check by changing this
+// definition to 0. Limit this functionality to the same environments wherein the ringbuffer is available.
+#ifndef CC_FEATURE_ENABLED
+  #if (CC_RINGBUFFER_AVAILABLE && CC_FEATURE_FLAGS_AVAILABLE && !defined(__i386__))
+    #define CC_FEATURE_ENABLED(FEATURE) os_feature_enabled(Cryptography, FEATURE)
+  #else
+    #define CC_FEATURE_ENABLED(FEATURE) 0
+  #endif
+#endif
+
+// Trace usage of deprecated or obscure functions. For now, this is
+// completely disabled.
+#ifndef CC_LOG_TRACE
+  #define CC_LOG_TRACE 0
+#endif
+
+// Defined by the XNU build scripts
+// Applies to code embedded in XNU but NOT to the kext
+#if defined(XNU_KERNEL_PRIVATE)
+ #define CC_XNU_KERNEL_PRIVATE 1
+#else
+ #define CC_XNU_KERNEL_PRIVATE 0
+#endif
+
+// handle unaligned data, if the cpu cannot. Currently for gladman AES and the C version of the SHA256
+#define CC_HANDLE_UNALIGNED_DATA CC_BASEBAND
+
+// BaseBand configuration
 #if CC_BASEBAND
 
 // -- ENDIANESS
+#if !defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
  #if defined(ENDIAN_LITTLE) || (defined(__arm__) && !defined(__BIG_ENDIAN))
   #define __LITTLE_ENDIAN__
  #elif !defined(ENDIAN_BIG) && !defined(__BIG_ENDIAN)
   #error Baseband endianess not defined.
  #endif
  #define AESOPT_ENDIAN_NO_FILE
+#endif
 
 // -- Architecture
  #define CCN_UNIT_SIZE  4 // 32 bits
- #define SAFE_IO          // AES support for unaligned Input/Output
 
 // -- External function
  #define assert ASSERT   // sanity
 // #1254-D: arithmetic on pointer to void or function type
 // #186-D: pointless comparison of unsigned integer with zero
 // #546-D: transfer of control bypasses initialization of
- #if   defined(__GNUC__)
+ #ifdef __arm__
+  #pragma diag_suppress 186, 1254,546
+ #elif defined(__GNUC__)
 // warning: pointer of type 'void *' used in arithmetic
   #pragma GCC diagnostic ignored "-Wpointer-arith"
- #endif // arm or gnuc
+ #endif // __arm__
+#define CC_SMALL_CODE 1
 
 #endif // CC_BASEBAND
 
+#if CC_RTKIT || CC_RTKITROM
+#define CC_SMALL_CODE 1
+#endif
+
+
+#ifndef CC_SMALL_CODE
+#define CC_SMALL_CODE 0
+#endif
+
 //CC_XNU_KERNEL_AVAILABLE indicates the availibity of XNU kernel functions,
 //like what we have on OSX, iOS, tvOS, Watch OS
 #if defined(__APPLE__) && defined(__MACH__)
  #define CC_XNU_KERNEL_AVAILABLE 0
 #endif
 
+//arm arch64 definition for gcc
+#if defined(__GNUC__) && defined(__aarch64__) && !defined(__arm64__)
+    #define __arm64__
+#endif
+
 #if !defined(CCN_UNIT_SIZE)
- #if defined(__arm64__) || defined(__x86_64__)  || defined(_WIN64) 
+ #if defined(__arm64__) || defined(__x86_64__)  || defined(_WIN64)
   #define CCN_UNIT_SIZE  8
  #elif defined(__arm__) || defined(__i386__) || defined(_WIN32)
   #define CCN_UNIT_SIZE  4
  #endif
 #endif
 
-#if __clang__ || CCN_UNIT_SIZE==8
- #define CC_ALIGNED(x) __attribute__ ((aligned(x)))
-#elif _MSC_VER
- #define CC_ALIGNED(x) __declspec(align(x))
+#if defined(_MSC_VER)
+    #if defined(__clang__)
+        #define CC_ALIGNED(x) __attribute__ ((aligned(x))) //clang compiler
+    #else
+        #define CC_ALIGNED(x) __declspec(align(x)) //MS complier
+    #endif
 #else
- #define CC_ALIGNED(x) __attribute__ ((aligned((x)>8?8:(x))))
+    #if __clang__ || CCN_UNIT_SIZE==8
+        #define CC_ALIGNED(x) __attribute__ ((aligned(x)))
+    #else
+        #define CC_ALIGNED(x) __attribute__ ((aligned((x)>8?8:(x))))
+    #endif
 #endif
 
+#if defined(__arm__)
+//this is copied from <arm/arch.h>, because <arm/arch.h> is not available on SEPROM environment
+#if defined (__ARM_ARCH_7A__) || defined (__ARM_ARCH_7S__) || defined (__ARM_ARCH_7F__) || defined (__ARM_ARCH_7K__) || defined(__ARM_ARCH_7EM__)
+  #define _ARM_ARCH_7
+ #endif
 
-#if   defined(__x86_64__) || defined(__i386__)
+ #if defined(__ARM_ARCH_6M__) || defined(__TARGET_ARCH_6S_M) || defined (__armv6m__)
+  #define _ARM_ARCH_6M
+ #endif
+#endif
+
+#if defined(__arm64__) || defined(__arm__)
+ #define CCN_IOS                                  1
+ #define CCN_OSX                                  0
+#elif defined(__x86_64__) || defined(__i386__)
  #define CCN_IOS                                  0
  #define CCN_OSX                                  1
-#endif 
+#endif
 
-#if CC_USE_L4 || CC_USE_S3
-/* No dynamic linking allowed in L4, e.g. avoid nonlazy symbols */
+#if CC_USE_S3
 /* For corecrypto kext, CC_STATIC should be undefined */
  #define CC_STATIC              1
 #endif
 
 #if !defined(CC_USE_HEAP_FOR_WORKSPACE)
- #if CC_USE_L4 || CC_IBOOT || defined(_MSC_VER)
- /* For L4, stack is too short, need to use HEAP for some computations */
- /* CC_USE_HEAP_FOR_WORKSPACE not supported for KERNEL!  */
-  #define CC_USE_HEAP_FOR_WORKSPACE 1
- #else
+ #if CC_USE_S3 || CC_USE_SEPROM || CC_RTKITROM
   #define CC_USE_HEAP_FOR_WORKSPACE 0
+ #else
+  #define CC_USE_HEAP_FOR_WORKSPACE 1
  #endif
 #endif
 
 /* memset_s is only available in few target */
-#if CC_KERNEL || CC_USE_SEPROM || defined(__CC_ARM) \
+#if CC_USE_SEPROM || defined(__CC_ARM) \
     || defined(__hexagon__) || CC_EFI
  #define CC_HAS_MEMSET_S 0
 #else
 #endif /* __has_include(<TargetConditionals.h>) */
 #endif /* defined(__has_include) */
 
-// Disable FIPS key gen algorithm on userland and kext so that related POST
-// is skipped and boot time is reduced
+// Disable RSA Keygen on iBridge
 #if defined(TARGET_OS_BRIDGE) && TARGET_OS_BRIDGE && CC_KERNEL
 #define CC_DISABLE_RSAKEYGEN 1 /* for iBridge */
 #else
 #define CC_DISABLE_RSAKEYGEN 0 /* default */
 #endif
 
+#if (CCN_UNIT_SIZE == 8) && !( defined(_MSC_VER) && defined(__clang__))
+#define CCEC25519_CURVE25519_64BIT 1
+#else
+#define CCEC25519_CURVE25519_64BIT 0
+#endif
+
 //- functions implemented in assembly ------------------------------------------
 //this the list of corecrypto clients that use assembly and the clang compiler
-#if !(CC_XNU_KERNEL_AVAILABLE || CC_KERNEL || CC_USE_L4 || CC_IBOOT || CC_USE_SEPROM || CC_USE_S3) && !defined(_WIN32) && CORECRYPTO_DEBUG
+#if !(CC_XNU_KERNEL_AVAILABLE || CC_KERNEL || CC_USE_L4 || CC_IBOOT || CC_RTKIT || CC_RTKITROM || CC_USE_SEPROM || CC_USE_S3) && !defined(_WIN32) && CORECRYPTO_DEBUG
  #warning "You are using the default corecrypto configuration, assembly optimizations may not be available for your platform"
 #endif
 
-// use this macro to strictly disable assembly regardless of cpu/os/compiler/etc
+// Enable assembler in Linux if CC_LINUX_ASM is defined
+#if (CC_LINUX || CC_SGX) && defined(CC_LINUX_ASM) && CC_LINUX_ASM
+#define CC_USE_ASM 1
+#endif
+
+// Use this macro to strictly disable assembly regardless of cpu/os/compiler/etc.
+// Our assembly code is not gcc compatible. Clang defines the __GNUC__ macro as well.
 #if !defined(CC_USE_ASM)
- #if defined(_MSC_VER) || CC_LINUX || CC_EFI || CC_BASEBAND
+ #if defined(_WIN32) || CC_EFI || CC_BASEBAND || CC_XNU_KERNEL_PRIVATE || (defined(__GNUC__) && !defined(__clang__)) || defined(__ANDROID_API__) || CC_LINUX
   #define CC_USE_ASM 0
  #else
   #define CC_USE_ASM 1
  #endif
 #endif
 
+#define CC_CACHE_DESCRIPTORS CC_KERNEL
+
 //-(1) ARM V7
 #if defined(_ARM_ARCH_7) && __clang__ && CC_USE_ASM
- #define CCN_DEDICATED_SQR      1
+ #define CCN_DEDICATED_SQR      CC_SMALL_CODE
  #define CCN_MUL_KARATSUBA      0 // no performance improvement
  #define CCN_ADD_ASM            1
  #define CCN_SUB_ASM            1
  #define CCN_ADDMUL1_ASM        1
  #define CCN_MUL1_ASM           1
  #define CCN_CMP_ASM            1
- #define CCN_ADD1_ASM           0
- #define CCN_SUB1_ASM           0
+ #define CCN_ADD1_ASM           1
+ #define CCN_SUB1_ASM           1
  #define CCN_N_ASM              1
  #define CCN_SET_ASM            1
  #define CCN_SHIFT_RIGHT_ASM    1
+ #if defined(__ARM_NEON__) 
+ #define CCN_SHIFT_LEFT_ASM     1
+ #else
+ #define CCN_SHIFT_LEFT_ASM     0
+ #endif
+ #define CCN_MULMOD_224_ASM     1
+ #define CCN_MULMOD_256_ASM     1
  #define CCAES_ARM_ASM          1
  #define CCAES_INTEL_ASM        0
- #if CC_KERNEL || CC_USE_L4 || CC_IBOOT || CC_USE_SEPROM || CC_USE_S3
+ #if CC_KERNEL || CC_USE_L4 || CC_IBOOT || CC_RTKIT || CC_RTKITROM || CC_USE_SEPROM || CC_USE_S3
   #define CCAES_MUX             0
  #else
   #define CCAES_MUX             1
  #define CCSHA2_VNG_INTEL       0
 
  #if defined(__ARM_NEON__) || CC_KERNEL
-  #define CCSHA1_VNG_ARMV7NEON   1
-  #define CCSHA2_VNG_ARMV7NEON   1
+  #define CCSHA1_VNG_ARM        1
+  #define CCSHA2_VNG_ARM        1
  #else /* !defined(__ARM_NEON__) */
-  #define CCSHA1_VNG_ARMV7NEON   0
-  #define CCSHA2_VNG_ARMV7NEON   0
+  #define CCSHA1_VNG_ARM        0
+  #define CCSHA2_VNG_ARM        0
  #endif /* !defined(__ARM_NEON__) */
  #define CCSHA256_ARMV6M_ASM 0
 
+ #define CC_ACCELERATECRYPTO    1
+
 //-(2) ARM 64
+#elif defined(__arm64__) && __clang__ && CC_USE_ASM
+ #define CCN_DEDICATED_SQR      CC_SMALL_CODE
+ #define CCN_MUL_KARATSUBA      0 // 4*n CCN_UNIT extra memory required.
+ #define CCN_ADD_ASM            1
+ #define CCN_SUB_ASM            1
+ #define CCN_MUL_ASM            1
+ #define CCN_ADDMUL1_ASM        0
+ #define CCN_MUL1_ASM           0
+ #define CCN_CMP_ASM            1
+ #define CCN_ADD1_ASM           0
+ #define CCN_SUB1_ASM           0
+ #define CCN_N_ASM              1
+ #define CCN_SET_ASM            0
+ #define CCN_SHIFT_RIGHT_ASM    1
+ #define CCN_SHIFT_LEFT_ASM     1
+ #define CCN_MULMOD_224_ASM     1
+ #define CCN_MULMOD_256_ASM     1
+ #define CCAES_ARM_ASM          1
+ #define CCAES_INTEL_ASM        0
+ #define CCAES_MUX              0        // On 64bit SoC, asm is much faster than HW
+ #define CCN_USE_BUILTIN_CLZ    1
+ #define CCSHA1_VNG_INTEL       0
+ #define CCSHA2_VNG_INTEL       0
+ #define CCSHA1_VNG_ARM         1
+ #define CCSHA2_VNG_ARM         1
+ #define CCSHA256_ARMV6M_ASM    0
+
+ #define CC_ACCELERATECRYPTO    1
+
+//-(3) Intel 32/64
 #elif (defined(__x86_64__) || defined(__i386__)) && __clang__ && CC_USE_ASM
  #define CCN_DEDICATED_SQR      1
- #define CCN_MUL_KARATSUBA      1 // 4*n CCN_UNIT extra memory required.
+ #define CCN_MUL_KARATSUBA      0 // 4*n CCN_UNIT extra memory required.
  /* These assembly routines only work for a single CCN_UNIT_SIZE. */
  #if (defined(__x86_64__) && CCN_UNIT_SIZE == 8) || (defined(__i386__) && CCN_UNIT_SIZE == 4)
   #define CCN_ADD_ASM            1
   #define CCN_CMP_ASM            1
   #define CCN_N_ASM              1
   #define CCN_SHIFT_RIGHT_ASM    1
+  #define CCN_SHIFT_LEFT_ASM     1
  #else
   #define CCN_CMP_ASM            0
   #define CCN_N_ASM              0
   #define CCN_SHIFT_RIGHT_ASM    0
+  #define CCN_SHIFT_LEFT_ASM     0
  #endif
 
- #define CCN_ADDMUL1_ASM        0
- #define CCN_MUL1_ASM           0
+ #define CCN_MULMOD_224_ASM     0
+ #if defined(__x86_64__) && CCN_UNIT_SIZE == 8 && !CC_SGX
+  #define CCN_MULMOD_256_ASM    1
+  #define CCN_ADDMUL1_ASM       1
+  #define CCN_MUL1_ASM          1
+ #else
+  #define CCN_MULMOD_256_ASM    0
+  #define CCN_ADDMUL1_ASM       0
+  #define CCN_MUL1_ASM          0
+ #endif
  #define CCN_ADD1_ASM           0
  #define CCN_SUB1_ASM           0
  #define CCN_SET_ASM            0
  #define CCN_USE_BUILTIN_CLZ    0
  #define CCSHA1_VNG_INTEL       1
  #define CCSHA2_VNG_INTEL       1
- #define CCSHA1_VNG_ARMV7NEON   0
- #define CCSHA2_VNG_ARMV7NEON   0
+ #define CCSHA1_VNG_ARM         0
+ #define CCSHA2_VNG_ARM         0
  #define CCSHA256_ARMV6M_ASM    0
 
-//-(4) disable assembly  
+ #define CC_ACCELERATECRYPTO    1
+
+//-(4) disable assembly
 #else
  #if CCN_UINT128_SUPPORT_FOR_64BIT_ARCH
   #define CCN_DEDICATED_SQR     1
  #else
   #define CCN_DEDICATED_SQR     0 //when assembly is off and 128-bit integers are not supported, dedicated square is off. This is the case on Windows
  #endif
- #define CCN_MUL_KARATSUBA      1 // 4*n CCN_UNIT extra memory required.
+ #define CCN_MUL_KARATSUBA      0 // 4*n CCN_UNIT extra memory required.
  #define CCN_ADD_ASM            0
  #define CCN_SUB_ASM            0
  #define CCN_MUL_ASM            0
  #define CCN_N_ASM              0
  #define CCN_SET_ASM            0
  #define CCN_SHIFT_RIGHT_ASM    0
+ #define CCN_SHIFT_LEFT_ASM     0
+ #define CCN_MULMOD_224_ASM     0
+ #define CCN_MULMOD_256_ASM     0
  #define CCAES_ARM_ASM          0
  #define CCAES_INTEL_ASM        0
  #define CCAES_MUX              0
  #define CCN_USE_BUILTIN_CLZ    0
  #define CCSHA1_VNG_INTEL       0
  #define CCSHA2_VNG_INTEL       0
- #define CCSHA1_VNG_ARMV7NEON   0
- #define CCSHA2_VNG_ARMV7NEON   0
+ #define CCSHA1_VNG_ARM         0
+ #define CCSHA2_VNG_ARM         0
  #define CCSHA256_ARMV6M_ASM    0
 
+ #define CC_ACCELERATECRYPTO    0
+
 #endif
 
 #define CC_INLINE static inline
 
-#if CORECRYPTO_USE_TRANSPARENT_UNION
-// Non null for transparent unions is ambiguous and cause problems
-// for most tools (GCC and others: 23919290).
- #define CC_NONNULL_TU(N)
-#else
- #define CC_NONNULL_TU(N)  CC_NONNULL(N)
-#endif
-
 #ifdef __GNUC__
  #define CC_NORETURN __attribute__((__noreturn__))
  #define CC_NOTHROW __attribute__((__nothrow__))
  #define CC_NONNULL(N) __attribute__((__nonnull__ N))
- #define CC_NONNULL1 __attribute__((__nonnull__(1)))
- #define CC_NONNULL2 __attribute__((__nonnull__(2)))
- #define CC_NONNULL3 __attribute__((__nonnull__(3)))
- #define CC_NONNULL4 __attribute__((__nonnull__(4)))
- #define CC_NONNULL5 __attribute__((__nonnull__(5)))
- #define CC_NONNULL6 __attribute__((__nonnull__(6)))
- #define CC_NONNULL7 __attribute__((__nonnull__(7)))
+ #define CC_NONNULL4 CC_NONNULL((4))
  #define CC_NONNULL_ALL __attribute__((__nonnull__))
  #define CC_SENTINEL __attribute__((__sentinel__))
+ // Only apply the `CC_CONST` attribute to functions with no side-effects where the output is a strict function of pass by value input vars with no exterior side-effects.
+ // Specifically, do not apply CC_CONST if the function has any arguments that are pointers (directly, or indirectly)
  #define CC_CONST __attribute__((__const__))
  #define CC_PURE __attribute__((__pure__))
  #define CC_WARN_RESULT __attribute__((__warn_unused_result__))
- #define CC_MALLOC __attribute__((__malloc__))
+ #define CC_MALLOC_CLEAR __attribute__((__malloc__))
  #define CC_UNUSED __attribute__((unused))
 #else /* !__GNUC__ */
 /*! @parseOnly */
  #define CC_UNUSED
 /*! @parseOnly */
  #define CC_NONNULL(N)
-/*! @parseOnly */
- #define CC_NORETURN
-/*! @parseOnly */
- #define CC_NOTHROW
-/*! @parseOnly */
- #define CC_NONNULL1
-/*! @parseOnly */
- #define CC_NONNULL2
-/*! @parseOnly */
- #define CC_NONNULL3
 /*! @parseOnly */
  #define CC_NONNULL4
 /*! @parseOnly */
- #define CC_NONNULL5
-/*! @parseOnly */
- #define CC_NONNULL6
+ #define CC_NORETURN
 /*! @parseOnly */
- #define CC_NONNULL7
+ #define CC_NOTHROW
 /*! @parseOnly */
  #define CC_NONNULL_ALL
 /*! @parseOnly */
 /*! @parseOnly */
  #define CC_WARN_RESULT
 /*! @parseOnly */
- #define CC_MALLOC
+ #define CC_MALLOC_CLEAR
 #endif /* !__GNUC__ */
 
 
+// Bridge differences between MachO and ELF compiler/assemblers. */
+#if CC_LINUX || CC_SGX
+#define CC_ASM_SECTION_CONST .rodata
+#define CC_ASM_PRIVATE_EXTERN .hidden
+#if CC_LINUX
+// We need to be sure that assembler can access relocated C
+// symbols. Sad but this is the quickest way to do that, at least with
+// our current linux compiler (clang-3.4).
+#define CC_C_LABEL(_sym) _sym@PLT
+#else /* CC_SGX */
+#define CC_C_LABEL(_sym) _sym
+#endif
+#define _IMM(x) $(x)
+#else /* !CC_LINUX && !CC_SGX */
+#define CC_ASM_SECTION_CONST .const
+#define CC_ASM_PRIVATE_EXTERN .private_extern
+#define CC_C_LABEL(_sym) _##_sym
+#define _IMM(x) $$(x)
+#endif /* !CC_LINUX && !CC_SGX */
+
+// Enable FIPSPOST function tracing only when supported. */
+#ifdef CORECRYPTO_POST_TRACE
+#define CC_FIPSPOST_TRACE 1
+#else
+#define CC_FIPSPOST_TRACE 0
+#endif
+
+#ifndef CC_INTERNAL_SDK
+#if __has_include(<System/i386/cpu_capabilities.h>)
+#define CC_INTERNAL_SDK 1
+#elif __has_include(<System/arm/cpu_capabilities.h>)
+#define CC_INTERNAL_SDK 1
+#else
+#define CC_INTERNAL_SDK 0
+#endif
+#endif
+
 #endif /* _CORECRYPTO_CC_CONFIG_H_ */