1 /* Copyright (c) (2012,2015-2019,2021,2024) 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 #include <corecrypto/ccsha2.h> 13 #include "ccsha2_internal.h" 14 #include "cc_runtime_config.h" 15 #include "fipspost_trace.h" 16 ccsha512_di(void)17const struct ccdigest_info *ccsha512_di(void) 18 { 19 FIPSPOST_TRACE_EVENT; 20 21 #if CC_USE_ASM && CCSHA2_VNG_INTEL && defined(__x86_64__) 22 if (CC_HAS_AVX512_AND_IN_KERNEL()) { 23 if (CC_HAS_SupplementalSSE3()) { 24 return &ccsha512_vng_intel_SupplementalSSE3_di; 25 } 26 27 return &ccsha512_ltc_di; 28 } 29 30 if (CC_HAS_AVX2()) { 31 return &ccsha512_vng_intel_AVX2_di; 32 } 33 34 if (CC_HAS_AVX1()) { 35 return &ccsha512_vng_intel_AVX1_di; 36 } 37 38 if (CC_HAS_SupplementalSSE3()) { 39 return &ccsha512_vng_intel_SupplementalSSE3_di; 40 } 41 42 return &ccsha512_ltc_di; 43 #elif CC_USE_ASM && CCSHA2_VNG_ARM 44 #if !CC_IBOOT && defined(__arm64__) 45 // These two conditions imply a runtime cpu capability check 46 if (CC_INTERNAL_SDK && CC_HAS_SHA512()) { 47 return &ccsha512_vng_arm_hw_di; 48 } 49 #endif 50 return &ccsha512_vng_arm_di; 51 #else 52 return &ccsha512_ltc_di; 53 #endif 54 } 55