aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/buf_es.h1
-rw-r--r--include/charset.h12
-rw-r--r--include/def_char.h25
-rw-r--r--include/libstate.h19
-rw-r--r--include/modules.h4
-rw-r--r--include/timers.h6
-rw-r--r--include/util.h3
-rw-r--r--modules/es_unix/es_unix.cpp2
-rw-r--r--src/buf_es.cpp8
-rw-r--r--src/charset.cpp103
-rw-r--r--src/def_char.cpp121
-rw-r--r--src/dsa_gen.cpp8
-rw-r--r--src/filter.cpp2
-rw-r--r--src/libstate.cpp70
-rw-r--r--src/make_prm.cpp12
-rw-r--r--src/modules.cpp39
-rw-r--r--src/numthry.cpp3
-rw-r--r--src/randpool.cpp2
-rw-r--r--src/timers.cpp24
19 files changed, 135 insertions, 329 deletions
diff --git a/include/buf_es.h b/include/buf_es.h
index 53749d25a..8c0312c77 100644
--- a/include/buf_es.h
+++ b/include/buf_es.h
@@ -24,7 +24,6 @@ class Buffered_EntropySource : public EntropySource
void add_bytes(const void*, u32bit);
void add_bytes(u64bit);
- void add_timestamp();
virtual void do_slow_poll() = 0;
virtual void do_fast_poll();
diff --git a/include/charset.h b/include/charset.h
index 81d8f5bca..2cd0b6e3f 100644
--- a/include/charset.h
+++ b/include/charset.h
@@ -12,18 +12,6 @@
namespace Botan {
-/*************************************************
-* Character Set Transcoder Interface *
-*************************************************/
-class Charset_Transcoder
- {
- public:
- virtual std::string transcode(const std::string&,
- Character_Set, Character_Set) const = 0;
-
- virtual ~Charset_Transcoder() {}
- };
-
namespace Charset {
/*************************************************
diff --git a/include/def_char.h b/include/def_char.h
deleted file mode 100644
index 407cedfb0..000000000
--- a/include/def_char.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*************************************************
-* Default Character Set Handling Header File *
-* (C) 1999-2007 The Botan Project *
-*************************************************/
-
-#ifndef BOTAN_DEFAULT_CHARSET_H__
-#define BOTAN_DEFAULT_CHARSET_H__
-
-#include <botan/charset.h>
-
-namespace Botan {
-
-/*************************************************
-* Default Character Set Transcoder Object *
-*************************************************/
-class Default_Charset_Transcoder : public Charset_Transcoder
- {
- public:
- std::string transcode(const std::string&,
- Character_Set, Character_Set) const;
- };
-
-}
-
-#endif
diff --git a/include/libstate.h b/include/libstate.h
index 297e39479..f8a1c6939 100644
--- a/include/libstate.h
+++ b/include/libstate.h
@@ -42,13 +42,6 @@ class Library_State
};
friend class Engine_Iterator;
- class UI
- {
- public:
- virtual void pulse(Pulse_Type) {}
- virtual ~UI() {}
- };
-
Allocator* get_allocator(const std::string& = "") const;
void add_allocator(Allocator*);
void set_default_allocator(const std::string&) const;
@@ -62,9 +55,6 @@ class Library_State
void add_entropy(EntropySource&, bool);
u32bit seed_prng(bool, u32bit);
- void set_timer(class Timer*);
- u64bit system_clock() const;
-
class Config& config() const;
class Mutex* get_mutex() const;
@@ -72,12 +62,6 @@ class Library_State
void set_x509_state(class X509_GlobalState*);
class X509_GlobalState& x509_state();
- void pulse(Pulse_Type) const;
- void set_ui(UI*);
-
- void set_transcoder(class Charset_Transcoder*);
- std::string transcode(const std::string,
- Character_Set, Character_Set) const;
private:
Library_State(const Library_State&) {}
Library_State& operator=(const Library_State&) { return (*this); }
@@ -89,15 +73,12 @@ class Library_State
class Mutex* engine_lock;
class Mutex* rng_lock;
- class Timer* timer;
mutable class Config* config_obj;
class X509_GlobalState* x509_state_obj;
std::map<std::string, Allocator*> alloc_factory;
mutable Allocator* cached_default_allocator;
- UI* ui;
- class Charset_Transcoder* transcoder;
RandomNumberGenerator* rng;
std::vector<Allocator*> allocators;
std::vector<EntropySource*> entropy_sources;
diff --git a/include/modules.h b/include/modules.h
index 1ec76478c..0ef6cb36c 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -19,8 +19,6 @@ class Modules
{
public:
virtual class Mutex_Factory* mutex_factory() const = 0;
- virtual class Timer* timer() const = 0;
- virtual class Charset_Transcoder* transcoder() const = 0;
virtual std::string default_allocator() const = 0;
@@ -38,8 +36,6 @@ class Builtin_Modules : public Modules
{
public:
class Mutex_Factory* mutex_factory() const;
- class Timer* timer() const;
- class Charset_Transcoder* transcoder() const;
std::string default_allocator() const;
diff --git a/include/timers.h b/include/timers.h
index 9c836f064..676d7bbd2 100644
--- a/include/timers.h
+++ b/include/timers.h
@@ -6,17 +6,19 @@
#ifndef BOTAN_TIMERS_H__
#define BOTAN_TIMERS_H__
-#include <botan/types.h>
+#include <botan/base.h>
namespace Botan {
/*************************************************
* Timer Interface *
*************************************************/
-class Timer
+class Timer : public EntropySource
{
public:
virtual u64bit clock() const;
+ u32bit slow_poll(byte[], u32bit);
+
virtual ~Timer() {}
protected:
static u64bit combine_timers(u32bit, u32bit, u32bit);
diff --git a/include/util.h b/include/util.h
index 2d9a70433..8cede5de9 100644
--- a/include/util.h
+++ b/include/util.h
@@ -11,10 +11,9 @@
namespace Botan {
/*************************************************
-* Timer Access Functions *
+* Time Access Functions *
*************************************************/
u64bit system_time();
-u64bit system_clock();
/*************************************************
* Memory Locking Functions *
diff --git a/modules/es_unix/es_unix.cpp b/modules/es_unix/es_unix.cpp
index 3aaf6369a..baa413d55 100644
--- a/modules/es_unix/es_unix.cpp
+++ b/modules/es_unix/es_unix.cpp
@@ -91,8 +91,6 @@ void Unix_EntropySource::do_slow_poll()
u32bit got = 0;
for(u32bit j = 0; j != sources.size(); j++)
{
- add_timestamp();
-
DataSource_Command pipe(sources[j].name_and_args, PATH);
SecureVector<byte> buffer(DEFAULT_BUFFERSIZE);
diff --git a/src/buf_es.cpp b/src/buf_es.cpp
index b0ae98865..95b07232b 100644
--- a/src/buf_es.cpp
+++ b/src/buf_es.cpp
@@ -74,14 +74,6 @@ void Buffered_EntropySource::add_bytes(u64bit entropy)
}
/*************************************************
-* Add entropy to the internal buffer *
-*************************************************/
-void Buffered_EntropySource::add_timestamp()
- {
- add_bytes(system_clock());
- }
-
-/*************************************************
* Take entropy from the internal buffer *
*************************************************/
u32bit Buffered_EntropySource::copy_out(byte out[], u32bit length,
diff --git a/src/charset.cpp b/src/charset.cpp
index 7cda83f0d..e19687163 100644
--- a/src/charset.cpp
+++ b/src/charset.cpp
@@ -6,20 +6,119 @@
#include <botan/charset.h>
#include <botan/hex.h>
#include <botan/base64.h>
-#include <botan/libstate.h>
+#include <botan/parsing.h>
#include <cctype>
namespace Botan {
namespace Charset {
+namespace {
+
+/*************************************************
+* Convert from UCS-2 to ISO 8859-1 *
+*************************************************/
+std::string ucs2_to_latin1(const std::string& ucs2)
+ {
+ if(ucs2.size() % 2 == 1)
+ throw Decoding_Error("UCS-2 string has an odd number of bytes");
+
+ std::string latin1;
+
+ for(u32bit j = 0; j != ucs2.size(); j += 2)
+ {
+ const byte c1 = ucs2[j];
+ const byte c2 = ucs2[j+1];
+
+ if(c1 != 0)
+ throw Decoding_Error("UCS-2 has non-Latin1 characters");
+
+ latin1 += static_cast<char>(c2);
+ }
+
+ return latin1;
+ }
+
+/*************************************************
+* Convert from UTF-8 to ISO 8859-1 *
+*************************************************/
+std::string utf8_to_latin1(const std::string& utf8)
+ {
+ std::string iso8859;
+
+ u32bit position = 0;
+ while(position != utf8.size())
+ {
+ const byte c1 = static_cast<byte>(utf8[position++]);
+
+ if(c1 <= 0x7F)
+ iso8859 += static_cast<char>(c1);
+ else if(c1 >= 0xC0 && c1 <= 0xC7)
+ {
+ if(position == utf8.size())
+ throw Decoding_Error("UTF-8: sequence truncated");
+
+ const byte c2 = static_cast<byte>(utf8[position++]);
+ const byte iso_char = ((c1 & 0x07) << 6) | (c2 & 0x3F);
+
+ if(iso_char <= 0x7F)
+ throw Decoding_Error("UTF-8: sequence longer than needed");
+
+ iso8859 += static_cast<char>(iso_char);
+ }
+ else
+ throw Decoding_Error("UTF-8: Unicode chars not in Latin1 used");
+ }
+
+ return iso8859;
+ }
+
+/*************************************************
+* Convert from ISO 8859-1 to UTF-8 *
+*************************************************/
+std::string latin1_to_utf8(const std::string& iso8859)
+ {
+ std::string utf8;
+ for(u32bit j = 0; j != iso8859.size(); ++j)
+ {
+ const byte c = static_cast<byte>(iso8859[j]);
+
+ if(c <= 0x7F)
+ utf8 += static_cast<char>(c);
+ else
+ {
+ utf8 += static_cast<char>((0xC0 | (c >> 6)));
+ utf8 += static_cast<char>((0x80 | (c & 0x3F)));
+ }
+ }
+ return utf8;
+ }
+
+}
+
/*************************************************
* Perform character set transcoding *
*************************************************/
std::string transcode(const std::string& str,
Character_Set to, Character_Set from)
{
- return global_state().transcode(str, to, from);
+ if(to == LOCAL_CHARSET)
+ to = LATIN1_CHARSET;
+ if(from == LOCAL_CHARSET)
+ from = LATIN1_CHARSET;
+
+ if(to == from)
+ return str;
+
+ if(from == LATIN1_CHARSET && to == UTF8_CHARSET)
+ return latin1_to_utf8(str);
+ if(from == UTF8_CHARSET && to == LATIN1_CHARSET)
+ return utf8_to_latin1(str);
+ if(from == UCS2_CHARSET && to == LATIN1_CHARSET)
+ return ucs2_to_latin1(str);
+
+ throw Invalid_Argument("Unknown transcoding operation from " +
+ to_string(from) + " to " + to_string(to));
}
/*************************************************
diff --git a/src/def_char.cpp b/src/def_char.cpp
deleted file mode 100644
index 0bbd719f6..000000000
--- a/src/def_char.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/*************************************************
-* Default Character Set Handling Source File *
-* (C) 1999-2007 The Botan Project *
-*************************************************/
-
-#include <botan/def_char.h>
-#include <botan/exceptn.h>
-#include <botan/parsing.h>
-
-namespace Botan {
-
-namespace {
-
-/*************************************************
-* Convert from UCS-2 to ISO 8859-1 *
-*************************************************/
-std::string ucs2_to_latin1(const std::string& ucs2)
- {
- if(ucs2.size() % 2 == 1)
- throw Decoding_Error("UCS-2 string has an odd number of bytes");
-
- std::string latin1;
-
- for(u32bit j = 0; j != ucs2.size(); j += 2)
- {
- const byte c1 = ucs2[j];
- const byte c2 = ucs2[j+1];
-
- if(c1 != 0)
- throw Decoding_Error("UCS-2 has non-Latin1 characters");
-
- latin1 += static_cast<char>(c2);
- }
-
- return latin1;
- }
-
-/*************************************************
-* Convert from UTF-8 to ISO 8859-1 *
-*************************************************/
-std::string utf8_to_latin1(const std::string& utf8)
- {
- std::string iso8859;
-
- u32bit position = 0;
- while(position != utf8.size())
- {
- const byte c1 = static_cast<byte>(utf8[position++]);
-
- if(c1 <= 0x7F)
- iso8859 += static_cast<char>(c1);
- else if(c1 >= 0xC0 && c1 <= 0xC7)
- {
- if(position == utf8.size())
- throw Decoding_Error("UTF-8: sequence truncated");
-
- const byte c2 = static_cast<byte>(utf8[position++]);
- const byte iso_char = ((c1 & 0x07) << 6) | (c2 & 0x3F);
-
- if(iso_char <= 0x7F)
- throw Decoding_Error("UTF-8: sequence longer than needed");
-
- iso8859 += static_cast<char>(iso_char);
- }
- else
- throw Decoding_Error("UTF-8: Unicode chars not in Latin1 used");
- }
-
- return iso8859;
- }
-
-/*************************************************
-* Convert from ISO 8859-1 to UTF-8 *
-*************************************************/
-std::string latin1_to_utf8(const std::string& iso8859)
- {
- std::string utf8;
- for(u32bit j = 0; j != iso8859.size(); ++j)
- {
- const byte c = static_cast<byte>(iso8859[j]);
-
- if(c <= 0x7F)
- utf8 += static_cast<char>(c);
- else
- {
- utf8 += static_cast<char>((0xC0 | (c >> 6)));
- utf8 += static_cast<char>((0x80 | (c & 0x3F)));
- }
- }
- return utf8;
- }
-
-}
-
-/*************************************************
-* Transcode between character sets *
-*************************************************/
-std::string Default_Charset_Transcoder::transcode(const std::string& str,
- Character_Set to,
- Character_Set from) const
- {
- if(to == LOCAL_CHARSET)
- to = LATIN1_CHARSET;
- if(from == LOCAL_CHARSET)
- from = LATIN1_CHARSET;
-
- if(to == from)
- return str;
-
- if(from == LATIN1_CHARSET && to == UTF8_CHARSET)
- return latin1_to_utf8(str);
- if(from == UTF8_CHARSET && to == LATIN1_CHARSET)
- return utf8_to_latin1(str);
- if(from == UCS2_CHARSET && to == LATIN1_CHARSET)
- return ucs2_to_latin1(str);
-
- throw Invalid_Argument("Unknown transcoding operation from " +
- to_string(from) + " to " + to_string(to));
- }
-
-}
diff --git a/src/dsa_gen.cpp b/src/dsa_gen.cpp
index c4e475a49..15a0b5ff8 100644
--- a/src/dsa_gen.cpp
+++ b/src/dsa_gen.cpp
@@ -84,8 +84,6 @@ bool DL_Group::generate_dsa_primes(BigInt& p, BigInt& q,
if(!is_prime(q))
return false;
- global_state().pulse(PRIME_FOUND);
-
const u32bit n = (pbits-1) / (HASH_SIZE * 8),
b = (pbits-1) % (HASH_SIZE * 8);
@@ -94,8 +92,6 @@ bool DL_Group::generate_dsa_primes(BigInt& p, BigInt& q,
for(u32bit j = 0; j != 4096; ++j)
{
- global_state().pulse(PRIME_SEARCHING);
-
for(u32bit k = 0; k <= n; ++k)
{
++seed;
@@ -110,10 +106,7 @@ bool DL_Group::generate_dsa_primes(BigInt& p, BigInt& q,
p = X - (X % (2*q) - 1);
if(p.bits() == pbits && is_prime(p))
- {
- global_state().pulse(PRIME_FOUND);
return true;
- }
}
return false;
}
@@ -129,7 +122,6 @@ SecureVector<byte> DL_Group::generate_dsa_primes(BigInt& p, BigInt& q,
while(true)
{
Global_RNG::randomize(seed, seed.size());
- global_state().pulse(PRIME_SEARCHING);
if(generate_dsa_primes(p, q, pbits, qbits, seed))
return seed;
diff --git a/src/filter.cpp b/src/filter.cpp
index 385ab28a8..dcd3c3b5d 100644
--- a/src/filter.cpp
+++ b/src/filter.cpp
@@ -25,8 +25,6 @@ Filter::Filter()
*************************************************/
void Filter::send(const byte input[], u32bit length)
{
- global_state().pulse(PIPE_WRITE);
-
bool nothing_attached = true;
for(u32bit j = 0; j != total_ports(); ++j)
if(next[j])
diff --git a/src/libstate.cpp b/src/libstate.cpp
index f6926cdb4..7d3b633cd 100644
--- a/src/libstate.cpp
+++ b/src/libstate.cpp
@@ -10,7 +10,6 @@
#include <botan/x509stat.h>
#include <botan/stl_util.h>
#include <botan/mutex.h>
-#include <botan/timers.h>
#include <botan/charset.h>
#include <botan/x931_rng.h>
#include <botan/fips140.h>
@@ -123,23 +122,6 @@ void Library_State::set_default_allocator(const std::string& type) const
}
/*************************************************
-* Set the high resolution clock implementation *
-*************************************************/
-void Library_State::set_timer(Timer* new_timer)
- {
- delete timer;
- timer = new_timer;
- }
-
-/*************************************************
-* Read a high resolution clock *
-*************************************************/
-u64bit Library_State::system_clock() const
- {
- return (timer) ? timer->clock() : 0;
- }
-
-/*************************************************
* Set the global PRNG *
*************************************************/
void Library_State::set_prng(RandomNumberGenerator* new_rng)
@@ -234,29 +216,6 @@ void Library_State::add_engine(Engine* engine)
}
/*************************************************
-* Set the character set transcoder object *
-*************************************************/
-void Library_State::set_transcoder(class Charset_Transcoder* transcoder)
- {
- if(this->transcoder)
- delete this->transcoder;
- this->transcoder = transcoder;
- }
-
-/*************************************************
-* Transcode a string from one charset to another *
-*************************************************/
-std::string Library_State::transcode(const std::string str,
- Character_Set to,
- Character_Set from) const
- {
- if(!transcoder)
- throw Invalid_State("Library_State::transcode: No transcoder set");
-
- return transcoder->transcode(str, to, from);
- }
-
-/*************************************************
* Set the X509 global state class *
*************************************************/
void Library_State::set_x509_state(X509_GlobalState* new_x509_state_obj)
@@ -277,24 +236,6 @@ X509_GlobalState& Library_State::x509_state()
}
/*************************************************
-* Set the UI object state *
-*************************************************/
-void Library_State::set_ui(UI* new_ui)
- {
- delete ui;
- ui = new_ui;
- }
-
-/*************************************************
-* Send a pulse to the UI object *
-*************************************************/
-void Library_State::pulse(Pulse_Type pulse_type) const
- {
- if(ui)
- ui->pulse(pulse_type);
- }
-
-/*************************************************
* Set the configuration object *
*************************************************/
Config& Library_State::config() const
@@ -328,10 +269,6 @@ void Library_State::initialize(const InitializerOptions& args,
cached_default_allocator = 0;
x509_state_obj = 0;
- ui = 0;
-
- timer = modules.timer();
- transcoder = modules.transcoder();
std::vector<Allocator*> mod_allocs = modules.allocators();
for(u32bit j = 0; j != mod_allocs.size(); ++j)
@@ -378,15 +315,11 @@ Library_State::Library_State()
allocator_lock = engine_lock = rng_lock = 0;
- timer = 0;
config_obj = 0;
x509_state_obj = 0;
- ui = 0;
- transcoder = 0;
rng = 0;
cached_default_allocator = 0;
- ui = 0;
}
/*************************************************
@@ -395,11 +328,8 @@ Library_State::Library_State()
Library_State::~Library_State()
{
delete x509_state_obj;
- delete transcoder;
delete rng;
- delete timer;
delete config_obj;
- delete ui;
std::for_each(entropy_sources.begin(), entropy_sources.end(),
del_fun<EntropySource>());
diff --git a/src/make_prm.cpp b/src/make_prm.cpp
index a3258c131..715192c8b 100644
--- a/src/make_prm.cpp
+++ b/src/make_prm.cpp
@@ -29,8 +29,6 @@ BigInt random_prime(u32bit bits, const BigInt& coprime,
while(true)
{
- global_state().pulse(PRIME_SEARCHING);
-
BigInt p = random_integer(bits);
p.set_bit(bits - 2);
p.set_bit(0);
@@ -42,10 +40,7 @@ BigInt random_prime(u32bit bits, const BigInt& coprime,
SecureVector<u32bit> sieve(sieve_size);
for(u32bit j = 0; j != sieve.size(); ++j)
- {
sieve[j] = p % PRIMES[j];
- global_state().pulse(PRIME_SIEVING);
- }
u32bit counter = 0;
while(true)
@@ -53,8 +48,6 @@ BigInt random_prime(u32bit bits, const BigInt& coprime,
if(counter == 4096 || p.bits() > bits)
break;
- global_state().pulse(PRIME_SEARCHING);
-
bool passes_sieve = true;
++counter;
p += modulo;
@@ -62,19 +55,14 @@ BigInt random_prime(u32bit bits, const BigInt& coprime,
for(u32bit j = 0; j != sieve.size(); ++j)
{
sieve[j] = (sieve[j] + modulo) % PRIMES[j];
- global_state().pulse(PRIME_SIEVING);
if(sieve[j] == 0)
passes_sieve = false;
}
if(!passes_sieve || gcd(p - 1, coprime) != 1)
continue;
- global_state().pulse(PRIME_PASSED_SIEVE);
if(passes_mr_tests(p))
- {
- global_state().pulse(PRIME_FOUND);
return p;
- }
}
}
}
diff --git a/src/modules.cpp b/src/modules.cpp
index 70ce21a01..e043ec970 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -5,7 +5,6 @@
#include <botan/modules.h>
#include <botan/defalloc.h>
-#include <botan/def_char.h>
#include <botan/eng_def.h>
#include <botan/timers.h>
@@ -94,24 +93,6 @@ Mutex_Factory* Builtin_Modules::mutex_factory() const
}
/*************************************************
-* Find a high resolution timer, if possible *
-*************************************************/
-Timer* Builtin_Modules::timer() const
- {
-#if defined(BOTAN_EXT_TIMER_HARDWARE)
- return new Hardware_Timer;
-#elif defined(BOTAN_EXT_TIMER_POSIX)
- return new POSIX_Timer;
-#elif defined(BOTAN_EXT_TIMER_UNIX)
- return new Unix_Timer;
-#elif defined(BOTAN_EXT_TIMER_WIN32)
- return new Win32_Timer;
-#else
- return new Timer;
-#endif
- }
-
-/*************************************************
* Find any usable allocators *
*************************************************/
std::vector<Allocator*> Builtin_Modules::allocators() const
@@ -152,6 +133,18 @@ std::vector<EntropySource*> Builtin_Modules::entropy_sources() const
{
std::vector<EntropySource*> sources;
+#if defined(BOTAN_EXT_TIMER_HARDWARE)
+ sources.push_back(new Hardware_Timer);
+#elif defined(BOTAN_EXT_TIMER_POSIX)
+ sources.push_back(new POSIX_Timer);
+#elif defined(BOTAN_EXT_TIMER_UNIX)
+ sources.push_back(new Unix_Timer);
+#elif defined(BOTAN_EXT_TIMER_WIN32)
+ sources.push_back(new Win32_Timer);
+#else
+ sources.push_back(new Timer);
+#endif
+
#if defined(BOTAN_EXT_ENTROPY_SRC_AEP)
sources.push_back(new AEP_EntropySource);
#endif
@@ -215,14 +208,6 @@ std::vector<Engine*> Builtin_Modules::engines() const
}
/*************************************************
-* Find the best transcoder option *
-*************************************************/
-Charset_Transcoder* Builtin_Modules::transcoder() const
- {
- return new Default_Charset_Transcoder;
- }
-
-/*************************************************
* Builtin_Modules Constructor *
*************************************************/
Builtin_Modules::Builtin_Modules(const InitializerOptions& args) :
diff --git a/src/numthry.cpp b/src/numthry.cpp
index 19fae1770..d5a992381 100644
--- a/src/numthry.cpp
+++ b/src/numthry.cpp
@@ -284,15 +284,12 @@ bool MillerRabin_Test::passes_test(const BigInt& a)
if(a < 2 || a >= n_minus_1)
throw Invalid_Argument("Bad size for nonce in Miller-Rabin test");
- global_state().pulse(PRIME_TESTING);
-
BigInt y = pow_mod(a);
if(y == 1 || y == n_minus_1)
return true;
for(u32bit j = 1; j != s; ++j)
{
- global_state().pulse(PRIME_TESTING);
y = reducer.square(y);
if(y == 1)
diff --git a/src/randpool.cpp b/src/randpool.cpp
index 2fdddf53e..7c3007008 100644
--- a/src/randpool.cpp
+++ b/src/randpool.cpp
@@ -59,7 +59,7 @@ void Randpool::randomize(byte out[], u32bit length) throw(PRNG_Unseeded)
*************************************************/
void Randpool::update_buffer()
{
- const u64bit timestamp = system_clock();
+ const u64bit timestamp = system_time();
for(u32bit j = 0; j != counter.size(); ++j)
if(++counter[j])
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);
}