summaryrefslogtreecommitdiffstats
path: root/src/crypto/rand/rand.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/crypto/rand/rand.c')
-rw-r--r--src/crypto/rand/rand.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/crypto/rand/rand.c b/src/crypto/rand/rand.c
index a647b6a..a96ac48 100644
--- a/src/crypto/rand/rand.c
+++ b/src/crypto/rand/rand.c
@@ -78,7 +78,8 @@ int RAND_bytes(uint8_t *buf, size_t len) {
return 1;
}
- if (!CRYPTO_have_hwrand()) {
+ if (!CRYPTO_have_hwrand() ||
+ !CRYPTO_hwrand(buf, len)) {
/* Without a hardware RNG to save us from address-space duplication, the OS
* entropy is used directly. */
CRYPTO_sysrand(buf, len);
@@ -108,8 +109,6 @@ int RAND_bytes(uint8_t *buf, size_t len) {
state->partial_block_used = sizeof(state->partial_block);
}
- CRYPTO_hwrand(buf, len);
-
if (len >= sizeof(state->partial_block)) {
size_t remaining = len;
while (remaining > 0) {