]> git.saurik.com Git - apple/xnu.git/blame - osfmk/corecrypto/ccsha2_internal.h
xnu-7195.101.1.tar.gz
[apple/xnu.git] / osfmk / corecrypto / ccsha2_internal.h
CommitLineData
5ba3f43e
A
1/*
2 * ccsha2_internal.h
3 * corecrypto
4 *
d9a64523 5 * Created on 12/19/2017
5ba3f43e 6 *
d9a64523 7 * Copyright (c) 2017 Apple Inc. All rights reserved.
5ba3f43e
A
8 *
9 *
10 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
11 *
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.
20 *
21 * Please obtain a copy of the License at
22 * http://www.opensource.apple.com/apsl/ and read it before using this file.
23 *
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.
31 *
32 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
33 */
34
35#ifndef _CORECRYPTO_CCSHA2_INTERNAL_H_
36#define _CORECRYPTO_CCSHA2_INTERNAL_H_
37
38#include <corecrypto/ccdigest.h>
39
cb323159
A
40#ifndef CCSHA2_DISABLE_SHA512
41#define CCSHA2_DISABLE_SHA512 0
42#endif
43
44#define CCSHA2_SHA256_USE_SHA512_K (CC_SMALL_CODE && !CCSHA2_DISABLE_SHA512)
45
d9a64523 46extern const struct ccdigest_info ccsha256_v6m_di;
5ba3f43e 47void ccsha256_v6m_compress(ccdigest_state_t state, size_t nblocks, const void *buf);
d9a64523
A
48
49void ccsha256_ltc_compress(ccdigest_state_t state, size_t nblocks, const void *buf);
5ba3f43e
A
50void ccsha512_ltc_compress(ccdigest_state_t state, size_t nblocks, const void *in);
51
52#if CCSHA2_VNG_INTEL
53#if defined __x86_64__
cb323159
A
54void ccsha256_vng_intel_avx2_compress(ccdigest_state_t state, size_t nblocks, const void *in) __asm__("_ccsha256_vng_intel_avx2_compress");
55void ccsha256_vng_intel_avx1_compress(ccdigest_state_t state, size_t nblocks, const void *in) __asm__("_ccsha256_vng_intel_avx1_compress");
56void ccsha256_vng_intel_ssse3_compress(ccdigest_state_t state, size_t nblocks, const void *in) __asm__("_ccsha256_vng_intel_sse3_compress");
57void ccsha512_vng_intel_avx2_compress(ccdigest_state_t state, size_t nblocks, const void *in) __asm__("_ccsha512_vng_intel_avx2_compress");
58void ccsha512_vng_intel_avx1_compress(ccdigest_state_t state, size_t nblocks, const void *in) __asm__("_ccsha512_vng_intel_avx1_compress");
59void ccsha512_vng_intel_ssse3_compress(ccdigest_state_t state, size_t nblocks, const void *in) __asm__("_ccsha512_vng_intel_ssse3_compress");
60
61#if CC_ACCELERATECRYPTO
62// AccelerateCrypto
63extern const struct ccdigest_info ccsha224_vng_intel_di;
64extern const struct ccdigest_info ccsha256_vng_intel_di;
65extern const struct ccdigest_info ccsha384_vng_intel_di;
66extern const struct ccdigest_info ccsha512_vng_intel_di;
f427ee49 67extern const struct ccdigest_info ccsha512_256_vng_intel_di;
cb323159 68#endif
d9a64523
A
69
70extern const struct ccdigest_info ccsha224_vng_intel_AVX2_di;
71extern const struct ccdigest_info ccsha224_vng_intel_AVX1_di;
72extern const struct ccdigest_info ccsha256_vng_intel_AVX2_di;
73extern const struct ccdigest_info ccsha256_vng_intel_AVX1_di;
74extern const struct ccdigest_info ccsha384_vng_intel_AVX2_di;
75extern const struct ccdigest_info ccsha384_vng_intel_AVX1_di;
76extern const struct ccdigest_info ccsha384_vng_intel_SupplementalSSE3_di;
77extern const struct ccdigest_info ccsha512_vng_intel_AVX2_di;
78extern const struct ccdigest_info ccsha512_vng_intel_AVX1_di;
79extern const struct ccdigest_info ccsha512_vng_intel_SupplementalSSE3_di;
f427ee49
A
80extern const struct ccdigest_info ccsha512_256_vng_intel_AVX2_di;
81extern const struct ccdigest_info ccsha512_256_vng_intel_AVX1_di;
82extern const struct ccdigest_info ccsha512_256_vng_intel_SupplementalSSE3_di;
83
5ba3f43e 84#endif
cb323159 85void ccsha256_vng_intel_sse3_compress(ccdigest_state_t state, size_t nblocks, const void *in) __asm__("_ccsha256_vng_intel_sse3_compress");
d9a64523
A
86#endif
87
88extern const uint32_t ccsha256_K[64];
89extern const uint64_t ccsha512_K[80];
90
5ba3f43e
A
91void ccsha512_final(const struct ccdigest_info *di, ccdigest_ctx_t ctx, unsigned char *digest);
92
93extern const uint32_t ccsha224_initial_state[8];
94extern const uint32_t ccsha256_initial_state[8];
95extern const uint64_t ccsha384_initial_state[8];
96extern const uint64_t ccsha512_initial_state[8];
f427ee49 97extern const uint64_t ccsha512_256_initial_state[8];
d9a64523 98
5ba3f43e 99#endif /* _CORECRYPTO_CCSHA2_INTERNAL_H_ */