SecurityPkg/RngDxe: Check before advertising Cpu Rng algo
RngGetBytes() relies on the RngLib. The RngLib might use the RNDR instruction if the FEAT_RNG feature is present. RngGetInfo and RngGetRNG both must check that RngGetBytes() is working before advertising/using it. To do so, allocate an array storing the available algorithms. The Rng algorithm at the lowest index will be the default Rng algorithm. The array is shared between RngGetInfo and RngGetRNG. This array is allocated when the driver is loaded, and freed when unloaded. This patch also prevents from having PcdCpuRngSupportedAlgorithm let to a zero GUID, but let the possibility to have no valid Rng algorithm in such case. Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com> Acked-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
committed by
mergify[bot]
parent
199031b2b0
commit
4b3e9d80be
@@ -27,6 +27,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "RngDxeInternals.h"
|
||||
|
||||
//
|
||||
// Array containing the validated Rng algorithm.
|
||||
// The entry with the lowest index will be the default algorithm.
|
||||
//
|
||||
UINTN mAvailableAlgoArrayCount;
|
||||
EFI_RNG_ALGORITHM *mAvailableAlgoArray;
|
||||
|
||||
//
|
||||
// The Random Number Generator (RNG) protocol
|
||||
//
|
||||
@@ -66,8 +73,39 @@ RngDriverEntry (
|
||||
&mRngRdRand,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
return Status;
|
||||
//
|
||||
// Get the list of available algorithm.
|
||||
//
|
||||
return GetAvailableAlgorithms ();
|
||||
}
|
||||
|
||||
/**
|
||||
This is the unload handle for RndgDxe module.
|
||||
|
||||
Disconnect the driver specified by ImageHandle from all the devices in the handle database.
|
||||
Uninstall all the protocols installed in the driver entry point.
|
||||
|
||||
@param[in] ImageHandle The drivers' driver image.
|
||||
|
||||
@retval EFI_SUCCESS The image is unloaded.
|
||||
@retval Others Failed to unload the image.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
RngDriverUnLoad (
|
||||
IN EFI_HANDLE ImageHandle
|
||||
)
|
||||
{
|
||||
//
|
||||
// Free the list of available algorithm.
|
||||
//
|
||||
FreeAvailableAlgorithms ();
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user