API参考
载入中...
搜索中...
未找到
crypt_sm3.h
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#ifndef CRYPT_SM3_H
17#define CRYPT_SM3_H
18
19#include "hitls_build.h"
20#ifdef HITLS_CRYPTO_SM3
21
22#include <stdint.h>
23#include <stdlib.h>
24#include "crypt_types.h"
25
26#ifdef HITLS_CRYPTO_PROVIDER
27#include "bsl_params.h"
28#endif
29
30#ifdef __cplusplus
31extern "C" {
32#endif /* __cpluscplus */
33
34#define CRYPT_SM3_BLOCKSIZE 64
35#define CRYPT_SM3_DIGESTSIZE 32
36
37typedef struct {
38 uint32_t h[CRYPT_SM3_DIGESTSIZE / sizeof(uint32_t)]; /* store the intermediate data of the hash value */
39 uint32_t hNum, lNum; /* input data counter, maximum value 2 ^ 64 bits */
40 uint8_t block[CRYPT_SM3_BLOCKSIZE]; /* store the remaining data which less than one block */
41 /* Number of remaining bytes in 'block' arrary that are stored less than one block */
42 uint32_t num;
43} CRYPT_SM3_Ctx;
44
45#define CRYPT_SM3_Squeeze NULL
46
54CRYPT_SM3_Ctx *CRYPT_SM3_NewCtx(void);
55
66CRYPT_SM3_Ctx *CRYPT_SM3_NewCtxEx(void *libCtx, int32_t algId);
67
74void CRYPT_SM3_FreeCtx(CRYPT_SM3_Ctx *ctx);
75
85int32_t CRYPT_SM3_Init(CRYPT_SM3_Ctx *ctx);
86
97int32_t CRYPT_SM3_InitEx(CRYPT_SM3_Ctx *ctx, void *param);
98
111int32_t CRYPT_SM3_Update(CRYPT_SM3_Ctx *ctx, const uint8_t *in, uint32_t len);
112
125int32_t CRYPT_SM3_Final(CRYPT_SM3_Ctx *ctx, uint8_t *out, uint32_t *outLen);
126
135int32_t CRYPT_SM3_Deinit(CRYPT_SM3_Ctx *ctx);
136
146int32_t CRYPT_SM3_CopyCtx(CRYPT_SM3_Ctx *dst, const CRYPT_SM3_Ctx *src);
147
156CRYPT_SM3_Ctx *CRYPT_SM3_DupCtx(const CRYPT_SM3_Ctx *src);
157
158#ifdef HITLS_CRYPTO_PROVIDER
169int32_t CRYPT_SM3_GetParam(CRYPT_SM3_Ctx *ctx, BSL_Param *param);
170#else
171#define CRYPT_SM3_GetParam NULL
172#endif // HITLS_CRYPTO_PROVIDER
173
174#ifdef __cplusplus
175}
176#endif /* __cpluscplus */
177
178#endif // HITLS_CRYPTO_SM3
179
180#endif // CRYPT_SM3_H