Files
slimbootloader/BootloaderCommonPkg/Library/SecureBootLib/SecureBootRndNumGen.c
Guo Dong 833ecbc46b Format update by coding style
1)  Replace TAB with spaces
2)  Convert CR, LF or LFCR to CRLF
3)  Remove trailing spaces
4)  Updated below strings:
       "EFI_D_INFO"  -> "DEBUG_INFO",
       "EFI_D_WARN"  -> "DEBUG_WARN",
       "EFI_D_ERROR" -> "DEBUG_ERROR",

Signed-off-by: Guo Dong <guo.dong@intel.com>
2020-02-07 22:43:45 -07:00

43 lines
1008 B
C

/** @file
Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <Library/BootloaderCommonLib.h>
#include <Library/RngLib.h>
/**
Generate RandomNumbers.
@param[out] Data Array of random numbers generated
@param[in] Size Size of the array to be generated.
@retval EFI_SUCCESS Random number generation successful.
@retval EFI_UNSUPPORTED Couldnt generate a random number.
**/
EFI_STATUS
EFIAPI
GenerateRandomNumbers (
OUT CHAR8 *Data,
IN UINTN Size
)
{
INT32 Status;
UINTN TempI, TempJ;
UINT32 Random;
for (TempI = 0; TempI < Size; ) {
Status = GetRandomNumber32(&Random);
if (Status != 1) {
return EFI_UNSUPPORTED;
}
for (TempJ = 0; TempJ < sizeof(Random) && TempI < Size; TempJ++, TempI++) {
Data[TempI] = ((CHAR8 *)&Random)[TempJ];
}
}
return EFI_SUCCESS;
}