TianoCore EDK2 master
|
#include <Uefi.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/RngLib.h>
#include <Register/RiscV64/RiscVEncoding.h>
#include "BaseRngLibInternals.h"
Go to the source code of this file.
Macros | |
#define | RISCV_CPU_FEATURE_ZKR_BITMASK 0x8 |
#define | SEED_RETRY_LOOPS 100 |
#define | STATE_SIZE 312 |
#define | MIDDLE 156 |
#define | INIT_SHIFT 62 |
#define | TWIST_MASK 0xb5026f5aa96619e9ULL |
#define | INIT_FACT 6364136223846793005ULL |
#define | SHIFT1 29 |
#define | MASK1 0x5555555555555555ULL |
#define | SHIFT2 17 |
#define | MASK2 0x71d67fffeda60000ULL |
#define | SHIFT3 37 |
#define | MASK3 0xfff7eee000000000ULL |
#define | SHIFT4 43 |
#define | LOWER_MASK 0x7fffffff |
#define | UPPER_MASK (~(UINT64)LOWER_MASK) |
Functions | |
STATIC VOID | SeedRng (IN UINT64 S) |
STATIC VOID | TwistRng (VOID) |
UINT64 | ReadSeed (VOID) |
STATIC BOOLEAN | Get64BitSeed (OUT UINT64 *Out) |
EFI_STATUS EFIAPI | BaseRngLibConstructor (VOID) |
BOOLEAN EFIAPI | ArchGetRandomNumber16 (OUT UINT16 *Rand) |
BOOLEAN EFIAPI | ArchGetRandomNumber32 (OUT UINT32 *Rand) |
BOOLEAN EFIAPI | ArchGetRandomNumber64 (OUT UINT64 *Rand) |
BOOLEAN EFIAPI | ArchIsRngSupported (VOID) |
Random number generator service that uses the SEED instruction to provide pseudorandom numbers.
Copyright (c) 2024, Rivos, Inc.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file Rng.c.
BOOLEAN EFIAPI ArchGetRandomNumber16 | ( | OUT UINT16 * | Rand | ) |
BOOLEAN EFIAPI ArchGetRandomNumber32 | ( | OUT UINT32 * | Rand | ) |
BOOLEAN EFIAPI ArchGetRandomNumber64 | ( | OUT UINT64 * | Rand | ) |
BOOLEAN EFIAPI ArchIsRngSupported | ( | VOID | ) |
EFI_STATUS EFIAPI BaseRngLibConstructor | ( | VOID | ) |
Gets seed value by executing trng instruction (CSR 0x15) amd returns the see to the caller 64bit value.
[out] | Out | Buffer pointer to store the 64-bit random value. |
TRUE | Random number generated successfully. |
FALSE | Failed to generate the random number. |
STATIC VOID TwistRng | ( | VOID | ) |
Initializes mState with entropy values. The initialization is based on the Seed value populated in mState[0] which then influences all the other values in the mState array. Later values are retrieved from the same array instead of calling trng instruction every time.