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