1 /*
2 * This file is part of the openHiTLS project.
3 *
4 * openHiTLS is licensed under the Mulan PSL v2.
5 * You can use this software according to the terms and conditions of the Mulan PSL v2.
6 * You may obtain a copy of Mulan PSL v2 at:
7 *
8 * http://license.coscl.org.cn/MulanPSL2
9 *
10 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13 * See the Mulan PSL v2 for more details.
14 */
15
16 #include "hitls_build.h"
17 #ifdef HITLS_CRYPTO_SHA3
18
19 #include <stdlib.h>
20 #include "securec.h"
21 #include "crypt_errno.h"
22 #include "crypt_utils.h"
23 #include "bsl_err_internal.h"
24 #include "bsl_sal.h"
25 #include "sha3_core.h"
26 #include "crypt_sha3.h"
27 #include "crypt_types.h"
28
29 struct CryptSha3Ctx {
30 uint8_t state[200]; // State array, 200bytes is 1600bits
31 uint32_t num; // Data length in the remaining buffer.
32 uint32_t blockSize; // For example, BlockSize(sha3-224) = ((1600 - 224 * 2) / 8) bytes
33 uint32_t mdSize; // sha3-224 corresponds to 28 bytes, sha3-256: 32 bytes, sha3-384: 48 bytes, sha3-512: 64 bytes
34 // Non-integer multiple data cache. 168 = (1600 - 128 * 2) / 8, that is maximum block size used by shake_*
35 uint8_t buf[168];
36 uint8_t padChr; // char for padding, sha3_* use 0x06 and shake_* use 0x1f
37 bool squeeze;
38 };
39
CRYPT_SHA3_NewCtx(void)40 static CRYPT_SHA3_Ctx *CRYPT_SHA3_NewCtx(void)
41 {
42 return BSL_SAL_Calloc(1, sizeof(CRYPT_SHA3_Ctx));
43 }
44
CRYPT_SHA3_FreeCtx(CRYPT_SHA3_Ctx * ctx)45 static void CRYPT_SHA3_FreeCtx(CRYPT_SHA3_Ctx *ctx)
46 {
47 CRYPT_SHA3_Ctx *mdCtx = ctx;
48 if (mdCtx == NULL) {
49 return;
50 }
51 BSL_SAL_ClearFree(ctx, sizeof(CRYPT_SHA3_Ctx));
52 }
53
CRYPT_SHA3_Init(CRYPT_SHA3_Ctx * ctx,uint32_t mdSize,uint32_t blockSize,uint8_t padChr)54 static int32_t CRYPT_SHA3_Init(CRYPT_SHA3_Ctx *ctx, uint32_t mdSize, uint32_t blockSize, uint8_t padChr)
55 {
56 if (ctx == NULL) {
57 BSL_ERR_PUSH_ERROR(CRYPT_NULL_INPUT);
58 return CRYPT_NULL_INPUT;
59 }
60 (void)memset_s(ctx, sizeof(CRYPT_SHA3_Ctx), 0, sizeof(CRYPT_SHA3_Ctx));
61 ctx->mdSize = mdSize;
62 ctx->padChr = padChr;
63 ctx->blockSize = blockSize;
64 return CRYPT_SUCCESS;
65 }
66
CRYPT_SHA3_Update(CRYPT_SHA3_Ctx * ctx,const uint8_t * in,uint32_t len)67 static int32_t CRYPT_SHA3_Update(CRYPT_SHA3_Ctx *ctx, const uint8_t *in, uint32_t len)
68 {
69 if (ctx == NULL || (in == NULL && len != 0)) {
70 BSL_ERR_PUSH_ERROR(CRYPT_NULL_INPUT);
71 return CRYPT_NULL_INPUT;
72 }
73 if (len == 0) {
74 return CRYPT_SUCCESS;
75 }
76
77 const uint8_t *data = in;
78 uint32_t left = ctx->blockSize - ctx->num;
79 uint32_t dataLen = len;
80
81 if (ctx->num != 0) {
82 if (dataLen < left) {
83 (void)memcpy_s(ctx->buf + ctx->num, left, data, dataLen);
84 ctx->num += dataLen;
85 return CRYPT_SUCCESS;
86 }
87
88 // When the external input data is greater than the remaining space of the block,
89 // copy the data of the remaining space.
90 (void)memcpy_s(ctx->buf + ctx->num, left, data, left);
91 SHA3_Absorb(ctx->state, ctx->buf, ctx->blockSize, ctx->blockSize);
92 dataLen -= left;
93 data += left;
94 ctx->num = 0;
95 }
96
97 data = SHA3_Absorb(ctx->state, data, dataLen, ctx->blockSize);
98 dataLen = len - (data - in);
99 if (dataLen != 0) {
100 // copy the remaining data to the cache array
101 (void)memcpy_s(ctx->buf, ctx->blockSize, data, dataLen);
102 ctx->num = dataLen;
103 }
104
105 return CRYPT_SUCCESS;
106 }
107
CRYPT_SHA3_Final(CRYPT_SHA3_Ctx * ctx,uint8_t * out,uint32_t * len)108 static int32_t CRYPT_SHA3_Final(CRYPT_SHA3_Ctx *ctx, uint8_t *out, uint32_t *len)
109 {
110 if (ctx == NULL || out == NULL || len == NULL) {
111 BSL_ERR_PUSH_ERROR(CRYPT_NULL_INPUT);
112 return CRYPT_NULL_INPUT;
113 }
114
115 if (*len < ctx->mdSize) {
116 BSL_ERR_PUSH_ERROR(CRYPT_SHA3_OUT_BUFF_LEN_NOT_ENOUGH);
117 return CRYPT_SHA3_OUT_BUFF_LEN_NOT_ENOUGH;
118 }
119
120 uint32_t left = ctx->blockSize - ctx->num;
121 uint32_t outLen = (ctx->mdSize == 0) ? *len : ctx->mdSize;
122 (void)memset_s(ctx->buf + ctx->num, left, 0, left);
123 ctx->buf[ctx->num] = ctx->padChr;
124 ctx->buf[ctx->blockSize - 1] |= 0x80; // 0x80 is the last 1 of pad 10*1 mode
125
126 (void)SHA3_Absorb(ctx->state, ctx->buf, ctx->blockSize, ctx->blockSize);
127 SHA3_Squeeze(ctx->state, out, outLen, ctx->blockSize, false);
128 *len = outLen;
129
130 return CRYPT_SUCCESS;
131 }
132
CRYPT_SHA3_Squeeze(CRYPT_SHA3_Ctx * ctx,uint8_t * out,uint32_t len)133 static int32_t CRYPT_SHA3_Squeeze(CRYPT_SHA3_Ctx *ctx, uint8_t *out, uint32_t len)
134 {
135 if (ctx == NULL || out == NULL) {
136 BSL_ERR_PUSH_ERROR(CRYPT_NULL_INPUT);
137 return CRYPT_NULL_INPUT;
138 }
139
140 if (!ctx->squeeze) {
141 uint32_t left = ctx->blockSize - ctx->num;
142 (void)memset_s(ctx->buf + ctx->num, left, 0, left);
143 ctx->buf[ctx->num] = ctx->padChr;
144 ctx->buf[ctx->blockSize - 1] |= 0x80; // 0x80 is the last 1 of pad 10*1 mode
145 (void)SHA3_Absorb(ctx->state, ctx->buf, ctx->blockSize, ctx->blockSize);
146 ctx->num = 0;
147 ctx->squeeze = true;
148 }
149 uint32_t tmpLen = len;
150 uint8_t *outTmp = out;
151 if (ctx->num != 0) {
152 uint32_t outLen = (ctx->num > len) ? len : ctx->num;
153 (void)memcpy_s(outTmp, outLen, ctx->buf + ctx->blockSize - ctx->num, outLen);
154 ctx->num -= outLen;
155 tmpLen -= outLen;
156 outTmp += outLen;
157 }
158 if (tmpLen > ctx->blockSize) {
159 uint32_t comLen = tmpLen / ctx->blockSize * ctx->blockSize;
160 SHA3_Squeeze(ctx->state, outTmp, comLen, ctx->blockSize, true);
161 outTmp += comLen;
162 tmpLen -= comLen;
163 }
164 if (tmpLen != 0) {
165 SHA3_Squeeze(ctx->state, ctx->buf, ctx->blockSize, ctx->blockSize, true);
166 (void)memcpy_s(outTmp, tmpLen, ctx->buf, tmpLen);
167 ctx->num = ctx->blockSize - tmpLen;
168 }
169 return CRYPT_SUCCESS;
170 }
171
CRYPT_SHA3_Deinit(CRYPT_SHA3_Ctx * ctx)172 static void CRYPT_SHA3_Deinit(CRYPT_SHA3_Ctx *ctx)
173 {
174 if (ctx == NULL) {
175 BSL_ERR_PUSH_ERROR(CRYPT_NULL_INPUT);
176 return;
177 }
178 BSL_SAL_CleanseData(ctx, sizeof(CRYPT_SHA3_Ctx));
179 }
180
CRYPT_SHA3_CopyCtx(CRYPT_SHA3_Ctx * dst,const CRYPT_SHA3_Ctx * src)181 static int32_t CRYPT_SHA3_CopyCtx(CRYPT_SHA3_Ctx *dst, const CRYPT_SHA3_Ctx *src)
182 {
183 if (dst == NULL || src == NULL) {
184 BSL_ERR_PUSH_ERROR(CRYPT_NULL_INPUT);
185 return CRYPT_NULL_INPUT;
186 }
187
188 (void)memcpy_s(dst, sizeof(CRYPT_SHA3_Ctx), src, sizeof(CRYPT_SHA3_Ctx));
189 return CRYPT_SUCCESS;
190 }
191
CRYPT_SHA3_DupCtx(const CRYPT_SHA3_Ctx * src)192 static CRYPT_SHA3_Ctx *CRYPT_SHA3_DupCtx(const CRYPT_SHA3_Ctx *src)
193 {
194 if (src == NULL) {
195 BSL_ERR_PUSH_ERROR(CRYPT_NULL_INPUT);
196 return NULL;
197 }
198 CRYPT_SHA3_Ctx *newCtx = CRYPT_SHA3_NewCtx();
199 if (newCtx == NULL) {
200 BSL_ERR_PUSH_ERROR(CRYPT_MEM_ALLOC_FAIL);
201 return NULL;
202 }
203 (void)memcpy_s(newCtx, sizeof(CRYPT_SHA3_Ctx), src, sizeof(CRYPT_SHA3_Ctx));
204 return newCtx;
205 }
206
207 // new context
CRYPT_SHA3_224_NewCtx(void)208 CRYPT_SHA3_224_Ctx *CRYPT_SHA3_224_NewCtx(void)
209 {
210 return CRYPT_SHA3_NewCtx();
211 }
CRYPT_SHA3_256_NewCtx(void)212 CRYPT_SHA3_256_Ctx *CRYPT_SHA3_256_NewCtx(void)
213 {
214 return CRYPT_SHA3_NewCtx();
215 }
CRYPT_SHA3_384_NewCtx(void)216 CRYPT_SHA3_384_Ctx *CRYPT_SHA3_384_NewCtx(void)
217 {
218 return CRYPT_SHA3_NewCtx();
219 }
CRYPT_SHA3_512_NewCtx(void)220 CRYPT_SHA3_512_Ctx *CRYPT_SHA3_512_NewCtx(void)
221 {
222 return CRYPT_SHA3_NewCtx();
223 }
CRYPT_SHAKE128_NewCtx(void)224 CRYPT_SHAKE128_Ctx* CRYPT_SHAKE128_NewCtx(void)
225 {
226 return CRYPT_SHA3_NewCtx();
227 }
CRYPT_SHAKE256_NewCtx(void)228 CRYPT_SHAKE256_Ctx* CRYPT_SHAKE256_NewCtx(void)
229 {
230 return CRYPT_SHA3_NewCtx();
231 }
232
233 // free context
CRYPT_SHA3_224_FreeCtx(CRYPT_SHA3_224_Ctx * ctx)234 void CRYPT_SHA3_224_FreeCtx(CRYPT_SHA3_224_Ctx* ctx)
235 {
236 CRYPT_SHA3_FreeCtx(ctx);
237 }
CRYPT_SHA3_256_FreeCtx(CRYPT_SHA3_256_Ctx * ctx)238 void CRYPT_SHA3_256_FreeCtx(CRYPT_SHA3_256_Ctx* ctx)
239 {
240 CRYPT_SHA3_FreeCtx(ctx);
241 }
CRYPT_SHA3_384_FreeCtx(CRYPT_SHA3_384_Ctx * ctx)242 void CRYPT_SHA3_384_FreeCtx(CRYPT_SHA3_384_Ctx* ctx)
243 {
244 CRYPT_SHA3_FreeCtx(ctx);
245 }
CRYPT_SHA3_512_FreeCtx(CRYPT_SHA3_512_Ctx * ctx)246 void CRYPT_SHA3_512_FreeCtx(CRYPT_SHA3_512_Ctx* ctx)
247 {
248 CRYPT_SHA3_FreeCtx(ctx);
249 }
CRYPT_SHAKE128_FreeCtx(CRYPT_SHAKE128_Ctx * ctx)250 void CRYPT_SHAKE128_FreeCtx(CRYPT_SHAKE128_Ctx* ctx)
251 {
252 CRYPT_SHA3_FreeCtx(ctx);
253 }
CRYPT_SHAKE256_FreeCtx(CRYPT_SHAKE256_Ctx * ctx)254 void CRYPT_SHAKE256_FreeCtx(CRYPT_SHAKE256_Ctx* ctx)
255 {
256 CRYPT_SHA3_FreeCtx(ctx);
257 }
258
CRYPT_SHA3_224_Init(CRYPT_SHA3_224_Ctx * ctx,BSL_Param * param)259 int32_t CRYPT_SHA3_224_Init(CRYPT_SHA3_224_Ctx *ctx, BSL_Param *param)
260 {
261 (void) param;
262 // 0x06 is SHA3 padding character, see https://keccak.team/keccak_specs_summary.html
263 return CRYPT_SHA3_Init(ctx, CRYPT_SHA3_224_DIGESTSIZE, CRYPT_SHA3_224_BLOCKSIZE, 0x06);
264 }
265
CRYPT_SHA3_256_Init(CRYPT_SHA3_256_Ctx * ctx,BSL_Param * param)266 int32_t CRYPT_SHA3_256_Init(CRYPT_SHA3_256_Ctx *ctx, BSL_Param *param)
267 {
268 (void) param;
269 // 0x06 is SHA3 padding character, see https://keccak.team/keccak_specs_summary.html
270 return CRYPT_SHA3_Init(ctx, CRYPT_SHA3_256_DIGESTSIZE, CRYPT_SHA3_256_BLOCKSIZE, 0x06);
271 }
272
CRYPT_SHA3_384_Init(CRYPT_SHA3_384_Ctx * ctx,BSL_Param * param)273 int32_t CRYPT_SHA3_384_Init(CRYPT_SHA3_384_Ctx *ctx, BSL_Param *param)
274 {
275 (void) param;
276 // 0x06 is SHA3 padding character, see https://keccak.team/keccak_specs_summary.html
277 return CRYPT_SHA3_Init(ctx, CRYPT_SHA3_384_DIGESTSIZE, CRYPT_SHA3_384_BLOCKSIZE, 0x06);
278 }
279
CRYPT_SHA3_512_Init(CRYPT_SHA3_512_Ctx * ctx,BSL_Param * param)280 int32_t CRYPT_SHA3_512_Init(CRYPT_SHA3_512_Ctx *ctx, BSL_Param *param)
281 {
282 (void) param;
283 // 0x06 is SHA3 padding character, see https://keccak.team/keccak_specs_summary.html
284 return CRYPT_SHA3_Init(ctx, CRYPT_SHA3_512_DIGESTSIZE, CRYPT_SHA3_512_BLOCKSIZE, 0x06);
285 }
286
CRYPT_SHAKE128_Init(CRYPT_SHAKE128_Ctx * ctx,BSL_Param * param)287 int32_t CRYPT_SHAKE128_Init(CRYPT_SHAKE128_Ctx *ctx, BSL_Param *param)
288 {
289 (void) param;
290 // 0x1f is SHA3 padding character, see https://keccak.team/keccak_specs_summary.html
291 return CRYPT_SHA3_Init(ctx, 0, CRYPT_SHAKE128_BLOCKSIZE, 0x1F);
292 }
293
CRYPT_SHAKE256_Init(CRYPT_SHAKE256_Ctx * ctx,BSL_Param * param)294 int32_t CRYPT_SHAKE256_Init(CRYPT_SHAKE256_Ctx *ctx, BSL_Param *param)
295 {
296 (void) param;
297 // 0x1f is SHA3 padding character, see https://keccak.team/keccak_specs_summary.html
298 return CRYPT_SHA3_Init(ctx, 0, CRYPT_SHAKE256_BLOCKSIZE, 0x1F);
299 }
300
CRYPT_SHA3_224_Update(CRYPT_SHA3_224_Ctx * ctx,const uint8_t * in,uint32_t len)301 int32_t CRYPT_SHA3_224_Update(CRYPT_SHA3_224_Ctx *ctx, const uint8_t *in, uint32_t len)
302 {
303 return CRYPT_SHA3_Update(ctx, in, len);
304 }
305
CRYPT_SHA3_256_Update(CRYPT_SHA3_256_Ctx * ctx,const uint8_t * in,uint32_t len)306 int32_t CRYPT_SHA3_256_Update(CRYPT_SHA3_256_Ctx *ctx, const uint8_t *in, uint32_t len)
307 {
308 return CRYPT_SHA3_Update(ctx, in, len);
309 }
310
CRYPT_SHA3_384_Update(CRYPT_SHA3_384_Ctx * ctx,const uint8_t * in,uint32_t len)311 int32_t CRYPT_SHA3_384_Update(CRYPT_SHA3_384_Ctx *ctx, const uint8_t *in, uint32_t len)
312 {
313 return CRYPT_SHA3_Update(ctx, in, len);
314 }
315
CRYPT_SHA3_512_Update(CRYPT_SHA3_512_Ctx * ctx,const uint8_t * in,uint32_t len)316 int32_t CRYPT_SHA3_512_Update(CRYPT_SHA3_512_Ctx *ctx, const uint8_t *in, uint32_t len)
317 {
318 return CRYPT_SHA3_Update(ctx, in, len);
319 }
320
CRYPT_SHAKE128_Update(CRYPT_SHAKE128_Ctx * ctx,const uint8_t * in,uint32_t len)321 int32_t CRYPT_SHAKE128_Update(CRYPT_SHAKE128_Ctx *ctx, const uint8_t *in, uint32_t len)
322 {
323 return CRYPT_SHA3_Update(ctx, in, len);
324 }
325
CRYPT_SHAKE256_Update(CRYPT_SHAKE256_Ctx * ctx,const uint8_t * in,uint32_t len)326 int32_t CRYPT_SHAKE256_Update(CRYPT_SHAKE256_Ctx *ctx, const uint8_t *in, uint32_t len)
327 {
328 return CRYPT_SHA3_Update(ctx, in, len);
329 }
330
CRYPT_SHA3_224_Final(CRYPT_SHA3_224_Ctx * ctx,uint8_t * out,uint32_t * len)331 int32_t CRYPT_SHA3_224_Final(CRYPT_SHA3_224_Ctx *ctx, uint8_t *out, uint32_t *len)
332 {
333 return CRYPT_SHA3_Final(ctx, out, len);
334 }
335
CRYPT_SHA3_256_Final(CRYPT_SHA3_256_Ctx * ctx,uint8_t * out,uint32_t * len)336 int32_t CRYPT_SHA3_256_Final(CRYPT_SHA3_256_Ctx *ctx, uint8_t *out, uint32_t *len)
337 {
338 return CRYPT_SHA3_Final(ctx, out, len);
339 }
340
CRYPT_SHA3_384_Final(CRYPT_SHA3_384_Ctx * ctx,uint8_t * out,uint32_t * len)341 int32_t CRYPT_SHA3_384_Final(CRYPT_SHA3_384_Ctx *ctx, uint8_t *out, uint32_t *len)
342 {
343 return CRYPT_SHA3_Final(ctx, out, len);
344 }
345
CRYPT_SHA3_512_Final(CRYPT_SHA3_512_Ctx * ctx,uint8_t * out,uint32_t * len)346 int32_t CRYPT_SHA3_512_Final(CRYPT_SHA3_512_Ctx *ctx, uint8_t *out, uint32_t *len)
347 {
348 return CRYPT_SHA3_Final(ctx, out, len);
349 }
350
CRYPT_SHAKE128_Final(CRYPT_SHAKE128_Ctx * ctx,uint8_t * out,uint32_t * len)351 int32_t CRYPT_SHAKE128_Final(CRYPT_SHAKE128_Ctx *ctx, uint8_t *out, uint32_t *len)
352 {
353 return CRYPT_SHA3_Final(ctx, out, len);
354 }
355
CRYPT_SHAKE256_Final(CRYPT_SHAKE256_Ctx * ctx,uint8_t * out,uint32_t * len)356 int32_t CRYPT_SHAKE256_Final(CRYPT_SHAKE256_Ctx *ctx, uint8_t *out, uint32_t *len)
357 {
358 return CRYPT_SHA3_Final(ctx, out, len);
359 }
360
CRYPT_SHAKE128_Squeeze(CRYPT_SHAKE128_Ctx * ctx,uint8_t * out,uint32_t len)361 int32_t CRYPT_SHAKE128_Squeeze(CRYPT_SHAKE128_Ctx *ctx, uint8_t *out, uint32_t len)
362 {
363 return CRYPT_SHA3_Squeeze(ctx, out, len);
364 }
CRYPT_SHAKE256_Squeeze(CRYPT_SHAKE256_Ctx * ctx,uint8_t * out,uint32_t len)365 int32_t CRYPT_SHAKE256_Squeeze(CRYPT_SHAKE256_Ctx *ctx, uint8_t *out, uint32_t len)
366 {
367 return CRYPT_SHA3_Squeeze(ctx, out, len);
368 }
369
CRYPT_SHA3_224_Deinit(CRYPT_SHA3_224_Ctx * ctx)370 void CRYPT_SHA3_224_Deinit(CRYPT_SHA3_224_Ctx *ctx)
371 {
372 CRYPT_SHA3_Deinit(ctx);
373 }
374
CRYPT_SHA3_256_Deinit(CRYPT_SHA3_256_Ctx * ctx)375 void CRYPT_SHA3_256_Deinit(CRYPT_SHA3_256_Ctx *ctx)
376 {
377 CRYPT_SHA3_Deinit(ctx);
378 }
379
CRYPT_SHA3_384_Deinit(CRYPT_SHA3_384_Ctx * ctx)380 void CRYPT_SHA3_384_Deinit(CRYPT_SHA3_384_Ctx *ctx)
381 {
382 CRYPT_SHA3_Deinit(ctx);
383 }
384
CRYPT_SHA3_512_Deinit(CRYPT_SHA3_512_Ctx * ctx)385 void CRYPT_SHA3_512_Deinit(CRYPT_SHA3_512_Ctx *ctx)
386 {
387 CRYPT_SHA3_Deinit(ctx);
388 }
389
CRYPT_SHAKE128_Deinit(CRYPT_SHAKE128_Ctx * ctx)390 void CRYPT_SHAKE128_Deinit(CRYPT_SHAKE128_Ctx *ctx)
391 {
392 CRYPT_SHA3_Deinit(ctx);
393 }
394
CRYPT_SHAKE256_Deinit(CRYPT_SHAKE256_Ctx * ctx)395 void CRYPT_SHAKE256_Deinit(CRYPT_SHAKE256_Ctx *ctx)
396 {
397 CRYPT_SHA3_Deinit(ctx);
398 }
399
CRYPT_SHA3_224_CopyCtx(CRYPT_SHA3_224_Ctx * dst,const CRYPT_SHA3_224_Ctx * src)400 int32_t CRYPT_SHA3_224_CopyCtx(CRYPT_SHA3_224_Ctx *dst, const CRYPT_SHA3_224_Ctx *src)
401 {
402 return CRYPT_SHA3_CopyCtx(dst, src);
403 }
404
CRYPT_SHA3_256_CopyCtx(CRYPT_SHA3_256_Ctx * dst,const CRYPT_SHA3_256_Ctx * src)405 int32_t CRYPT_SHA3_256_CopyCtx(CRYPT_SHA3_256_Ctx *dst, const CRYPT_SHA3_256_Ctx *src)
406 {
407 return CRYPT_SHA3_CopyCtx(dst, src);
408 }
409
CRYPT_SHA3_384_CopyCtx(CRYPT_SHA3_384_Ctx * dst,const CRYPT_SHA3_384_Ctx * src)410 int32_t CRYPT_SHA3_384_CopyCtx(CRYPT_SHA3_384_Ctx *dst, const CRYPT_SHA3_384_Ctx *src)
411 {
412 return CRYPT_SHA3_CopyCtx(dst, src);
413 }
414
CRYPT_SHA3_512_CopyCtx(CRYPT_SHA3_512_Ctx * dst,const CRYPT_SHA3_512_Ctx * src)415 int32_t CRYPT_SHA3_512_CopyCtx(CRYPT_SHA3_512_Ctx *dst, const CRYPT_SHA3_512_Ctx *src)
416 {
417 return CRYPT_SHA3_CopyCtx(dst, src);
418 }
419
CRYPT_SHAKE128_CopyCtx(CRYPT_SHA3_384_Ctx * dst,const CRYPT_SHA3_384_Ctx * src)420 int32_t CRYPT_SHAKE128_CopyCtx(CRYPT_SHA3_384_Ctx *dst, const CRYPT_SHA3_384_Ctx *src)
421 {
422 return CRYPT_SHA3_CopyCtx(dst, src);
423 }
424
CRYPT_SHAKE256_CopyCtx(CRYPT_SHA3_512_Ctx * dst,const CRYPT_SHA3_512_Ctx * src)425 int32_t CRYPT_SHAKE256_CopyCtx(CRYPT_SHA3_512_Ctx *dst, const CRYPT_SHA3_512_Ctx *src)
426 {
427 return CRYPT_SHA3_CopyCtx(dst, src);
428 }
429
CRYPT_SHA3_224_DupCtx(const CRYPT_SHA3_224_Ctx * src)430 CRYPT_SHA3_224_Ctx *CRYPT_SHA3_224_DupCtx(const CRYPT_SHA3_224_Ctx *src)
431 {
432 return CRYPT_SHA3_DupCtx(src);
433 }
434
CRYPT_SHA3_256_DupCtx(const CRYPT_SHA3_256_Ctx * src)435 CRYPT_SHA3_256_Ctx *CRYPT_SHA3_256_DupCtx(const CRYPT_SHA3_256_Ctx *src)
436 {
437 return CRYPT_SHA3_DupCtx(src);
438 }
439
CRYPT_SHA3_384_DupCtx(const CRYPT_SHA3_384_Ctx * src)440 CRYPT_SHA3_384_Ctx *CRYPT_SHA3_384_DupCtx(const CRYPT_SHA3_384_Ctx *src)
441 {
442 return CRYPT_SHA3_DupCtx(src);
443 }
444
CRYPT_SHA3_512_DupCtx(const CRYPT_SHA3_512_Ctx * src)445 CRYPT_SHA3_512_Ctx *CRYPT_SHA3_512_DupCtx(const CRYPT_SHA3_512_Ctx *src)
446 {
447 return CRYPT_SHA3_DupCtx(src);
448 }
449
CRYPT_SHAKE128_DupCtx(const CRYPT_SHA3_384_Ctx * src)450 CRYPT_SHA3_384_Ctx *CRYPT_SHAKE128_DupCtx(const CRYPT_SHA3_384_Ctx *src)
451 {
452 return CRYPT_SHA3_DupCtx(src);
453 }
454
CRYPT_SHAKE256_DupCtx(const CRYPT_SHA3_512_Ctx * src)455 CRYPT_SHA3_512_Ctx *CRYPT_SHAKE256_DupCtx(const CRYPT_SHA3_512_Ctx *src)
456 {
457 return CRYPT_SHA3_DupCtx(src);
458 }
459
460 #endif // HITLS_CRYPTO_SHA3
461