summaryrefslogtreecommitdiff
path: root/random
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2015-12-27 12:39:45 +0100
committerWerner Koch <wk@gnupg.org>2015-12-27 20:24:57 +0100
commit5a78e7f15e0dd96a8bf64e2bb142880bf8ea6965 (patch)
treeaea1a16c43ffbe95e69b8bcb605722228a2756e8 /random
parenta5a87d2b8627314593b06d19018484a7f7701227 (diff)
downloadlibgcrypt-5a78e7f15e0dd96a8bf64e2bb142880bf8ea6965.tar.gz
random: Take at max 25% from RDRAND
* random/rndlinux.c (_gcry_rndlinux_gather_random): Change use of RDRAND from 50% to 25%. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'random')
-rw-r--r--random/rndlinux.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/random/rndlinux.c b/random/rndlinux.c
index 9eeec574..0cb65dfd 100644
--- a/random/rndlinux.c
+++ b/random/rndlinux.c
@@ -139,10 +139,18 @@ _gcry_rndlinux_gather_random (void (*add)(const void*, size_t,
/* First read from a hardware source. However let it account only
- for up to 50% of the requested bytes. */
+ for up to 50% (or 25% for RDRAND) of the requested bytes. */
n_hw = _gcry_rndhw_poll_slow (add, origin);
- if (n_hw > length/2)
- n_hw = length/2;
+ if ((_gcry_get_hw_features () & HWF_INTEL_RDRAND))
+ {
+ if (n_hw > length/4)
+ n_hw = length/4;
+ }
+ else
+ {
+ if (n_hw > length/2)
+ n_hw = length/2;
+ }
if (length > 1)
length -= n_hw;