]>
Commit | Line | Data |
---|---|---|
4e5ecdba RC |
1 | /** @file\r |
2 | Function prototypes for UEFI Random Number Generator protocol support.\r | |
3 | \r | |
4 | Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>\r | |
5 | \r | |
6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
7 | \r | |
8 | **/\r | |
9 | \r | |
10 | #ifndef RNGDXE_INTERNALS_H_\r | |
11 | #define RNGDXE_INTERNALS_H_\r | |
12 | \r | |
13 | /**\r | |
14 | Returns information about the random number generation implementation.\r | |
15 | \r | |
16 | @param[in] This A pointer to the EFI_RNG_PROTOCOL instance.\r | |
17 | @param[in,out] RNGAlgorithmListSize On input, the size in bytes of RNGAlgorithmList.\r | |
18 | On output with a return code of EFI_SUCCESS, the size\r | |
19 | in bytes of the data returned in RNGAlgorithmList. On output\r | |
20 | with a return code of EFI_BUFFER_TOO_SMALL,\r | |
21 | the size of RNGAlgorithmList required to obtain the list.\r | |
22 | @param[out] RNGAlgorithmList A caller-allocated memory buffer filled by the driver\r | |
23 | with one EFI_RNG_ALGORITHM element for each supported\r | |
24 | RNG algorithm. The list must not change across multiple\r | |
25 | calls to the same driver. The first algorithm in the list\r | |
26 | is the default algorithm for the driver.\r | |
27 | \r | |
28 | @retval EFI_SUCCESS The RNG algorithm list was returned successfully.\r | |
29 | @retval EFI_UNSUPPORTED The services is not supported by this driver.\r | |
30 | @retval EFI_DEVICE_ERROR The list of algorithms could not be retrieved due to a\r | |
31 | hardware or firmware error.\r | |
32 | @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect.\r | |
33 | @retval EFI_BUFFER_TOO_SMALL The buffer RNGAlgorithmList is too small to hold the result.\r | |
34 | \r | |
35 | **/\r | |
36 | EFI_STATUS\r | |
37 | EFIAPI\r | |
38 | RngGetInfo (\r | |
c411b485 MK |
39 | IN EFI_RNG_PROTOCOL *This,\r |
40 | IN OUT UINTN *RNGAlgorithmListSize,\r | |
41 | OUT EFI_RNG_ALGORITHM *RNGAlgorithmList\r | |
4e5ecdba RC |
42 | );\r |
43 | \r | |
44 | /**\r | |
45 | Produces and returns an RNG value using either the default or specified RNG algorithm.\r | |
46 | \r | |
47 | @param[in] This A pointer to the EFI_RNG_PROTOCOL instance.\r | |
48 | @param[in] RNGAlgorithm A pointer to the EFI_RNG_ALGORITHM that identifies the RNG\r | |
49 | algorithm to use. May be NULL in which case the function will\r | |
50 | use its default RNG algorithm.\r | |
51 | @param[in] RNGValueLength The length in bytes of the memory buffer pointed to by\r | |
52 | RNGValue. The driver shall return exactly this numbers of bytes.\r | |
53 | @param[out] RNGValue A caller-allocated memory buffer filled by the driver with the\r | |
54 | resulting RNG value.\r | |
55 | \r | |
56 | @retval EFI_SUCCESS The RNG value was returned successfully.\r | |
57 | @retval EFI_UNSUPPORTED The algorithm specified by RNGAlgorithm is not supported by\r | |
58 | this driver.\r | |
59 | @retval EFI_DEVICE_ERROR An RNG value could not be retrieved due to a hardware or\r | |
60 | firmware error.\r | |
61 | @retval EFI_NOT_READY There is not enough random data available to satisfy the length\r | |
62 | requested by RNGValueLength.\r | |
63 | @retval EFI_INVALID_PARAMETER RNGValue is NULL or RNGValueLength is zero.\r | |
64 | \r | |
65 | **/\r | |
66 | EFI_STATUS\r | |
67 | EFIAPI\r | |
68 | RngGetRNG (\r | |
c411b485 MK |
69 | IN EFI_RNG_PROTOCOL *This,\r |
70 | IN EFI_RNG_ALGORITHM *RNGAlgorithm OPTIONAL,\r | |
71 | IN UINTN RNGValueLength,\r | |
72 | OUT UINT8 *RNGValue\r | |
4e5ecdba RC |
73 | );\r |
74 | \r | |
75 | /**\r | |
76 | Returns information about the random number generation implementation.\r | |
77 | \r | |
78 | @param[in,out] RNGAlgorithmListSize On input, the size in bytes of RNGAlgorithmList.\r | |
79 | On output with a return code of EFI_SUCCESS, the size\r | |
80 | in bytes of the data returned in RNGAlgorithmList. On output\r | |
81 | with a return code of EFI_BUFFER_TOO_SMALL,\r | |
82 | the size of RNGAlgorithmList required to obtain the list.\r | |
83 | @param[out] RNGAlgorithmList A caller-allocated memory buffer filled by the driver\r | |
84 | with one EFI_RNG_ALGORITHM element for each supported\r | |
85 | RNG algorithm. The list must not change across multiple\r | |
86 | calls to the same driver. The first algorithm in the list\r | |
87 | is the default algorithm for the driver.\r | |
88 | \r | |
89 | @retval EFI_SUCCESS The RNG algorithm list was returned successfully.\r | |
90 | @retval EFI_BUFFER_TOO_SMALL The buffer RNGAlgorithmList is too small to hold the result.\r | |
91 | \r | |
92 | **/\r | |
93 | UINTN\r | |
94 | EFIAPI\r | |
95 | ArchGetSupportedRngAlgorithms (\r | |
c411b485 MK |
96 | IN OUT UINTN *RNGAlgorithmListSize,\r |
97 | OUT EFI_RNG_ALGORITHM *RNGAlgorithmList\r | |
4e5ecdba RC |
98 | );\r |
99 | \r | |
100 | /**\r | |
101 | Runs CPU RNG instruction to fill a buffer of arbitrary size with random bytes.\r | |
102 | \r | |
103 | @param[in] Length Size of the buffer, in bytes, to fill with.\r | |
104 | @param[out] RandBuffer Pointer to the buffer to store the random result.\r | |
105 | \r | |
106 | @retval EFI_SUCCESS Random bytes generation succeeded.\r | |
107 | @retval EFI_NOT_READY Failed to request random bytes.\r | |
108 | \r | |
109 | **/\r | |
110 | EFI_STATUS\r | |
111 | EFIAPI\r | |
112 | RngGetBytes (\r | |
c411b485 MK |
113 | IN UINTN Length,\r |
114 | OUT UINT8 *RandBuffer\r | |
4e5ecdba RC |
115 | );\r |
116 | \r | |
c411b485 | 117 | #endif // RNGDXE_INTERNALS_H_\r |