1 /* Copyright (c) (2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020) Apple Inc. All rights reserved. 2 * 3 * corecrypto is licensed under Apple Inc.’s Internal Use License Agreement (which 4 * is contained in the License.txt file distributed with corecrypto) and only to 5 * people who accept that license. IMPORTANT: Any license rights granted to you by 6 * Apple Inc. (if any) are limited to internal use within your organization only on 7 * devices and computers you own or control, for the sole purpose of verifying the 8 * security characteristics and correct functioning of the Apple Software. You may 9 * not, directly or indirectly, redistribute the Apple Software or any portions thereof. 10 */ 11 12 #ifndef _CORECRYPTO_CC_CONFIG_H_ 13 #define _CORECRYPTO_CC_CONFIG_H_ 14 15 /* A word about configuration macros: 16 17 Conditional configuration macros specific to corecrypto should be named CORECRYPTO_xxx 18 or CCxx_yyy and be defined to be either 0 or 1 in this file. You can add an 19 #ifndef #error construct at the end of this file to make sure it's always defined. 20 21 They should always be tested using the #if directive, never the #ifdef directive. 22 23 No other conditional macros shall ever be used (except in this file) 24 25 Configuration Macros that are defined outside of corecrypto (eg: KERNEL, DEBUG, ...) 26 shall only be used in this file to define CCxxx macros. 27 28 External macros should be assumed to be either undefined, defined with no value, 29 or defined as true or false. We shall strive to build with -Wundef whenever possible, 30 so the following construct should be used to test external macros in this file: 31 32 #if defined(DEBUG) && (DEBUG) 33 #define CORECRYPTO_DEBUG 1 34 #else 35 #define CORECRYPTO_DEBUG 0 36 #endif 37 38 39 It is acceptable to define a conditional CC_xxxx macro in an implementation file, 40 to be used only in this file. 41 42 The current code is not guaranteed to follow those rules, but should be fixed to. 43 44 Corecrypto requires GNU and C99 compatibility. 45 Typically enabled by passing --gnu --c99 to the compiler (eg. armcc) 46 47 */ 48 49 //Do not set this macros to 1, unless you are developing/testing for Linux under macOS 50 #define CORECRYPTO_SIMULATE_POSIX_ENVIRONMENT 0 51 52 //Do not set these macros to 1, unless you are developing/testing for Windows under macOS 53 #define CORECRYPTO_SIMULATE_WINDOWS_ENVIRONMENT 0 54 #define CORECRYPTO_HACK_FOR_WINDOWS_DEVELOPMENT 0 55 56 #if (defined(DEBUG) && (DEBUG)) || defined(_DEBUG) //MSVC defines _DEBUG 57 /* CC_DEBUG is already used in CommonCrypto */ 58 #define CORECRYPTO_DEBUG 1 59 #else 60 #define CORECRYPTO_DEBUG 0 61 #endif 62 63 // This macro can be used to enable prints when a condition in the macro "cc_require" 64 // is false. This is especially useful to confirm that negative testing fails 65 // at the intended location 66 #define CORECRYPTO_DEBUG_ENABLE_CC_REQUIRE_PRINTS 0 67 68 #if defined(KERNEL) && (KERNEL) 69 #define CC_KERNEL 1 // KEXT, XNU repo or kernel components such as AppleKeyStore 70 #else 71 #define CC_KERNEL 0 72 #endif 73 74 #if defined(LINUX_SGX) && (LINUX_SGX) 75 #define CC_SGX 1 76 #else 77 #define CC_SGX 0 78 #endif 79 80 #if (defined(__linux__) && !(CC_SGX)) || CORECRYPTO_SIMULATE_POSIX_ENVIRONMENT 81 #define CC_LINUX 1 82 #else 83 #define CC_LINUX 0 84 #endif 85 86 #if defined(__ANDROID__) && (__ANDROID__) 87 #define CC_ANDROID 1 88 #else 89 #define CC_ANDROID 0 90 #endif 91 92 #if defined(USE_L4) && (USE_L4) 93 #define CC_USE_L4 1 94 #else 95 #define CC_USE_L4 0 96 #endif 97 98 #if defined(RTKIT) && (RTKIT) 99 #define CC_RTKIT 1 100 #else 101 #define CC_RTKIT 0 102 #endif 103 104 #if defined(RTKITROM) && (RTKITROM) 105 #define CC_RTKITROM 1 106 #else 107 #define CC_RTKITROM 0 108 #endif 109 110 #if defined(USE_SEPROM) && (USE_SEPROM) 111 #define CC_USE_SEPROM 1 112 #else 113 #define CC_USE_SEPROM 0 114 #endif 115 116 #if defined(USE_S3) && (USE_S3) 117 #define CC_USE_S3 1 118 #else 119 #define CC_USE_S3 0 120 #endif 121 122 #if (defined(ICE_FEATURES_ENABLED)) || (defined(MAVERICK) && (MAVERICK)) 123 #define CC_BASEBAND 1 124 #else 125 #define CC_BASEBAND 0 126 #endif 127 128 #if defined(EFI) && (EFI) 129 #define CC_EFI 1 130 #else 131 #define CC_EFI 0 132 #endif 133 134 #if defined(IBOOT) && (IBOOT) 135 #define CC_IBOOT 1 136 #else 137 #define CC_IBOOT 0 138 #endif 139 140 #if defined(TARGET_OS_BRIDGE) 141 #define CC_BRIDGE TARGET_OS_BRIDGE 142 #else 143 #define CC_BRIDGE 0 144 #endif 145 146 // Check if we're running on a generic, userspace platform, i.e., not in the kernel, SEP, etc. 147 #ifndef CC_GENERIC_PLATFORM 148 #define CC_GENERIC_PLATFORM \ 149 (!CC_RTKIT && !CC_KERNEL && !CC_USE_L4 && \ 150 !CC_RTKITROM && !CC_EFI && !CC_IBOOT && \ 151 !CC_USE_SEPROM && !CC_ANDROID && !CC_LINUX && \ 152 !CC_BRIDGE) 153 #endif 154 155 // Check for availability of internal Darwin SPIs. 156 #ifndef CC_DARWIN_SPIS_AVAILABLE 157 #if defined(__has_include) 158 #define CC_DARWIN_SPIS_AVAILABLE __has_include(<os/log_private.h>) 159 #else 160 #define CC_DARWIN_SPIS_AVAILABLE 0 161 #endif 162 #endif 163 164 // Check for open source builds 165 166 // ccringbuffer availability 167 // Only enable the ccringbuffer data structure in generic, userspace builds where memory allocation is not an issue. 168 #ifndef CC_RINGBUFFER_AVAILABLE 169 #define CC_RINGBUFFER_AVAILABLE (CC_GENERIC_PLATFORM && CC_DARWIN_SPIS_AVAILABLE && !CC_OPEN_SOURCE) 170 #endif 171 172 // os_log integration 173 // Only enable logging support in generic, userspace builds with the desired Darwin SPIs. 174 #ifndef CC_LOGGING_AVAILABLE 175 #define CC_LOGGING_AVAILABLE (CC_GENERIC_PLATFORM && CC_DARWIN_SPIS_AVAILABLE && !CC_OPEN_SOURCE) 176 #endif 177 178 // FeatureFlag integration 179 // Only enable feature flag support in generic, userspace builds with the desired Darwin SPIs. 180 // This requires linking against libsystem_featureflags to function correctly. 181 #ifndef CC_FEATURE_FLAGS_AVAILABLE 182 #if defined(__has_include) 183 #define CC_FEATURE_FLAGS_AVAILABLE __has_include(<os/feature_private.h>) 184 #else 185 #define CC_FEATURE_FLAGS_AVAILABLE 0 186 #endif 187 #endif 188 189 // Macro to determine if a specific feature is available. 190 // Turn off all features at compile time if desired and avoid the runtime check by changing this 191 // definition to 0. Limit this functionality to the same environments wherein the ringbuffer is available. 192 #ifndef CC_FEATURE_ENABLED 193 #if (CC_RINGBUFFER_AVAILABLE && CC_FEATURE_FLAGS_AVAILABLE && !defined(__i386__)) 194 #define CC_FEATURE_ENABLED(FEATURE) os_feature_enabled(Cryptography, FEATURE) 195 #else 196 #define CC_FEATURE_ENABLED(FEATURE) 0 197 #endif 198 #endif 199 200 // Trace usage of deprecated or obscure functions. For now, this is 201 // completely disabled. 202 #ifndef CC_LOG_TRACE 203 #define CC_LOG_TRACE 0 204 #endif 205 206 // Defined by the XNU build scripts 207 // Applies to code embedded in XNU but NOT to the kext 208 #if defined(XNU_KERNEL_PRIVATE) 209 #define CC_XNU_KERNEL_PRIVATE 1 210 #else 211 #define CC_XNU_KERNEL_PRIVATE 0 212 #endif 213 214 // handle unaligned data, if the cpu cannot. Currently for gladman AES and the C version of the SHA256 215 #define CC_HANDLE_UNALIGNED_DATA CC_BASEBAND 216 217 // BaseBand configuration 218 #if CC_BASEBAND 219 220 // -- ENDIANESS 221 #if !defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) 222 #if defined(ENDIAN_LITTLE) || (defined(__arm__) && !defined(__BIG_ENDIAN)) 223 #define __LITTLE_ENDIAN__ 224 #elif !defined(ENDIAN_BIG) && !defined(__BIG_ENDIAN) 225 #error Baseband endianess not defined. 226 #endif 227 #define AESOPT_ENDIAN_NO_FILE 228 #endif 229 230 // -- Architecture 231 #define CCN_UNIT_SIZE 4 // 32 bits 232 233 // -- External function 234 #define assert ASSERT // sanity 235 236 // -- Warnings 237 // Ignore irrelevant warnings after verification 238 // #1254-D: arithmetic on pointer to void or function type 239 // #186-D: pointless comparison of unsigned integer with zero 240 // #546-D: transfer of control bypasses initialization of 241 #ifdef __arm__ 242 #pragma diag_suppress 186, 1254,546 243 #elif defined(__GNUC__) 244 // warning: pointer of type 'void *' used in arithmetic 245 #pragma GCC diagnostic ignored "-Wpointer-arith" 246 #endif // __arm__ 247 #define CC_SMALL_CODE 1 248 249 #endif // CC_BASEBAND 250 251 #if CC_RTKIT || CC_RTKITROM 252 #define CC_SMALL_CODE 1 253 #endif 254 255 256 #ifndef CC_SMALL_CODE 257 #define CC_SMALL_CODE 0 258 #endif 259 260 //CC_XNU_KERNEL_AVAILABLE indicates the availibity of XNU kernel functions, 261 //like what we have on OSX, iOS, tvOS, Watch OS 262 #if defined(__APPLE__) && defined(__MACH__) 263 #define CC_XNU_KERNEL_AVAILABLE 1 264 #else 265 #define CC_XNU_KERNEL_AVAILABLE 0 266 #endif 267 268 //arm arch64 definition for gcc 269 #if defined(__GNUC__) && defined(__aarch64__) && !defined(__arm64__) 270 #define __arm64__ 271 #endif 272 273 #if !defined(CCN_UNIT_SIZE) 274 #if defined(__arm64__) || defined(__x86_64__) || defined(_WIN64) 275 #define CCN_UNIT_SIZE 8 276 #elif defined(__arm__) || defined(__i386__) || defined(_WIN32) 277 #define CCN_UNIT_SIZE 4 278 #else 279 #error undefined architecture 280 #endif 281 #endif /* !defined(CCN_UNIT_SIZE) */ 282 283 284 //this allows corecrypto Windows development using xcode 285 #if defined(CORECRYPTO_SIMULATE_WINDOWS_ENVIRONMENT) 286 #if CORECRYPTO_SIMULATE_WINDOWS_ENVIRONMENT && CC_XNU_KERNEL_AVAILABLE && CORECRYPTO_DEBUG 287 #define CC_USE_ASM 0 288 #define CC_USE_HEAP_FOR_WORKSPACE 1 289 #if (CCN_UNIT_SIZE==8) 290 #define CCN_UINT128_SUPPORT_FOR_64BIT_ARCH 0 291 #else 292 #define CCN_UINT128_SUPPORT_FOR_64BIT_ARCH 1 293 #endif 294 #endif 295 #endif 296 297 #if !defined(CCN_UINT128_SUPPORT_FOR_64BIT_ARCH) 298 #if defined(_WIN64) && defined(_WIN32) && (CCN_UNIT_SIZE==8) 299 #define CCN_UINT128_SUPPORT_FOR_64BIT_ARCH 0 300 #elif defined(_WIN32) 301 #define CCN_UINT128_SUPPORT_FOR_64BIT_ARCH 1//should not be a problem 302 #else 303 #define CCN_UINT128_SUPPORT_FOR_64BIT_ARCH 1 304 #endif 305 #endif 306 307 #if defined(_MSC_VER) 308 #if defined(__clang__) 309 #define CC_ALIGNED(x) __attribute__ ((aligned(x))) //clang compiler 310 #else 311 #define CC_ALIGNED(x) __declspec(align(x)) //MS complier 312 #endif 313 #else 314 #if __clang__ || CCN_UNIT_SIZE==8 315 #define CC_ALIGNED(x) __attribute__ ((aligned(x))) 316 #else 317 #define CC_ALIGNED(x) __attribute__ ((aligned((x)>8?8:(x)))) 318 #endif 319 #endif 320 321 #if defined(__arm__) 322 //this is copied from <arm/arch.h>, because <arm/arch.h> is not available on SEPROM environment 323 #if defined (__ARM_ARCH_7A__) || defined (__ARM_ARCH_7S__) || defined (__ARM_ARCH_7F__) || defined (__ARM_ARCH_7K__) || defined(__ARM_ARCH_7EM__) 324 #define _ARM_ARCH_7 325 #endif 326 327 #if defined(__ARM_ARCH_6M__) || defined(__TARGET_ARCH_6S_M) || defined (__armv6m__) 328 #define _ARM_ARCH_6M 329 #endif 330 #endif 331 332 #if defined(__arm64__) || defined(__arm__) 333 #define CCN_IOS 1 334 #define CCN_OSX 0 335 #elif defined(__x86_64__) || defined(__i386__) 336 #define CCN_IOS 0 337 #define CCN_OSX 1 338 #endif 339 340 #if CC_USE_S3 341 /* For corecrypto kext, CC_STATIC should be undefined */ 342 #define CC_STATIC 1 343 #endif 344 345 #if !defined(CC_USE_HEAP_FOR_WORKSPACE) 346 #if CC_USE_S3 || CC_USE_SEPROM || CC_RTKITROM 347 #define CC_USE_HEAP_FOR_WORKSPACE 0 348 #else 349 #define CC_USE_HEAP_FOR_WORKSPACE 1 350 #endif 351 #endif 352 353 /* memset_s is only available in few target */ 354 #if CC_USE_SEPROM || defined(__CC_ARM) \ 355 || defined(__hexagon__) || CC_EFI 356 #define CC_HAS_MEMSET_S 0 357 #else 358 #define CC_HAS_MEMSET_S 1 359 #endif 360 361 // Include target conditionals if available. 362 #if defined(__has_include) /* portability */ 363 #if __has_include(<TargetConditionals.h>) 364 #include <TargetConditionals.h> 365 #endif /* __has_include(<TargetConditionals.h>) */ 366 #endif /* defined(__has_include) */ 367 368 // Disable RSA Keygen on iBridge 369 #if defined(TARGET_OS_BRIDGE) && TARGET_OS_BRIDGE && CC_KERNEL 370 #define CC_DISABLE_RSAKEYGEN 1 /* for iBridge */ 371 #else 372 #define CC_DISABLE_RSAKEYGEN 0 /* default */ 373 #endif 374 375 #if (CCN_UNIT_SIZE == 8) && !( defined(_MSC_VER) && defined(__clang__)) 376 #define CCEC25519_CURVE25519_64BIT 1 377 #else 378 #define CCEC25519_CURVE25519_64BIT 0 379 #endif 380 381 //- functions implemented in assembly ------------------------------------------ 382 //this the list of corecrypto clients that use assembly and the clang compiler 383 #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 384 #warning "You are using the default corecrypto configuration, assembly optimizations may not be available for your platform" 385 #endif 386 387 // Enable assembler in Linux if CC_LINUX_ASM is defined 388 #if (CC_LINUX || CC_SGX) && defined(CC_LINUX_ASM) && CC_LINUX_ASM 389 #define CC_USE_ASM 1 390 #endif 391 392 // Use this macro to strictly disable assembly regardless of cpu/os/compiler/etc. 393 // Our assembly code is not gcc compatible. Clang defines the __GNUC__ macro as well. 394 #if !defined(CC_USE_ASM) 395 #if defined(_WIN32) || CC_EFI || CC_BASEBAND || CC_XNU_KERNEL_PRIVATE || (defined(__GNUC__) && !defined(__clang__)) || defined(__ANDROID_API__) || CC_LINUX 396 #define CC_USE_ASM 0 397 #else 398 #define CC_USE_ASM 1 399 #endif 400 #endif 401 402 #define CC_CACHE_DESCRIPTORS CC_KERNEL 403 404 //-(1) ARM V7 405 #if defined(_ARM_ARCH_7) && __clang__ && CC_USE_ASM 406 #define CCN_DEDICATED_SQR CC_SMALL_CODE 407 #define CCN_MUL_KARATSUBA 0 // no performance improvement 408 #define CCN_ADD_ASM 1 409 #define CCN_SUB_ASM 1 410 #define CCN_MUL_ASM 0 411 #define CCN_ADDMUL1_ASM 1 412 #define CCN_MUL1_ASM 1 413 #define CCN_CMP_ASM 1 414 #define CCN_ADD1_ASM 1 415 #define CCN_SUB1_ASM 1 416 #define CCN_N_ASM 1 417 #define CCN_SET_ASM 1 418 #define CCN_SHIFT_RIGHT_ASM 1 419 #if defined(__ARM_NEON__) 420 #define CCN_SHIFT_LEFT_ASM 1 421 #else 422 #define CCN_SHIFT_LEFT_ASM 0 423 #endif 424 #define CCN_MULMOD_224_ASM 1 425 #define CCN_MULMOD_256_ASM 1 426 #define CCAES_ARM_ASM 1 427 #define CCAES_INTEL_ASM 0 428 #if CC_KERNEL || CC_USE_L4 || CC_IBOOT || CC_RTKIT || CC_RTKITROM || CC_USE_SEPROM || CC_USE_S3 429 #define CCAES_MUX 0 430 #else 431 #define CCAES_MUX 1 432 #endif 433 #define CCN_USE_BUILTIN_CLZ 1 434 #define CCSHA1_VNG_INTEL 0 435 #define CCSHA2_VNG_INTEL 0 436 437 #if defined(__ARM_NEON__) || CC_KERNEL 438 #define CCSHA1_VNG_ARM 1 439 #define CCSHA2_VNG_ARM 1 440 #else /* !defined(__ARM_NEON__) */ 441 #define CCSHA1_VNG_ARM 0 442 #define CCSHA2_VNG_ARM 0 443 #endif /* !defined(__ARM_NEON__) */ 444 #define CCSHA256_ARMV6M_ASM 0 445 446 #define CC_ACCELERATECRYPTO 1 447 448 //-(2) ARM 64 449 #elif defined(__arm64__) && __clang__ && CC_USE_ASM 450 #define CCN_DEDICATED_SQR CC_SMALL_CODE 451 #define CCN_MUL_KARATSUBA 0 // 4*n CCN_UNIT extra memory required. 452 #define CCN_ADD_ASM 1 453 #define CCN_SUB_ASM 1 454 #define CCN_MUL_ASM 1 455 #define CCN_ADDMUL1_ASM 0 456 #define CCN_MUL1_ASM 0 457 #define CCN_CMP_ASM 1 458 #define CCN_ADD1_ASM 0 459 #define CCN_SUB1_ASM 0 460 #define CCN_N_ASM 1 461 #define CCN_SET_ASM 0 462 #define CCN_SHIFT_RIGHT_ASM 1 463 #define CCN_SHIFT_LEFT_ASM 1 464 #define CCN_MULMOD_224_ASM 1 465 #define CCN_MULMOD_256_ASM 1 466 #define CCAES_ARM_ASM 1 467 #define CCAES_INTEL_ASM 0 468 #define CCAES_MUX 0 // On 64bit SoC, asm is much faster than HW 469 #define CCN_USE_BUILTIN_CLZ 1 470 #define CCSHA1_VNG_INTEL 0 471 #define CCSHA2_VNG_INTEL 0 472 #define CCSHA1_VNG_ARM 1 473 #define CCSHA2_VNG_ARM 1 474 #define CCSHA256_ARMV6M_ASM 0 475 476 #define CC_ACCELERATECRYPTO 1 477 478 //-(3) Intel 32/64 479 #elif (defined(__x86_64__) || defined(__i386__)) && __clang__ && CC_USE_ASM 480 #define CCN_DEDICATED_SQR 1 481 #define CCN_MUL_KARATSUBA 0 // 4*n CCN_UNIT extra memory required. 482 /* These assembly routines only work for a single CCN_UNIT_SIZE. */ 483 #if (defined(__x86_64__) && CCN_UNIT_SIZE == 8) || (defined(__i386__) && CCN_UNIT_SIZE == 4) 484 #define CCN_ADD_ASM 1 485 #define CCN_SUB_ASM 1 486 #define CCN_MUL_ASM 1 487 #else 488 #define CCN_ADD_ASM 0 489 #define CCN_SUB_ASM 0 490 #define CCN_MUL_ASM 0 491 #endif 492 493 #if (defined(__x86_64__) && CCN_UNIT_SIZE == 8) 494 #define CCN_CMP_ASM 1 495 #define CCN_N_ASM 1 496 #define CCN_SHIFT_RIGHT_ASM 1 497 #define CCN_SHIFT_LEFT_ASM 1 498 #else 499 #define CCN_CMP_ASM 0 500 #define CCN_N_ASM 0 501 #define CCN_SHIFT_RIGHT_ASM 0 502 #define CCN_SHIFT_LEFT_ASM 0 503 #endif 504 505 #define CCN_MULMOD_224_ASM 0 506 #if defined(__x86_64__) && CCN_UNIT_SIZE == 8 && !CC_SGX 507 #define CCN_MULMOD_256_ASM 1 508 #define CCN_ADDMUL1_ASM 1 509 #define CCN_MUL1_ASM 1 510 #else 511 #define CCN_MULMOD_256_ASM 0 512 #define CCN_ADDMUL1_ASM 0 513 #define CCN_MUL1_ASM 0 514 #endif 515 #define CCN_ADD1_ASM 0 516 #define CCN_SUB1_ASM 0 517 #define CCN_SET_ASM 0 518 #define CCAES_ARM_ASM 0 519 #define CCAES_INTEL_ASM 1 520 #define CCAES_MUX 0 521 #define CCN_USE_BUILTIN_CLZ 0 522 #define CCSHA1_VNG_INTEL 1 523 #define CCSHA2_VNG_INTEL 1 524 #define CCSHA1_VNG_ARM 0 525 #define CCSHA2_VNG_ARM 0 526 #define CCSHA256_ARMV6M_ASM 0 527 528 #define CC_ACCELERATECRYPTO 1 529 530 //-(4) disable assembly 531 #else 532 #if CCN_UINT128_SUPPORT_FOR_64BIT_ARCH 533 #define CCN_DEDICATED_SQR 1 534 #else 535 #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 536 #endif 537 #define CCN_MUL_KARATSUBA 0 // 4*n CCN_UNIT extra memory required. 538 #define CCN_ADD_ASM 0 539 #define CCN_SUB_ASM 0 540 #define CCN_MUL_ASM 0 541 #define CCN_ADDMUL1_ASM 0 542 #define CCN_MUL1_ASM 0 543 #define CCN_CMP_ASM 0 544 #define CCN_ADD1_ASM 0 545 #define CCN_SUB1_ASM 0 546 #define CCN_N_ASM 0 547 #define CCN_SET_ASM 0 548 #define CCN_SHIFT_RIGHT_ASM 0 549 #define CCN_SHIFT_LEFT_ASM 0 550 #define CCN_MULMOD_224_ASM 0 551 #define CCN_MULMOD_256_ASM 0 552 #define CCAES_ARM_ASM 0 553 #define CCAES_INTEL_ASM 0 554 #define CCAES_MUX 0 555 #define CCN_USE_BUILTIN_CLZ 0 556 #define CCSHA1_VNG_INTEL 0 557 #define CCSHA2_VNG_INTEL 0 558 #define CCSHA1_VNG_ARM 0 559 #define CCSHA2_VNG_ARM 0 560 #define CCSHA256_ARMV6M_ASM 0 561 562 #define CC_ACCELERATECRYPTO 0 563 564 #endif 565 566 #define CC_INLINE static inline 567 568 #ifdef __GNUC__ 569 #define CC_NORETURN __attribute__((__noreturn__)) 570 #define CC_NOTHROW __attribute__((__nothrow__)) 571 #define CC_NONNULL(N) __attribute__((__nonnull__ N)) 572 #define CC_NONNULL4 CC_NONNULL((4)) 573 #define CC_NONNULL_ALL __attribute__((__nonnull__)) 574 #define CC_SENTINEL __attribute__((__sentinel__)) 575 // 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. 576 // Specifically, do not apply CC_CONST if the function has any arguments that are pointers (directly, or indirectly) 577 #define CC_CONST __attribute__((__const__)) 578 #define CC_PURE __attribute__((__pure__)) 579 #define CC_WARN_RESULT __attribute__((__warn_unused_result__)) 580 #define CC_MALLOC_CLEAR __attribute__((__malloc__)) 581 #define CC_UNUSED __attribute__((unused)) 582 #else /* !__GNUC__ */ 583 /*! @parseOnly */ 584 #define CC_UNUSED 585 /*! @parseOnly */ 586 #define CC_NONNULL(N) 587 /*! @parseOnly */ 588 #define CC_NONNULL4 589 /*! @parseOnly */ 590 #define CC_NORETURN 591 /*! @parseOnly */ 592 #define CC_NOTHROW 593 /*! @parseOnly */ 594 #define CC_NONNULL_ALL 595 /*! @parseOnly */ 596 #define CC_SENTINEL 597 /*! @parseOnly */ 598 #define CC_CONST 599 /*! @parseOnly */ 600 #define CC_PURE 601 /*! @parseOnly */ 602 #define CC_WARN_RESULT 603 /*! @parseOnly */ 604 #define CC_MALLOC_CLEAR 605 #endif /* !__GNUC__ */ 606 607 608 // Bridge differences between MachO and ELF compiler/assemblers. */ 609 #if CC_LINUX || CC_SGX 610 #define CC_ASM_SECTION_CONST .rodata 611 #define CC_ASM_PRIVATE_EXTERN .hidden 612 #if CC_LINUX 613 // We need to be sure that assembler can access relocated C 614 // symbols. Sad but this is the quickest way to do that, at least with 615 // our current linux compiler (clang-3.4). 616 #define CC_C_LABEL(_sym) _sym@PLT 617 #else /* CC_SGX */ 618 #define CC_C_LABEL(_sym) _sym 619 #endif 620 #define _IMM(x) $(x) 621 #else /* !CC_LINUX && !CC_SGX */ 622 #define CC_ASM_SECTION_CONST .const 623 #define CC_ASM_PRIVATE_EXTERN .private_extern 624 #define CC_C_LABEL(_sym) _##_sym 625 #define _IMM(x) $$(x) 626 #endif /* !CC_LINUX && !CC_SGX */ 627 628 // Enable FIPSPOST function tracing only when supported. */ 629 #ifdef CORECRYPTO_POST_TRACE 630 #define CC_FIPSPOST_TRACE 1 631 #else 632 #define CC_FIPSPOST_TRACE 0 633 #endif 634 635 #ifndef CC_INTERNAL_SDK 636 #if __has_include(<System/i386/cpu_capabilities.h>) 637 #define CC_INTERNAL_SDK 1 638 #elif __has_include(<System/arm/cpu_capabilities.h>) 639 #define CC_INTERNAL_SDK 1 640 #else 641 #define CC_INTERNAL_SDK 0 642 #endif 643 #endif 644 645 #endif /* _CORECRYPTO_CC_CONFIG_H_ */ 646