--- /dev/null
+/** @file\r
+ EFI_RNG_PROTOCOL as defined in UEFI 2.4.\r
+ The UEFI Random Number Generator Protocol is used to provide random bits for use \r
+ in applications, or entropy for seeding other random number generators.\r
+\r
+Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials are licensed and made available under\r
+the terms and conditions of the BSD License that accompanies this distribution.\r
+The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php.\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef __EFI_RNG_PROTOCOL_H__\r
+#define __EFI_RNG_PROTOCOL_H__\r
+\r
+///\r
+/// Global ID for the Random Number Generator Protocol\r
+///\r
+#define EFI_RNG_PROTOCOL_GUID \\r
+ { \\r
+ 0x3152bca5, 0xeade, 0x433d, {0x86, 0x2e, 0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44 } \\r
+ }\r
+\r
+typedef struct _EFI_RNG_PROTOCOL EFI_RNG_PROTOCOL;\r
+\r
+///\r
+/// A selection of EFI_RNG_PROTOCOL algorithms.\r
+/// The algorithms listed are optional, not meant to be exhaustive and be argmented by \r
+/// vendors or other industry standards.\r
+///\r
+\r
+typedef EFI_GUID EFI_RNG_ALGORITHM;\r
+\r
+///\r
+/// The algorithms corresponds to SP800-90 as defined in\r
+/// NIST SP 800-90, "Recommendation for Random Number Generation Using Deterministic Random\r
+/// Bit Generators", March 2007.\r
+///\r
+#define EFI_RNG_ALGORITHM_SP800_90_HASH_256_GUID \\r
+ { \\r
+ 0xa7af67cb, 0x603b, 0x4d42, {0xba, 0x21, 0x70, 0xbf, 0xb6, 0x29, 0x3f, 0x96 } \\r
+ }\r
+#define EFI_RNG_ALGORITHM_SP800_90_HMAC_256_GUID \\r
+ { \\r
+ 0xc5149b43, 0xae85, 0x4f53, {0x99, 0x82, 0xb9, 0x43, 0x35, 0xd3, 0xa9, 0xe7 } \\r
+ }\r
+#define EFI_RNG_ALGORITHM_SP800_90_CTR_256_GUID \\r
+ { \\r
+ 0x44f0de6e, 0x4d8c, 0x4045, {0xa8, 0xc7, 0x4d, 0xd1, 0x68, 0x85, 0x6b, 0x9e } \\r
+ }\r
+///\r
+/// The algorithms correspond to X9.31 as defined in\r
+/// NIST, "Recommended Random Number Generator Based on ANSI X9.31 Appendix A.2.4 Using\r
+/// the 3-Key Triple DES and AES Algorithm", January 2005.\r
+///\r
+#define EFI_RNG_ALGORITHM_X9_31_3DES_GUID \\r
+ { \\r
+ 0x63c4785a, 0xca34, 0x4012, {0xa3, 0xc8, 0x0b, 0x6a, 0x32, 0x4f, 0x55, 0x46 } \\r
+ }\r
+#define EFI_RNG_ALGORITHM_X9_31_AES_GUID \\r
+ { \\r
+ 0xacd03321, 0x777e, 0x4d3d, {0xb1, 0xc8, 0x20, 0xcf, 0xd8, 0x88, 0x20, 0xc9 } \\r
+ }\r
+///\r
+/// The "raw" algorithm, when supported, is intended to provide entropy directly from\r
+/// the source, without it going through some deterministic random bit generator.\r
+///\r
+#define EFI_RNG_ALGORITHM_RAW \\r
+ { \\r
+ 0xe43176d7, 0xb6e8, 0x4827, {0xb7, 0x84, 0x7f, 0xfd, 0xc4, 0xb6, 0x85, 0x61 } \\r
+ }\r
+\r
+/**\r
+ Returns information about the random number generation implementation.\r
+\r
+ @param[in] This A pointer to the EFI_RNG_PROTOCOL instance.\r
+ @param[in,out] RNGAlgorithmListSize On input, the size in bytes of RNGAlgorithmList. \r
+ On output with a return code of EFI_SUCCESS, the size\r
+ in bytes of the data returned in RNGAlgorithmList. On output\r
+ with a return code of EFI_BUFFER_TOO_SMALL,\r
+ the size of RNGAlgorithmList required to obtain the list.\r
+ @param[out] RNGAlgorithmList A caller-allocated memory buffer filled by the driver\r
+ with one EFI_RNG_ALGORITHM element for each supported\r
+ RNG algorithm. The list must not change across multiple\r
+ calls to the same driver. The first algorithm in the list\r
+ is the default algorithm for the driver.\r
+\r
+ @retval EFI_SUCCESS The RNG algorithm list was returned successfully.\r
+ @retval EFI_UNSUPPORTED The services is not supported by this driver.\r
+ @retval EFI_DEVICE_ERROR The list of algorithms could not be retrieved due to a\r
+ hardware or firmware error.\r
+ @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect.\r
+ @retval EFI_BUFFER_TOO_SMALL The buffer RNGAlgorithmList is too small to hold the result.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_RNG_GET_INFO) (\r
+ IN EFI_RNG_PROTOCOL *This,\r
+ IN OUT UINTN *RNGAlgorithmListSize,\r
+ OUT EFI_RNG_ALGORITHM *RNGAlgorithmList\r
+ );\r
+\r
+/**\r
+ Produces and returns an RNG value using either the default or specified RNG algorithm.\r
+\r
+ @param[in] This A pointer to the EFI_RNG_PROTOCOL instance.\r
+ @param[in] RNGAlgorithm A pointer to the EFI_RNG_ALGORITHM that identifies the RNG\r
+ algorithm to use. May be NULL in which case the function will\r
+ use its default RNG algorithm.\r
+ @param[in] RNGValueLength The length in bytes of the memory buffer pointed to by\r
+ RNGValue. The driver shall return exactly this numbers of bytes.\r
+ @param[out] RNGValue A caller-allocated memory buffer filled by the driver with the\r
+ resulting RNG value.\r
+\r
+ @retval EFI_SUCCESS The RNG value was returned successfully.\r
+ @retval EFI_UNSUPPORTED The algorithm specified by RNGAlgorithm is not supported by\r
+ this driver.\r
+ @retval EFI_DEVICE_ERROR An RNG value could not be retrieved due to a hardware or\r
+ firmware error.\r
+ @retval EFI_NOT_READY There is not enough random data available to satisfy the length\r
+ requested by RNGValueLength.\r
+ @retval EFI_INVALID_PARAMETER RNGValue is NULL or RNGValueLength is zero.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_RNG_GET_RNG) (\r
+ IN EFI_RNG_PROTOCOL *This,\r
+ IN EFI_RNG_ALGORITHM *RNGAlgorithm, OPTIONAL\r
+ IN UINTN RNGValueLength,\r
+ OUT UINT8 *RNGValue\r
+ );\r
+\r
+///\r
+/// The Random Number Generator (RNG) protocol provides random bits for use in \r
+/// applications, or entropy for seeding other random number generators.\r
+///\r
+struct _EFI_RNG_PROTOCOL {\r
+ EFI_RNG_GET_INFO GetInfo;\r
+ EFI_RNG_GET_RNG GetRNG;\r
+};\r
+\r
+extern EFI_GUID gEfiRngProtocolGuid;\r
+extern EFI_GUID gEfiRngAlgorithmSp80090Hash256Guid;\r
+extern EFI_GUID gEfiRngAlgorithmSp80090Hmac256Guid;\r
+extern EFI_GUID gEfiRngAlgorithmSp80090Ctr256Guid;\r
+extern EFI_GUID gEfiRngAlgorithmX9313DesGuid;\r
+extern EFI_GUID gEfiRngAlgorithmX931AesGuid;\r
+extern EFI_GUID gEfiRngAlgorithmRaw;\r
+\r
+#endif\r