API参考
载入中...
搜索中...
未找到
crypt_ecc_pkey.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_ECC_PKEY_H
17#define CRYPT_ECC_PKEY_H
18
19#include "hitls_build.h"
20#ifdef HITLS_CRYPTO_ECC
21
22#include "crypt_bn.h"
23#include "crypt_ecc.h"
24#include "crypt_algid.h"
25#include "sal_atomic.h"
26#include "bsl_params.h"
27#include "crypt_params_key.h"
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#ifndef CRYPT_ECC_TRY_MAX_CNT
34#define CRYPT_ECC_TRY_MAX_CNT 100 // Maximum number of attempts to generate keys and signatures
35#endif
36
37/* ECC key context */
38typedef struct ECC_PkeyCtx {
39 BN_BigNum *prvkey; // Private key
40 ECC_Point *pubkey; // Public key
41 ECC_Para *para; // Key parameter
42 CRYPT_PKEY_PointFormat pointFormat; // Public key point format
43 uint32_t useCofactorMode; // Indicates whether to use the cofactor mode. 1 indicates yes, and 0 indicates no.
44 BSL_SAL_RefCount references;
45 CRYPT_MD_AlgId signMdId; // For SignData Function
46 uint32_t flag;
47 void *libCtx;
48 char *mdAttr;
49} ECC_Pkey;
50
60ECC_Pkey *ECC_DupCtx(ECC_Pkey *ctx);
61
68void ECC_FreeCtx(ECC_Pkey *ctx);
69
79uint32_t ECC_PkeyGetBits(const ECC_Pkey *ctx);
80
91int32_t ECC_GetPara(const ECC_Pkey *pkey, CRYPT_EccPara *eccPara);
92
105int32_t ECC_GenPublicKey(ECC_Pkey *ctx);
106
119int32_t ECC_PkeyGen(ECC_Pkey *ctx);
120
133int32_t ECC_PkeySetPrvKey(ECC_Pkey *ctx, const CRYPT_EccPrv *prv);
134
147int32_t ECC_PkeySetPubKey(ECC_Pkey *ctx, const CRYPT_EccPub *pub);
160int32_t ECC_PkeyGetPrvKey(const ECC_Pkey *ctx, CRYPT_EccPrv *prv);
161
175int32_t ECC_PkeyGetPubKey(const ECC_Pkey *ctx, CRYPT_EccPub *pub);
176
189int32_t ECC_PkeySetPrvKeyEx(ECC_Pkey *ctx, const BSL_Param *para);
190
203int32_t ECC_PkeySetPubKeyEx(ECC_Pkey *ctx, const BSL_Param *para);
204
217int32_t ECC_PkeyGetPrvKeyEx(const ECC_Pkey *ctx, BSL_Param *para);
218
232int32_t ECC_PkeyGetPubKeyEx(const ECC_Pkey *ctx, BSL_Param *para);
233
244int32_t ECC_GetParaEx(const ECC_Pkey *ctx, BSL_Param *para);
245
259int32_t ECC_PkeyCtrl(ECC_Pkey *ctx, int32_t opt, void *val, uint32_t len);
260
269ECC_Pkey *ECC_PkeyNewCtx(CRYPT_PKEY_ParaId id);
270
271#ifdef HITLS_CRYPTO_ECC_CMP
286int32_t ECC_PkeyCmp(const ECC_Pkey *a, const ECC_Pkey *b);
287#else
288#define ECC_PkeyCmp NULL
289#endif
290
301int32_t ECC_SetPara(ECC_Pkey *ctx, ECC_Para *para);
302
303#ifdef HITLS_CRYPTO_ECC_CHECK
304
316int32_t ECC_PkeyCheck(const ECC_Pkey *pkey1, const ECC_Pkey *pkey2, uint32_t checkType);
317
318#endif // HITLS_CRYPTO_ECC_CHECK
319
320#ifdef __cplusplus
321}
322#endif
323
324#endif // HITLS_CRYPTO_ECC
325
326#endif // CRYPT_ECC_PKEY_H
Parameter identifiers
CRYPT_PKEY_ParaId
定义 crypt_algid.h:208
CRYPT_PKEY_PointFormat
定义 crypt_algid.h:370
CRYPT_MD_AlgId
定义 crypt_algid.h:68
CRYPT_Data CRYPT_EccPub
定义 crypt_types.h:414
CRYPT_Data CRYPT_EccPrv
定义 crypt_types.h:275
定义 crypt_types.h:155