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