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