summaryrefslogtreecommitdiff
path: root/extra/yassl/taocrypt/src/random.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'extra/yassl/taocrypt/src/random.cpp')
-rw-r--r--extra/yassl/taocrypt/src/random.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/extra/yassl/taocrypt/src/random.cpp b/extra/yassl/taocrypt/src/random.cpp
index cf0720b11d8..945a7fa6ff7 100644
--- a/extra/yassl/taocrypt/src/random.cpp
+++ b/extra/yassl/taocrypt/src/random.cpp
@@ -26,6 +26,8 @@
#include "runtime.hpp"
#include "random.hpp"
+#include <string.h>
+
#if defined(_WIN32)
#define _WIN32_WINNT 0x0400
@@ -52,6 +54,7 @@ RandomNumberGenerator::RandomNumberGenerator()
// place a generated block in output
void RandomNumberGenerator::GenerateBlock(byte* output, word32 sz)
{
+ memset(output, 0, sz);
cipher_.Process(output, output, sz);
}
@@ -94,10 +97,9 @@ void OS_Seed::GenerateSeed(byte* output, word32 sz)
OS_Seed::OS_Seed()
{
fd_ = open("/dev/urandom",O_RDONLY);
+ if (fd_ == -1) {
+ fd_ = open("/dev/random",O_RDONLY);
if (fd_ == -1)
- {
- fd_ = open("/dev/random",O_RDONLY);
- if (fd_ == -1)
error_.SetError(OPEN_RAN_E);
}
}