The patch is good. Thanks.
And we helped to commit this change into EDKII project at r14392. 

Best Regards & Thanks,
LONG, Qin

-----Original Message-----
From: Gary Ching-Pang Lin [mailto:g...@suse.com] 
Sent: Wednesday, May 29, 2013 11:47 AM
To: edk2-devel@lists.sourceforge.net
Subject: [edk2] [PATCH v3] CryptoPkg/Rand: Return the status of random number 
generator

Though the comment of RandomSeed() states it should return FALSE if there is 
not enough entropy for random generation, the function always returns TRUE. 
This commit checks the status of pseudorandom number generator to match the 
comment.

Contributed-under: TianoCore Contribution Agreement 1.0

Signed-off-by: Gary Ching-Pang Lin <g...@suse.com>
---
 CryptoPkg/Library/BaseCryptLib/Rand/CryptRand.c    | 5 ++++-
 CryptoPkg/Library/BaseCryptLib/Rand/CryptRandItc.c | 5 ++++-  
CryptoPkg/Library/BaseCryptLib/Rand/CryptRandTsc.c | 5 ++++-
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/CryptoPkg/Library/BaseCryptLib/Rand/CryptRand.c 
b/CryptoPkg/Library/BaseCryptLib/Rand/CryptRand.c
index 4a056e8..02558ed 100644
--- a/CryptoPkg/Library/BaseCryptLib/Rand/CryptRand.c
+++ b/CryptoPkg/Library/BaseCryptLib/Rand/CryptRand.c
@@ -57,7 +57,10 @@ RandomSeed (
     RAND_seed (DefaultSeed, sizeof (DefaultSeed));
   }
 
-  return TRUE;
+  if (RAND_status() == 1) {
+    return TRUE;
+  }
+  return FALSE;
 }
 
 /**
diff --git a/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandItc.c 
b/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandItc.c
index dcc1853..29ca85a 100644
--- a/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandItc.c
+++ b/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandItc.c
@@ -65,7 +65,10 @@ RandomSeed (
     RAND_seed (DefaultSeed, sizeof (DefaultSeed));
   }
 
-  return TRUE;
+  if (RAND_status() == 1) {
+    return TRUE;
+  }
+  return FALSE;
 }
 
 /**
diff --git a/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandTsc.c 
b/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandTsc.c
index 7259ed5..0fa859d 100644
--- a/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandTsc.c
+++ b/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandTsc.c
@@ -65,7 +65,10 @@ RandomSeed (
     RAND_seed (DefaultSeed, sizeof (DefaultSeed));
   }
 
-  return TRUE;
+  if (RAND_status() == 1) {
+    return TRUE;
+  }
+  return FALSE;
 }
 
 /**
--
1.8.1.4


------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to