diff options
author | lloyd <[email protected]> | 2008-04-07 01:00:05 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-04-07 01:00:05 +0000 |
commit | ac81da89ac0dca6a4d4cc6cf12de29bf66709e57 (patch) | |
tree | a681c5eba6110b96a987a18cbad60a0920e9c257 | |
parent | 4191064d79916508e531c4f28ddb244527f64d5c (diff) |
The intent of this branch is to remove the global library state object
(Library_State, in libstate.{h,cpp}). It causes numerous 'interesting'
problems with threads, etc, and the best solution here is to move to
more or less an object-capability model, where the only objects that
a piece of code can access are those which can be referenced through
its arguments.
First things first, remove the UI 'pulse' code. It is neither necessary
nor sufficient for writing proper GUI/event driven code using Botan, has
likely never been used in real code, and, given that, causes a distressing
amount of overhead in terms of function calls made.
-rw-r--r-- | include/libstate.h | 11 | ||||
-rw-r--r-- | src/dsa_gen.cpp | 8 | ||||
-rw-r--r-- | src/filter.cpp | 2 | ||||
-rw-r--r-- | src/libstate.cpp | 22 | ||||
-rw-r--r-- | src/make_prm.cpp | 12 | ||||
-rw-r--r-- | src/numthry.cpp | 3 |
6 files changed, 0 insertions, 58 deletions
diff --git a/include/libstate.h b/include/libstate.h index 297e39479..49f1c1b0f 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; @@ -72,9 +65,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; @@ -96,7 +86,6 @@ class Library_State std::map<std::string, Allocator*> alloc_factory; mutable Allocator* cached_default_allocator; - UI* ui; class Charset_Transcoder* transcoder; RandomNumberGenerator* rng; std::vector<Allocator*> allocators; 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..7a742b468 100644 --- a/src/libstate.cpp +++ b/src/libstate.cpp @@ -277,24 +277,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,7 +310,6 @@ void Library_State::initialize(const InitializerOptions& args, cached_default_allocator = 0; x509_state_obj = 0; - ui = 0; timer = modules.timer(); transcoder = modules.transcoder(); @@ -382,11 +363,9 @@ Library_State::Library_State() config_obj = 0; x509_state_obj = 0; - ui = 0; transcoder = 0; rng = 0; cached_default_allocator = 0; - ui = 0; } /************************************************* @@ -399,7 +378,6 @@ Library_State::~Library_State() 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/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) |