TianoCore EDK2 master
Loading...
Searching...
No Matches
RngLibTimer.c File Reference
#include <Base.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/TimerLib.h>

Go to the source code of this file.

Macros

#define DEFAULT_DELAY_TIME_IN_MICROSECONDS   10
 

Functions

RETURN_STATUS EFIAPI BaseRngLibTimerConstructor (VOID)
 
STATIC UINT32 CalculateMinimumDecentDelayInMicroseconds (VOID)
 
BOOLEAN EFIAPI GetRandomNumber16 (OUT UINT16 *Rand)
 
BOOLEAN EFIAPI GetRandomNumber32 (OUT UINT32 *Rand)
 
BOOLEAN EFIAPI GetRandomNumber64 (OUT UINT64 *Rand)
 
BOOLEAN EFIAPI GetRandomNumber128 (OUT UINT64 *Rand)
 
RETURN_STATUS EFIAPI GetRngGuid (GUID *RngGuid)
 

Detailed Description

BaseRng Library that uses the TimerLib to provide reasonably random numbers. Do not use this on a production system.

Copyright (c) Microsoft Corporation. SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file RngLibTimer.c.

Macro Definition Documentation

◆ DEFAULT_DELAY_TIME_IN_MICROSECONDS

#define DEFAULT_DELAY_TIME_IN_MICROSECONDS   10

Definition at line 14 of file RngLibTimer.c.

Function Documentation

◆ BaseRngLibTimerConstructor()

RETURN_STATUS EFIAPI BaseRngLibTimerConstructor ( VOID  )

This implementation is to be replaced by its MdeModulePkg copy. The cause being that some GUIDs (gEdkiiRngAlgorithmUnSafe) cannot be defined in the MdePkg.

Return values
EFI_SUCCESSThe constructor always returns EFI_SUCCESS.

Definition at line 25 of file RngLibTimer.c.

◆ CalculateMinimumDecentDelayInMicroseconds()

STATIC UINT32 CalculateMinimumDecentDelayInMicroseconds ( VOID  )

Using the TimerLib GetPerformanceCounterProperties() we delay for enough time for the PerformanceCounter to increment.

If the return value from GetPerformanceCounterProperties (TimerLib) is zero, this function will return 10 and attempt to assert.

Definition at line 47 of file RngLibTimer.c.

◆ GetRandomNumber128()

BOOLEAN EFIAPI GetRandomNumber128 ( OUT UINT64 *  Rand)

Generates a 128-bit random number.

if Rand is NULL, then ASSERT().

Parameters
[out]RandBuffer pointer to store the 128-bit random value.
Return values
TRUERandom number generated successfully.
FALSEFailed to generate the random number.

Definition at line 200 of file RngLibTimer.c.

◆ GetRandomNumber16()

BOOLEAN EFIAPI GetRandomNumber16 ( OUT UINT16 *  Rand)

Generates a 16-bit random number.

if Rand is NULL, then ASSERT().

Parameters
[out]RandBuffer pointer to store the 16-bit random value.
Return values
TRUERandom number generated successfully.
FALSEFailed to generate the random number.

Definition at line 80 of file RngLibTimer.c.

◆ GetRandomNumber32()

BOOLEAN EFIAPI GetRandomNumber32 ( OUT UINT32 *  Rand)

Generates a 32-bit random number.

if Rand is NULL, then ASSERT().

Parameters
[out]RandBuffer pointer to store the 32-bit random value.
Return values
TRUERandom number generated successfully.
FALSEFailed to generate the random number.

Definition at line 120 of file RngLibTimer.c.

◆ GetRandomNumber64()

BOOLEAN EFIAPI GetRandomNumber64 ( OUT UINT64 *  Rand)

Generates a 64-bit random number.

if Rand is NULL, then ASSERT().

Parameters
[out]RandBuffer pointer to store the 64-bit random value.
Return values
TRUERandom number generated successfully.
FALSEFailed to generate the random number.

Definition at line 160 of file RngLibTimer.c.

◆ GetRngGuid()

RETURN_STATUS EFIAPI GetRngGuid ( GUID RngGuid)

Get a GUID identifying the RNG algorithm implementation.

Parameters
[out]RngGuidIf success, contains the GUID identifying the RNG algorithm implementation.
Return values
EFI_SUCCESSSuccess.
EFI_UNSUPPORTEDNot supported.
EFI_INVALID_PARAMETERInvalid parameter.

Definition at line 228 of file RngLibTimer.c.