This is null version of RngLib which is used for those platforms or
components which don't need random number.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1871
Cc: Jiewen Yao <[email protected]>
Cc: Chao Zhang <[email protected]>
Cc: Michael D Kinney <[email protected]>
Cc: Liming Gao <[email protected]>
Cc: Laszlo Ersek <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Ray Ni <[email protected]>
Signed-off-by: Jian J Wang <[email protected]>
---
 .../RngLibNull/RngLibNull.c                   | 95 +++++++++++++++++++
 .../RngLibNull/RngLibNull.inf                 | 31 ++++++
 .../RngLibNull/RngLibNull.uni                 | 14 +++
 3 files changed, 140 insertions(+)
 create mode 100644 SecurityPkg/RandomNumberGenerator/RngLibNull/RngLibNull.c
 create mode 100644 SecurityPkg/RandomNumberGenerator/RngLibNull/RngLibNull.inf
 create mode 100644 SecurityPkg/RandomNumberGenerator/RngLibNull/RngLibNull.uni

diff --git a/SecurityPkg/RandomNumberGenerator/RngLibNull/RngLibNull.c 
b/SecurityPkg/RandomNumberGenerator/RngLibNull/RngLibNull.c
new file mode 100644
index 0000000000..13677abc84
--- /dev/null
+++ b/SecurityPkg/RandomNumberGenerator/RngLibNull/RngLibNull.c
@@ -0,0 +1,95 @@
+/** @file
+  Null version of Random number generator services.
+
+Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/RngLib.h>
+
+/**
+  Generates a 16-bit random number.
+
+  if Rand is NULL, then ASSERT().
+
+  @param[out] Rand     Buffer pointer to store the 16-bit random value.
+
+  @retval TRUE         Random number generated successfully.
+  @retval FALSE        Failed to generate the random number.
+
+**/
+BOOLEAN
+EFIAPI
+GetRandomNumber16 (
+  OUT     UINT16                    *Rand
+  )
+{
+  ASSERT (FALSE);
+  return FALSE;
+}
+
+/**
+  Generates a 32-bit random number.
+
+  if Rand is NULL, then ASSERT().
+
+  @param[out] Rand     Buffer pointer to store the 32-bit random value.
+
+  @retval TRUE         Random number generated successfully.
+  @retval FALSE        Failed to generate the random number.
+
+**/
+BOOLEAN
+EFIAPI
+GetRandomNumber32 (
+  OUT     UINT32                    *Rand
+  )
+{
+  ASSERT (FALSE);
+  return FALSE;
+}
+
+/**
+  Generates a 64-bit random number.
+
+  if Rand is NULL, then ASSERT().
+
+  @param[out] Rand     Buffer pointer to store the 64-bit random value.
+
+  @retval TRUE         Random number generated successfully.
+  @retval FALSE        Failed to generate the random number.
+
+**/
+BOOLEAN
+EFIAPI
+GetRandomNumber64 (
+  OUT     UINT64                    *Rand
+  )
+{
+  ASSERT (FALSE);
+  return FALSE;
+}
+
+/**
+  Generates a 128-bit random number.
+
+  if Rand is NULL, then ASSERT().
+
+  @param[out] Rand     Buffer pointer to store the 128-bit random value.
+
+  @retval TRUE         Random number generated successfully.
+  @retval FALSE        Failed to generate the random number.
+
+**/
+BOOLEAN
+EFIAPI
+GetRandomNumber128 (
+  OUT     UINT64                    *Rand
+  )
+{
+  ASSERT (FALSE);
+  return FALSE;
+}
diff --git a/SecurityPkg/RandomNumberGenerator/RngLibNull/RngLibNull.inf 
b/SecurityPkg/RandomNumberGenerator/RngLibNull/RngLibNull.inf
new file mode 100644
index 0000000000..f6494cdb82
--- /dev/null
+++ b/SecurityPkg/RandomNumberGenerator/RngLibNull/RngLibNull.inf
@@ -0,0 +1,31 @@
+## @file
+#  Null instance of RNG (Random Number Generator) Library.
+#
+#  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = RngLibNull
+  MODULE_UNI_FILE                = RngLibNull.uni
+  FILE_GUID                      = CD8991F8-2061-4084-8C9E-9C6F352DC58D
+  MODULE_TYPE                    = BASE
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = RngLib
+
+#
+#  VALID_ARCHITECTURES           = IA32 X64 ARM AARCH64
+#
+
+[Sources]
+  RngLibNull.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  BaseLib
+  DebugLib
diff --git a/SecurityPkg/RandomNumberGenerator/RngLibNull/RngLibNull.uni 
b/SecurityPkg/RandomNumberGenerator/RngLibNull/RngLibNull.uni
new file mode 100644
index 0000000000..40b2ec3fe1
--- /dev/null
+++ b/SecurityPkg/RandomNumberGenerator/RngLibNull/RngLibNull.uni
@@ -0,0 +1,14 @@
+// /** @file
+// Null Instance of RNG (Random Number Generator) Library.
+//
+// Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+//
+// SPDX-License-Identifier: BSD-2-Clause-Patent
+//
+// **/
+
+
+#string STR_MODULE_ABSTRACT             #language en-US "Null Instance of RNG 
Library"
+
+#string STR_MODULE_DESCRIPTION          #language en-US "Caution: This is a 
null version of RNG library and SHOULD NOT be used on any product ever."
+
-- 
2.17.1.windows.2


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#50432): https://edk2.groups.io/g/devel/message/50432
Mute This Topic: https://groups.io/mt/54019525/21656
Group Owner: [email protected]
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to