summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortye1 <tye1@6f19259b-4bc3-4df7-8a09-765794883524>2013-05-29 05:30:13 +0000
committertye1 <tye1@6f19259b-4bc3-4df7-8a09-765794883524>2013-05-29 05:30:13 +0000
commitb3a18a1a1770316bfabbc29a44586db24c8c9076 (patch)
tree7832680d61b7ea5c10f4379d940b30457808b4b4
parente8dc04b7433a6d61311ca07be848dcda78395f3f (diff)
downloadedk2-platforms-b3a18a1a1770316bfabbc29a44586db24c8c9076.tar.xz
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 <glin@suse.com> Reviewed-by: Long Qin <qin.long@intel.com> Reviewed-by: Ye Ting <ting.ye@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14392 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--CryptoPkg/Library/BaseCryptLib/Rand/CryptRand.c6
-rw-r--r--CryptoPkg/Library/BaseCryptLib/Rand/CryptRandItc.c6
-rw-r--r--CryptoPkg/Library/BaseCryptLib/Rand/CryptRandTsc.c6
3 files changed, 15 insertions, 3 deletions
diff --git a/CryptoPkg/Library/BaseCryptLib/Rand/CryptRand.c b/CryptoPkg/Library/BaseCryptLib/Rand/CryptRand.c
index 4a056e89d8..dc3ab992d0 100644
--- a/CryptoPkg/Library/BaseCryptLib/Rand/CryptRand.c
+++ b/CryptoPkg/Library/BaseCryptLib/Rand/CryptRand.c
@@ -57,7 +57,11 @@ 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 dcc1853f13..0f27f253d2 100644
--- a/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandItc.c
+++ b/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandItc.c
@@ -65,7 +65,11 @@ 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 7259ed50da..dbdd6383a4 100644
--- a/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandTsc.c
+++ b/CryptoPkg/Library/BaseCryptLib/Rand/CryptRandTsc.c
@@ -65,7 +65,11 @@ RandomSeed (
RAND_seed (DefaultSeed, sizeof (DefaultSeed));
}
- return TRUE;
+ if (RAND_status () == 1) {
+ return TRUE;
+ }
+
+ return FALSE;
}
/**