Hi, Gary,

The update looks good for me.
One extra comment for the statement of type casting. It's not one common 
expression in EDKII using "!!" to cast an integer to Boolean. I prefer to 
change it like below, for better style consistence.
        If (RAND_status() == 1) {
     return TRUE;
    }
    return FALSE;


Best Regards & Thanks,
LONG, Qin

-----Original Message-----
From: Gary Ching-Pang Lin [mailto:g...@suse.com] 
Sent: Tuesday, May 28, 2013 5:31 PM
To: edk2-devel@lists.sourceforge.net
Subject: [edk2] [PATCH v2] 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    | 2 +-
 CryptoPkg/Library/BaseCryptLib/Rand/CryptRandItc.c | 2 +-  
CryptoPkg/Library/BaseCryptLib/Rand/CryptRandTsc.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/CryptoPkg/Library/BaseCryptLib/Rand/CryptRand.c 
b/CryptoPkg/Library/BaseCryptLib/Rand/CryptRand.c
index 4a056e8..81d1a29 100644
--- a/CryptoPkg/Library/BaseCryptLib/Rand/CryptRand.c
+++ b/CryptoPkg/Library/BaseCryptLib/Rand/CryptRand.c
@@ -57,7 +57,7 @@ RandomSeed (
     RAND_seed (DefaultSeed, sizeof (DefaultSeed));
   }
 
-  return TRUE;
+  return !!RAND_status();
 }
 
 /**
diff --git a/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandItc.c 
b/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandItc.c
index dcc1853..a8a6b51 100644
--- a/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandItc.c
+++ b/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandItc.c
@@ -65,7 +65,7 @@ RandomSeed (
     RAND_seed (DefaultSeed, sizeof (DefaultSeed));
   }
 
-  return TRUE;
+  return !!RAND_status();
 }
 
 /**
diff --git a/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandTsc.c 
b/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandTsc.c
index 7259ed5..c75726d 100644
--- a/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandTsc.c
+++ b/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandTsc.c
@@ -65,7 +65,7 @@ RandomSeed (
     RAND_seed (DefaultSeed, sizeof (DefaultSeed));
   }
 
-  return TRUE;
+  return !!RAND_status();
 }
 
 /**
--
1.8.1.4


------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
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