API参考
载入中...
搜索中...
未找到
crypt_sha1.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_SHA1_H
17#define CRYPT_SHA1_H
18
19#include "hitls_build.h"
20#ifdef HITLS_CRYPTO_SHA1
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/* Length of the message digest buffer. */
35#define CRYPT_SHA1_DIGESTSIZE 20
36
37/* Message processing block size */
38#define CRYPT_SHA1_BLOCKSIZE 64
39
40/* SHA-1 context structure */
41typedef struct CryptSha1Ctx {
42 uint8_t m[CRYPT_SHA1_BLOCKSIZE]; /* store the remaining data which less than one block */
43 uint32_t h[CRYPT_SHA1_DIGESTSIZE / sizeof(uint32_t)]; /* store the intermediate data of the hash value */
44 uint32_t hNum, lNum; /* input data counter, maximum value 2 ^ 64 bits */
45 int32_t errorCode; /* Error code */
46 uint32_t count; /* Number of remaining data bytes less than one block, corresponding to the length of the m */
47} CRYPT_SHA1_Ctx;
48
49#define CRYPT_SHA1_Squeeze NULL
50
58CRYPT_SHA1_Ctx *CRYPT_SHA1_NewCtx(void);
59
70CRYPT_SHA1_Ctx *CRYPT_SHA1_NewCtxEx(void *libCtx, int32_t algId);
71
78void CRYPT_SHA1_FreeCtx(CRYPT_SHA1_Ctx *ctx);
79
89int32_t CRYPT_SHA1_Init(CRYPT_SHA1_Ctx *ctx);
90
101int32_t CRYPT_SHA1_InitEx(CRYPT_SHA1_Ctx *ctx, void *param);
102
115int32_t CRYPT_SHA1_Update(CRYPT_SHA1_Ctx *ctx, const uint8_t *in, uint32_t len);
116
130int32_t CRYPT_SHA1_Final(CRYPT_SHA1_Ctx *ctx, uint8_t *out, uint32_t *len);
131
140int32_t CRYPT_SHA1_Deinit(CRYPT_SHA1_Ctx *ctx);
141
151int32_t CRYPT_SHA1_CopyCtx(CRYPT_SHA1_Ctx *dst, const CRYPT_SHA1_Ctx *src);
152
161CRYPT_SHA1_Ctx *CRYPT_SHA1_DupCtx(const CRYPT_SHA1_Ctx *src);
162
163#ifdef HITLS_CRYPTO_PROVIDER
174int32_t CRYPT_SHA1_GetParam(CRYPT_SHA1_Ctx *ctx, BSL_Param *param);
175#else
176#define CRYPT_SHA1_GetParam NULL
177#endif
178
179#ifdef __cplusplus
180}
181#endif /* __cpluscplus */
182
183#endif // HITLS_CRYPTO_SHA1
184
185#endif // CRYPT_SHA1_H