API参考
载入中...
搜索中...
未找到
crypt_dh.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_DH_H
17#define CRYPT_DH_H
18
19#include "hitls_build.h"
20#ifdef HITLS_CRYPTO_DH
21
22#include <stdint.h>
23#include "crypt_types.h"
24#include "crypt_algid.h"
25#include "bsl_params.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif /* __cpluscplus */
30
31#ifndef CRYPT_DH_TRY_CNT_MAX
32#define CRYPT_DH_TRY_CNT_MAX 100
33#endif
34
35/* DH key parameter */
36typedef struct DH_Para CRYPT_DH_Para;
37
38/* DH key context */
39typedef struct DH_Ctx CRYPT_DH_Ctx;
40
48CRYPT_DH_Ctx *CRYPT_DH_NewCtx(void);
49
59CRYPT_DH_Ctx *CRYPT_DH_NewCtxEx(void *libCtx);
60
70CRYPT_DH_Ctx *CRYPT_DH_DupCtx(CRYPT_DH_Ctx *ctx);
71
78void CRYPT_DH_FreeCtx(CRYPT_DH_Ctx *ctx);
79
89CRYPT_DH_Para *CRYPT_DH_NewPara(const CRYPT_DhPara *para);
90
97void CRYPT_DH_FreePara(CRYPT_DH_Para *dhPara);
98
112int32_t CRYPT_DH_SetPara(CRYPT_DH_Ctx *ctx, const CRYPT_DhPara *para);
113
126int32_t CRYPT_DH_GetPara(const CRYPT_DH_Ctx *ctx, CRYPT_DhPara *para);
136CRYPT_DH_Para *CRYPT_DH_NewParaById(int32_t id);
137
146CRYPT_PKEY_ParaId CRYPT_DH_GetParaId(const CRYPT_DH_Ctx *ctx);
147
157uint32_t CRYPT_DH_GetBits(const CRYPT_DH_Ctx *ctx);
158
172int32_t CRYPT_DH_Gen(CRYPT_DH_Ctx *ctx);
173
191int32_t CRYPT_DH_ComputeShareKey(const CRYPT_DH_Ctx *ctx, const CRYPT_DH_Ctx *pubKey,
192 uint8_t *shareKey, uint32_t *shareKeyLen);
193
208int32_t CRYPT_DH_SetPrvKey(CRYPT_DH_Ctx *ctx, const CRYPT_DhPrv *prv);
209
224int32_t CRYPT_DH_SetPubKey(CRYPT_DH_Ctx *ctx, const CRYPT_DhPub *pub);
225
239int32_t CRYPT_DH_GetPrvKey(const CRYPT_DH_Ctx *ctx, CRYPT_DhPrv *prv);
240
254int32_t CRYPT_DH_GetPubKey(const CRYPT_DH_Ctx *ctx, CRYPT_DhPub *pub);
255
256#ifdef HITLS_BSL_PARAMS
271int32_t CRYPT_DH_SetPrvKeyEx(CRYPT_DH_Ctx *ctx, const BSL_Param *para);
272
287int32_t CRYPT_DH_SetPubKeyEx(CRYPT_DH_Ctx *ctx, const BSL_Param *para);
288
302int32_t CRYPT_DH_GetPrvKeyEx(const CRYPT_DH_Ctx *ctx, BSL_Param *para);
303
317int32_t CRYPT_DH_GetPubKeyEx(const CRYPT_DH_Ctx *ctx, BSL_Param *para);
318
332int32_t CRYPT_DH_SetParaEx(CRYPT_DH_Ctx *ctx, const BSL_Param *para);
333
346int32_t CRYPT_DH_GetParaEx(const CRYPT_DH_Ctx *ctx, BSL_Param *para);
347#endif
348
349#ifdef HITLS_CRYPTO_DH_CHECK
361int32_t CRYPT_DH_Check(uint32_t checkType, const CRYPT_DH_Ctx *pkey1, const CRYPT_DH_Ctx *pkey2);
362
363#endif // HITLS_CRYPTO_DH_CHECK
364
365#ifdef HITLS_CRYPTO_DH_CMP
380int32_t CRYPT_DH_Cmp(const CRYPT_DH_Ctx *a, const CRYPT_DH_Ctx *b);
381#else
382#define CRYPT_DH_Cmp NULL
383#endif
384
397int32_t CRYPT_DH_Ctrl(CRYPT_DH_Ctx *ctx, int32_t opt, void *val, uint32_t len);
398
409int32_t CRYPT_DH_CopyParam(const CRYPT_DH_Ctx *src, CRYPT_DH_Ctx *dest);
410
419int32_t CRYPT_DH_GetSecBits(const CRYPT_DH_Ctx *ctx);
420
421#ifdef __cplusplus
422}
423#endif
424
425#endif // HITLS_CRYPTO_DH
426
427#endif // CRYPT_DH_H
CRYPT_PKEY_ParaId
定义 crypt_algid.h:208
CRYPT_Data CRYPT_DhPrv
定义 crypt_types.h:296
CRYPT_Data CRYPT_DhPub
定义 crypt_types.h:435
定义 crypt_types.h:495