diff options
author | lloyd <[email protected]> | 2013-04-19 16:00:40 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2013-04-19 16:00:40 +0000 |
commit | a28ddc43bbb8445df5345007fed1782f13d38503 (patch) | |
tree | b06d3d0eafe1296b711ff4a7b0a7a0b101f55ca1 | |
parent | 94e8fa0af180b42661cfde352e57bad2f71e11ac (diff) |
Add a constant to make it more obvious that the clock polling
is not considered as contributing entropy to a rng poll.
-rw-r--r-- | src/entropy/entropy_src.h | 2 | ||||
-rw-r--r-- | src/entropy/hres_timer/hres_timer.cpp | 18 |
2 files changed, 11 insertions, 9 deletions
diff --git a/src/entropy/entropy_src.h b/src/entropy/entropy_src.h index e130574f4..6d70207e1 100644 --- a/src/entropy/entropy_src.h +++ b/src/entropy/entropy_src.h @@ -117,7 +117,7 @@ class BOTAN_DLL Entropy_Accumulator_BufferedComputation : }; /** -* Abstract interface to a source of (hopefully unpredictable) system entropy +* Abstract interface to a source of entropy */ class BOTAN_DLL EntropySource { diff --git a/src/entropy/hres_timer/hres_timer.cpp b/src/entropy/hres_timer/hres_timer.cpp index c6b31d996..c7a8404cf 100644 --- a/src/entropy/hres_timer/hres_timer.cpp +++ b/src/entropy/hres_timer/hres_timer.cpp @@ -19,21 +19,24 @@ namespace Botan { */ void High_Resolution_Timestamp::poll(Entropy_Accumulator& accum) { + // Don't count the timestamp as contributing any entropy + const double ESTIMATED_ENTROPY_PER_BYTE = 0.0; + #if defined(BOTAN_TARGET_OS_HAS_QUERY_PERF_COUNTER) { LARGE_INTEGER tv; ::QueryPerformanceCounter(&tv); - accum.add(tv.QuadPart, 0); + accum.add(tv.QuadPart, ESTIMATED_ENTROPY_PER_BYTE); } #endif #if defined(BOTAN_TARGET_OS_HAS_CLOCK_GETTIME) -#define CLOCK_POLL(src) \ - do { \ - struct timespec ts; \ - clock_gettime(src, &ts); \ - accum.add(&ts, sizeof(ts), 0); \ +#define CLOCK_POLL(src) \ + do { \ + struct timespec ts; \ + ::clock_gettime(src, &ts); \ + accum.add(&ts, sizeof(ts), ESTIMATED_ENTROPY_PER_BYTE); \ } while(0) #if defined(CLOCK_REALTIME) @@ -94,8 +97,7 @@ void High_Resolution_Timestamp::poll(Entropy_Accumulator& accum) #endif - // Don't count the timestamp as contributing entropy - accum.add(rtc, 0); + accum.add(rtc, ESTIMATED_ENTROPY_PER_BYTE); #endif } |