API参考
载入中...
搜索中...
未找到
crypt_sm9_eal.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
25
26#ifndef CRYPT_SM9_EAL_H
27#define CRYPT_SM9_EAL_H
28
29#include "hitls_build.h"
30#ifdef HITLS_CRYPTO_SM9
31
32#include <stdint.h>
33#include "crypt_types.h"
34#include "bsl_params.h"
35#include "crypt_errno.h"
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41/* SM9 context is opaque to EAL layer */
42typedef struct SM9_Ctx_st CRYPT_SM9_Ctx;
43
48CRYPT_SM9_Ctx *CRYPT_SM9_NewCtx(void);
49
55CRYPT_SM9_Ctx *CRYPT_SM9_DupCtx(const CRYPT_SM9_Ctx *ctx);
56
61void CRYPT_SM9_FreeCtx(CRYPT_SM9_Ctx *ctx);
62
68int32_t CRYPT_SM9_Gen(CRYPT_SM9_Ctx *ctx);
69
87int32_t CRYPT_SM9_SetPubKeyEx(CRYPT_SM9_Ctx *ctx, const BSL_Param *param);
88
102int32_t CRYPT_SM9_SetPrvKeyEx(CRYPT_SM9_Ctx *ctx, const BSL_Param *param);
103
110int32_t CRYPT_SM9_GetPubKeyEx(const CRYPT_SM9_Ctx *ctx, BSL_Param *param);
111
118int32_t CRYPT_SM9_GetPrvKeyEx(const CRYPT_SM9_Ctx *ctx, BSL_Param *param);
119
130int32_t CRYPT_SM9_Sign(const CRYPT_SM9_Ctx *ctx, int32_t mdId,
131 const uint8_t *data, uint32_t dataLen,
132 uint8_t *sign, uint32_t *signLen);
133
144int32_t CRYPT_SM9_Verify(const CRYPT_SM9_Ctx *ctx, int32_t mdId,
145 const uint8_t *data, uint32_t dataLen,
146 const uint8_t *sign, uint32_t signLen);
147
157int32_t CRYPT_SM9_Encrypt(const CRYPT_SM9_Ctx *ctx,
158 const uint8_t *data, uint32_t dataLen,
159 uint8_t *out, uint32_t *outLen);
160
170int32_t CRYPT_SM9_Decrypt(const CRYPT_SM9_Ctx *ctx,
171 const uint8_t *data, uint32_t dataLen,
172 uint8_t *out, uint32_t *outLen);
173
182int32_t CRYPT_SM9_ComputeShareKey(const CRYPT_SM9_Ctx *selfCtx, const CRYPT_SM9_Ctx *peerCtx,
183 uint8_t *out, uint32_t *outLen);
184
193int32_t CRYPT_SM9_Ctrl(CRYPT_SM9_Ctx *ctx, int32_t cmd, void *val, uint32_t valLen);
194
201int32_t CRYPT_SM9_Check(int32_t checkType, const CRYPT_SM9_Ctx *ctx1, const CRYPT_SM9_Ctx *ctx2);
202
209int32_t CRYPT_SM9_Cmp(const CRYPT_SM9_Ctx *ctx1, const CRYPT_SM9_Ctx *ctx2);
210
211#ifdef __cplusplus
212}
213#endif
214
215#endif // HITLS_CRYPTO_SM9
216#endif /* CRYPT_SM9_EAL_H */