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