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