[Botan-devel] Considering merge of n.r.b.remove-libstate, request for review

Jack Lloyd lloyd at randombit.net
Thu Apr 17 12:15:00 EDT 2008


There is still a lot of work left to go on remove-libstate but I am
pretty happy with what is in there now and considering a merge at this
point to push what has been done into 1.7.6.

Attached is a diff of the include/ files versus n.r.b mainline (1.7.5,
more or less). Full diff available via monotone (or email me).

Notable:
  rng.h / Global_RNG namespace are gone:
     Global_RNG was always just a facade around accessing the global
     random number generator. Force all callers accessing the global
     state to access it directly instead. (The idea of
     .remove-libstate is eventually the global RNG/Library_State
     object goes away entirely, and functions that need access to an
     RNG are passed a reference to one explicitly).

  Timer objects are entropy sources / system_clock goes away:
     Timer values are fed into the RNG during a poll, but are not used
     during generation (which Randpool previously did use: instead of
     a counter+timestamp to mix into the pool, only a counter is used)
     (This does mean we could use more than one, though this is not
     the case currently).

  UI, Charset_Transcoder, and X509_GlobalState are removed entirely.

Comments about what I'm doing here would be appreciated. If I don't
hear anything, this will probably land sometime early next week.

-Jack
-------------- next part --------------
#
# old_revision [85596a0b1fbee6696261d36def7dad742375f7d9]
#
# delete "include/def_char.h"
# 
# delete "include/rng.h"
# 
# delete "include/x509stat.h"
# 
# patch "include/botan.h"
#  from [221f7daa0502628bd269bea853806056ff68f965]
#    to [e8deb87811288cd18988ea6087bc31fdfe7b1f66]
# 
# patch "include/buf_es.h"
#  from [bd1753e4e7fadd64f774b874e1e2b0557bad8a9b]
#    to [bf69fc56fb8169929d529afc2e911f954408a838]
# 
# patch "include/charset.h"
#  from [190ea188126117198e9ea487740c472d317b5b12]
#    to [d14be390cbcd1b0b0a33005c0c6b2165c66fd8b1]
# 
# patch "include/libstate.h"
#  from [d6b846b9bb2fde1aa134ff88409e7972ba3f229c]
#    to [f08d397ce253b7d175d4dfc30ccd9f1ddee48279]
# 
# patch "include/modules.h"
#  from [3df00e474fd54aa6d8d6a7e061a11d6e8ec91e2a]
#    to [f9acec52a4673e8190322182af16df37231aa2dc]
# 
# patch "include/timers.h"
#  from [30ce6b52c2033dd4b7e07d481cad8f5645b64559]
#    to [daca1eda904eb675a4650496aa1c9e61360a5bc8]
# 
# patch "include/util.h"
#  from [aa94cc91d4d5605f8dae20fd20ce5fc364867b37]
#    to [f4cfec7dc5d51e8ac7356cd289c1b0599f24216a]
# 
# patch "include/x509_ext.h"
#  from [5dadb128c26e85f79f355a2d889b2389de39789f]
#    to [b43b458be1f994c023d5f73991e9b6097fcf0247]
#
============================================================
--- 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	bd1753e4e7fadd64f774b874e1e2b0557bad8a9b
+++ include/buf_es.h	bf69fc56fb8169929d529afc2e911f954408a838
@@ -24,7 +24,6 @@ class Buffered_EntropySource : public En
 
       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	190ea188126117198e9ea487740c472d317b5b12
+++ include/charset.h	d14be390cbcd1b0b0a33005c0c6b2165c66fd8b1
@@ -12,18 +12,6 @@ namespace Botan {
 
 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 {
 
 /*************************************************
============================================================
--- include/libstate.h	d6b846b9bb2fde1aa134ff88409e7972ba3f229c
+++ include/libstate.h	f08d397ce253b7d175d4dfc30ccd9f1ddee48279
@@ -42,19 +42,13 @@ 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;
 
       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 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 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	3df00e474fd54aa6d8d6a7e061a11d6e8ec91e2a
+++ include/modules.h	f9acec52a4673e8190322182af16df37231aa2dc
@@ -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;
 
============================================================
--- include/timers.h	30ce6b52c2033dd4b7e07d481cad8f5645b64559
+++ include/timers.h	daca1eda904eb675a4650496aa1c9e61360a5bc8
@@ -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);
============================================================
--- include/util.h	aa94cc91d4d5605f8dae20fd20ce5fc364867b37
+++ include/util.h	f4cfec7dc5d51e8ac7356cd289c1b0599f24216a
@@ -11,10 +11,9 @@ namespace Botan {
 namespace Botan {
 
 /*************************************************
-* Timer Access Functions                         *
+* Time Access Functions                          *
 *************************************************/
 u64bit system_time();
-u64bit system_clock();
 
 /*************************************************
 * Memory Locking Functions                       *
============================================================
--- include/x509_ext.h	5dadb128c26e85f79f355a2d889b2389de39789f
+++ include/x509_ext.h	b43b458be1f994c023d5f73991e9b6097fcf0247
@@ -56,6 +56,8 @@ class Extensions : public ASN1_Object
       Extensions(bool st = true) : should_throw(st) {}
       ~Extensions();
    private:
+      static Certificate_Extension* get_extension(const OID&);
+
       std::vector<Certificate_Extension*> extensions;
       bool should_throw;
    };


More information about the botan-devel mailing list