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