5 * Created on 12/19/2017
7 * Copyright (c) 2017 Apple Inc. All rights reserved.
10 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
12 * This file contains Original Code and/or Modifications of Original Code
13 * as defined in and that are subject to the Apple Public Source License
14 * Version 2.0 (the 'License'). You may not use this file except in
15 * compliance with the License. The rights granted to you under the License
16 * may not be used to create, or enable the creation or redistribution of,
17 * unlawful or unlicensed copies of an Apple operating system, or to
18 * circumvent, violate, or enable the circumvention or violation of, any
19 * terms of an Apple operating system software license agreement.
21 * Please obtain a copy of the License at
22 * http://www.opensource.apple.com/apsl/ and read it before using this file.
24 * The Original Code and all software distributed under the License are
25 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
26 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
27 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
28 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
29 * Please see the License for the specific language governing rights and
30 * limitations under the License.
32 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
35 #ifndef _CORECRYPTO_CCSHA2_INTERNAL_H_
36 #define _CORECRYPTO_CCSHA2_INTERNAL_H_
38 #include <corecrypto/ccdigest.h>
40 #ifndef CCSHA2_DISABLE_SHA512
41 #define CCSHA2_DISABLE_SHA512 0
44 #define CCSHA2_SHA256_USE_SHA512_K (CC_SMALL_CODE && !CCSHA2_DISABLE_SHA512)
46 extern const struct ccdigest_info ccsha256_v6m_di
;
47 void ccsha256_v6m_compress(ccdigest_state_t state
, size_t nblocks
, const void *buf
);
49 void ccsha256_ltc_compress(ccdigest_state_t state
, size_t nblocks
, const void *buf
);
50 void ccsha512_ltc_compress(ccdigest_state_t state
, size_t nblocks
, const void *in
);
53 #if defined __x86_64__
54 void ccsha256_vng_intel_avx2_compress(ccdigest_state_t state
, size_t nblocks
, const void *in
) __asm__("_ccsha256_vng_intel_avx2_compress");
55 void ccsha256_vng_intel_avx1_compress(ccdigest_state_t state
, size_t nblocks
, const void *in
) __asm__("_ccsha256_vng_intel_avx1_compress");
56 void ccsha256_vng_intel_ssse3_compress(ccdigest_state_t state
, size_t nblocks
, const void *in
) __asm__("_ccsha256_vng_intel_sse3_compress");
57 void ccsha512_vng_intel_avx2_compress(ccdigest_state_t state
, size_t nblocks
, const void *in
) __asm__("_ccsha512_vng_intel_avx2_compress");
58 void ccsha512_vng_intel_avx1_compress(ccdigest_state_t state
, size_t nblocks
, const void *in
) __asm__("_ccsha512_vng_intel_avx1_compress");
59 void ccsha512_vng_intel_ssse3_compress(ccdigest_state_t state
, size_t nblocks
, const void *in
) __asm__("_ccsha512_vng_intel_ssse3_compress");
61 #if CC_ACCELERATECRYPTO
63 extern const struct ccdigest_info ccsha224_vng_intel_di
;
64 extern const struct ccdigest_info ccsha256_vng_intel_di
;
65 extern const struct ccdigest_info ccsha384_vng_intel_di
;
66 extern const struct ccdigest_info ccsha512_vng_intel_di
;
67 extern const struct ccdigest_info ccsha512_256_vng_intel_di
;
70 extern const struct ccdigest_info ccsha224_vng_intel_AVX2_di
;
71 extern const struct ccdigest_info ccsha224_vng_intel_AVX1_di
;
72 extern const struct ccdigest_info ccsha256_vng_intel_AVX2_di
;
73 extern const struct ccdigest_info ccsha256_vng_intel_AVX1_di
;
74 extern const struct ccdigest_info ccsha384_vng_intel_AVX2_di
;
75 extern const struct ccdigest_info ccsha384_vng_intel_AVX1_di
;
76 extern const struct ccdigest_info ccsha384_vng_intel_SupplementalSSE3_di
;
77 extern const struct ccdigest_info ccsha512_vng_intel_AVX2_di
;
78 extern const struct ccdigest_info ccsha512_vng_intel_AVX1_di
;
79 extern const struct ccdigest_info ccsha512_vng_intel_SupplementalSSE3_di
;
80 extern const struct ccdigest_info ccsha512_256_vng_intel_AVX2_di
;
81 extern const struct ccdigest_info ccsha512_256_vng_intel_AVX1_di
;
82 extern const struct ccdigest_info ccsha512_256_vng_intel_SupplementalSSE3_di
;
85 void ccsha256_vng_intel_sse3_compress(ccdigest_state_t state
, size_t nblocks
, const void *in
) __asm__("_ccsha256_vng_intel_sse3_compress");
88 extern const uint32_t ccsha256_K
[64];
89 extern const uint64_t ccsha512_K
[80];
91 void ccsha512_final(const struct ccdigest_info
*di
, ccdigest_ctx_t ctx
, unsigned char *digest
);
93 extern const uint32_t ccsha224_initial_state
[8];
94 extern const uint32_t ccsha256_initial_state
[8];
95 extern const uint64_t ccsha384_initial_state
[8];
96 extern const uint64_t ccsha512_initial_state
[8];
97 extern const uint64_t ccsha512_256_initial_state
[8];
99 #endif /* _CORECRYPTO_CCSHA2_INTERNAL_H_ */