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