API参考
载入中...
搜索中...
未找到
es_noise_source.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 ES_NOISE_SOURCE_H
17#define ES_NOISE_SOURCE_H
18
19#include "hitls_build.h"
20#if defined(HITLS_CRYPTO_ENTROPY) && defined(HITLS_CRYPTO_ENTROPY_SYS)
21
22#include <stdint.h>
23#include "bsl_list.h"
24#include "es_health_test.h"
25#include "crypt_types.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31typedef struct {
32 /* Whether to enable the health test */
33 bool enableTest;
34 /* Whether the noise source automatically performs the health test */
35 bool autoTest;
36 /* Whether the noise source is available */
37 bool isEnable;
38 /* Whether the noise source is initialized */
39 bool isInit;
40 /* Noise source name, which must be unique. */
41 char *name;
42 /* Initialization parameters of the noise source */
43 void *para;
44 /* Noise Source Handle */
45 void *usrdata;
46 /* Noise Source Initialization Interface. */
47 void *(*init)(void *para);
48 /* Interface for Obtaining Noise Sources. */
49 int32_t (*read)(void *usrdata, uint32_t timeout, uint8_t *buf, uint32_t bufLen);
50 /* Noise Source Deinitialization Interface. */
51 void (*deinit)(void *usrdata);
52 /* minimum entropy, bit entropy contained in a byte. */
53 uint32_t minEntropy;
54 ES_HealthTest state;
55} ES_NoiseSource;
56
57/* Noise Source List create. */
58BslList *ES_NsListCreat(void);
59
60/* Noise Source List Initialization. */
61int32_t ES_NsListInit(BslList *nsList, bool enableTest);
62
63/* Noise Source List deinitialization. */
64void ES_NsListDeinit(BslList *nsList);
65
66/* Noise Source List release. */
67void ES_NsListFree(BslList *nsList);
68
82int32_t ES_NsAdd(BslList *nsList, const char *name, bool autoTest, uint32_t minEntropy,
83 const CRYPT_EAL_NsMethod *method, const CRYPT_EAL_NsTestPara *para);
84
94int32_t ES_NsRemove(BslList *nsList, const char *name);
95
106int32_t ES_NsRead(ES_NoiseSource *ns, uint8_t *buf, uint32_t bufLen);
107
116uint32_t ES_NsListGetMinEntropy(BslList *nsList);
117
118/* Obtains the handle of the cpu-jiiter. */
119ES_NoiseSource *ES_CpuJitterGetCtx(void);
120
121/* Obtains the handle of the timestamp. */
122ES_NoiseSource *ES_TimeStampGetCtx(void);
123#ifdef __cplusplus
124}
125#endif
126
127#endif
128
129#endif
定义 bsl_list.h:49
定义 crypt_types.h:188
定义 crypt_types.h:199