]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SecurityPkg/RngDxe: Remove ArchGetSupportedRngAlgorithms()
authorPierre Gondois <Pierre.Gondois@arm.com>
Fri, 28 Oct 2022 15:32:52 +0000 (17:32 +0200)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sun, 6 Nov 2022 16:32:28 +0000 (16:32 +0000)
RngGetInfo() is one of the 2 functions of the EFI_RNG_PROTOCOL.
RngGetInfo() is currently a mere wrapper around
ArchGetSupportedRngAlgorithms() which is implemented differently
depending on the architecture used.

RngGetInfo() does nothing more than calling
ArchGetSupportedRngAlgorithms(). So remove it, and let RngGetInfo()
be implemented differently according to the architecture.

This follows the implementation of the other function of the
EFI_RNG_PROTOCOL, RngGetRNG().

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Acked-by: Jiewen Yao <jiewen.yao@intel.com>
SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/RngDxe.c
SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c
SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c
SecurityPkg/RandomNumberGenerator/RngDxe/RngDxeInternals.h

index 3daf847d46d357ac9ef2e10337da7ee6e7878787..6d989f7ea3765c4830961ed9b6f1bfaeaef64054 100644 (file)
@@ -14,6 +14,7 @@
   Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>\r
   Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
   (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
+  Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.<BR>\r
 \r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
@@ -85,6 +86,7 @@ RngGetRNG (
 /**\r
   Returns information about the random number generation implementation.\r
 \r
+  @param[in]     This                 A pointer to the EFI_RNG_PROTOCOL instance.\r
   @param[in,out] RNGAlgorithmListSize On input, the size in bytes of RNGAlgorithmList.\r
                                       On output with a return code of EFI_SUCCESS, the size\r
                                       in bytes of the data returned in RNGAlgorithmList. On output\r
@@ -97,14 +99,19 @@ RngGetRNG (
                                       is the default algorithm for the driver.\r
 \r
   @retval EFI_SUCCESS                 The RNG algorithm list was returned successfully.\r
+  @retval EFI_UNSUPPORTED             The services is not supported by this driver.\r
+  @retval EFI_DEVICE_ERROR            The list of algorithms could not be retrieved due to a\r
+                                      hardware or firmware error.\r
+  @retval EFI_INVALID_PARAMETER       One or more of the parameters are incorrect.\r
   @retval EFI_BUFFER_TOO_SMALL        The buffer RNGAlgorithmList is too small to hold the result.\r
 \r
 **/\r
-UINTN\r
+EFI_STATUS\r
 EFIAPI\r
-ArchGetSupportedRngAlgorithms (\r
-  IN OUT UINTN              *RNGAlgorithmListSize,\r
-  OUT    EFI_RNG_ALGORITHM  *RNGAlgorithmList\r
+RngGetInfo (\r
+  IN EFI_RNG_PROTOCOL    *This,\r
+  IN OUT UINTN           *RNGAlgorithmListSize,\r
+  OUT EFI_RNG_ALGORITHM  *RNGAlgorithmList\r
   )\r
 {\r
   UINTN              RequiredSize;\r
@@ -112,6 +119,10 @@ ArchGetSupportedRngAlgorithms (
 \r
   RequiredSize = sizeof (EFI_RNG_ALGORITHM);\r
 \r
+  if ((This == NULL) || (RNGAlgorithmListSize == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   if (*RNGAlgorithmListSize < RequiredSize) {\r
     *RNGAlgorithmListSize = RequiredSize;\r
     return EFI_BUFFER_TOO_SMALL;\r
index df7db12b771cd6ff2ffa59d7e14373a34bac4253..b2d2236380fd03954b9b4ed48d526d031d7abf76 100644 (file)
@@ -104,6 +104,7 @@ RngGetRNG (
 /**\r
   Returns information about the random number generation implementation.\r
 \r
+  @param[in]     This                 A pointer to the EFI_RNG_PROTOCOL instance.\r
   @param[in,out] RNGAlgorithmListSize On input, the size in bytes of RNGAlgorithmList.\r
                                       On output with a return code of EFI_SUCCESS, the size\r
                                       in bytes of the data returned in RNGAlgorithmList. On output\r
@@ -116,18 +117,27 @@ RngGetRNG (
                                       is the default algorithm for the driver.\r
 \r
   @retval EFI_SUCCESS                 The RNG algorithm list was returned successfully.\r
+  @retval EFI_UNSUPPORTED             No supported algorithms found.\r
+  @retval EFI_DEVICE_ERROR            The list of algorithms could not be retrieved due to a\r
+                                      hardware or firmware error.\r
+  @retval EFI_INVALID_PARAMETER       One or more of the parameters are incorrect.\r
   @retval EFI_BUFFER_TOO_SMALL        The buffer RNGAlgorithmList is too small to hold the result.\r
 \r
 **/\r
-UINTN\r
+EFI_STATUS\r
 EFIAPI\r
-ArchGetSupportedRngAlgorithms (\r
-  IN OUT UINTN              *RNGAlgorithmListSize,\r
-  OUT    EFI_RNG_ALGORITHM  *RNGAlgorithmList\r
+RngGetInfo (\r
+  IN EFI_RNG_PROTOCOL    *This,\r
+  IN OUT UINTN           *RNGAlgorithmListSize,\r
+  OUT EFI_RNG_ALGORITHM  *RNGAlgorithmList\r
   )\r
 {\r
   UINTN  RequiredSize;\r
 \r
+  if ((This == NULL) || (RNGAlgorithmListSize == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   RequiredSize = 2 * sizeof (EFI_RNG_ALGORITHM);\r
 \r
   if (*RNGAlgorithmListSize < RequiredSize) {\r
@@ -135,6 +145,10 @@ ArchGetSupportedRngAlgorithms (
     return EFI_BUFFER_TOO_SMALL;\r
   }\r
 \r
+  if (RNGAlgorithmList == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   CopyMem (&RNGAlgorithmList[0], &gEfiRngAlgorithmSp80090Ctr256Guid, sizeof (EFI_RNG_ALGORITHM));\r
 \r
   // x86 platforms also support EFI_RNG_ALGORITHM_RAW via RDSEED\r
index 6f52eeff4a09db6303cf9e7d918c9ac23b05a2b4..6608ca8804a5df89c37cfffe78b5b43114c04b2d 100644 (file)
@@ -28,55 +28,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 \r
 #include "RngDxeInternals.h"\r
 \r
-/**\r
-  Returns information about the random number generation implementation.\r
-\r
-  @param[in]     This                 A pointer to the EFI_RNG_PROTOCOL instance.\r
-  @param[in,out] RNGAlgorithmListSize On input, the size in bytes of RNGAlgorithmList.\r
-                                      On output with a return code of EFI_SUCCESS, the size\r
-                                      in bytes of the data returned in RNGAlgorithmList. On output\r
-                                      with a return code of EFI_BUFFER_TOO_SMALL,\r
-                                      the size of RNGAlgorithmList required to obtain the list.\r
-  @param[out] RNGAlgorithmList        A caller-allocated memory buffer filled by the driver\r
-                                      with one EFI_RNG_ALGORITHM element for each supported\r
-                                      RNG algorithm. The list must not change across multiple\r
-                                      calls to the same driver. The first algorithm in the list\r
-                                      is the default algorithm for the driver.\r
-\r
-  @retval EFI_SUCCESS                 The RNG algorithm list was returned successfully.\r
-  @retval EFI_UNSUPPORTED             The services is not supported by this driver.\r
-  @retval EFI_DEVICE_ERROR            The list of algorithms could not be retrieved due to a\r
-                                      hardware or firmware error.\r
-  @retval EFI_INVALID_PARAMETER       One or more of the parameters are incorrect.\r
-  @retval EFI_BUFFER_TOO_SMALL        The buffer RNGAlgorithmList is too small to hold the result.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-RngGetInfo (\r
-  IN EFI_RNG_PROTOCOL    *This,\r
-  IN OUT UINTN           *RNGAlgorithmListSize,\r
-  OUT EFI_RNG_ALGORITHM  *RNGAlgorithmList\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  if ((This == NULL) || (RNGAlgorithmListSize == NULL)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Return algorithm list supported by driver.\r
-  //\r
-  if (RNGAlgorithmList != NULL) {\r
-    Status = ArchGetSupportedRngAlgorithms (RNGAlgorithmListSize, RNGAlgorithmList);\r
-  } else {\r
-    Status = EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
 //\r
 // The Random Number Generator (RNG) protocol\r
 //\r
index 48d2d27c16080b2f4794788f3f1ec5687060934a..7ecab140483def8505b34dd2d8998441b8ade430 100644 (file)
@@ -74,31 +74,6 @@ RngGetRNG (
   OUT UINT8             *RNGValue\r
   );\r
 \r
-/**\r
-  Returns information about the random number generation implementation.\r
-\r
-  @param[in,out] RNGAlgorithmListSize On input, the size in bytes of RNGAlgorithmList.\r
-                                      On output with a return code of EFI_SUCCESS, the size\r
-                                      in bytes of the data returned in RNGAlgorithmList. On output\r
-                                      with a return code of EFI_BUFFER_TOO_SMALL,\r
-                                      the size of RNGAlgorithmList required to obtain the list.\r
-  @param[out] RNGAlgorithmList        A caller-allocated memory buffer filled by the driver\r
-                                      with one EFI_RNG_ALGORITHM element for each supported\r
-                                      RNG algorithm. The list must not change across multiple\r
-                                      calls to the same driver. The first algorithm in the list\r
-                                      is the default algorithm for the driver.\r
-\r
-  @retval EFI_SUCCESS                 The RNG algorithm list was returned successfully.\r
-  @retval EFI_BUFFER_TOO_SMALL        The buffer RNGAlgorithmList is too small to hold the result.\r
-\r
-**/\r
-UINTN\r
-EFIAPI\r
-ArchGetSupportedRngAlgorithms (\r
-  IN OUT UINTN              *RNGAlgorithmListSize,\r
-  OUT    EFI_RNG_ALGORITHM  *RNGAlgorithmList\r
-  );\r
-\r
 /**\r
   Runs CPU RNG instruction to fill a buffer of arbitrary size with random bytes.\r
 \r