]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /********************************************************************** |
2 | Copyright(c) 2011-2016 Intel Corporation All rights reserved. | |
3 | ||
4 | Redistribution and use in source and binary forms, with or without | |
1e59de90 | 5 | modification, are permitted provided that the following conditions |
7c673cae FG |
6 | are met: |
7 | * Redistributions of source code must retain the above copyright | |
8 | notice, this list of conditions and the following disclaimer. | |
9 | * Redistributions in binary form must reproduce the above copyright | |
10 | notice, this list of conditions and the following disclaimer in | |
11 | the documentation and/or other materials provided with the | |
12 | distribution. | |
13 | * Neither the name of Intel Corporation nor the names of its | |
14 | contributors may be used to endorse or promote products derived | |
15 | from this software without specific prior written permission. | |
16 | ||
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
28 | **********************************************************************/ | |
29 | ||
30 | #ifndef _MH_SHA1_MURMUR3_X64_128_INTERNAL_H_ | |
31 | #define _MH_SHA1_MURMUR3_X64_128_INTERNAL_H_ | |
32 | ||
33 | /** | |
34 | * @file mh_sha1_murmur3_x64_128_internal.h | |
35 | * @brief mh_sha1_murmur3_x64_128 internal function prototypes and macros | |
36 | * | |
37 | * Interface for mh_sha1_murmur3_x64_128 internal functions | |
38 | * | |
39 | */ | |
40 | #include <stdint.h> | |
41 | #include "mh_sha1_internal.h" | |
42 | #include "mh_sha1_murmur3_x64_128.h" | |
43 | ||
44 | #ifdef __cplusplus | |
45 | extern "C" { | |
46 | #endif | |
47 | ||
48 | #ifdef _MSC_VER | |
49 | # define inline __inline | |
50 | #endif | |
51 | ||
52 | /******************************************************************* | |
53 | * mh_sha1_murmur3_x64_128 API internal function prototypes | |
54 | * Multiple versions of Update and Finalize functions are supplied which use | |
55 | * multiple versions of block and tail process subfunctions. | |
56 | ******************************************************************/ | |
57 | ||
58 | /** | |
59 | * @brief Calculate blocks which size is MH_SHA1_BLOCK_SIZE*N | |
60 | * | |
61 | * This function determines what instruction sets are enabled and selects the | |
62 | * appropriate version at runtime. | |
63 | * | |
64 | * @param input_data Pointer to input data to be processed | |
65 | * @param mh_sha1_digests 16 segments digests | |
66 | * @param frame_buffer Pointer to buffer which is a temp working area | |
67 | * @param murmur3_x64_128_digests Murmur3 digest | |
68 | * @param num_blocks The number of blocks. | |
69 | * @returns none | |
70 | * | |
71 | */ | |
72 | // Each function needs an individual C or ASM file because they impact performance much. | |
73 | //They will be called by mh_sha1_murmur3_x64_128_update_XXX. | |
74 | void mh_sha1_murmur3_x64_128_block (const uint8_t * input_data, | |
75 | uint32_t mh_sha1_digests[SHA1_DIGEST_WORDS][HASH_SEGS], | |
76 | uint8_t frame_buffer[MH_SHA1_BLOCK_SIZE], | |
77 | uint32_t murmur3_x64_128_digests[MURMUR3_x64_128_DIGEST_WORDS], | |
78 | uint32_t num_blocks); | |
79 | ||
80 | /** | |
81 | * @brief Calculate blocks which size is MH_SHA1_BLOCK_SIZE*N | |
82 | * | |
83 | * @param input_data Pointer to input data to be processed | |
84 | * @param mh_sha1_digests 16 segments digests | |
85 | * @param frame_buffer Pointer to buffer which is a temp working area | |
86 | * @param murmur3_x64_128_digests Murmur3 digest | |
87 | * @param num_blocks The number of blocks. | |
88 | * @returns none | |
89 | * | |
90 | */ | |
91 | void mh_sha1_murmur3_x64_128_block_base (const uint8_t * input_data, | |
92 | uint32_t mh_sha1_digests[SHA1_DIGEST_WORDS][HASH_SEGS], | |
93 | uint8_t frame_buffer[MH_SHA1_BLOCK_SIZE], | |
94 | uint32_t murmur3_x64_128_digests[MURMUR3_x64_128_DIGEST_WORDS], | |
95 | uint32_t num_blocks); | |
96 | ||
97 | /** | |
98 | * @brief Calculate blocks which size is MH_SHA1_BLOCK_SIZE*N | |
99 | * | |
100 | * @requires SSE | |
101 | * | |
102 | * @param input_data Pointer to input data to be processed | |
103 | * @param mh_sha1_digests 16 segments digests | |
104 | * @param frame_buffer Pointer to buffer which is a temp working area | |
105 | * @param murmur3_x64_128_digests Murmur3 digest | |
106 | * @param num_blocks The number of blocks. | |
107 | * @returns none | |
108 | * | |
109 | */ | |
110 | void mh_sha1_murmur3_x64_128_block_sse (const uint8_t * input_data, | |
111 | uint32_t mh_sha1_digests[SHA1_DIGEST_WORDS][HASH_SEGS], | |
112 | uint8_t frame_buffer[MH_SHA1_BLOCK_SIZE], | |
113 | uint32_t murmur3_x64_128_digests[MURMUR3_x64_128_DIGEST_WORDS], | |
114 | uint32_t num_blocks); | |
115 | ||
116 | /** | |
117 | * @brief Calculate blocks which size is MH_SHA1_BLOCK_SIZE*N | |
118 | * | |
119 | * @requires AVX | |
120 | * | |
121 | * @param input_data Pointer to input data to be processed | |
122 | * @param mh_sha1_digests 16 segments digests | |
123 | * @param frame_buffer Pointer to buffer which is a temp working area | |
124 | * @param murmur3_x64_128_digests Murmur3 digest | |
125 | * @param num_blocks The number of blocks. | |
126 | * @returns none | |
127 | * | |
128 | */ | |
129 | void mh_sha1_murmur3_x64_128_block_avx (const uint8_t * input_data, | |
130 | uint32_t mh_sha1_digests[SHA1_DIGEST_WORDS][HASH_SEGS], | |
131 | uint8_t frame_buffer[MH_SHA1_BLOCK_SIZE], | |
132 | uint32_t murmur3_x64_128_digests[MURMUR3_x64_128_DIGEST_WORDS], | |
133 | uint32_t num_blocks); | |
134 | ||
135 | /** | |
136 | * @brief Calculate blocks which size is MH_SHA1_BLOCK_SIZE*N | |
137 | * | |
138 | * @requires AVX2 | |
139 | * | |
140 | * @param input_data Pointer to input data to be processed | |
141 | * @param mh_sha1_digests 16 segments digests | |
142 | * @param frame_buffer Pointer to buffer which is a temp working area | |
143 | * @param murmur3_x64_128_digests Murmur3 digest | |
144 | * @param num_blocks The number of blocks. | |
145 | * @returns none | |
146 | * | |
147 | */ | |
148 | void mh_sha1_murmur3_x64_128_block_avx2 (const uint8_t * input_data, | |
149 | uint32_t mh_sha1_digests[SHA1_DIGEST_WORDS][HASH_SEGS], | |
150 | uint8_t frame_buffer[MH_SHA1_BLOCK_SIZE], | |
151 | uint32_t murmur3_x64_128_digests[MURMUR3_x64_128_DIGEST_WORDS], | |
152 | uint32_t num_blocks); | |
153 | ||
154 | /** | |
155 | * @brief Calculate blocks which size is MH_SHA1_BLOCK_SIZE*N | |
156 | * | |
157 | * @requires AVX512 | |
158 | * | |
159 | * @param input_data Pointer to input data to be processed | |
160 | * @param mh_sha1_digests 16 segments digests | |
161 | * @param frame_buffer Pointer to buffer which is a temp working area | |
162 | * @param murmur3_x64_128_digests Murmur3 digest | |
163 | * @param num_blocks The number of blocks. | |
164 | * @returns none | |
165 | * | |
166 | */ | |
167 | void mh_sha1_murmur3_x64_128_block_avx512 (const uint8_t * input_data, | |
168 | uint32_t mh_sha1_digests[SHA1_DIGEST_WORDS][HASH_SEGS], | |
169 | uint8_t frame_buffer[MH_SHA1_BLOCK_SIZE], | |
170 | uint32_t murmur3_x64_128_digests[MURMUR3_x64_128_DIGEST_WORDS], | |
171 | uint32_t num_blocks); | |
172 | /******************************************************************* | |
173 | * murmur hash API | |
174 | ******************************************************************/ | |
175 | ||
176 | /** | |
177 | * @brief Calculate murmur digest of blocks which size is 16*N. | |
178 | * @param input_data Pointer to input data to be processed | |
179 | * @param num_blocks The number of blocks which size is 16. | |
180 | * @param murmur3_x64_128_digests Murmur3 digest | |
181 | * @returns none | |
182 | * | |
183 | */ | |
184 | void murmur3_x64_128_block(const uint8_t * input_data, uint32_t num_blocks, | |
185 | uint32_t digests[MURMUR3_x64_128_DIGEST_WORDS]); | |
186 | ||
187 | /** | |
188 | * @brief Do the tail process which is less than 16Byte. | |
189 | * @param tail_buffer Pointer to input data to be processed | |
190 | * @param total_len The total length of the input_data | |
191 | * @param digests Murmur3 digest | |
192 | * @returns none | |
193 | * | |
194 | */ | |
195 | void murmur3_x64_128_tail(const uint8_t * tail_buffer, uint32_t total_len, | |
196 | uint32_t digests[MURMUR3_x64_128_DIGEST_WORDS]); | |
197 | ||
198 | #ifdef __cplusplus | |
199 | } | |
200 | #endif | |
201 | ||
202 | #endif |