1 /* Copyright (c) (2010,2011,2012,2014,2015,2016,2017,2018,2019) 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_CCSHA2_H_ 13 #define _CORECRYPTO_CCSHA2_H_ 14 15 #include <corecrypto/ccdigest.h> 16 17 /* sha2 selectors */ 18 const struct ccdigest_info *ccsha224_di(void); 19 const struct ccdigest_info *ccsha256_di(void); 20 const struct ccdigest_info *ccsha384_di(void); 21 const struct ccdigest_info *ccsha512_di(void); 22 const struct ccdigest_info *ccsha512_256_di(void); // SHA512/256 (cf FIPS 180-4 https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf) 23 24 #define ccoid_sha224 ((unsigned char *)"\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x04") 25 #define ccoid_sha224_len 11 26 27 #define ccoid_sha256 ((unsigned char *)"\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x01") 28 #define ccoid_sha256_len 11 29 30 #define ccoid_sha384 ((unsigned char *)"\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x02") 31 #define ccoid_sha384_len 11 32 33 #define ccoid_sha512 ((unsigned char *)"\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x03") 34 #define ccoid_sha512_len 11 35 36 #define ccoid_sha512_256 ((unsigned char *)"\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x06") 37 #define ccoid_sha512_256_len 11 38 39 /* SHA256 */ 40 #define CCSHA256_BLOCK_SIZE 64 41 #define CCSHA256_OUTPUT_SIZE 32 42 #define CCSHA256_STATE_SIZE 32 43 extern const struct ccdigest_info ccsha256_ltc_di; 44 #if CCSHA2_VNG_INTEL 45 extern const struct ccdigest_info ccsha224_vng_intel_SupplementalSSE3_di; 46 extern const struct ccdigest_info ccsha256_vng_intel_SupplementalSSE3_di; 47 #endif 48 #if CCSHA2_VNG_ARM 49 extern const struct ccdigest_info ccsha224_vng_arm_di; 50 extern const struct ccdigest_info ccsha256_vng_arm_di; 51 #if CC_ACCELERATECRYPTO && defined(__arm64__) && CCSHA2_VNG_ARM 52 extern const struct ccdigest_info ccsha256_vng_arm64neon_di; 53 #endif // CC_ACCELERATECRYPTO 54 extern const struct ccdigest_info ccsha384_vng_arm_di; 55 extern const struct ccdigest_info ccsha512_vng_arm_di; 56 extern const struct ccdigest_info ccsha512_256_vng_arm_di; 57 #endif 58 59 /* SHA224 */ 60 #define CCSHA224_OUTPUT_SIZE 28 61 extern const struct ccdigest_info ccsha224_ltc_di; 62 63 /* SHA512 */ 64 #define CCSHA512_BLOCK_SIZE 128 65 #define CCSHA512_OUTPUT_SIZE 64 66 #define CCSHA512_STATE_SIZE 64 67 extern const struct ccdigest_info ccsha512_ltc_di; 68 69 /* SHA512/256 */ 70 // FIPS 180-4 71 // https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf 72 #define CCSHA512_256_BLOCK_SIZE 128 73 #define CCSHA512_256_OUTPUT_SIZE 32 74 #define CCSHA512_256_STATE_SIZE 64 75 extern const struct ccdigest_info ccsha512_256_ltc_di; 76 77 /* SHA384 */ 78 #define CCSHA384_OUTPUT_SIZE 48 79 extern const struct ccdigest_info ccsha384_ltc_di; 80 81 #endif /* _CORECRYPTO_CCSHA2_H_ */ 82