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