aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/asn1/asn1_tm.cpp2
-rw-r--r--src/cert/cvc/asn1_eac_tm.cpp2
-rw-r--r--src/cert/cvc/cvc_self.cpp2
-rw-r--r--src/cert/x509/crl_ent.cpp2
-rw-r--r--src/cert/x509/x509_ca.cpp2
-rw-r--r--src/cert/x509/x509opt.cpp2
-rw-r--r--src/cert/x509/x509stor.cpp2
-rw-r--r--src/rng/auto_rng/info.txt1
-rw-r--r--src/timer/cpu_counter/info.txt36
-rw-r--r--src/timer/cpu_counter/tm_hard.cpp51
-rw-r--r--src/timer/cpu_counter/tm_hard.h33
-rw-r--r--src/timer/gettimeofday/info.txt33
-rw-r--r--src/timer/gettimeofday/tm_unix.cpp23
-rw-r--r--src/timer/gettimeofday/tm_unix.h27
-rw-r--r--src/timer/info.txt14
-rw-r--r--src/timer/posix_rt/info.txt29
-rw-r--r--src/timer/posix_rt/tm_posix.cpp32
-rw-r--r--src/timer/posix_rt/tm_posix.h27
-rw-r--r--src/timer/timer.cpp64
-rw-r--r--src/timer/timer.h53
-rw-r--r--src/timer/win32_query_perf_ctr/info.txt26
-rw-r--r--src/timer/win32_query_perf_ctr/tm_win32.cpp23
-rw-r--r--src/timer/win32_query_perf_ctr/tm_win32.h27
-rw-r--r--src/utils/time.h39
24 files changed, 46 insertions, 506 deletions
diff --git a/src/asn1/asn1_tm.cpp b/src/asn1/asn1_tm.cpp
index 09bc4d347..c57d1bc73 100644
--- a/src/asn1/asn1_tm.cpp
+++ b/src/asn1/asn1_tm.cpp
@@ -10,7 +10,7 @@
#include <botan/ber_dec.h>
#include <botan/charset.h>
#include <botan/parsing.h>
-#include <botan/timer.h>
+#include <botan/time.h>
namespace Botan {
diff --git a/src/cert/cvc/asn1_eac_tm.cpp b/src/cert/cvc/asn1_eac_tm.cpp
index 947b9e66d..f361e6098 100644
--- a/src/cert/cvc/asn1_eac_tm.cpp
+++ b/src/cert/cvc/asn1_eac_tm.cpp
@@ -12,7 +12,7 @@
#include <botan/charset.h>
#include <botan/parsing.h>
#include <botan/rounding.h>
-#include <botan/timer.h>
+#include <botan/time.h>
namespace Botan {
diff --git a/src/cert/cvc/cvc_self.cpp b/src/cert/cvc/cvc_self.cpp
index 46bf145fc..98d90d0af 100644
--- a/src/cert/cvc/cvc_self.cpp
+++ b/src/cert/cvc/cvc_self.cpp
@@ -14,7 +14,7 @@
#include <botan/look_pk.h>
#include <botan/cvc_req.h>
#include <botan/cvc_ado.h>
-#include <botan/timer.h>
+#include <botan/time.h>
#include <sstream>
namespace Botan {
diff --git a/src/cert/x509/crl_ent.cpp b/src/cert/x509/crl_ent.cpp
index a8a989c24..42a742ebb 100644
--- a/src/cert/x509/crl_ent.cpp
+++ b/src/cert/x509/crl_ent.cpp
@@ -11,7 +11,7 @@
#include <botan/ber_dec.h>
#include <botan/bigint.h>
#include <botan/oids.h>
-#include <botan/timer.h>
+#include <botan/time.h>
namespace Botan {
diff --git a/src/cert/x509/x509_ca.cpp b/src/cert/x509/x509_ca.cpp
index c3ab2a739..4c4748065 100644
--- a/src/cert/x509/x509_ca.cpp
+++ b/src/cert/x509/x509_ca.cpp
@@ -13,7 +13,7 @@
#include <botan/bigint.h>
#include <botan/parsing.h>
#include <botan/oids.h>
-#include <botan/timer.h>
+#include <botan/time.h>
#include <algorithm>
#include <typeinfo>
#include <iterator>
diff --git a/src/cert/x509/x509opt.cpp b/src/cert/x509/x509opt.cpp
index 03bcd20f4..c6421d9ca 100644
--- a/src/cert/x509/x509opt.cpp
+++ b/src/cert/x509/x509opt.cpp
@@ -8,7 +8,7 @@
#include <botan/x509self.h>
#include <botan/oids.h>
#include <botan/parsing.h>
-#include <botan/timer.h>
+#include <botan/time.h>
namespace Botan {
diff --git a/src/cert/x509/x509stor.cpp b/src/cert/x509/x509stor.cpp
index 9c6dced25..515215a21 100644
--- a/src/cert/x509/x509stor.cpp
+++ b/src/cert/x509/x509stor.cpp
@@ -10,7 +10,7 @@
#include <botan/pubkey.h>
#include <botan/look_pk.h>
#include <botan/oids.h>
-#include <botan/timer.h>
+#include <botan/time.h>
#include <algorithm>
#include <memory>
diff --git a/src/rng/auto_rng/info.txt b/src/rng/auto_rng/info.txt
index 7d5d5ddcc..3c83bfb5e 100644
--- a/src/rng/auto_rng/info.txt
+++ b/src/rng/auto_rng/info.txt
@@ -12,5 +12,4 @@ auto_rng.cpp
<requires>
hmac
sha2
-timer
</requires>
diff --git a/src/timer/cpu_counter/info.txt b/src/timer/cpu_counter/info.txt
deleted file mode 100644
index 025663a84..000000000
--- a/src/timer/cpu_counter/info.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-realname "Hardware Timer"
-
-define TIMER_HARDWARE
-
-load_on asm_ok
-
-<add>
-tm_hard.cpp
-tm_hard.h
-</add>
-
-<cc>
-gcc
-</cc>
-
-<arch>
-# RDTSC: Pentium and up
-i586
-i686
-athlon
-pentium4
-pentium-m
-amd64
-
-ppc # PPC timebase register
-ppc64 # PPC timebase register
-alpha # rpcc
-sparc64 # %tick register
-ia64 # ar.itc
-s390x
-hppa
-</arch>
-
-<requires>
-timer
-</requires>
diff --git a/src/timer/cpu_counter/tm_hard.cpp b/src/timer/cpu_counter/tm_hard.cpp
deleted file mode 100644
index 9e31aee39..000000000
--- a/src/timer/cpu_counter/tm_hard.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
-* Hardware Timer
-* (C) 1999-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#include <botan/tm_hard.h>
-
-namespace Botan {
-
-/*
-* Get the timestamp
-*/
-u64bit Hardware_Timer::clock() const
- {
- u64bit rtc = 0;
-
-#if defined(BOTAN_TARGET_ARCH_IS_IA32) || defined(BOTAN_TARGET_ARCH_IS_AMD64)
- u32bit rtc_low = 0, rtc_high = 0;
- asm volatile("rdtsc" : "=d" (rtc_high), "=a" (rtc_low));
- rtc = (static_cast<u64bit>(rtc_high) << 32) | rtc_low;
-
-#elif defined(BOTAN_TARGET_ARCH_IS_PPC) || defined(BOTAN_TARGET_ARCH_IS_PPC64)
- u32bit rtc_low = 0, rtc_high = 0;
- asm volatile("mftbu %0; mftb %1" : "=r" (rtc_high), "=r" (rtc_low));
- rtc = (static_cast<u64bit>(rtc_high) << 32) | rtc_low;
-
-#elif defined(BOTAN_TARGET_ARCH_IS_ALPHA)
- asm volatile("rpcc %0" : "=r" (rtc));
-
-#elif defined(BOTAN_TARGET_ARCH_IS_SPARC64)
- asm volatile("rd %%tick, %0" : "=r" (rtc));
-
-#elif defined(BOTAN_TARGET_ARCH_IS_IA64)
- asm volatile("mov %0=ar.itc" : "=r" (rtc));
-
-#elif defined(BOTAN_TARGET_ARCH_IS_S390X)
- asm volatile("stck 0(%0)" : : "a" (&rtc) : "memory", "cc");
-
-#elif defined(BOTAN_TARGET_ARCH_IS_HPPA)
- asm volatile("mfctl 16,%0" : "=r" (rtc)); // 64-bit only?
-
-#else
- #error "Unsure how to access hardware timer on this system"
-#endif
-
- return rtc;
- }
-
-}
diff --git a/src/timer/cpu_counter/tm_hard.h b/src/timer/cpu_counter/tm_hard.h
deleted file mode 100644
index 2e338eca8..000000000
--- a/src/timer/cpu_counter/tm_hard.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-* Hardware Timer
-* (C) 1999-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#ifndef BOTAN_TIMER_HARDWARE_H__
-#define BOTAN_TIMER_HARDWARE_H__
-
-#include <botan/timer.h>
-
-namespace Botan {
-
-/*
-* Hardware Timer
-*/
-class BOTAN_DLL Hardware_Timer : public Timer
- {
- public:
- /*
- @todo: Add sync(Timer& wall_clock, bool milliseconds) which busy
- loops using wall_clock and tries to guess the tick rate of the
- hardware counter, allowing it to be used for benchmarks, etc
- */
-
- std::string name() const { return "Hardware Timer"; }
- u64bit clock() const;
- };
-
-}
-
-#endif
diff --git a/src/timer/gettimeofday/info.txt b/src/timer/gettimeofday/info.txt
deleted file mode 100644
index a58e8088d..000000000
--- a/src/timer/gettimeofday/info.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-realname "Unix Timer"
-
-define TIMER_UNIX
-
-load_on auto
-modset unix,beos
-
-<add>
-tm_unix.cpp
-tm_unix.h
-</add>
-
-<os>
-aix
-beos
-cygwin
-darwin
-freebsd
-dragonfly
-hpux
-irix
-linux
-netbsd
-openbsd
-qnx
-solaris
-tru64
-</os>
-
-<requires>
-timer
-</requires>
-
diff --git a/src/timer/gettimeofday/tm_unix.cpp b/src/timer/gettimeofday/tm_unix.cpp
deleted file mode 100644
index 9d8ac4a04..000000000
--- a/src/timer/gettimeofday/tm_unix.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
-* Unix Timer
-* (C) 1999-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#include <botan/tm_unix.h>
-#include <sys/time.h>
-
-namespace Botan {
-
-/*
-* Get the timestamp
-*/
-u64bit Unix_Timer::clock() const
- {
- struct ::timeval tv;
- ::gettimeofday(&tv, 0);
- return combine_timers(tv.tv_sec, tv.tv_usec, 1000000);
- }
-
-}
diff --git a/src/timer/gettimeofday/tm_unix.h b/src/timer/gettimeofday/tm_unix.h
deleted file mode 100644
index c304dbb5c..000000000
--- a/src/timer/gettimeofday/tm_unix.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-* Unix Timer
-* (C) 1999-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#ifndef BOTAN_TIMER_UNIX_H__
-#define BOTAN_TIMER_UNIX_H__
-
-#include <botan/timer.h>
-
-namespace Botan {
-
-/*
-* Unix Timer
-*/
-class BOTAN_DLL Unix_Timer : public Timer
- {
- public:
- std::string name() const { return "Unix gettimeofday"; }
- u64bit clock() const;
- };
-
-}
-
-#endif
diff --git a/src/timer/info.txt b/src/timer/info.txt
deleted file mode 100644
index 6408dca45..000000000
--- a/src/timer/info.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-realname "Timer Base Class"
-
-define TIMER
-
-load_on auto
-
-<add>
-timer.cpp
-timer.h
-</add>
-
-<requires>
-rng
-</requires>
diff --git a/src/timer/posix_rt/info.txt b/src/timer/posix_rt/info.txt
deleted file mode 100644
index fa530ea1a..000000000
--- a/src/timer/posix_rt/info.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-realname "POSIX Timer"
-
-define TIMER_POSIX
-
-load_on auto
-
-<add>
-tm_posix.cpp
-tm_posix.h
-</add>
-
-<libs>
-linux -> rt
-</libs>
-
-# The *BSDs put clock_gettime in sys/time.h, not time.h like POSIX says
-<os>
-cygwin
-linux
-#freebsd
-dragonfly
-#netbsd
-#openbsd
-</os>
-
-<requires>
-timer
-</requires>
-
diff --git a/src/timer/posix_rt/tm_posix.cpp b/src/timer/posix_rt/tm_posix.cpp
deleted file mode 100644
index 96182025c..000000000
--- a/src/timer/posix_rt/tm_posix.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-* POSIX Timer
-* (C) 1999-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#include <botan/tm_posix.h>
-
-#ifndef _POSIX_C_SOURCE
- #define _POSIX_C_SOURCE 199309
-#endif
-
-#include <time.h>
-
-#ifndef CLOCK_REALTIME
- #define CLOCK_REALTIME 0
-#endif
-
-namespace Botan {
-
-/*
-* Get the timestamp
-*/
-u64bit POSIX_Timer::clock() const
- {
- struct ::timespec tv;
- ::clock_gettime(CLOCK_REALTIME, &tv);
- return combine_timers(tv.tv_sec, tv.tv_nsec, 1000000000);
- }
-
-}
diff --git a/src/timer/posix_rt/tm_posix.h b/src/timer/posix_rt/tm_posix.h
deleted file mode 100644
index 8bedccfa2..000000000
--- a/src/timer/posix_rt/tm_posix.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-* POSIX Timer
-* (C) 1999-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#ifndef BOTAN_TIMER_POSIX_H__
-#define BOTAN_TIMER_POSIX_H__
-
-#include <botan/timer.h>
-
-namespace Botan {
-
-/*
-* POSIX Timer
-*/
-class BOTAN_DLL POSIX_Timer : public Timer
- {
- public:
- std::string name() const { return "POSIX clock_gettime"; }
- u64bit clock() const;
- };
-
-}
-
-#endif
diff --git a/src/timer/timer.cpp b/src/timer/timer.cpp
deleted file mode 100644
index 16d7dc368..000000000
--- a/src/timer/timer.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
-* Timestamp Functions
-* (C) 1999-2009 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#include <botan/timer.h>
-#include <botan/loadstor.h>
-#include <ctime>
-
-namespace Botan {
-
-/**
-* Get the system clock
-*/
-u64bit system_time()
- {
- return static_cast<u64bit>(std::time(0));
- }
-
-/*
-* Convert a time_t to a struct tm
-*/
-std::tm time_t_to_tm(u64bit timer)
- {
- std::time_t time_val = static_cast<std::time_t>(timer);
-
- std::tm* tm_p = std::gmtime(&time_val);
- if (tm_p == 0)
- throw Encoding_Error("time_t_to_tm could not convert");
- return (*tm_p);
- }
-
-/**
-* Read the clock and return the output
-*/
-void Timer::poll(Entropy_Accumulator& accum)
- {
- const u64bit clock_value = this->clock();
- accum.add(clock_value, 0);
- }
-
-/**
-* Combine a two time values into a single one
-*/
-u64bit Timer::combine_timers(u32bit seconds, u32bit parts, u32bit parts_hz)
- {
- static const u64bit NANOSECONDS_UNITS = 1000000000;
-
- u64bit res = seconds * NANOSECONDS_UNITS;
- res += parts * (NANOSECONDS_UNITS / parts_hz);
- return res;
- }
-
-/**
-* ANSI Clock
-*/
-u64bit ANSI_Clock_Timer::clock() const
- {
- return combine_timers(std::time(0), std::clock(), CLOCKS_PER_SEC);
- }
-
-}
diff --git a/src/timer/timer.h b/src/timer/timer.h
deleted file mode 100644
index 603027f6d..000000000
--- a/src/timer/timer.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
-* Timestamp Functions
-* (C) 1999-2009 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#ifndef BOTAN_TIMERS_H__
-#define BOTAN_TIMERS_H__
-
-#include <botan/rng.h>
-#include <ctime>
-
-namespace Botan {
-
-/*
-* Time Access/Conversion Functions
-*/
-BOTAN_DLL u64bit system_time();
-
-BOTAN_DLL std::tm time_t_to_tm(u64bit);
-
-/**
-* Timer Interface
-*/
-class BOTAN_DLL Timer : public EntropySource
- {
- public:
- /**
- @return nanoseconds resolution timestamp, unknown epoch
- */
- virtual u64bit clock() const = 0;
-
- void poll(Entropy_Accumulator& accum);
-
- virtual ~Timer() {}
- protected:
- static u64bit combine_timers(u32bit, u32bit, u32bit);
- };
-
-/**
-* ANSI Clock Timer
-*/
-class BOTAN_DLL ANSI_Clock_Timer : public Timer
- {
- public:
- std::string name() const { return "ANSI clock"; }
- u64bit clock() const;
- };
-
-}
-
-#endif
diff --git a/src/timer/win32_query_perf_ctr/info.txt b/src/timer/win32_query_perf_ctr/info.txt
deleted file mode 100644
index 4bb1ddb34..000000000
--- a/src/timer/win32_query_perf_ctr/info.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-realname "Win32 Timer"
-
-define TIMER_WIN32
-modset win32
-
-load_on auto
-
-<add>
-tm_win32.cpp
-tm_win32.h
-</add>
-
-<os>
-cygwin
-windows
-mingw
-</os>
-
-<libs>
-windows -> user32.lib
-</libs>
-
-<requires>
-timer
-</requires>
-
diff --git a/src/timer/win32_query_perf_ctr/tm_win32.cpp b/src/timer/win32_query_perf_ctr/tm_win32.cpp
deleted file mode 100644
index 6b878e6e2..000000000
--- a/src/timer/win32_query_perf_ctr/tm_win32.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
-* Win32 Timer
-* (C) 1999-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#include <botan/tm_win32.h>
-#include <windows.h>
-
-namespace Botan {
-
-/*
-* Get the timestamp
-*/
-u64bit Win32_Timer::clock() const
- {
- LARGE_INTEGER tv;
- ::QueryPerformanceCounter(&tv);
- return tv.QuadPart;
- }
-
-}
diff --git a/src/timer/win32_query_perf_ctr/tm_win32.h b/src/timer/win32_query_perf_ctr/tm_win32.h
deleted file mode 100644
index 5bcb720ab..000000000
--- a/src/timer/win32_query_perf_ctr/tm_win32.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-* Win32 Timer
-* (C) 1999-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#ifndef BOTAN_TIMER_WIN32_H__
-#define BOTAN_TIMER_WIN32_H__
-
-#include <botan/timer.h>
-
-namespace Botan {
-
-/*
-* Win32 Timer
-*/
-class BOTAN_DLL Win32_Timer : public Timer
- {
- public:
- std::string name() const { return "Win32 QueryPerformanceCounter"; }
- u64bit clock() const;
- };
-
-}
-
-#endif
diff --git a/src/utils/time.h b/src/utils/time.h
new file mode 100644
index 000000000..3052aec44
--- /dev/null
+++ b/src/utils/time.h
@@ -0,0 +1,39 @@
+/*
+* Time Functions
+* (C) 2009 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#ifndef BOTAN_TIME_OPS_H__
+#define BOTAN_TIME_OPS_H__
+
+#include <ctime>
+
+namespace Botan {
+
+/*
+* Convert a time_t value to a struct tm
+*/
+inline std::tm time_t_to_tm(u64bit time_int)
+ {
+ std::time_t time_val = static_cast<std::time_t>(time_int);
+
+ std::tm* tm_p = std::gmtime(&time_val);
+ if (tm_p == 0)
+ throw Encoding_Error("time_t_to_tm could not convert");
+ return (*tm_p);
+ }
+
+/**
+* Get the system clock
+*/
+inline u64bit system_time()
+ {
+ return static_cast<u64bit>(std::time(0));
+ }
+
+}
+
+
+#endif