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