API参考
载入中...
搜索中...
未找到
crypt_curve25519.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_CURVE25519_H
17#define CRYPT_CURVE25519_H
18
19#include "hitls_build.h"
20#ifdef HITLS_CRYPTO_CURVE25519
21
22#include <stdint.h>
23#include "crypt_local_types.h"
24#include "bsl_params.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30#define CRYPT_CURVE25519_KEYLEN 32
31#define CRYPT_CURVE25519_SIGNLEN 64
32
33typedef struct CryptCurve25519Ctx CRYPT_CURVE25519_Ctx;
34
35#ifdef HITLS_CRYPTO_X25519
43CRYPT_CURVE25519_Ctx *CRYPT_X25519_NewCtx(void);
44
54CRYPT_CURVE25519_Ctx *CRYPT_X25519_NewCtxEx(void *libCtx);
55#endif
56
57#ifdef HITLS_CRYPTO_ED25519
65CRYPT_CURVE25519_Ctx *CRYPT_ED25519_NewCtx(void);
66
76CRYPT_CURVE25519_Ctx *CRYPT_ED25519_NewCtxEx(void *libCtx);
77#endif
78
88CRYPT_CURVE25519_Ctx *CRYPT_CURVE25519_DupCtx(CRYPT_CURVE25519_Ctx *ctx);
89
96void CRYPT_CURVE25519_FreeCtx(CRYPT_CURVE25519_Ctx *pkey);
97
112int32_t CRYPT_CURVE25519_Ctrl(CRYPT_CURVE25519_Ctx *pkey, int32_t opt, void *val, uint32_t len);
113
125int32_t CRYPT_CURVE25519_SetPubKey(CRYPT_CURVE25519_Ctx *pkey, const CRYPT_Curve25519Pub *pub);
126
139int32_t CRYPT_CURVE25519_GetPubKey(const CRYPT_CURVE25519_Ctx *pkey, CRYPT_Curve25519Pub *pub);
140
152int32_t CRYPT_CURVE25519_SetPrvKey(CRYPT_CURVE25519_Ctx *pkey, const CRYPT_Curve25519Prv *prv);
153
166int32_t CRYPT_CURVE25519_GetPrvKey(const CRYPT_CURVE25519_Ctx *pkey, CRYPT_Curve25519Prv *prv);
167
168#ifdef HITLS_BSL_PARAMS
180int32_t CRYPT_CURVE25519_SetPubKeyEx(CRYPT_CURVE25519_Ctx *pkey, const BSL_Param *para);
181
193int32_t CRYPT_CURVE25519_SetPrvKeyEx(CRYPT_CURVE25519_Ctx *pkey, const BSL_Param *para);
194
207int32_t CRYPT_CURVE25519_GetPubKeyEx(const CRYPT_CURVE25519_Ctx *pkey, BSL_Param *para);
208
221int32_t CRYPT_CURVE25519_GetPrvKeyEx(const CRYPT_CURVE25519_Ctx *pkey, BSL_Param *para);
222#endif
223
232int32_t CRYPT_CURVE25519_GetBits(const CRYPT_CURVE25519_Ctx *pkey);
233
234#ifdef HITLS_CRYPTO_ED25519
255int32_t CRYPT_CURVE25519_Sign(CRYPT_CURVE25519_Ctx *pkey, int32_t algId, const uint8_t *msg,
256 uint32_t msgLen, uint8_t *sign, uint32_t *signLen);
257
266int32_t CRYPT_CURVE25519_GetSignLen(const CRYPT_CURVE25519_Ctx *pkey);
267
288int32_t CRYPT_CURVE25519_Verify(const CRYPT_CURVE25519_Ctx *pkey, int32_t algId, const uint8_t *msg,
289 uint32_t msgLen, const uint8_t *sign, uint32_t signLen);
290
304int32_t CRYPT_ED25519_GenKey(CRYPT_CURVE25519_Ctx *pkey);
305#endif /* HITLS_CRYPTO_ED25519 */
306
307#ifdef HITLS_CRYPTO_X25519
320int32_t CRYPT_CURVE25519_ComputeSharedKey(CRYPT_CURVE25519_Ctx *prvKey, CRYPT_CURVE25519_Ctx *pubKey,
321 uint8_t *sharedKey, uint32_t *shareKeyLen);
322
334int32_t CRYPT_X25519_GenKey(CRYPT_CURVE25519_Ctx *pkey);
335#endif /* HITLS_CRYPTO_X25519 */
336
337#ifdef HITLS_CRYPTO_CURVE25519_CMP
349int32_t CRYPT_CURVE25519_Cmp(const CRYPT_CURVE25519_Ctx *a, const CRYPT_CURVE25519_Ctx *b);
350#else
351#define CRYPT_CURVE25519_Cmp NULL
352#endif
353
362int32_t CRYPT_CURVE25519_GetSecBits(const CRYPT_CURVE25519_Ctx *ctx);
363
364#ifdef HITLS_CRYPTO_KEY_DECODE_CHAIN
372int32_t CRYPT_CURVE25519_Import(CRYPT_CURVE25519_Ctx *ctx, const BSL_Param *params);
373
381int32_t CRYPT_CURVE25519_Export(const CRYPT_CURVE25519_Ctx *ctx, BSL_Param *params);
382#endif // HITLS_CRYPTO_KEY_DECODE_CHAIN
383
384#ifdef HITLS_CRYPTO_ED25519_CHECK
385
397int32_t CRYPT_ED25519_Check(uint32_t checkType, const CRYPT_CURVE25519_Ctx *pkey1, const CRYPT_CURVE25519_Ctx *pkey2);
398#endif // HITLS_CRYPTO_ED25519_CHECK
399
400#ifdef HITLS_CRYPTO_X25519_CHECK
412int32_t CRYPT_X25519_Check(uint32_t checkType, const CRYPT_CURVE25519_Ctx *pkey1, const CRYPT_CURVE25519_Ctx *pkey2);
413
414#endif // HITLS_CRYPTO_X25519_CHECK
415
416#ifdef __cplusplus
417}
418#endif
419
420#endif // HITLS_CRYPTO_CURVE25519
421
422#endif // CRYPT_CURVE25519_H
CRYPT_Data CRYPT_Curve25519Prv
定义 crypt_types.h:310
CRYPT_Data CRYPT_Curve25519Pub
定义 crypt_types.h:449