Secure Key technology.\r
\r
Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
#include <Library/TimerLib.h>\r
#include <Protocol/Rng.h>\r
\r
-//\r
-// The maximun number of retries to obtain one available random number. \r
-//\r
-#define RETRY_LIMIT 10\r
-\r
-/**\r
- Determines whether or not RDRAND instruction is supported by the host hardware.\r
-\r
- @retval EFI_SUCCESS RDRAND instruction supported.\r
- @retval EFI_UNSUPPORTED RDRAND instruction not supported.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-IsRdRandSupported (\r
- VOID\r
- );\r
-\r
-/**\r
- Generates a 16-bit random number through RDRAND instruction.\r
-\r
- @param[out] Rand Buffer pointer to store the random result.\r
-\r
- @retval TRUE RDRAND call was successful.\r
- @retval FALSE Failed attempts to call RDRAND.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-RdRand16Step (\r
- OUT UINT16 *Rand\r
- );\r
-\r
-/**\r
- Generates a 32-bit random number through RDRAND instruction.\r
-\r
- @param[out] Rand Buffer pointer to store the random result.\r
-\r
- @retval TRUE RDRAND call was successful.\r
- @retval FALSE Failed attempts to call RDRAND.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-RdRand32Step (\r
- OUT UINT32 *Rand\r
- );\r
-\r
-/**\r
- Generates a 64-bit random number through RDRAND instruction.\r
-\r
- @param[out] Rand Buffer pointer to store the random result.\r
-\r
- @retval TRUE RDRAND call was successful.\r
- @retval FALSE Failed attempts to call RDRAND.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-RdRand64Step (\r
- OUT UINT64 *Rand\r
- );\r
-\r
-/**\r
- Calls RDRAND to obtain a 16-bit random number.\r
-\r
- @param[out] Rand Buffer pointer to store the random result.\r
- @param[in] NeedRetry Determine whether or not to loop retry.\r
-\r
- @retval EFI_SUCCESS RDRAND call was successful.\r
- @retval EFI_NOT_READY Failed attempts to call RDRAND.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-RdRand16 (\r
- OUT UINT16 *Rand,\r
- IN BOOLEAN NeedRetry\r
- );\r
-\r
-/**\r
- Calls RDRAND to obtain a 32-bit random number.\r
-\r
- @param[out] Rand Buffer pointer to store the random result.\r
- @param[in] NeedRetry Determine whether or not to loop retry.\r
-\r
- @retval EFI_SUCCESS RDRAND call was successful.\r
- @retval EFI_NOT_READY Failed attempts to call RDRAND.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-RdRand32 (\r
- OUT UINT32 *Rand,\r
- IN BOOLEAN NeedRetry\r
- );\r
-\r
-/**\r
- Calls RDRAND to obtain a 64-bit random number.\r
-\r
- @param[out] Rand Buffer pointer to store the random result.\r
- @param[in] NeedRetry Determine whether or not to loop retry.\r
-\r
- @retval EFI_SUCCESS RDRAND call was successful.\r
- @retval EFI_NOT_READY Failed attempts to call RDRAND.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-RdRand64 (\r
- OUT UINT64 *Rand,\r
- IN BOOLEAN NeedRetry\r
- );\r
- \r
-/**\r
- Calls RDRAND to request a word-length random number.\r
-\r
- @param[out] Rand Buffer pointer to store the random number.\r
- @param[in] NeedRetry Determine whether or not to loop retry.\r
-\r
- @retval EFI_SUCCESS Random word generation succeeded.\r
- @retval EFI_NOT_READY Failed to request random word.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-RdRandWord (\r
- OUT UINTN *Rand,\r
- IN BOOLEAN NeedRetry\r
- );\r
-\r
-/**\r
- Calls RDRAND to request multiple word-length random numbers.\r
-\r
- @param[in] Length Size of the buffer, in words, to fill with.\r
- @param[out] RandBuffer Pointer to the buffer to store the random result.\r
-\r
- @retval EFI_SUCCESS Random words generation succeeded.\r
- @retval EFI_NOT_READY Failed to request random words.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-RdRandGetWords (\r
- IN UINTN Length,\r
- OUT UINTN *RandBuffer\r
- );\r
-\r
/**\r
Calls RDRAND to fill a buffer of arbitrary size with random bytes.\r
\r
OUT UINT8 *Entropy\r
);\r
\r
-#endif // __RD_RAND_H__
\ No newline at end of file
+#endif // __RD_RAND_H__\r