aboutsummaryrefslogtreecommitdiffstats
path: root/src/timers.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/timers.cpp')
-rw-r--r--src/timers.cpp24
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);
}