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