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