API参考
载入中...
搜索中...
未找到
crypt_provider.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_PROVIDER_H
17#define CRYPT_PROVIDER_H
18
19#include "hitls_build.h"
20#ifdef HITLS_CRYPTO_PROVIDER
21
22#include "crypt_eal_provider.h"
23#include "crypt_eal_implprovider.h"
24#include "bsl_list.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif /* __cplusplus */
29
30#define CRYPT_EAL_DEFAULT_PROVIDER "default"
31
32// Maximum length of provider name
33#define DEFAULT_PROVIDER_NAME_LEN_MAX 255
34
35#if defined(HITLS_CRYPTO_ENTROPY) && \
36 (defined(HITLS_CRYPTO_ENTROPY_GETENTROPY) || defined(HITLS_CRYPTO_ENTROPY_DEVRANDOM) || \
37 defined(HITLS_CRYPTO_ENTROPY_SYS) || defined(HITLS_CRYPTO_ENTROPY_HARDWARE))
38#define HITLS_CRYPTO_ENTROPY_DEFAULT
39#endif
40
41typedef enum {
42 CRYPT_PROVIDER_GET_USER_CTX = 1,
43 CRYPT_PROVIDER_CTRL_MAX,
44} CRYPT_ProviderCtrlCmd;
45
46struct EAL_LibCtx {
47 BslList *providers; // managing providers
49#ifdef HITLS_BSL_SAL_DL
50 char *searchProviderPath;
51#endif
52#ifdef HITLS_CRYPTO_DRBG
53 void *drbg;
54#endif // drbg
55};
56
57int32_t CRYPT_EAL_InitPreDefinedProviders(void);
58void CRYPT_EAL_FreePreDefinedProviders(void);
59
60int32_t CRYPT_EAL_DefaultProvInit(CRYPT_EAL_ProvMgrCtx *mgrCtx, BSL_Param *param,
61 CRYPT_EAL_Func *capFuncs, CRYPT_EAL_Func **outFuncs, void **provCtx);
62
63int32_t CRYPT_EAL_AddNewProvMgrCtx(CRYPT_EAL_LibCtx *libCtx, const char *providerName, const char *providerPath,
64 CRYPT_EAL_ImplProviderInit init, void *handle, BSL_Param *param, CRYPT_EAL_ProvMgrCtx **ctx);
65
66int32_t CRYPT_EAL_ProviderGetFuncsAndMgrCtx(CRYPT_EAL_LibCtx *libCtx, int32_t operaId, int32_t algId,
67 const char *attribute, const CRYPT_EAL_Func **funcs, CRYPT_EAL_ProvMgrCtx **mgrCtx, bool noPushError);
68
69CRYPT_EAL_LibCtx* CRYPT_EAL_GetGlobalLibCtx(void);
70CRYPT_EAL_LibCtx *GetCurrentProviderLibCtx(CRYPT_EAL_LibCtx *libCtx);
71
72int32_t CRYPT_EAL_ProviderQuery(CRYPT_EAL_ProvMgrCtx *ctx, int32_t operaId, CRYPT_EAL_AlgInfo **algInfos);
73#ifdef __cplusplus
74}
75#endif /* __cpluscplus */
76
77#endif /* HITLS_CRYPTO_PROVIDER */
78#endif /* CRYPT_PROVIDER_H */
void * BSL_SAL_ThreadLockHandle
定义 bsl_sal.h:63
int32_t(* CRYPT_EAL_ImplProviderInit)(CRYPT_EAL_ProvMgrCtx *mgrCtx, BSL_Param *param, CRYPT_EAL_Func *capFuncs, CRYPT_EAL_Func **outFuncs, void **provCtx)
Provider initialization function prototype,
定义 crypt_eal_implprovider.h:120
定义 crypt_eal_implprovider.h:36
定义 crypt_types.h:952