1*fdd8201dSApple OSS Distributions /* Copyright (c) (2010,2011,2012,2014,2015,2016,2017,2018,2019) Apple Inc. All rights reserved. 2*fdd8201dSApple OSS Distributions * 3*fdd8201dSApple OSS Distributions * corecrypto is licensed under Apple Inc.’s Internal Use License Agreement (which 4*fdd8201dSApple OSS Distributions * is contained in the License.txt file distributed with corecrypto) and only to 5*fdd8201dSApple OSS Distributions * people who accept that license. IMPORTANT: Any license rights granted to you by 6*fdd8201dSApple OSS Distributions * Apple Inc. (if any) are limited to internal use within your organization only on 7*fdd8201dSApple OSS Distributions * devices and computers you own or control, for the sole purpose of verifying the 8*fdd8201dSApple OSS Distributions * security characteristics and correct functioning of the Apple Software. You may 9*fdd8201dSApple OSS Distributions * not, directly or indirectly, redistribute the Apple Software or any portions thereof. 10*fdd8201dSApple OSS Distributions */ 11*fdd8201dSApple OSS Distributions 12*fdd8201dSApple OSS Distributions #ifndef _CORECRYPTO_CCSHA2_H_ 13*fdd8201dSApple OSS Distributions #define _CORECRYPTO_CCSHA2_H_ 14*fdd8201dSApple OSS Distributions 15*fdd8201dSApple OSS Distributions #include <corecrypto/ccdigest.h> 16*fdd8201dSApple OSS Distributions 17*fdd8201dSApple OSS Distributions /* sha2 selectors */ 18*fdd8201dSApple OSS Distributions const struct ccdigest_info *ccsha224_di(void); 19*fdd8201dSApple OSS Distributions const struct ccdigest_info *ccsha256_di(void); 20*fdd8201dSApple OSS Distributions const struct ccdigest_info *ccsha384_di(void); 21*fdd8201dSApple OSS Distributions const struct ccdigest_info *ccsha512_di(void); 22*fdd8201dSApple OSS Distributions 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*fdd8201dSApple OSS Distributions 24*fdd8201dSApple OSS Distributions #define ccoid_sha224 ((unsigned char *)"\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x04") 25*fdd8201dSApple OSS Distributions #define ccoid_sha224_len 11 26*fdd8201dSApple OSS Distributions 27*fdd8201dSApple OSS Distributions #define ccoid_sha256 ((unsigned char *)"\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x01") 28*fdd8201dSApple OSS Distributions #define ccoid_sha256_len 11 29*fdd8201dSApple OSS Distributions 30*fdd8201dSApple OSS Distributions #define ccoid_sha384 ((unsigned char *)"\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x02") 31*fdd8201dSApple OSS Distributions #define ccoid_sha384_len 11 32*fdd8201dSApple OSS Distributions 33*fdd8201dSApple OSS Distributions #define ccoid_sha512 ((unsigned char *)"\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x03") 34*fdd8201dSApple OSS Distributions #define ccoid_sha512_len 11 35*fdd8201dSApple OSS Distributions 36*fdd8201dSApple OSS Distributions #define ccoid_sha512_256 ((unsigned char *)"\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x06") 37*fdd8201dSApple OSS Distributions #define ccoid_sha512_256_len 11 38*fdd8201dSApple OSS Distributions 39*fdd8201dSApple OSS Distributions /* SHA256 */ 40*fdd8201dSApple OSS Distributions #define CCSHA256_BLOCK_SIZE 64 41*fdd8201dSApple OSS Distributions #define CCSHA256_OUTPUT_SIZE 32 42*fdd8201dSApple OSS Distributions #define CCSHA256_STATE_SIZE 32 43*fdd8201dSApple OSS Distributions extern const struct ccdigest_info ccsha256_ltc_di; 44*fdd8201dSApple OSS Distributions #if CCSHA2_VNG_INTEL 45*fdd8201dSApple OSS Distributions extern const struct ccdigest_info ccsha224_vng_intel_SupplementalSSE3_di; 46*fdd8201dSApple OSS Distributions extern const struct ccdigest_info ccsha256_vng_intel_SupplementalSSE3_di; 47*fdd8201dSApple OSS Distributions #endif 48*fdd8201dSApple OSS Distributions #if CCSHA2_VNG_ARM 49*fdd8201dSApple OSS Distributions extern const struct ccdigest_info ccsha224_vng_arm_di; 50*fdd8201dSApple OSS Distributions extern const struct ccdigest_info ccsha256_vng_arm_di; 51*fdd8201dSApple OSS Distributions #if CC_ACCELERATECRYPTO && defined(__arm64__) && CCSHA2_VNG_ARM 52*fdd8201dSApple OSS Distributions extern const struct ccdigest_info ccsha256_vng_arm64neon_di; 53*fdd8201dSApple OSS Distributions #endif // CC_ACCELERATECRYPTO 54*fdd8201dSApple OSS Distributions extern const struct ccdigest_info ccsha384_vng_arm_di; 55*fdd8201dSApple OSS Distributions extern const struct ccdigest_info ccsha512_vng_arm_di; 56*fdd8201dSApple OSS Distributions extern const struct ccdigest_info ccsha512_256_vng_arm_di; 57*fdd8201dSApple OSS Distributions #endif 58*fdd8201dSApple OSS Distributions 59*fdd8201dSApple OSS Distributions /* SHA224 */ 60*fdd8201dSApple OSS Distributions #define CCSHA224_OUTPUT_SIZE 28 61*fdd8201dSApple OSS Distributions extern const struct ccdigest_info ccsha224_ltc_di; 62*fdd8201dSApple OSS Distributions 63*fdd8201dSApple OSS Distributions /* SHA512 */ 64*fdd8201dSApple OSS Distributions #define CCSHA512_BLOCK_SIZE 128 65*fdd8201dSApple OSS Distributions #define CCSHA512_OUTPUT_SIZE 64 66*fdd8201dSApple OSS Distributions #define CCSHA512_STATE_SIZE 64 67*fdd8201dSApple OSS Distributions extern const struct ccdigest_info ccsha512_ltc_di; 68*fdd8201dSApple OSS Distributions 69*fdd8201dSApple OSS Distributions /* SHA512/256 */ 70*fdd8201dSApple OSS Distributions // FIPS 180-4 71*fdd8201dSApple OSS Distributions // https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf 72*fdd8201dSApple OSS Distributions #define CCSHA512_256_BLOCK_SIZE 128 73*fdd8201dSApple OSS Distributions #define CCSHA512_256_OUTPUT_SIZE 32 74*fdd8201dSApple OSS Distributions #define CCSHA512_256_STATE_SIZE 64 75*fdd8201dSApple OSS Distributions extern const struct ccdigest_info ccsha512_256_ltc_di; 76*fdd8201dSApple OSS Distributions 77*fdd8201dSApple OSS Distributions /* SHA384 */ 78*fdd8201dSApple OSS Distributions #define CCSHA384_OUTPUT_SIZE 48 79*fdd8201dSApple OSS Distributions extern const struct ccdigest_info ccsha384_ltc_di; 80*fdd8201dSApple OSS Distributions 81*fdd8201dSApple OSS Distributions #endif /* _CORECRYPTO_CCSHA2_H_ */ 82