API参考
载入中...
搜索中...
未找到
crypt_ecc.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_H
17#define CRYPT_ECC_H
18
19#include "hitls_build.h"
20#ifdef HITLS_CRYPTO_ECC
21
22#include "crypt_bn.h"
23#include "crypt_algid.h"
24#include "crypt_types.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
33typedef struct EccPointInfo ECC_Point;
34
38typedef struct EccPara ECC_Para;
39
43typedef struct {
44 int8_t *num;
45 uint32_t *wide;
46 uint32_t size;
47 uint32_t baseBits; // Indicates the offset start address of the first block.
48 uint32_t offset;
49} ReCodeData;
50
60ECC_Para *ECC_NewPara(CRYPT_PKEY_ParaId id);
61
70void ECC_FreePara(ECC_Para *para);
71
80CRYPT_PKEY_ParaId ECC_GetParaId(const ECC_Para *para);
81
90CRYPT_PKEY_ParaId GetCurveId(const CRYPT_EccPara *eccPara);
91
101ECC_Point *ECC_NewPoint(const ECC_Para *para);
102
111void ECC_FreePoint(ECC_Point *pt);
112
123int32_t ECC_CopyPoint(ECC_Point *dst, const ECC_Point *src);
124
134ECC_Point *ECC_DupPoint(const ECC_Point *pt);
135
148int32_t ECC_PointCmp(const ECC_Para *para, const ECC_Point *a, const ECC_Point *b);
149
162int32_t ECC_GetPoint(const ECC_Para *para, ECC_Point *pt, CRYPT_Data *x, CRYPT_Data *y);
163
176int32_t ECC_GetPoint2Bn(const ECC_Para *para, ECC_Point *pt, BN_BigNum *x, BN_BigNum *y);
177
189int32_t ECC_GetPointDataX(const ECC_Para *para, ECC_Point *pt, BN_BigNum *x);
190
204int32_t ECC_PointMul(ECC_Para *para, ECC_Point *r,
205 const BN_BigNum *k, const ECC_Point *pt);
206
220int32_t ECC_PointMulAdd(ECC_Para *para, ECC_Point *r,
221 const BN_BigNum *k1, const BN_BigNum *k2, const ECC_Point *pt);
222
236int32_t ECC_EncodePoint(const ECC_Para *para, ECC_Point *pt, uint8_t *data, uint32_t *dataLen,
238
251int32_t ECC_DecodePoint(const ECC_Para *para, ECC_Point *pt, const uint8_t *data, uint32_t dataLen);
252
262BN_BigNum *ECC_GetParaH(const ECC_Para *para);
263
273BN_BigNum *ECC_GetParaN(const ECC_Para *para);
274
284BN_BigNum *ECC_GetParaA(const ECC_Para *para);
285
295BN_BigNum *ECC_GetParaB(const ECC_Para *para);
296
306BN_BigNum *ECC_GetParaX(const ECC_Para *para);
307
317BN_BigNum *ECC_GetParaY(const ECC_Para *para);
318
327uint32_t ECC_ParaBits(const ECC_Para *para);
328
338ECC_Para *ECC_DupPara(const ECC_Para *para);
339
350int32_t ECC_PointCheck(const ECC_Point *pt);
351
352
362ECC_Point *ECC_GetGFromPara(const ECC_Para *para);
363
374ReCodeData *ECC_ReCodeK(const BN_BigNum *k, uint32_t window);
375
384void ECC_ReCodeFree(ReCodeData *code);
385
396int32_t ECC_ModOrderInv(const ECC_Para *para, BN_BigNum *r, const BN_BigNum *a);
397
410int32_t ECC_PointAddAffine(const ECC_Para *para, ECC_Point *r, const ECC_Point *a, const ECC_Point *b);
411
420int32_t ECC_GetSecBits(const ECC_Para *para);
430void ECC_SetLibCtx(void *libCtx, ECC_Para *para);
431
442int32_t ECC_PointBlind(const ECC_Para *para, ECC_Point *pt);
443
453int32_t ECC_PointToMont(const ECC_Para *para, ECC_Point *pt, BN_Optimizer *opt);
454
464void ECC_PointFromMont(const ECC_Para *para, ECC_Point *r);
465
466#ifdef __cplusplus
467}
468#endif
469
470#endif // HITLS_CRYPTO_ECC
471
472#endif // CRYPT_ECC_H
CRYPT_PKEY_ParaId
定义 crypt_algid.h:208
CRYPT_PKEY_PointFormat
定义 crypt_algid.h:370
定义 crypt_types.h:38
定义 crypt_types.h:155