diff options
author | lloyd <[email protected]> | 2008-04-07 01:41:17 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-04-07 01:41:17 +0000 |
commit | a48d895cf5e6874f4ae60c803bda17d62edb7a7b (patch) | |
tree | 2a9531c1ee40403b5a0ff218280bbbe6c9cb2db9 /src/timers.cpp | |
parent | d4121aee5eeab8328bb6a59ba0c2f16e2d3a72fa (diff) |
In Botan, the Timer base class provides access to a high-resolution
timer with an unspecified update rate and epoch. It is only used
inside the entropy sources to provide some timing-dependent
randomness. However, it is easier and basically 'as good' to treat the
timers as entropy sources in their own right and feed their output
directly into an entropy pool.
This commit removes Library_State::system_clock and all calls to that
function.
Diffstat (limited to 'src/timers.cpp')
-rw-r--r-- | src/timers.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/timers.cpp b/src/timers.cpp index da02e46c6..559d77843 100644 --- a/src/timers.cpp +++ b/src/timers.cpp @@ -4,24 +4,19 @@ *************************************************/ #include <botan/timers.h> -#include <botan/libstate.h> +#include <botan/loadstor.h> #include <ctime> namespace Botan { /************************************************* -* Timer Access Functions * +* Get the system clock * *************************************************/ u64bit system_time() { return static_cast<u64bit>(std::time(0)); } -u64bit system_clock() - { - return global_state().system_clock(); - } - /************************************************* * Default Timer clock reading * *************************************************/ @@ -31,11 +26,24 @@ u64bit Timer::clock() const } /************************************************* +* Read the clock and return the output * +*************************************************/ +u32bit Timer::slow_poll(byte out[], u32bit length) + { + const u64bit clock_value = this->clock(); + + for(u32bit j = 0; j != sizeof(clock_value); ++j) + out[j % length] ^= get_byte(j, clock_value); + + return (length < 8) ? length : 8; + } + +/************************************************* * Combine a two time values into a single one * *************************************************/ u64bit Timer::combine_timers(u32bit seconds, u32bit parts, u32bit parts_hz) { - const u64bit NANOSECONDS_UNITS = 1000000000; + static const u64bit NANOSECONDS_UNITS = 1000000000; parts *= (NANOSECONDS_UNITS / parts_hz); return ((seconds * NANOSECONDS_UNITS) + parts); } |