TianoCore EDK2 master
Loading...
Searching...
No Matches
CryptRand.c File Reference
#include "InternalCryptLib.h"
#include <Library/RngLib.h>

Go to the source code of this file.

Functions

BOOLEAN EFIAPI RandomSeed (IN CONST UINT8 *Seed OPTIONAL, IN UINTN SeedSize)
 
BOOLEAN EFIAPI RandomBytes (OUT UINT8 *Output, IN UINTN Size)
 
INT32 MbedtlsRand (VOID *RngState, UINT8 *Output, UINTN Len)
 

Detailed Description

Pseudorandom Number Generator Wrapper Implementation over MbedTLS.

Copyright (c) 2024, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file CryptRand.c.

Function Documentation

◆ MbedtlsRand()

INT32 MbedtlsRand ( VOID *  RngState,
UINT8 *  Output,
UINTN  Len 
)

The MbedTLS function f_rng, which MbedtlsRand implements.

Parameters
[in]RngStateNot used, just for compatibility with mbedtls.
[out]OutputPointer to buffer to receive random value.
[in]LenSize of random bytes to generate.
Return values
0Pseudorandom byte stream generated successfully.
Non-0Pseudorandom number generator fails to generate due to lack of entropy.

Definition at line 103 of file CryptRand.c.

◆ RandomBytes()

BOOLEAN EFIAPI RandomBytes ( OUT UINT8 *  Output,
IN UINTN  Size 
)

Generates a pseudorandom byte stream of the specified size.

If Output is NULL, then return FALSE.

Parameters
[out]OutputPointer to buffer to receive random value.
[in]SizeSize of random bytes to generate.
Return values
TRUEPseudorandom byte stream generated successfully.
FALSEPseudorandom number generator fails to generate due to lack of entropy.

Definition at line 52 of file CryptRand.c.

◆ RandomSeed()

BOOLEAN EFIAPI RandomSeed ( IN CONST UINT8 *Seed  OPTIONAL,
IN UINTN  SeedSize 
)

Sets up the seed value for the pseudorandom number generator.

This function sets up the seed value for the pseudorandom number generator. If Seed is not NULL, then the seed passed in is used. If Seed is NULL, then default seed is used.

Parameters
[in]SeedPointer to seed value. If NULL, default seed is used.
[in]SeedSizeSize of seed value. If Seed is NULL, this parameter is ignored.
Return values
TRUEPseudorandom number generator has enough entropy for random generation.
FALSEPseudorandom number generator does not have enough entropy for random generation.

Definition at line 30 of file CryptRand.c.