The unified diff between revisions [2fac918f..] and [4e40e885..] is displayed below. It can also be downloaded as a raw diff.

#
#
# delete "include/def_char.h"
#
# delete "include/rng.h"
#
# delete "include/x509stat.h"
#
# delete "src/def_char.cpp"
#
# delete "src/rng.cpp"
#
# delete "src/x509stat.cpp"
#
# patch "checks/bench.cpp"
#  from [c6edf6ea5b86de31a9297b8c4a38e20b00b17569]
#    to [194dc330534f8d0998eed9b5d92191844d30ea32]
#
# patch "checks/bigint.cpp"
#  from [51aea731b8d78f775d76dfa8eefa899ab31db372]
#    to [42fd0bfcf3602642e4309c39141cb3fe0a68e922]
#
# patch "checks/dolook2.cpp"
#  from [85311129695d27a3c04ac8d6c56ac0ed7a640d61]
#    to [6e047326952c5f224d647e9e9407209728bc0627]
#
# patch "checks/pk.cpp"
#  from [a0ffa6b2be8ad430f539826f492632bad4a836c6]
#    to [29d3ee1e629ecb164b57caf11f80703043ec1bbe]
#
# patch "checks/pk_bench.cpp"
#  from [7397a3fd478a3c1d33965d946c497172b4eb1940]
#    to [cfa4efb5884ff9975c16091b3d7f70310dbf1c5e]
#
# patch "checks/validate.cpp"
#  from [f82aaa5253a65fe9f48a69617bdcc9f92587a22f]
#    to [0be5b3c114c588d0b1c20fe2766bf0fae03b26a8]
#
# patch "doc/api.tex"
#  from [e993f153276da7f0753f4d6b9acece713cf8ad86]
#    to [fc52b858bc1ab49ec15a6948dbd1c750fea69db4]
#
# patch "include/asn1_int.h"
#  from [5caaae2713c3f14a3a4508263e52bc3331674c36]
#    to [7cd7ae2878098baae23635e2706739b648ab5634]
#
# patch "include/botan.h"
#  from [221f7daa0502628bd269bea853806056ff68f965]
#    to [e8deb87811288cd18988ea6087bc31fdfe7b1f66]
#
# patch "include/buf_es.h"
#  from [9e2738c31e98547443cd0cb21daaa64161890e8c]
#    to [6d0b85ee23b95511cca43e7754a65494d8553b0c]
#
# patch "include/charset.h"
#  from [2302b355b8fdafcb4908254cb954713bbce45ac5]
#    to [d14be390cbcd1b0b0a33005c0c6b2165c66fd8b1]
#
# patch "include/enums.h"
#  from [0f58933dfab00e05a9a5e6e629503f375ae9607a]
#    to [9fcb09ae52890c249997ea8355a9bd7d3464f2de]
#
# patch "include/libstate.h"
#  from [447f0bbcbc4387c2622e86efd374413784764484]
#    to [cc522cb9ab803f77a13c05a42addb46e0272cdcc]
#
# patch "include/modules.h"
#  from [8243eb4fd9554ef933c197e08ad9a623671708f4]
#    to [dd2710c408c7a116b96db31d53b8fdcee5a65e31]
#
# patch "include/timers.h"
#  from [bc5a5ce2e7f0ba2d66481add7c5b585ab21e85df]
#    to [1924a8a71eece12b946c93dfa0189f3dde13e21a]
#
# patch "include/util.h"
#  from [f4d9e0bb9bd1e620203ac85b38735ac5ed8e0158]
#    to [e78434c0e695bc47ad2c0bdfbfbae8ba36bda8f7]
#
# patch "include/x509_ext.h"
#  from [f78f64cdb6e00e4d88a5ada4c1a9703d42f1b071]
#    to [3d07a4bbddc8ec683e40448dc6a5d9307ec345c0]
#
# patch "modules/es_unix/es_unix.cpp"
#  from [3495698920d874c5adbd331f340f9eee5f5aeb57]
#    to [aff0f9506f4d6069ba3f17cef22f93e75262abd3]
#
# patch "src/big_rand.cpp"
#  from [c96c8d30259476fe7dc6657e0890fa65092599e4]
#    to [39572abe8e5f783ed4cf42de2c524f851215ce2e]
#
# patch "src/buf_es.cpp"
#  from [89a5377290a8224a1bd14db3cf14dc5e5aba9e19]
#    to [aa507bb49b93b77a65b3cba83c3aeee1edf99026]
#
# patch "src/charset.cpp"
#  from [04f4dfbbb744679263591ea0af8c61a71160a78f]
#    to [ed45191ce62ae8c6bd98fa8cb040d82b1cd386ee]
#
# patch "src/dsa_gen.cpp"
#  from [00d226503a5125dc91efda28bb31dc2b270f6f43]
#    to [1f560b9c58461ea5dc96d1e92d45bb6b3e05f822]
#
# patch "src/eme1.cpp"
#  from [013b576a89f274430f9dcd121501ee880f9a4d7a]
#    to [00d13c8afa26f93a0b45dc81946d8d6db10baf93]
#
# patch "src/eme_pkcs.cpp"
#  from [af8da75524147763c7388e694431ac39d8e012d7]
#    to [957e51a698ddf990fec5d003064ff4eb4a28607a]
#
# patch "src/emsa4.cpp"
#  from [fb05b67a47bbb8e2aae85ddecad268f8482551cc]
#    to [dc0f0dbfdaed2ec2ae85bbeed3ff0303013c58fc]
#
# patch "src/filter.cpp"
#  from [cdf7148e946c93f3d08e48b7360029fe815f28ee]
#    to [ee4772bcc40c136c29204a37c94201de730999ad]
#
# patch "src/keypair.cpp"
#  from [f285c4e75e8fa14c1cad0eb6261adb476251dfc3]
#    to [4f2e835c21a1b15d2a497cf2b80b90ef2724bd86]
#
# patch "src/libstate.cpp"
#  from [5c0ae9a34f2214a7b11f0076172600bde71dbcb6]
#    to [46e21742f98783366ba944270205003f7b6e1707]
#
# patch "src/make_prm.cpp"
#  from [83c6312cc45c5657734b544d35e256d1e6d5feff]
#    to [67084166fa8d39268b1743f5d5f1231d4265f427]
#
# patch "src/modules.cpp"
#  from [bd04ca7b4523ffba0fabc47e0bb99a5167cf695b]
#    to [6f7f44e1c3b66c17ea4a6ffe4cd28152d08012cf]
#
# patch "src/numthry.cpp"
#  from [5818781e08d5adb2212ff87aedd8514699835619]
#    to [ce29bfd5f77b486f69081a6884cf35374480821d]
#
# patch "src/pbes1.cpp"
#  from [9ff336e0d509325626e80c2dff2fdcfb462f7791]
#    to [4d0a544192358205f1728ff1387c6a3d9d6ccafa]
#
# patch "src/pbes2.cpp"
#  from [d25db9a10db0db03145b7c4b681ef39e6ac3ee9f]
#    to [3f302e265f72dbf7081b62e777febdf4d5b468aa]
#
# patch "src/randpool.cpp"
#  from [a8b1457d392fffbdf66fe8e4bf50f2a4c97944ab]
#    to [ee4d60d4cf28a7075e1fc511de81f9af5494f8fa]
#
# patch "src/s2k.cpp"
#  from [18cad51f740efcc1961b093d061c1b0e79417679]
#    to [0772628727b4f4a862aeba06213e5972397e3a35]
#
# patch "src/symkey.cpp"
#  from [5d1526f451b9ef883a132dba6ff6cfcebf7e4e4d]
#    to [585161d46a0cbfa100d6887b78449458cd115a7b]
#
# patch "src/timers.cpp"
#  from [89a971d5ddfa26fdffd9395cb8f489811a9ec3cf]
#    to [dfdece2313e3e2501b6feb29fce75ede18f72d5d]
#
# patch "src/x509_ext.cpp"
#  from [73142667ecce6c88731ac958ec83140c4523680d]
#    to [5724ac53f27fc3f50ab9df3d44a1ed2f52b34517]
#
============================================================
--- checks/bench.cpp	c6edf6ea5b86de31a9297b8c4a38e20b00b17569
+++ checks/bench.cpp	194dc330534f8d0998eed9b5d92191844d30ea32
@@ -5,7 +5,7 @@
 #include <string>
 #include <exception>

