Series Reviewed-by: Michael Kinney <michael.d.kin...@intel.com>
>-----Original Message----- >From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of >Thomas Palmer >Sent: Thursday, October 08, 2015 10:13 AM >To: edk2-devel@lists.01.org >Cc: Zhang, Chao B >Subject: [edk2] [PATCH 1/3] MdePkg: Create GetRandomNumber128 in RngLib > >Declare GetRandomNumber128 in RngLib.h. >Create GetRandomNumber128 in BaseRngLib, which is simply calling >GetRandomNumber64 twice > >A GetRandomNumber128 function allows platforms with 128bit HWRNGs to >save on IO overhead that comes from having to prime the HWRNG device >before each read operation. Using the HWRNG installed on the HP ProLiant >m400 moonshot cartridge, this will save about 50ms per RAW Entropy >operation as compared with calling GetRandomNumber64 twice. > >Contributed-under: TianoCore Contribution Agreement 1.0 >Signed-off-by: Thomas Palmer <thomas.pal...@hpe.com> >--- > MdePkg/Include/Library/RngLib.h | 17 +++++++++++++++++ > MdePkg/Library/BaseRngLib/BaseRng.c | 32 >++++++++++++++++++++++++++++++++ > 2 files changed, 49 insertions(+) > >diff --git a/MdePkg/Include/Library/RngLib.h >b/MdePkg/Include/Library/RngLib.h >index 157a931..ece4394 100644 >--- a/MdePkg/Include/Library/RngLib.h >+++ b/MdePkg/Include/Library/RngLib.h >@@ -66,4 +66,21 @@ GetRandomNumber64 ( > OUT UINT64 *Rand > ); > >+/** >+ 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 >+ ); >+ > #endif // __RNG_LIB_H__ >diff --git a/MdePkg/Library/BaseRngLib/BaseRng.c >b/MdePkg/Library/BaseRngLib/BaseRng.c >index 279df30..2c8df56 100644 >--- a/MdePkg/Library/BaseRngLib/BaseRng.c >+++ b/MdePkg/Library/BaseRngLib/BaseRng.c >@@ -155,3 +155,35 @@ GetRandomNumber64 ( > > 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 (Rand != NULL); >+ >+ // >+ // Read first 64 bits >+ // >+ if (!GetRandomNumber64 (Rand)) { >+ return FALSE; >+ } >+ >+ // >+ // Read second 64 bits >+ // >+ return GetRandomNumber64 (++Rand); >+} >-- >1.7.9.5 > >_______________________________________________ >edk2-devel mailing list >edk2-devel@lists.01.org >https://lists.01.org/mailman/listinfo/edk2-devel _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel