Path: blob/main/sys/contrib/edk2/Include/Guid/Rng.h
96339 views
/** @file1Random Number Generator (RNG) GUIDs and structures shared across RNG interfaces.23Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>4Copyright (c) Microsoft Corporation.5SPDX-License-Identifier: BSD-2-Clause-Patent67**/89#ifndef RNG_GUID_H_10#define RNG_GUID_H_1112typedef struct _EFI_RNG_INTERFACE EFI_RNG_INTERFACE;1314///15/// A selection of EFI_RNG_PROTOCOL algorithms.16/// The algorithms listed are optional, not meant to be exhaustive and be argmented by17/// vendors or other industry standards.18///19typedef EFI_GUID EFI_RNG_ALGORITHM;2021///22/// The algorithms corresponds to SP800-90 as defined in23/// NIST SP 800-90, "Recommendation for Random Number Generation Using Deterministic Random24/// Bit Generators", March 2007.25///26#define EFI_RNG_ALGORITHM_SP800_90_HASH_256_GUID \27{ \280xa7af67cb, 0x603b, 0x4d42, {0xba, 0x21, 0x70, 0xbf, 0xb6, 0x29, 0x3f, 0x96 } \29}30#define EFI_RNG_ALGORITHM_SP800_90_HMAC_256_GUID \31{ \320xc5149b43, 0xae85, 0x4f53, {0x99, 0x82, 0xb9, 0x43, 0x35, 0xd3, 0xa9, 0xe7 } \33}34#define EFI_RNG_ALGORITHM_SP800_90_CTR_256_GUID \35{ \360x44f0de6e, 0x4d8c, 0x4045, {0xa8, 0xc7, 0x4d, 0xd1, 0x68, 0x85, 0x6b, 0x9e } \37}3839///40/// The algorithms correspond to X9.31 as defined in41/// NIST, "Recommended Random Number Generator Based on ANSI X9.31 Appendix A.2.4 Using42/// the 3-Key Triple DES and AES Algorithm", January 2005.43///44#define EFI_RNG_ALGORITHM_X9_31_3DES_GUID \45{ \460x63c4785a, 0xca34, 0x4012, {0xa3, 0xc8, 0x0b, 0x6a, 0x32, 0x4f, 0x55, 0x46 } \47}48#define EFI_RNG_ALGORITHM_X9_31_AES_GUID \49{ \500xacd03321, 0x777e, 0x4d3d, {0xb1, 0xc8, 0x20, 0xcf, 0xd8, 0x88, 0x20, 0xc9 } \51}5253///54/// The "raw" algorithm, when supported, is intended to provide entropy directly from55/// the source, without it going through some deterministic random bit generator.56///57#define EFI_RNG_ALGORITHM_RAW \58{ \590xe43176d7, 0xb6e8, 0x4827, {0xb7, 0x84, 0x7f, 0xfd, 0xc4, 0xb6, 0x85, 0x61 } \60}6162///63/// The Arm Architecture states the RNDR that the DRBG algorithm should be compliant64/// with NIST SP800-90A, while not mandating a particular algorithm, so as to be65/// inclusive of different geographies.66///67#define EFI_RNG_ALGORITHM_ARM_RNDR \68{ \690x43d2fde3, 0x9d4e, 0x4d79, {0x02, 0x96, 0xa8, 0x9b, 0xca, 0x78, 0x08, 0x41} \70}7172/**73Returns information about the random number generation implementation.7475@param[in] This A pointer to this interface instance.76@param[in,out] RNGAlgorithmListSize On input, the size in bytes of RNGAlgorithmList.77On output with a return code of EFI_SUCCESS, the size78in bytes of the data returned in RNGAlgorithmList. On output79with a return code of EFI_BUFFER_TOO_SMALL,80the size of RNGAlgorithmList required to obtain the list.81@param[out] RNGAlgorithmList A caller-allocated memory buffer filled by the driver82with one EFI_RNG_ALGORITHM element for each supported83RNG algorithm. The list must not change across multiple84calls to the same driver. The first algorithm in the list85is the default algorithm for the driver.8687@retval EFI_SUCCESS The RNG algorithm list was returned successfully.88@retval EFI_UNSUPPORTED The services is not supported by this driver.89@retval EFI_DEVICE_ERROR The list of algorithms could not be retrieved due to a90hardware or firmware error.91@retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect.92@retval EFI_BUFFER_TOO_SMALL The buffer RNGAlgorithmList is too small to hold the result.9394**/95typedef96EFI_STATUS97(EFIAPI *EFI_RNG_GET_INFO)(98IN EFI_RNG_INTERFACE *This,99IN OUT UINTN *RNGAlgorithmListSize,100OUT EFI_RNG_ALGORITHM *RNGAlgorithmList101);102103/**104Produces and returns an RNG value using either the default or specified RNG algorithm.105106@param[in] This A pointer to this interface instance.107@param[in] RNGAlgorithm A pointer to the EFI_RNG_ALGORITHM that identifies the RNG108algorithm to use. May be NULL in which case the function will109use its default RNG algorithm.110@param[in] RNGValueLength The length in bytes of the memory buffer pointed to by111RNGValue. The driver shall return exactly this numbers of bytes.112@param[out] RNGValue A caller-allocated memory buffer filled by the driver with the113resulting RNG value.114115@retval EFI_SUCCESS The RNG value was returned successfully.116@retval EFI_UNSUPPORTED The algorithm specified by RNGAlgorithm is not supported by117this driver.118@retval EFI_DEVICE_ERROR An RNG value could not be retrieved due to a hardware or119firmware error.120@retval EFI_NOT_READY There is not enough random data available to satisfy the length121requested by RNGValueLength.122@retval EFI_INVALID_PARAMETER RNGValue is NULL or RNGValueLength is zero.123124**/125typedef126EFI_STATUS127(EFIAPI *EFI_RNG_GET_RNG)(128IN EFI_RNG_INTERFACE *This,129IN EFI_RNG_ALGORITHM *RNGAlgorithm OPTIONAL,130IN UINTN RNGValueLength,131OUT UINT8 *RNGValue132);133134///135/// The Random Number Generator (RNG) interface provides random bits for use in136/// applications, or entropy for seeding other random number generators.137///138/// This interface is shared between the RNG Protocol defined in the UEFI 2.4 Specification139/// and the RNG PPI defined in the PI 1.9 Specification.140///141struct _EFI_RNG_INTERFACE {142EFI_RNG_GET_INFO GetInfo;143EFI_RNG_GET_RNG GetRNG;144};145146extern EFI_GUID gEfiRngAlgorithmSp80090Hash256Guid;147extern EFI_GUID gEfiRngAlgorithmSp80090Hmac256Guid;148extern EFI_GUID gEfiRngAlgorithmSp80090Ctr256Guid;149extern EFI_GUID gEfiRngAlgorithmX9313DesGuid;150extern EFI_GUID gEfiRngAlgorithmX931AesGuid;151extern EFI_GUID gEfiRngAlgorithmRaw;152extern EFI_GUID gEfiRngAlgorithmArmRndr;153154#endif // #ifndef RNG_GUID_H_155156157