Use the new RngLib to provide the IA32/X64 random data for RngDxe. Remove x86 specific functions from RdRand files. Simplify RngDxe by using WriteUnaligned64 for all platforms. Use GetRandomNumber128 in RngDxe to leverage 128 bit support provided by some HW RNG devices. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Thomas Palmer <thomas.palmer@hpe.com> Reviewed-by: Samer El-Haj-Mahmoud <elhaj@hpe.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Reviewed-by: Chao Zhang <chao.b.zhang@intel.com> Reviewed-by: Qin Long <qin.long@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18591 6f19259b-4bc3-4df7-8a09-765794883524
67 lines
2.2 KiB
C
67 lines
2.2 KiB
C
/** @file
|
|
Header for the RDRAND APIs used by RNG DXE driver.
|
|
|
|
Support API definitions for RDRAND instruction access, which will leverage
|
|
Intel Secure Key technology to provide high-quality random numbers for use
|
|
in applications, or entropy for seeding other random number generators.
|
|
Refer to http://software.intel.com/en-us/articles/intel-digital-random-number
|
|
-generator-drng-software-implementation-guide/ for more information about Intel
|
|
Secure Key technology.
|
|
|
|
Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
|
|
(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
|
|
This program and the accompanying materials
|
|
are licensed and made available under the terms and conditions of the BSD License
|
|
which accompanies this distribution. The full text of the license may be found at
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
**/
|
|
|
|
#ifndef __RD_RAND_H__
|
|
#define __RD_RAND_H__
|
|
|
|
#include <Library/BaseLib.h>
|
|
#include <Library/BaseMemoryLib.h>
|
|
#include <Library/UefiBootServicesTableLib.h>
|
|
#include <Library/TimerLib.h>
|
|
#include <Protocol/Rng.h>
|
|
|
|
/**
|
|
Calls RDRAND to fill a buffer of arbitrary size with random bytes.
|
|
|
|
@param[in] Length Size of the buffer, in bytes, to fill with.
|
|
@param[out] RandBuffer Pointer to the buffer to store the random result.
|
|
|
|
@retval EFI_SUCCESS Random bytes generation succeeded.
|
|
@retval EFI_NOT_READY Failed to request random bytes.
|
|
|
|
**/
|
|
EFI_STATUS
|
|
EFIAPI
|
|
RdRandGetBytes (
|
|
IN UINTN Length,
|
|
OUT UINT8 *RandBuffer
|
|
);
|
|
|
|
/**
|
|
Generate high-quality entropy source through RDRAND.
|
|
|
|
@param[in] Length Size of the buffer, in bytes, to fill with.
|
|
@param[out] Entropy Pointer to the buffer to store the entropy data.
|
|
|
|
@retval EFI_SUCCESS Entropy generation succeeded.
|
|
@retval EFI_NOT_READY Failed to request random data.
|
|
|
|
**/
|
|
EFI_STATUS
|
|
EFIAPI
|
|
RdRandGenerateEntropy (
|
|
IN UINTN Length,
|
|
OUT UINT8 *Entropy
|
|
);
|
|
|
|
#endif // __RD_RAND_H__
|