aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/libstate.h5
-rw-r--r--include/x509_ext.h2
-rw-r--r--include/x509stat.h35
-rw-r--r--src/libstate.cpp24
-rw-r--r--src/x509_ext.cpp27
-rw-r--r--src/x509stat.cpp76
6 files changed, 25 insertions, 144 deletions
diff --git a/include/libstate.h b/include/libstate.h
index f8a1c6939..0b2a2959f 100644
--- a/include/libstate.h
+++ b/include/libstate.h
@@ -58,10 +58,6 @@ class Library_State
class Config& config() const;
class Mutex* get_mutex() const;
-
- void set_x509_state(class X509_GlobalState*);
- class X509_GlobalState& x509_state();
-
private:
Library_State(const Library_State&) {}
Library_State& operator=(const Library_State&) { return (*this); }
@@ -74,7 +70,6 @@ class Library_State
class Mutex* rng_lock;
mutable class Config* config_obj;
- class X509_GlobalState* x509_state_obj;
std::map<std::string, Allocator*> alloc_factory;
mutable Allocator* cached_default_allocator;
diff --git a/include/x509_ext.h b/include/x509_ext.h
index 13a58d7d5..63052f3c1 100644
--- a/include/x509_ext.h
+++ b/include/x509_ext.h
@@ -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;
};
diff --git a/include/x509stat.h b/include/x509stat.h
deleted file mode 100644
index c13cc31fa..000000000
--- a/include/x509stat.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*************************************************
-* Globally Saved X.509 State Header *
-* (C) 1999-2007 The Botan Project *
-*************************************************/
-
-#include <botan/asn1_oid.h>
-
-namespace Botan {
-
-/*************************************************
-* Prototype for a Certificate Extension *
-*************************************************/
-class Extension_Prototype
- {
- public:
- virtual class Certificate_Extension* make(const OID&) = 0;
- virtual ~Extension_Prototype() {}
- };
-
-/*************************************************
-* X.509 Global State *
-*************************************************/
-class X509_GlobalState
- {
- public:
- void add(Extension_Prototype*);
- class Certificate_Extension* get_extension(const OID&) const;
-
- X509_GlobalState();
- ~X509_GlobalState();
- private:
- std::vector<Extension_Prototype*> prototypes;
- };
-
-}
diff --git a/src/libstate.cpp b/src/libstate.cpp
index 7d3b633cd..7f0c41b83 100644
--- a/src/libstate.cpp
+++ b/src/libstate.cpp
@@ -7,7 +7,6 @@
#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/charset.h>
@@ -216,26 +215,6 @@ void Library_State::add_engine(Engine* engine)
}
/*************************************************
-* 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 configuration object *
*************************************************/
Config& Library_State::config() const
@@ -268,7 +247,6 @@ void Library_State::initialize(const InitializerOptions& args,
rng_lock = get_mutex();
cached_default_allocator = 0;
- x509_state_obj = 0;
std::vector<Allocator*> mod_allocs = modules.allocators();
for(u32bit j = 0; j != mod_allocs.size(); ++j)
@@ -316,7 +294,6 @@ Library_State::Library_State()
allocator_lock = engine_lock = rng_lock = 0;
config_obj = 0;
- x509_state_obj = 0;
rng = 0;
cached_default_allocator = 0;
@@ -327,7 +304,6 @@ Library_State::Library_State()
*************************************************/
Library_State::~Library_State()
{
- delete x509_state_obj;
delete rng;
delete config_obj;
diff --git a/src/x509_ext.cpp b/src/x509_ext.cpp
index 197a86004..1c655d057 100644
--- a/src/x509_ext.cpp
+++ b/src/x509_ext.cpp
@@ -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 {
/*************************************************
+* 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& from_source)
.verify_end()
.end_cons();
- Certificate_Extension* ext =
- global_state().x509_state().get_extension(oid);
+ Certificate_Extension* ext = get_extension(oid);
if(!ext)
{
diff --git a/src/x509stat.cpp b/src/x509stat.cpp
deleted file mode 100644
index 45b858c02..000000000
--- a/src/x509stat.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*************************************************
-* Globally Saved X.509 State Source *
-* (C) 1999-2007 The Botan Project *
-*************************************************/
-
-#include <botan/x509stat.h>
-#include <botan/x509_ext.h>
-#include <botan/oids.h>
-
-namespace Botan {
-
-/*************************************************
-* Add a new prototype *
-*************************************************/
-void X509_GlobalState::add(Extension_Prototype* proto)
- {
- if(proto)
- prototypes.push_back(proto);
- }
-
-/*************************************************
-* Get an extension object *
-*************************************************/
-Certificate_Extension* X509_GlobalState::get_extension(const OID& oid) const
- {
- Certificate_Extension* extension = 0;
- for(u32bit j = 0; j != prototypes.size() && !extension; ++j)
- extension = prototypes[j]->make(oid);
- return extension;
- }
-
-/*************************************************
-* Set up a new global state for X.509 *
-*************************************************/
-X509_GlobalState::X509_GlobalState()
- {
-
-#define CREATE_PROTOTYPE(NAME, TYPE) \
- do { \
- struct TYPE ## _Prototype : public Extension_Prototype \
- { \
- Certificate_Extension* make(const OID& oid) \
- { \
- if(Botan::OIDS::name_of(oid, NAME)) \
- return new Botan::Cert_Extension::TYPE(); \
- return 0; \
- } \
- }; \
- \
- add(new TYPE ## _Prototype); \
- } while(0);
-
- CREATE_PROTOTYPE("X509v3.KeyUsage", Key_Usage);
- CREATE_PROTOTYPE("X509v3.BasicConstraints", Basic_Constraints);
- CREATE_PROTOTYPE("X509v3.SubjectKeyIdentifier", Subject_Key_ID);
- CREATE_PROTOTYPE("X509v3.AuthorityKeyIdentifier", Authority_Key_ID);
- CREATE_PROTOTYPE("X509v3.ExtendedKeyUsage", Extended_Key_Usage);
- CREATE_PROTOTYPE("X509v3.IssuerAlternativeName", Issuer_Alternative_Name);
- CREATE_PROTOTYPE("X509v3.SubjectAlternativeName", Subject_Alternative_Name);
- CREATE_PROTOTYPE("X509v3.CRLNumber", CRL_Number);
- CREATE_PROTOTYPE("X509v3.CertificatePolicies", Certificate_Policies);
-
-#undef CREATE_PROTOTYPE
- }
-
-/*************************************************
-* Destroy this global state object *
-*************************************************/
-X509_GlobalState::~X509_GlobalState()
- {
- for(u32bit j = 0; j != prototypes.size(); ++j)
- delete prototypes[j];
- prototypes.clear();
- }
-
-}