summaryrefslogtreecommitdiff
path: root/MdePkg/Include/Library/RngLib.h
diff options
context:
space:
mode:
authorQin Long <qin.long@intel.com>2015-09-21 05:54:03 +0000
committerqlong <qlong@Edk2>2015-09-21 05:54:03 +0000
commit255c8e22a5171fc52d0e7c297b2267e83d48bd5c (patch)
treed3fe32e1e20795928918c867d5688ffd5c4d7e25 /MdePkg/Include/Library/RngLib.h
parent3cfc7813bb7e904c4a940d638facc10be5e22645 (diff)
downloadedk2-platforms-255c8e22a5171fc52d0e7c297b2267e83d48bd5c.tar.xz
MdePkg: Add RngLib into MdePkg
Add one library class (RngLib.h) with three GetRandomNumber16/32/64 APIs to provide random number generator services, and one library instance (BaseRngLib), based on Intel RdRand instruction access, to provide high-quality random numbers generator. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qin Long <qin.long@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18519 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg/Include/Library/RngLib.h')
-rw-r--r--MdePkg/Include/Library/RngLib.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/MdePkg/Include/Library/RngLib.h b/MdePkg/Include/Library/RngLib.h
new file mode 100644
index 0000000000..157a93139c
--- /dev/null
+++ b/MdePkg/Include/Library/RngLib.h
@@ -0,0 +1,69 @@
+/** @file
+ Provides random number generator services.
+
+Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef __RNG_LIB_H__
+#define __RNG_LIB_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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+#endif // __RNG_LIB_H__