aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/config.h5
-rw-r--r--include/libstate.h1
-rw-r--r--src/asn1_str.cpp15
-rw-r--r--src/config.cpp8
-rw-r--r--src/crl_ent.cpp4
-rw-r--r--src/dl_group.cpp3
-rw-r--r--src/libstate.cpp12
-rw-r--r--src/oids.cpp15
-rw-r--r--src/pk_keys.cpp4
-rw-r--r--src/pkcs8.cpp4
-rw-r--r--src/x509_ca.cpp9
-rw-r--r--src/x509_crl.cpp4
-rw-r--r--src/x509_ext.cpp4
-rw-r--r--src/x509stor.cpp6
14 files changed, 48 insertions, 46 deletions
diff --git a/include/config.h b/include/config.h
index 2c513088a..65147e3e6 100644
--- a/include/config.h
+++ b/include/config.h
@@ -42,11 +42,6 @@ class BOTAN_DLL Config
Mutex* mutex;
};
-/*************************************************
-* Hook for the global config *
-*************************************************/
-BOTAN_DLL Config& global_config();
-
}
#endif
diff --git a/include/libstate.h b/include/libstate.h
index 51be2431e..63c01d270 100644
--- a/include/libstate.h
+++ b/include/libstate.h
@@ -46,6 +46,7 @@ class BOTAN_DLL Library_State
void set_default_allocator(const std::string&) const;
class Config& config() const;
+ std::string option(const std::string&) const;
class Mutex* get_mutex() const;
private:
diff --git a/src/asn1_str.cpp b/src/asn1_str.cpp
index 22809345d..52dcdc55e 100644
--- a/src/asn1_str.cpp
+++ b/src/asn1_str.cpp
@@ -8,7 +8,7 @@
#include <botan/ber_dec.h>
#include <botan/charset.h>
#include <botan/parsing.h>
-#include <botan/config.h>
+#include <botan/libstate.h>
namespace Botan {
@@ -17,7 +17,8 @@ namespace {
/*************************************************
* Choose an encoding for the string *
*************************************************/
-ASN1_Tag choose_encoding(const std::string& str)
+ASN1_Tag choose_encoding(const std::string& str,
+ const std::string& type)
{
static const byte IS_PRINTABLE[256] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -44,14 +45,14 @@ ASN1_Tag choose_encoding(const std::string& str)
0x00, 0x00, 0x00, 0x00 };
for(u32bit j = 0; j != str.size(); ++j)
+ {
if(!IS_PRINTABLE[static_cast<byte>(str[j])])
{
- const std::string type = global_config().option("x509/ca/str_type");
-
if(type == "utf8") return UTF8_STRING;
if(type == "latin1") return T61_STRING;
throw Invalid_Argument("Bad setting for x509/ca/str_type: " + type);
}
+ }
return PRINTABLE_STRING;
}
@@ -77,7 +78,8 @@ ASN1_String::ASN1_String(const std::string& str, ASN1_Tag t) : tag(t)
iso_8859_str = Charset::transcode(str, LOCAL_CHARSET, LATIN1_CHARSET);
if(tag == DIRECTORY_STRING)
- tag = choose_encoding(iso_8859_str);
+ tag = choose_encoding(iso_8859_str,
+ global_state().option("x509/ca/str_type"));
if(tag != NUMERIC_STRING &&
tag != PRINTABLE_STRING &&
@@ -96,7 +98,8 @@ ASN1_String::ASN1_String(const std::string& str, ASN1_Tag t) : tag(t)
ASN1_String::ASN1_String(const std::string& str)
{
iso_8859_str = Charset::transcode(str, LOCAL_CHARSET, LATIN1_CHARSET);
- tag = choose_encoding(iso_8859_str);
+ tag = choose_encoding(iso_8859_str,
+ global_state().option("x509/ca/str_type"));
}
/*************************************************
diff --git a/src/config.cpp b/src/config.cpp
index f274de560..121335c7d 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -13,14 +13,6 @@
namespace Botan {
/*************************************************
-* Get the global configuration object *
-*************************************************/
-Config& global_config()
- {
- return global_state().config();
- }
-
-/*************************************************
* Dereference an alias *
*************************************************/
std::string deref_alias(const std::string& name)
diff --git a/src/crl_ent.cpp b/src/crl_ent.cpp
index 180640d6e..4a85b99c2 100644
--- a/src/crl_ent.cpp
+++ b/src/crl_ent.cpp
@@ -8,7 +8,7 @@
#include <botan/der_enc.h>
#include <botan/ber_dec.h>
#include <botan/bigint.h>
-#include <botan/config.h>
+#include <botan/libstate.h>
#include <botan/oids.h>
#include <botan/util.h>
@@ -92,7 +92,7 @@ void CRL_Entry::decode_from(BER_Decoder& source)
if(source.more_items())
{
std::string action =
- global_config().option("x509/crl/unknown_critical");
+ global_state().option("x509/crl/unknown_critical");
if(action != "throw" && action != "ignore")
throw Invalid_Argument("Bad setting x509/crl/unknown_critical: "
diff --git a/src/dl_group.cpp b/src/dl_group.cpp
index 523129327..5db2c045b 100644
--- a/src/dl_group.cpp
+++ b/src/dl_group.cpp
@@ -5,6 +5,7 @@
#include <botan/dl_group.h>
#include <botan/config.h>
+#include <botan/libstate.h>
#include <botan/parsing.h>
#include <botan/numthry.h>
#include <botan/der_enc.h>
@@ -28,7 +29,7 @@ DL_Group::DL_Group()
*************************************************/
DL_Group::DL_Group(const std::string& type)
{
- std::string grp_contents = global_config().get("dl", type);
+ std::string grp_contents = global_state().config().get("dl", type);
if(grp_contents == "")
throw Invalid_Argument("DL_Group: Unknown group " + type);
diff --git a/src/libstate.cpp b/src/libstate.cpp
index 8b1e04cdb..d0848b52d 100644
--- a/src/libstate.cpp
+++ b/src/libstate.cpp
@@ -1,6 +1,6 @@
/*************************************************
* Library Internal/Global State Source File *
-* (C) 1999-2007 Jack Lloyd *
+* (C) 1999-2008 Jack Lloyd *
*************************************************/
#include <botan/libstate.h>
@@ -143,7 +143,7 @@ void Library_State::add_engine(Engine* engine)
}
/*************************************************
-* Set the configuration object *
+* Get the configuration object *
*************************************************/
Config& Library_State::config() const
{
@@ -157,6 +157,14 @@ Config& Library_State::config() const
}
/*************************************************
+* Set the configuration object *
+*************************************************/
+std::string Library_State::option(const std::string& name) const
+ {
+ return config().option(name);
+ }
+
+/*************************************************
* Load a set of modules *
*************************************************/
void Library_State::initialize(const InitializerOptions& args,
diff --git a/src/oids.cpp b/src/oids.cpp
index da81e7718..8402edb18 100644
--- a/src/oids.cpp
+++ b/src/oids.cpp
@@ -5,6 +5,7 @@
#include <botan/oids.h>
#include <botan/config.h>
+#include <botan/libstate.h>
namespace Botan {
@@ -17,10 +18,10 @@ void add_oid(const OID& oid, const std::string& name)
{
const std::string oid_str = oid.as_string();
- if(!global_config().is_set("oid2str", oid_str))
- global_config().set("oid2str", oid_str, name);
- if(!global_config().is_set("str2oid", name))
- global_config().set("str2oid", name, oid_str);
+ if(!global_state().config().is_set("oid2str", oid_str))
+ global_state().config().set("oid2str", oid_str, name);
+ if(!global_state().config().is_set("str2oid", name))
+ global_state().config().set("str2oid", name, oid_str);
}
/*************************************************
@@ -28,7 +29,7 @@ void add_oid(const OID& oid, const std::string& name)
*************************************************/
std::string lookup(const OID& oid)
{
- std::string name = global_config().get("oid2str", oid.as_string());
+ std::string name = global_state().config().get("oid2str", oid.as_string());
if(name == "")
return oid.as_string();
return name;
@@ -39,7 +40,7 @@ std::string lookup(const OID& oid)
*************************************************/
OID lookup(const std::string& name)
{
- std::string value = global_config().get("str2oid", name);
+ std::string value = global_state().config().get("str2oid", name);
if(value != "")
return OID(value);
@@ -58,7 +59,7 @@ OID lookup(const std::string& name)
*************************************************/
bool have_oid(const std::string& name)
{
- return global_config().is_set("str2oid", name);
+ return global_state().config().is_set("str2oid", name);
}
/*************************************************
diff --git a/src/pk_keys.cpp b/src/pk_keys.cpp
index c442b7555..d991f3788 100644
--- a/src/pk_keys.cpp
+++ b/src/pk_keys.cpp
@@ -4,7 +4,7 @@
*************************************************/
#include <botan/pk_keys.h>
-#include <botan/config.h>
+#include <botan/libstate.h>
#include <botan/oids.h>
namespace Botan {
@@ -16,7 +16,7 @@ namespace {
*************************************************/
bool key_check_level(const std::string& type)
{
- const std::string setting = global_config().option("pk/test/" + type);
+ const std::string setting = global_state().option("pk/test/" + type);
if(setting == "basic")
return false;
return true;
diff --git a/src/pkcs8.cpp b/src/pkcs8.cpp
index fe5041a62..c19b7d507 100644
--- a/src/pkcs8.cpp
+++ b/src/pkcs8.cpp
@@ -8,7 +8,7 @@
#include <botan/ber_dec.h>
#include <botan/asn1_obj.h>
#include <botan/pk_algs.h>
-#include <botan/config.h>
+#include <botan/libstate.h>
#include <botan/oids.h>
#include <botan/pem.h>
#include <botan/pbe.h>
@@ -166,7 +166,7 @@ void encrypt_key(const Private_Key& key,
const std::string& pass, const std::string& pbe_algo,
X509_Encoding encoding)
{
- const std::string DEFAULT_PBE = global_config().option("base/default_pbe");
+ const std::string DEFAULT_PBE = global_state().option("base/default_pbe");
Pipe raw_key;
raw_key.start_msg();
diff --git a/src/x509_ca.cpp b/src/x509_ca.cpp
index a1bac73bb..24cc35a74 100644
--- a/src/x509_ca.cpp
+++ b/src/x509_ca.cpp
@@ -7,6 +7,7 @@
#include <botan/x509stor.h>
#include <botan/der_enc.h>
#include <botan/ber_dec.h>
+#include <botan/libstate.h>
#include <botan/config.h>
#include <botan/lookup.h>
#include <botan/look_pk.h>
@@ -188,7 +189,7 @@ X509_CRL X509_CA::make_crl(const std::vector<CRL_Entry>& revoked,
if(next_update == 0)
next_update = timespec_to_u32bit(
- global_config().option("x509/crl/next_update"));
+ global_state().option("x509/crl/next_update"));
// Totally stupid: ties encoding logic to the return of std::time!!
const u64bit current_time = system_time();
@@ -252,19 +253,19 @@ PK_Signer* choose_sig_format(const Private_Key& key,
if(algo_name == "RSA")
{
- std::string hash = global_config().option("x509/ca/rsa_hash");
+ std::string hash = global_state().option("x509/ca/rsa_hash");
if(hash == "")
throw Invalid_State("No value set for x509/ca/rsa_hash");
- hash = global_config().deref_alias(hash);
+ hash = global_state().config().deref_alias(hash);
padding = "EMSA3(" + hash + ")";
format = IEEE_1363;
}
else if(algo_name == "DSA")
{
- std::string hash = global_config().deref_alias("SHA-1");
+ std::string hash = global_state().config().deref_alias("SHA-1");
padding = "EMSA1(" + hash + ")";
format = DER_SEQUENCE;
}
diff --git a/src/x509_crl.cpp b/src/x509_crl.cpp
index 6bd1ecd5d..306c78bd1 100644
--- a/src/x509_crl.cpp
+++ b/src/x509_crl.cpp
@@ -8,7 +8,7 @@
#include <botan/ber_dec.h>
#include <botan/parsing.h>
#include <botan/bigint.h>
-#include <botan/config.h>
+#include <botan/libstate.h>
#include <botan/oids.h>
namespace Botan {
@@ -78,7 +78,7 @@ void X509_CRL::force_decode()
{
BER_Decoder crl_options(next.value);
- std::string action = global_config().option("x509/crl/unknown_critical");
+ std::string action = global_state().option("x509/crl/unknown_critical");
if(action != "throw" && action != "ignore")
throw Invalid_Argument("Bad value of x509/crl/unknown_critical: "
+ action);
diff --git a/src/x509_ext.cpp b/src/x509_ext.cpp
index 42a5bad01..3595a0492 100644
--- a/src/x509_ext.cpp
+++ b/src/x509_ext.cpp
@@ -8,7 +8,7 @@
#include <botan/ber_dec.h>
#include <botan/lookup.h>
#include <botan/oids.h>
-#include <botan/config.h>
+#include <botan/libstate.h>
#include <botan/bit_ops.h>
#include <algorithm>
#include <memory>
@@ -80,7 +80,7 @@ void Extensions::encode_into(DER_Encoder& to_object) const
std::string setting;
if(ext->config_id() != "")
- setting = global_config().option("x509/exts/" + ext->config_id());
+ setting = global_state().option("x509/exts/" + ext->config_id());
if(setting == "")
setting = "yes";
diff --git a/src/x509stor.cpp b/src/x509stor.cpp
index dcbc31942..6eb79286c 100644
--- a/src/x509stor.cpp
+++ b/src/x509stor.cpp
@@ -8,7 +8,7 @@
#include <botan/pubkey.h>
#include <botan/look_pk.h>
#include <botan/oids.h>
-#include <botan/config.h>
+#include <botan/libstate.h>
#include <botan/util.h>
#include <algorithm>
#include <memory>
@@ -173,10 +173,10 @@ X509_Store::X509_Store()
revoked_info_valid = true;
time_slack = timespec_to_u32bit(
- global_config().option("x509/validity_slack"));
+ global_state().option("x509/validity_slack"));
validation_cache_timeout = timespec_to_u32bit(
- global_config().option("x509/cache_verify_results"));
+ global_state().option("x509/cache_verify_results"));
}
/*************************************************