1 | /** @file
|
---|
2 | EFI_RNG_PROTOCOL as defined in UEFI 2.4.
|
---|
3 | The UEFI Random Number Generator Protocol is used to provide random bits for use
|
---|
4 | in applications, or entropy for seeding other random number generators.
|
---|
5 |
|
---|
6 | Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
|
---|
7 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
8 |
|
---|
9 | **/
|
---|
10 |
|
---|
11 | #ifndef __EFI_RNG_PROTOCOL_H__
|
---|
12 | #define __EFI_RNG_PROTOCOL_H__
|
---|
13 |
|
---|
14 | ///
|
---|
15 | /// Global ID for the Random Number Generator Protocol
|
---|
16 | ///
|
---|
17 | #define EFI_RNG_PROTOCOL_GUID \
|
---|
18 | { \
|
---|
19 | 0x3152bca5, 0xeade, 0x433d, {0x86, 0x2e, 0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44 } \
|
---|
20 | }
|
---|
21 |
|
---|
22 | typedef struct _EFI_RNG_PROTOCOL EFI_RNG_PROTOCOL;
|
---|
23 |
|
---|
24 | ///
|
---|
25 | /// A selection of EFI_RNG_PROTOCOL algorithms.
|
---|
26 | /// The algorithms listed are optional, not meant to be exhaustive and be argmented by
|
---|
27 | /// vendors or other industry standards.
|
---|
28 | ///
|
---|
29 |
|
---|
30 | typedef EFI_GUID EFI_RNG_ALGORITHM;
|
---|
31 |
|
---|
32 | ///
|
---|
33 | /// The algorithms corresponds to SP800-90 as defined in
|
---|
34 | /// NIST SP 800-90, "Recommendation for Random Number Generation Using Deterministic Random
|
---|
35 | /// Bit Generators", March 2007.
|
---|
36 | ///
|
---|
37 | #define EFI_RNG_ALGORITHM_SP800_90_HASH_256_GUID \
|
---|
38 | { \
|
---|
39 | 0xa7af67cb, 0x603b, 0x4d42, {0xba, 0x21, 0x70, 0xbf, 0xb6, 0x29, 0x3f, 0x96 } \
|
---|
40 | }
|
---|
41 | #define EFI_RNG_ALGORITHM_SP800_90_HMAC_256_GUID \
|
---|
42 | { \
|
---|
43 | 0xc5149b43, 0xae85, 0x4f53, {0x99, 0x82, 0xb9, 0x43, 0x35, 0xd3, 0xa9, 0xe7 } \
|
---|
44 | }
|
---|
45 | #define EFI_RNG_ALGORITHM_SP800_90_CTR_256_GUID \
|
---|
46 | { \
|
---|
47 | 0x44f0de6e, 0x4d8c, 0x4045, {0xa8, 0xc7, 0x4d, 0xd1, 0x68, 0x85, 0x6b, 0x9e } \
|
---|
48 | }
|
---|
49 | ///
|
---|
50 | /// The algorithms correspond to X9.31 as defined in
|
---|
51 | /// NIST, "Recommended Random Number Generator Based on ANSI X9.31 Appendix A.2.4 Using
|
---|
52 | /// the 3-Key Triple DES and AES Algorithm", January 2005.
|
---|
53 | ///
|
---|
54 | #define EFI_RNG_ALGORITHM_X9_31_3DES_GUID \
|
---|
55 | { \
|
---|
56 | 0x63c4785a, 0xca34, 0x4012, {0xa3, 0xc8, 0x0b, 0x6a, 0x32, 0x4f, 0x55, 0x46 } \
|
---|
57 | }
|
---|
58 | #define EFI_RNG_ALGORITHM_X9_31_AES_GUID \
|
---|
59 | { \
|
---|
60 | 0xacd03321, 0x777e, 0x4d3d, {0xb1, 0xc8, 0x20, 0xcf, 0xd8, 0x88, 0x20, 0xc9 } \
|
---|
61 | }
|
---|
62 | ///
|
---|
63 | /// The "raw" algorithm, when supported, is intended to provide entropy directly from
|
---|
64 | /// the source, without it going through some deterministic random bit generator.
|
---|
65 | ///
|
---|
66 | #define EFI_RNG_ALGORITHM_RAW \
|
---|
67 | { \
|
---|
68 | 0xe43176d7, 0xb6e8, 0x4827, {0xb7, 0x84, 0x7f, 0xfd, 0xc4, 0xb6, 0x85, 0x61 } \
|
---|
69 | }
|
---|
70 | ///
|
---|
71 | /// The Arm Architecture states the RNDR that the DRBG algorithm should be compliant
|
---|
72 | /// with NIST SP800-90A, while not mandating a particular algorithm, so as to be
|
---|
73 | /// inclusive of different geographies.
|
---|
74 | ///
|
---|
75 | #define EFI_RNG_ALGORITHM_ARM_RNDR \
|
---|
76 | { \
|
---|
77 | 0x43d2fde3, 0x9d4e, 0x4d79, {0x02, 0x96, 0xa8, 0x9b, 0xca, 0x78, 0x08, 0x41} \
|
---|
78 | }
|
---|
79 |
|
---|
80 | /**
|
---|
81 | Returns information about the random number generation implementation.
|
---|
82 |
|
---|
83 | @param[in] This A pointer to the EFI_RNG_PROTOCOL instance.
|
---|
84 | @param[in,out] RNGAlgorithmListSize On input, the size in bytes of RNGAlgorithmList.
|
---|
85 | On output with a return code of EFI_SUCCESS, the size
|
---|
86 | in bytes of the data returned in RNGAlgorithmList. On output
|
---|
87 | with a return code of EFI_BUFFER_TOO_SMALL,
|
---|
88 | the size of RNGAlgorithmList required to obtain the list.
|
---|
89 | @param[out] RNGAlgorithmList A caller-allocated memory buffer filled by the driver
|
---|
90 | with one EFI_RNG_ALGORITHM element for each supported
|
---|
91 | RNG algorithm. The list must not change across multiple
|
---|
92 | calls to the same driver. The first algorithm in the list
|
---|
93 | is the default algorithm for the driver.
|
---|
94 |
|
---|
95 | @retval EFI_SUCCESS The RNG algorithm list was returned successfully.
|
---|
96 | @retval EFI_UNSUPPORTED The services is not supported by this driver.
|
---|
97 | @retval EFI_DEVICE_ERROR The list of algorithms could not be retrieved due to a
|
---|
98 | hardware or firmware error.
|
---|
99 | @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect.
|
---|
100 | @retval EFI_BUFFER_TOO_SMALL The buffer RNGAlgorithmList is too small to hold the result.
|
---|
101 |
|
---|
102 | **/
|
---|
103 | typedef
|
---|
104 | EFI_STATUS
|
---|
105 | (EFIAPI *EFI_RNG_GET_INFO)(
|
---|
106 | IN EFI_RNG_PROTOCOL *This,
|
---|
107 | IN OUT UINTN *RNGAlgorithmListSize,
|
---|
108 | OUT EFI_RNG_ALGORITHM *RNGAlgorithmList
|
---|
109 | );
|
---|
110 |
|
---|
111 | /**
|
---|
112 | Produces and returns an RNG value using either the default or specified RNG algorithm.
|
---|
113 |
|
---|
114 | @param[in] This A pointer to the EFI_RNG_PROTOCOL instance.
|
---|
115 | @param[in] RNGAlgorithm A pointer to the EFI_RNG_ALGORITHM that identifies the RNG
|
---|
116 | algorithm to use. May be NULL in which case the function will
|
---|
117 | use its default RNG algorithm.
|
---|
118 | @param[in] RNGValueLength The length in bytes of the memory buffer pointed to by
|
---|
119 | RNGValue. The driver shall return exactly this numbers of bytes.
|
---|
120 | @param[out] RNGValue A caller-allocated memory buffer filled by the driver with the
|
---|
121 | resulting RNG value.
|
---|
122 |
|
---|
123 | @retval EFI_SUCCESS The RNG value was returned successfully.
|
---|
124 | @retval EFI_UNSUPPORTED The algorithm specified by RNGAlgorithm is not supported by
|
---|
125 | this driver.
|
---|
126 | @retval EFI_DEVICE_ERROR An RNG value could not be retrieved due to a hardware or
|
---|
127 | firmware error.
|
---|
128 | @retval EFI_NOT_READY There is not enough random data available to satisfy the length
|
---|
129 | requested by RNGValueLength.
|
---|
130 | @retval EFI_INVALID_PARAMETER RNGValue is NULL or RNGValueLength is zero.
|
---|
131 |
|
---|
132 | **/
|
---|
133 | typedef
|
---|
134 | EFI_STATUS
|
---|
135 | (EFIAPI *EFI_RNG_GET_RNG)(
|
---|
136 | IN EFI_RNG_PROTOCOL *This,
|
---|
137 | IN EFI_RNG_ALGORITHM *RNGAlgorithm OPTIONAL,
|
---|
138 | IN UINTN RNGValueLength,
|
---|
139 | OUT UINT8 *RNGValue
|
---|
140 | );
|
---|
141 |
|
---|
142 | ///
|
---|
143 | /// The Random Number Generator (RNG) protocol provides random bits for use in
|
---|
144 | /// applications, or entropy for seeding other random number generators.
|
---|
145 | ///
|
---|
146 | struct _EFI_RNG_PROTOCOL {
|
---|
147 | EFI_RNG_GET_INFO GetInfo;
|
---|
148 | EFI_RNG_GET_RNG GetRNG;
|
---|
149 | };
|
---|
150 |
|
---|
151 | extern EFI_GUID gEfiRngProtocolGuid;
|
---|
152 | extern EFI_GUID gEfiRngAlgorithmSp80090Hash256Guid;
|
---|
153 | extern EFI_GUID gEfiRngAlgorithmSp80090Hmac256Guid;
|
---|
154 | extern EFI_GUID gEfiRngAlgorithmSp80090Ctr256Guid;
|
---|
155 | extern EFI_GUID gEfiRngAlgorithmX9313DesGuid;
|
---|
156 | extern EFI_GUID gEfiRngAlgorithmX931AesGuid;
|
---|
157 | extern EFI_GUID gEfiRngAlgorithmRaw;
|
---|
158 | extern EFI_GUID gEfiRngAlgorithmArmRndr;
|
---|
159 |
|
---|
160 | #endif
|
---|