blob: d81cd608eb11c044ed527f2158eafaaace46f60b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
/*
* Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef TS_PLATFORM_INTERFACE_ENTROPY_H
#define TS_PLATFORM_INTERFACE_ENTROPY_H
/*
* Interface definintion for a platform entropy driver. A platform provider will
* provide concrete implementations of this interface for each alternative
* implementation supported.
*/
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Virtual interface for a platform entropy driver. A platform will provide
* one or more concrete implementations of this interface.
*/
struct ts_plat_entropy_iface
{
/**
* \brief Poll for bytes of entropy from a platform entropy source
*
* \param context Platform driver context
* \param output Buffer for output
* \param nbyte Desired number of bytes
* \param len The number of bytes returned (could be zero)
*
* \return 0 if successful.
*/
int (*poll)(void *context, unsigned char *output, size_t nbyte, size_t *len);
};
/*
* A platform entropy driver instance.
*/
struct ts_plat_entropy_driver
{
void *context; /**< Opaque driver context */
const struct ts_plat_entropy_iface *iface; /**< Interface methods */
};
/**
* \brief Factory method to construct a platform specific entropy driver
*
* \param driver Pointer to driver structure to initialize on construction.
* \param config Driver specific configuration or NULL if none.
*
* \return 0 if successful.
*/
int ts_plat_entropy_create(struct ts_plat_entropy_driver *driver, void *config);
/**
* \brief Destroy a driver constructed using the factory method
*
* \param driver Pointer to driver structure for constructed driver.
*/
void ts_plat_entropy_destroy(struct ts_plat_entropy_driver *driver);
#ifdef __cplusplus
}
#endif
#endif /* TS_PLATFORM_INTERFACE_ENTROPY_H */
|