-#include <botan/rng.h>
+#include <botan/libstate.h>
 #include <botan/filters.h>
 using namespace Botan_types;
 using Botan::u64bit;
@@ -31,7 +31,7 @@ double bench_filter(std::string name, Bo
    static const u32bit BUFFERSIZE = 32*1024;
    byte buf[BUFFERSIZE];

-   Botan::Global_RNG::randomize(buf, BUFFERSIZE);
+   Botan::global_state().randomize(buf, BUFFERSIZE);

    u32bit iterations = 0;
    u64bit start = get_clock(), clocks_used = 0;
============================================================
--- checks/bigint.cpp	51aea731b8d78f775d76dfa8eefa899ab31db372
+++ checks/bigint.cpp	42fd0bfcf3602642e4309c39141cb3fe0a68e922
@@ -7,7 +7,7 @@
 #include <botan/bigint.h>
 #include <botan/exceptn.h>
 #include <botan/numthry.h>
-#include <botan/rng.h>
+#include <botan/libstate.h>
 using namespace Botan;

 #include "common.h"
@@ -264,7 +264,7 @@ u32bit check_mod(const std::vector<std::
    /* Won't work for us, just pick one at random */
    while(b_word == 0)
       for(u32bit j = 0; j != 2*sizeof(word); j++)
-         b_word = (b_word << 4) ^ Global_RNG::random();
+         b_word = (b_word << 4) ^ global_state().random();

    b = b_word;

============================================================
--- checks/dolook2.cpp	85311129695d27a3c04ac8d6c56ac0ed7a640d61
+++ checks/dolook2.cpp	6e047326952c5f224d647e9e9407209728bc0627
@@ -8,7 +8,7 @@
 #include <botan/filters.h>
 #include <botan/randpool.h>
 #include <botan/x931_rng.h>
-#include <botan/rng.h>
+#include <botan/libstate.h>
 using namespace Botan;

 /* A weird little hack to fit S2K algorithms into the validation suite
@@ -49,7 +49,7 @@ class RNG_Filter : public Filter
       void write(const byte[], u32bit);
       RNG_Filter(RandomNumberGenerator* r) : rng(r), buffer(1024)
          {
-         Global_RNG::randomize(buffer, buffer.size());
+         global_state().randomize(buffer, buffer.size());
          rng->add_entropy(buffer, buffer.size());
          }
       ~RNG_Filter() { delete rng; }
============================================================
--- checks/pk.cpp	a0ffa6b2be8ad430f539826f492632bad4a836c6
+++ checks/pk.cpp	29d3ee1e629ecb164b57caf11f80703043ec1bbe
@@ -21,7 +21,7 @@
 #include <botan/numthry.h>

 #include <botan/x931_rng.h>
-#include <botan/rng.h>
+#include <botan/libstate.h>
 using namespace Botan;

 #include "common.h"
@@ -196,7 +196,7 @@ u32bit do_pk_validation_tests(const std:

    global_state().set_prng(new ANSI_X931_RNG);
    for(u32bit j = 0; j != 2; j++)
-      Global_RNG::seed(true, 384);
+      global_state().seed_prng(true, 384);

    do_pk_keygen_tests();
    do_x509_tests();
@@ -251,7 +251,7 @@ void validate_encryption(PK_Encryptor* e

    global_state().set_prng(new ANSI_X931_RNG);
    for(u32bit j = 0; j != 2; j++)
-      Global_RNG::seed(true, 384);
+      global_state().seed_prng(true, 384);

    validate_decryption(d, algo, out, message, failure);
    delete e;
@@ -292,7 +292,7 @@ void validate_signature(PK_Verifier* v,

    global_state().set_prng(new ANSI_X931_RNG);
    for(u32bit j = 0; j != 2; j++)
-      Global_RNG::seed(true, 384);
+      global_state().seed_prng(true, 384);

    delete v;
    delete s;
============================================================
--- checks/pk_bench.cpp	7397a3fd478a3c1d33965d946c497172b4eb1940
+++ checks/pk_bench.cpp	cfa4efb5884ff9975c16091b3d7f70310dbf1c5e
@@ -8,7 +8,7 @@

 #include <botan/pkcs8.h>
 #include <botan/look_pk.h>
-#include <botan/rng.h>
+#include <botan/libstate.h>

 using namespace Botan;

@@ -219,7 +219,7 @@ void bench_enc(PK_Encryptor* enc, const
    while(clocks_used < seconds * ticks)
       {
       runs++;
-      Global_RNG::randomize(msg, MSG_SIZE);
+      global_state().randomize(msg, MSG_SIZE);

       u64bit start = get_clock();
       enc->encrypt(msg, MSG_SIZE);
@@ -237,7 +237,7 @@ void bench_dec(PK_Encryptor* enc, PK_Dec
    {
    static const u32bit MSG_SIZE = 16;
    byte msg[MSG_SIZE];
-   Global_RNG::randomize(msg, MSG_SIZE);
+   global_state().randomize(msg, MSG_SIZE);
    SecureVector<byte> output;

    u32bit runs = 0;
@@ -250,7 +250,7 @@ void bench_dec(PK_Encryptor* enc, PK_Dec
       {
       runs++;

-      Global_RNG::randomize(msg, MSG_SIZE);
+      global_state().randomize(msg, MSG_SIZE);
       msg[0] |= 0x80; // make sure it works with "Raw" padding
       encrypted_msg = enc->encrypt(msg, MSG_SIZE);

@@ -286,7 +286,7 @@ void bench_sig(PK_Signer* sig, const std
    while(clocks_used < seconds * ticks)
       {
       runs++;
-      Global_RNG::randomize(msg, MSG_SIZE);
+      global_state().randomize(msg, MSG_SIZE);
       u64bit start = get_clock();
       sig->update(msg, MSG_SIZE);
       sig->signature();
@@ -304,7 +304,7 @@ void bench_ver(PK_Signer* sig, PK_Verifi
    {
    static const u32bit MSG_SIZE = 16;
    byte msg[MSG_SIZE];
-   Global_RNG::randomize(msg, MSG_SIZE);
+   global_state().randomize(msg, MSG_SIZE);

    sig->update(msg, MSG_SIZE);
    SecureVector<byte> signature = sig->signature();
@@ -317,7 +317,7 @@ void bench_ver(PK_Signer* sig, PK_Verifi
       // feel free to tweak, but make sure this always runs when runs == 0
       if(runs % 100 == 0)
          {
-         Global_RNG::randomize(msg, MSG_SIZE);
+         global_state().randomize(msg, MSG_SIZE);
          sig->update(msg, MSG_SIZE);
          signature = sig->signature();
          }
@@ -352,7 +352,7 @@ void bench_kas(PK_Key_Agreement* kas, co
    while(clocks_used < seconds * ticks)
       {
       runs++;
-      Global_RNG::randomize(key, REMOTE_KEY_SIZE);
+      global_state().randomize(key, REMOTE_KEY_SIZE);

       u64bit start = get_clock();
       kas->derive_key(0, key, REMOTE_KEY_SIZE);
============================================================
--- checks/validate.cpp	f82aaa5253a65fe9f48a69617bdcc9f92587a22f
+++ checks/validate.cpp	0be5b3c114c588d0b1c20fe2766bf0fae03b26a8
@@ -10,7 +10,7 @@

 #include <botan/filters.h>
 #include <botan/exceptn.h>
-#include <botan/rng.h>
+#include <botan/libstate.h>
 using namespace Botan_types;

 #define EXTRA_TESTS 0
@@ -31,7 +31,7 @@ u32bit random_word(u32bit max)
    /* normal version */
    u32bit r = 0;
    for(u32bit j = 0; j != 4; j++)
-      r = (r << 8) | Botan::Global_RNG::random();
+      r = (r << 8) | Botan::global_state().random();
    return ((r % max) + 1); // return between 1 and max inclusive
 #endif
    }
============================================================
--- doc/api.tex	e993f153276da7f0753f4d6b9acece713cf8ad86
+++ doc/api.tex	fc52b858bc1ab49ec15a6948dbd1c750fea69db4
@@ -2457,50 +2457,6 @@ \section{User Interfaces}
 in general (ideally under a permissive license such as public domain or
 MIT/BSD), feel free to send in a copy.

-\subsection{Pulses}
-
-If you call a function in the library that turns out to take a long time (such
-as generating a 4096-bit prime), your pretty GUI will block up while the
-library does something, because the event loop is not being run. Not only does
-this look bad, it prevents the user from doing something else while the library
-works. The way around this is to register a pulse function.
-
-By creating a class that inherits from \type{Library\_State::UI} and
-passing it to \function{global\_function}().\function{set\_ui}, you
-can cause a pulse to be sent to your object occasionally (generally
-when performing long running operations like prime generation;
-eventually this will be extended for all operations that might take
-longer than a few milliseconds).
-
-You can recieve a pulse by implementing the member function
-\function{pulse}(\type{Pulse\_Type}) within your UI class.  The
-\type{Pulse\_Type} enum provides mildly useful information about the
-operation in progress (for a full list of the defined
-\type{Pulse\_Type} values, see \filename{enums.h}). The type code
-allows you do simple feedback such as that GnuPG does during key
-generation (printing various characters as the prime generation
-process proceeds, such as '-' for prime test failed, '+' for prime
-test worked, and so on).
-
-Generally the thing to do inside the pulse function is to run the GUI's event
-loop, for example with GTK+:
-
-\begin{verbatim}
-   while(gtk_events_pending())
-      gtk_main_iteration();
-\end{verbatim}
-
-which will flush out the event queue and make your GUI seem nice and
-responsive. For a particularly long-running operation (one that takes more than
-a second or two), you will probably want to put up a progress bar. While you
-can update it directly from the pulse function, be warned that the pulse
-function is called at irregular intervals, so your progress bar's movement
-might seem choppy if you update it directly from the pulse. It may be a better
-move to instead set up a timer (preferably through the GUI framework) that runs
-every fixed timeslice, and updates the bar when the timer goes off. As long as
-the pulse function is called often enough (which is should), simply running the
-event loop and letting the timer function do the updates will work fine.
-
 \pagebreak
 \section{Policy Configuration}

============================================================
--- include/asn1_int.h	5caaae2713c3f14a3a4508263e52bc3331674c36
+++ include/asn1_int.h	7cd7ae2878098baae23635e2706739b648ab5634
@@ -7,12 +7,48 @@
 #define BOTAN_ASN1_H__

 #include <botan/secmem.h>
-#include <botan/enums.h>
 #include <botan/exceptn.h>

 namespace Botan {

 /*************************************************
+* ASN.1 Type and Class Tags                      *
+*************************************************/
+enum ASN1_Tag {
+   UNIVERSAL        = 0x00,
+   APPLICATION      = 0x40,
+   CONTEXT_SPECIFIC = 0x80,
+   PRIVATE          = 0xC0,
+
+   CONSTRUCTED      = 0x20,
+
+   EOC              = 0x00,
+   BOOLEAN          = 0x01,
+   INTEGER          = 0x02,
+   BIT_STRING       = 0x03,
+   OCTET_STRING     = 0x04,
+   NULL_TAG         = 0x05,
+   OBJECT_ID        = 0x06,
+   ENUMERATED       = 0x0A,
+   SEQUENCE         = 0x10,
+   SET              = 0x11,
+
+   UTF8_STRING      = 0x0C,
+   NUMERIC_STRING   = 0x12,
+   PRINTABLE_STRING = 0x13,
+   T61_STRING       = 0x14,
+   IA5_STRING       = 0x16,
+   VISIBLE_STRING   = 0x1A,
+   BMP_STRING       = 0x1E,
+
+   UTC_TIME         = 0x17,
+   GENERALIZED_TIME = 0x18,
+
+   NO_OBJECT        = 0xFF00,
+   DIRECTORY_STRING = 0xFF01
+};
+
+/*************************************************
 * Basic ASN.1 Object Interface                   *
 *************************************************/
 class BOTAN_DLL ASN1_Object
============================================================
--- include/botan.h	221f7daa0502628bd269bea853806056ff68f965
+++ include/botan.h	e8deb87811288cd18988ea6087bc31fdfe7b1f66
@@ -7,6 +7,5 @@
 #include <botan/config.h>
 #include <botan/init.h>
 #include <botan/lookup.h>
-#include <botan/rng.h>
 #include <botan/version.h>
 #include <botan/parsing.h>
============================================================
--- include/buf_es.h	9e2738c31e98547443cd0cb21daaa64161890e8c
+++ include/buf_es.h	6d0b85ee23b95511cca43e7754a65494d8553b0c
@@ -24,7 +24,6 @@ class BOTAN_DLL Buffered_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();
============================================================
--- include/charset.h	2302b355b8fdafcb4908254cb954713bbce45ac5
+++ include/charset.h	d14be390cbcd1b0b0a33005c0c6b2165c66fd8b1
@@ -12,18 +12,6 @@ namespace Botan {

 namespace Botan {

-/*************************************************
-* Character Set Transcoder Interface             *
-*************************************************/
-class BOTAN_DLL Charset_Transcoder
-   {
-   public:
-      virtual std::string transcode(const std::string&,
-                                    Character_Set, Character_Set) const = 0;
-
-      virtual ~Charset_Transcoder() {}
-   };
-
 namespace Charset {

 /*************************************************
============================================================
--- include/enums.h	0f58933dfab00e05a9a5e6e629503f375ae9607a
+++ include/enums.h	9fcb09ae52890c249997ea8355a9bd7d3464f2de
@@ -9,43 +9,6 @@ namespace Botan {
 namespace Botan {

 /*************************************************
-* ASN.1 Type and Class Tags                      *
-*************************************************/
-enum ASN1_Tag {
-   UNIVERSAL        = 0x00,
-   APPLICATION      = 0x40,
-   CONTEXT_SPECIFIC = 0x80,
-   PRIVATE          = 0xC0,
-
-   CONSTRUCTED      = 0x20,
-
-   EOC              = 0x00,
-   BOOLEAN          = 0x01,
-   INTEGER          = 0x02,
-   BIT_STRING       = 0x03,
-   OCTET_STRING     = 0x04,
-   NULL_TAG         = 0x05,
-   OBJECT_ID        = 0x06,
-   ENUMERATED       = 0x0A,
-   SEQUENCE         = 0x10,
-   SET              = 0x11,
-
-   UTF8_STRING      = 0x0C,
-   NUMERIC_STRING   = 0x12,
-   PRINTABLE_STRING = 0x13,
-   T61_STRING       = 0x14,
-   IA5_STRING       = 0x16,
-   VISIBLE_STRING   = 0x1A,
-   BMP_STRING       = 0x1E,
-
-   UTC_TIME         = 0x17,
-   GENERALIZED_TIME = 0x18,
-
-   NO_OBJECT        = 0xFF00,
-   DIRECTORY_STRING = 0xFF01
-};
-
-/*************************************************
 * X.509v3 Key Constraints                        *
 *************************************************/
 enum Key_Constraints {
@@ -99,21 +62,6 @@ enum Character_Set {
    LATIN1_CHARSET
 };

-/*************************************************
-* Pulse Function                                 *
-*************************************************/
-enum Pulse_Type {
-   GENERAL_PULSE,
-
-   PIPE_WRITE,
-
-   PRIME_SEARCHING,
-   PRIME_SIEVING,
-   PRIME_PASSED_SIEVE,
-   PRIME_TESTING,
-   PRIME_FOUND
-};
-
 static const u32bit NO_CERT_PATH_LIMIT = 0xFFFFFFF0;

 }
============================================================
--- include/libstate.h	447f0bbcbc4387c2622e86efd374413784764484
+++ include/libstate.h	cc522cb9ab803f77a13c05a42addb46e0272cdcc
@@ -42,19 +42,13 @@ class BOTAN_DLL Library_State
          };
       friend class Engine_Iterator;

-      class BOTAN_DLL 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;

       bool rng_is_seeded() const { return rng->is_seeded(); }
       void randomize(byte[], u32bit);
+      byte random();

       void set_prng(RandomNumberGenerator*);
       void add_entropy_source(EntropySource*, bool = true);
@@ -62,22 +56,9 @@ class BOTAN_DLL 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;
-
-      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 +70,11 @@ class BOTAN_DLL 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;
============================================================
--- include/modules.h	8243eb4fd9554ef933c197e08ad9a623671708f4
+++ include/modules.h	dd2710c408c7a116b96db31d53b8fdcee5a65e31
@@ -19,8 +19,6 @@ class BOTAN_DLL 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 BOTAN_DLL Builtin_Modules : public
    {
    public:
       class Mutex_Factory* mutex_factory() const;
-      class Timer* timer() const;
-      class Charset_Transcoder* transcoder() const;

       std::string default_allocator() const;

============================================================
--- include/timers.h	bc5a5ce2e7f0ba2d66481add7c5b585ab21e85df
+++ include/timers.h	1924a8a71eece12b946c93dfa0189f3dde13e21a
@@ -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 BOTAN_DLL Timer
+class BOTAN_DLL Timer : public EntropySource
    {
    public:
       virtual u64bit clock() const;
+      u32bit slow_poll(byte[], u32bit);
+
       virtual ~Timer() {}
    protected:
       static u64bit combine_timers(u32bit, u32bit, u32bit);
============================================================
--- include/util.h	f4d9e0bb9bd1e620203ac85b38735ac5ed8e0158
+++ include/util.h	e78434c0e695bc47ad2c0bdfbfbae8ba36bda8f7
@@ -11,10 +11,9 @@ namespace Botan {
 namespace Botan {

 /*************************************************
-* Timer Access Functions                         *
+* Time Access Functions                          *
 *************************************************/
 BOTAN_DLL u64bit system_time();
-BOTAN_DLL u64bit system_clock();

 /*************************************************
 * Memory Locking Functions                       *
============================================================
--- include/x509_ext.h	f78f64cdb6e00e4d88a5ada4c1a9703d42f1b071
+++ include/x509_ext.h	3d07a4bbddc8ec683e40448dc6a5d9307ec345c0
@@ -56,6 +56,8 @@ class BOTAN_DLL Extensions : public ASN1
       Extensions(bool st = true) : should_throw(st) {}
       ~Extensions();
    private:
+      static Certificate_Extension* get_extension(const OID&);
+
       std::vector<Certificate_Extension*> extensions;
       bool should_throw;
    };
============================================================
--- modules/es_unix/es_unix.cpp	3495698920d874c5adbd331f340f9eee5f5aeb57
+++ modules/es_unix/es_unix.cpp	aff0f9506f4d6069ba3f17cef22f93e75262abd3
@@ -90,8 +90,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);

============================================================
--- src/big_rand.cpp	c96c8d30259476fe7dc6657e0890fa65092599e4
+++ src/big_rand.cpp	39572abe8e5f783ed4cf42de2c524f851215ce2e
@@ -6,7 +6,7 @@
 #include <botan/bigint.h>
 #include <botan/parsing.h>
 #include <botan/numthry.h>
-#include <botan/rng.h>
+#include <botan/libstate.h>

 namespace Botan {

@@ -36,7 +36,7 @@ void BigInt::randomize(u32bit bitsize)
    else
       {
       SecureVector<byte> array((bitsize + 7) / 8);
-      Global_RNG::randomize(array, array.size());
+      global_state().randomize(array, array.size());
       if(bitsize % 8)
          array[0] &= 0xFF >> (8 - (bitsize % 8));
       array[0] |= 0x80 >> ((bitsize % 8) ? (8 - bitsize % 8) : 0);
============================================================
--- src/buf_es.cpp	89a5377290a8224a1bd14db3cf14dc5e5aba9e19
+++ src/buf_es.cpp	aa507bb49b93b77a65b3cba83c3aeee1edf99026
@@ -74,14 +74,6 @@ void Buffered_EntropySource::add_bytes(u
    }

 /*************************************************
-* 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,
============================================================
--- src/charset.cpp	04f4dfbbb744679263591ea0af8c61a71160a78f
+++ src/charset.cpp	ed45191ce62ae8c6bd98fa8cb040d82b1cd386ee
@@ -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));
    }

 /*************************************************
============================================================
--- src/dsa_gen.cpp	00d226503a5125dc91efda28bb31dc2b270f6f43
+++ src/dsa_gen.cpp	1f560b9c58461ea5dc96d1e92d45bb6b3e05f822
@@ -5,10 +5,9 @@

 #include <botan/dl_group.h>
 #include <botan/numthry.h>
-#include <botan/libstate.h>
 #include <botan/lookup.h>
 #include <botan/parsing.h>
-#include <botan/rng.h>
+#include <botan/libstate.h>
 #include <algorithm>
 #include <memory>

@@ -84,8 +83,6 @@ bool DL_Group::generate_dsa_primes(BigIn
    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 +91,6 @@ bool DL_Group::generate_dsa_primes(BigIn

    for(u32bit j = 0; j != 4096; ++j)
       {
-      global_state().pulse(PRIME_SEARCHING);
-
       for(u32bit k = 0; k <= n; ++k)
          {
          ++seed;
@@ -110,10 +105,7 @@ bool DL_Group::generate_dsa_primes(BigIn
       p = X - (X % (2*q) - 1);

       if(p.bits() == pbits && is_prime(p))
-         {
-         global_state().pulse(PRIME_FOUND);
          return true;
-         }
       }
    return false;
    }
@@ -128,8 +120,7 @@ SecureVector<byte> DL_Group::generate_ds

    while(true)
       {
-      Global_RNG::randomize(seed, seed.size());
-      global_state().pulse(PRIME_SEARCHING);
+      global_state().randomize(seed, seed.size());

       if(generate_dsa_primes(p, q, pbits, qbits, seed))
          return seed;
============================================================
--- src/eme1.cpp	013b576a89f274430f9dcd121501ee880f9a4d7a
+++ src/eme1.cpp	00d13c8afa26f93a0b45dc81946d8d6db10baf93
@@ -4,7 +4,7 @@
 *************************************************/

 #include <botan/eme.h>
-#include <botan/rng.h>
+#include <botan/libstate.h>
 #include <botan/lookup.h>
 #include <botan/look_pk.h>
 #include <memory>
@@ -26,7 +26,7 @@ SecureVector<byte> EME1::pad(const byte

    out.clear();

-   Global_RNG::randomize(out, HASH_LENGTH);
+   global_state().randomize(out, HASH_LENGTH);

    out.copy(HASH_LENGTH, Phash, Phash.size());
    out[out.size() - in_length - 1] = 0x01;
============================================================
--- src/eme_pkcs.cpp	af8da75524147763c7388e694431ac39d8e012d7
+++ src/eme_pkcs.cpp	957e51a698ddf990fec5d003064ff4eb4a28607a
@@ -4,7 +4,7 @@
 *************************************************/

 #include <botan/eme.h>
-#include <botan/rng.h>
+#include <botan/libstate.h>

 namespace Botan {

@@ -26,7 +26,7 @@ SecureVector<byte> EME_PKCS1v15::pad(con
    out[0] = 0x02;
    for(u32bit j = 1; j != olen - inlen - 1; ++j)
       while(out[j] == 0)
-         out[j] = Global_RNG::random();
+         out[j] = global_state().random();
    out.copy(olen - inlen, in, inlen);

    return out;
============================================================
--- src/emsa4.cpp	fb05b67a47bbb8e2aae85ddecad268f8482551cc
+++ src/emsa4.cpp	dc0f0dbfdaed2ec2ae85bbeed3ff0303013c58fc
@@ -7,7 +7,7 @@
 #include <botan/lookup.h>
 #include <botan/look_pk.h>
 #include <botan/bit_ops.h>
-#include <botan/rng.h>
+#include <botan/libstate.h>

 namespace Botan {

@@ -43,7 +43,7 @@ SecureVector<byte> EMSA4::encoding_of(co
    const u32bit output_length = (output_bits + 7) / 8;

    SecureVector<byte> salt(SALT_SIZE);
-   Global_RNG::randomize(salt, SALT_SIZE);
+   global_state().randomize(salt, SALT_SIZE);

    for(u32bit j = 0; j != 8; ++j)
       hash->update(0);
============================================================
--- src/filter.cpp	cdf7148e946c93f3d08e48b7360029fe815f28ee
+++ src/filter.cpp	ee4772bcc40c136c29204a37c94201de730999ad
@@ -25,8 +25,6 @@ void Filter::send(const byte input[], u3
 *************************************************/
 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])
============================================================
--- src/keypair.cpp	f285c4e75e8fa14c1cad0eb6261adb476251dfc3
+++ src/keypair.cpp	4f2e835c21a1b15d2a497cf2b80b90ef2724bd86
@@ -5,7 +5,7 @@

 #include <botan/keypair.h>
 #include <botan/look_pk.h>
-#include <botan/rng.h>
+#include <botan/libstate.h>
 #include <memory>

 namespace Botan {
@@ -24,7 +24,7 @@ void check_key(PK_Encryptor* encryptor,
    std::auto_ptr<PK_Decryptor> dec(decryptor);

    SecureVector<byte> message(enc->maximum_input_size() - 1);
-   Global_RNG::randomize(message, message.size());
+   global_state().randomize(message, message.size());

    SecureVector<byte> ciphertext = enc->encrypt(message);
    if(ciphertext == message)
@@ -44,7 +44,7 @@ void check_key(PK_Signer* signer, PK_Ver
    std::auto_ptr<PK_Verifier> ver(verifier);

    SecureVector<byte> message(16);
-   Global_RNG::randomize(message, message.size());
+   global_state().randomize(message, message.size());

    SecureVector<byte> signature;

============================================================
--- src/libstate.cpp	5c0ae9a34f2214a7b11f0076172600bde71dbcb6
+++ src/libstate.cpp	46e21742f98783366ba944270205003f7b6e1707
@@ -7,10 +7,8 @@
 #include <botan/config.h>
 #include <botan/modules.h>
 #include <botan/engine.h>
-#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/selftest.h>
@@ -123,23 +121,6 @@ void Library_State::set_default_allocato
    }

 /*************************************************
-* 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)
@@ -161,6 +142,16 @@ void Library_State::randomize(byte out[]
    }

 /*************************************************
+* Get a byte from the global PRNG                *
+*************************************************/
+byte Library_State::random()
+   {
+   byte out;
+   rng->randomize(&out, 1);
+   return out;
+   }
+
+/*************************************************
 * Add a new entropy source to use                *
 *************************************************/
 void Library_State::add_entropy_source(EntropySource* src, bool last_in_list)
@@ -234,67 +225,6 @@ void Library_State::add_engine(Engine* e
    }

 /*************************************************
-* 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)
-   {
-   delete x509_state_obj;
-   x509_state_obj = new_x509_state_obj;
-   }
-
-/*************************************************
-* Get the X509 global state class                *
-*************************************************/
-X509_GlobalState& Library_State::x509_state()
-   {
-   if(!x509_state_obj)
-      x509_state_obj = new X509_GlobalState();
-
-   return (*x509_state_obj);
-   }
-
-/*************************************************
-* 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
@@ -327,12 +257,7 @@ void Library_State::initialize(const Ini
    rng_lock = get_mutex();

    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)
       add_allocator(mod_allocs[j]);
@@ -378,15 +303,10 @@ 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;
    }

 /*************************************************
@@ -394,12 +314,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>());
============================================================
--- src/make_prm.cpp	83c6312cc45c5657734b544d35e256d1e6d5feff
+++ src/make_prm.cpp	67084166fa8d39268b1743f5d5f1231d4265f427
@@ -29,8 +29,6 @@ BigInt random_prime(u32bit bits, const B

    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 B
       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 B
          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 B
          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;
-            }
          }
       }
    }
============================================================
--- src/modules.cpp	bd04ca7b4523ffba0fabc47e0bb99a5167cf695b
+++ src/modules.cpp	6f7f44e1c3b66c17ea4a6ffe4cd28152d08012cf
@@ -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>
 #include <botan/parsing.h>
@@ -95,24 +94,6 @@ Mutex_Factory* Builtin_Modules::mutex_fa
    }

 /*************************************************
-* 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
@@ -153,6 +134,18 @@ std::vector<EntropySource*> Builtin_Modu
    {
    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
@@ -224,14 +217,6 @@ std::vector<Engine*> Builtin_Modules::en
    }

 /*************************************************
-* 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) :
============================================================
--- src/numthry.cpp	5818781e08d5adb2212ff87aedd8514699835619
+++ src/numthry.cpp	ce29bfd5f77b486f69081a6884cf35374480821d
@@ -284,15 +284,12 @@ bool MillerRabin_Test::passes_test(const
    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)
============================================================
--- src/pbes1.cpp	9ff336e0d509325626e80c2dff2fdcfb462f7791
+++ src/pbes1.cpp	4d0a544192358205f1728ff1387c6a3d9d6ccafa
@@ -8,7 +8,7 @@
 #include <botan/ber_dec.h>
 #include <botan/parsing.h>
 #include <botan/lookup.h>
-#include <botan/rng.h>
+#include <botan/libstate.h>
 #include <algorithm>
 #include <memory>

@@ -86,7 +86,7 @@ void PBE_PKCS5v15::new_params()
    {
    iterations = 2048;
    salt.create(8);
-   Global_RNG::randomize(salt, salt.size());
+   global_state().randomize(salt, salt.size());
    }

 /*************************************************
============================================================
--- src/pbes2.cpp	d25db9a10db0db03145b7c4b681ef39e6ac3ee9f
+++ src/pbes2.cpp	3f302e265f72dbf7081b62e777febdf4d5b468aa
@@ -8,7 +8,7 @@
 #include <botan/ber_dec.h>
 #include <botan/parsing.h>
 #include <botan/lookup.h>
-#include <botan/rng.h>
+#include <botan/libstate.h>
 #include <botan/asn1_obj.h>
 #include <botan/oids.h>
 #include <algorithm>
@@ -87,8 +87,8 @@ void PBE_PKCS5v20::new_params()
    key_length = max_keylength_of(cipher_algo);
    salt.create(8);
    iv.create(block_size_of(cipher_algo));
-   Global_RNG::randomize(salt, salt.size());
-   Global_RNG::randomize(iv, iv.size());
+   global_state().randomize(salt, salt.size());
+   global_state().randomize(iv, iv.size());
    }

 /*************************************************
============================================================
--- src/randpool.cpp	a8b1457d392fffbdf66fe8e4bf50f2a4c97944ab
+++ src/randpool.cpp	ee4d60d4cf28a7075e1fc511de81f9af5494f8fa
@@ -59,7 +59,7 @@ void Randpool::update_buffer()
 *************************************************/
 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])
============================================================
--- src/s2k.cpp	18cad51f740efcc1961b093d061c1b0e79417679
+++ src/s2k.cpp	0772628727b4f4a862aeba06213e5972397e3a35
@@ -4,7 +4,7 @@
 *************************************************/

 #include <botan/s2k.h>
-#include <botan/rng.h>
+#include <botan/libstate.h>

 namespace Botan {

@@ -47,7 +47,7 @@ void S2K::new_random_salt(u32bit length)
 void S2K::new_random_salt(u32bit length)
    {
    salt.create(length);
-   Global_RNG::randomize(salt, length);
+   global_state().randomize(salt, length);
    }

 }
============================================================
--- src/symkey.cpp	5d1526f451b9ef883a132dba6ff6cfcebf7e4e4d
+++ src/symkey.cpp	585161d46a0cbfa100d6887b78449458cd115a7b
@@ -7,7 +7,7 @@
 #include <botan/bit_ops.h>
 #include <botan/pipe.h>
 #include <botan/hex.h>
-#include <botan/rng.h>
+#include <botan/libstate.h>
 #include <algorithm>

 namespace Botan {
@@ -18,7 +18,7 @@ void OctetString::change(u32bit length)
 void OctetString::change(u32bit length)
    {
    bits.create(length);
-   Global_RNG::randomize(bits, length);
+   global_state().randomize(bits, length);
    }

 /*************************************************
============================================================
--- src/timers.cpp	89a971d5ddfa26fdffd9395cb8f489811a9ec3cf
+++ src/timers.cpp	dfdece2313e3e2501b6feb29fce75ede18f72d5d
@@ -4,30 +4,38 @@
 *************************************************/

 #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()
+/*************************************************
+* Default Timer clock reading                    *
+*************************************************/
+u64bit Timer::clock() const
    {
-   return global_state().system_clock();
+   return combine_timers(std::time(0), std::clock(), CLOCKS_PER_SEC);
    }

 /*************************************************
-* Default Timer clock reading                    *
+* Read the clock and return the output           *
 *************************************************/
-u64bit Timer::clock() const
+u32bit Timer::slow_poll(byte out[], u32bit length)
    {
-   return combine_timers(std::time(0), std::clock(), CLOCKS_PER_SEC);
+   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;
    }

 /*************************************************
@@ -35,7 +43,7 @@ u64bit Timer::combine_timers(u32bit seco
 *************************************************/
 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);
    }
============================================================
--- src/x509_ext.cpp	73142667ecce6c88731ac958ec83140c4523680d
+++ src/x509_ext.cpp	5724ac53f27fc3f50ab9df3d44a1ed2f52b34517
@@ -4,8 +4,6 @@
 *************************************************/

 #include <botan/x509_ext.h>
-#include <botan/x509stat.h>
-#include <botan/libstate.h>
 #include <botan/der_enc.h>
 #include <botan/ber_dec.h>
 #include <botan/lookup.h>
@@ -18,6 +16,28 @@ namespace Botan {
 namespace Botan {

 /*************************************************
+* List of X.509 Certificate Extensions           *
+*************************************************/
+Certificate_Extension* Extensions::get_extension(const OID& oid)
+   {
+#define X509_EXTENSION(NAME, TYPE) \
+   if(OIDS::name_of(oid, NAME))    \
+      return new Cert_Extension::TYPE();
+
+   X509_EXTENSION("X509v3.KeyUsage", Key_Usage);
+   X509_EXTENSION("X509v3.BasicConstraints", Basic_Constraints);
+   X509_EXTENSION("X509v3.SubjectKeyIdentifier", Subject_Key_ID);
+   X509_EXTENSION("X509v3.AuthorityKeyIdentifier", Authority_Key_ID);
+   X509_EXTENSION("X509v3.ExtendedKeyUsage", Extended_Key_Usage);
+   X509_EXTENSION("X509v3.IssuerAlternativeName", Issuer_Alternative_Name);
+   X509_EXTENSION("X509v3.SubjectAlternativeName", Subject_Alternative_Name);
+   X509_EXTENSION("X509v3.CRLNumber", CRL_Number);
+   X509_EXTENSION("X509v3.CertificatePolicies", Certificate_Policies);
+
+   return 0;
+   }
+
+/*************************************************
 * Extensions Copy Constructor                    *
 *************************************************/
 Extensions::Extensions(const Extensions& extensions) : ASN1_Object()
@@ -107,8 +127,7 @@ void Extensions::decode_from(BER_Decoder
             .verify_end()
          .end_cons();

-      Certificate_Extension* ext =
-         global_state().x509_state().get_extension(oid);
+      Certificate_Extension* ext = get_extension(oid);

       if(!ext)
          {