]>
git.proxmox.com Git - mirror_edk2.git/blob - SecurityPkg/RandomNumberGenerator/RngDxe/RdRand.h
20fd9fbd3ffa0a653d8e639e84bc5ee81f892eca
2 Header for the RDRAND APIs used by RNG DXE driver.
4 Support API definitions for RDRAND instruction access, which will leverage
5 Intel Secure Key technology to provide high-quality random numbers for use
6 in applications, or entropy for seeding other random number generators.
7 Refer to http://software.intel.com/en-us/articles/intel-digital-random-number
8 -generator-drng-software-implementation-guide/ for more information about Intel
11 Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
12 This program and the accompanying materials
13 are licensed and made available under the terms and conditions of the BSD License
14 which accompanies this distribution. The full text of the license may be found at
15 http://opensource.org/licenses/bsd-license.php
17 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
18 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
25 #include <Library/BaseLib.h>
26 #include <Library/BaseMemoryLib.h>
27 #include <Library/UefiBootServicesTableLib.h>
28 #include <Library/TimerLib.h>
29 #include <Protocol/Rng.h>
32 // The maximun number of retries to obtain one available random number.
34 #define RETRY_LIMIT 10
37 Determines whether or not RDRAND instruction is supported by the host hardware.
39 @retval EFI_SUCCESS RDRAND instruction supported.
40 @retval EFI_UNSUPPORTED RDRAND instruction not supported.
50 Generates a 16-bit random number through RDRAND instruction.
52 @param[out] Rand Buffer pointer to store the random result.
54 @retval TRUE RDRAND call was successful.
55 @retval FALSE Failed attempts to call RDRAND.
65 Generates a 32-bit random number through RDRAND instruction.
67 @param[out] Rand Buffer pointer to store the random result.
69 @retval TRUE RDRAND call was successful.
70 @retval FALSE Failed attempts to call RDRAND.
80 Generates a 64-bit random number through RDRAND instruction.
82 @param[out] Rand Buffer pointer to store the random result.
84 @retval TRUE RDRAND call was successful.
85 @retval FALSE Failed attempts to call RDRAND.
95 Calls RDRAND to obtain a 16-bit random number.
97 @param[out] Rand Buffer pointer to store the random result.
98 @param[in] NeedRetry Determine whether or not to loop retry.
100 @retval EFI_SUCCESS RDRAND call was successful.
101 @retval EFI_NOT_READY Failed attempts to call RDRAND.
112 Calls RDRAND to obtain a 32-bit random number.
114 @param[out] Rand Buffer pointer to store the random result.
115 @param[in] NeedRetry Determine whether or not to loop retry.
117 @retval EFI_SUCCESS RDRAND call was successful.
118 @retval EFI_NOT_READY Failed attempts to call RDRAND.
129 Calls RDRAND to obtain a 64-bit random number.
131 @param[out] Rand Buffer pointer to store the random result.
132 @param[in] NeedRetry Determine whether or not to loop retry.
134 @retval EFI_SUCCESS RDRAND call was successful.
135 @retval EFI_NOT_READY Failed attempts to call RDRAND.
146 Calls RDRAND to request a word-length random number.
148 @param[out] Rand Buffer pointer to store the random number.
149 @param[in] NeedRetry Determine whether or not to loop retry.
151 @retval EFI_SUCCESS Random word generation succeeded.
152 @retval EFI_NOT_READY Failed to request random word.
163 Calls RDRAND to request multiple word-length random numbers.
165 @param[in] Length Size of the buffer, in words, to fill with.
166 @param[out] RandBuffer Pointer to the buffer to store the random result.
168 @retval EFI_SUCCESS Random words generation succeeded.
169 @retval EFI_NOT_READY Failed to request random words.
176 OUT UINTN
*RandBuffer
180 Calls RDRAND to fill a buffer of arbitrary size with random bytes.
182 @param[in] Length Size of the buffer, in bytes, to fill with.
183 @param[out] RandBuffer Pointer to the buffer to store the random result.
185 @retval EFI_SUCCESS Random bytes generation succeeded.
186 @retval EFI_NOT_READY Failed to request random bytes.
193 OUT UINT8
*RandBuffer
197 Generate high-quality entropy source through RDRAND.
199 @param[in] Length Size of the buffer, in bytes, to fill with.
200 @param[out] Entropy Pointer to the buffer to store the entropy data.
202 @retval EFI_SUCCESS Entropy generation succeeded.
203 @retval EFI_NOT_READY Failed to request random data.
208 RdRandGenerateEntropy (
213 #endif // __RD_RAND_H__