summaryrefslogtreecommitdiffstats
path: root/MdePkg/Library/BaseRngLib/AArch64/Rndr.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdePkg/Library/BaseRngLib/AArch64/Rndr.c')
-rw-r--r--MdePkg/Library/BaseRngLib/AArch64/Rndr.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/MdePkg/Library/BaseRngLib/AArch64/Rndr.c b/MdePkg/Library/BaseRngLib/AArch64/Rndr.c
index 20811bf3eb..d39db62153 100644
--- a/MdePkg/Library/BaseRngLib/AArch64/Rndr.c
+++ b/MdePkg/Library/BaseRngLib/AArch64/Rndr.c
@@ -2,6 +2,7 @@
Random number generator service that uses the RNDR instruction
to provide pseudorandom numbers.
+ Copyright (c) 2023, Arm Limited. All rights reserved.<BR>
Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
@@ -11,6 +12,7 @@
#include <Uefi.h>
#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/RngLib.h>
@@ -138,3 +140,43 @@ ArchIsRngSupported (
{
return mRndrSupported;
}
+
+/**
+ Get a GUID identifying the RNG algorithm implementation.
+
+ @param [out] RngGuid If success, contains the GUID identifying
+ the RNG algorithm implementation.
+
+ @retval EFI_SUCCESS Success.
+ @retval EFI_UNSUPPORTED Not supported.
+ @retval EFI_INVALID_PARAMETER Invalid parameter.
+**/
+EFI_STATUS
+EFIAPI
+GetRngGuid (
+ GUID *RngGuid
+ )
+{
+ GUID *RngLibGuid;
+
+ if (RngGuid == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (!mRndrSupported) {
+ return EFI_UNSUPPORTED;
+ }
+
+ //
+ // If the platform advertises the algorithm behind RNDR instruction,
+ // use it. Otherwise use gEfiRngAlgorithmArmRndr.
+ //
+ RngLibGuid = PcdGetPtr (PcdCpuRngSupportedAlgorithm);
+ if (!IsZeroGuid (RngLibGuid)) {
+ CopyMem (RngGuid, RngLibGuid, sizeof (*RngGuid));
+ } else {
+ CopyMem (RngGuid, &gEfiRngAlgorithmArmRndr, sizeof (*RngGuid));
+ }
+
+ return EFI_SUCCESS;
+}