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