API参考
载入中...
搜索中...
未找到
crypt_md5.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_MD5_H
17#define CRYPT_MD5_H
18
19#include "hitls_build.h"
20#ifdef HITLS_CRYPTO_MD5
21
22#include <stdlib.h>
23#include <stdint.h>
24#include "crypt_types.h"
25#include "bsl_params.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31#define CRYPT_MD5_DIGESTSIZE 16
32#define CRYPT_MD5_BLOCKSIZE 64
33
34/* md5 ctx */
35typedef struct CryptMd5Ctx {
36 uint32_t h[CRYPT_MD5_DIGESTSIZE / sizeof(uint32_t)]; /* store the intermediate data of the hash value */
37 uint8_t block[CRYPT_MD5_BLOCKSIZE]; /* store the remaining data of less than one block */
38 uint32_t hNum, lNum; /* input data counter, maximum value 2 ^ 64 bits */
39 /* Number of remaining bytes in 'block' arrary that are stored less than one block */
40 uint32_t num;
41} CRYPT_MD5_Ctx;
42
43#define CRYPT_MD5_Squeeze NULL
44
52CRYPT_MD5_Ctx *CRYPT_MD5_NewCtx(void);
53
64CRYPT_MD5_Ctx *CRYPT_MD5_NewCtxEx(void *libCtx, int32_t algId);
65
72void CRYPT_MD5_FreeCtx(CRYPT_MD5_Ctx *ctx);
82int32_t CRYPT_MD5_Init(CRYPT_MD5_Ctx *ctx);
83
94int32_t CRYPT_MD5_InitEx(CRYPT_MD5_Ctx *ctx, void *param);
95
104int32_t CRYPT_MD5_Deinit(CRYPT_MD5_Ctx *ctx);
105
118int32_t CRYPT_MD5_Update(CRYPT_MD5_Ctx *ctx, const uint8_t *in, uint32_t len);
119
132int32_t CRYPT_MD5_Final(CRYPT_MD5_Ctx *ctx, uint8_t *out, uint32_t *outLen);
133
143int32_t CRYPT_MD5_CopyCtx(CRYPT_MD5_Ctx *dst, const CRYPT_MD5_Ctx *src);
144
153CRYPT_MD5_Ctx *CRYPT_MD5_DupCtx(const CRYPT_MD5_Ctx *src);
154
155#ifdef HITLS_CRYPTO_PROVIDER
166int32_t CRYPT_MD5_GetParam(CRYPT_MD5_Ctx *ctx, BSL_Param *param);
167#else
168#define CRYPT_MD5_GetParam NULL
169#endif
170
171#ifdef __cplusplus
172}
173#endif
174
175#endif // HITLS_CRYPTO_MD5
176
177#endif // CRYPT_MD5_H