aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <lloyd@randombit.net>2008-04-12 03:08:18 +0000
committerlloyd <lloyd@randombit.net>2008-04-12 03:08:18 +0000
commit66d92bc063a4cbb69e4242a15c3a90daa3db069e (patch)
treef48af6779692e324cbee3ee64cdf45c98a619f5f
parent21669116db5ccb075d92a24af763f7b8c7a32976 (diff)
Remove Config::option_as_u32bit - the only advantage it had over calling
to_u32but on the return value from Config::option was that it passed it through parse_expr, which did some simple evaluation tricks so you could say 64*1024. That does not seem worth the cost in code, especially because most of the values so controlled are probably never changed. By making them compile time constants, additional optimizations are possible in the source as well as by the compiler. Remove the pkcs8_tries config option. Hardcode that value to 3 instead. I want to rewrite that code in the relatively near future and all that will (hopefully) go away.
-rw-r--r--include/config.h1
-rw-r--r--include/parsing.h1
-rw-r--r--src/config.cpp8
-rw-r--r--src/parsing.cpp28
-rw-r--r--src/pk_core.cpp3
-rw-r--r--src/pkcs8.cpp3
-rw-r--r--src/policy.cpp1
7 files changed, 3 insertions, 42 deletions
diff --git a/include/config.h b/include/config.h
index 48f013573..86344cc86 100644
--- a/include/config.h
+++ b/include/config.h
@@ -31,7 +31,6 @@ class Config
const std::string&, bool = true);
std::string option(const std::string&) const;
- u32bit option_as_u32bit(const std::string&) const;
u32bit option_as_time(const std::string&) const;
void set_option(const std::string, const std::string&);
diff --git a/include/parsing.h b/include/parsing.h
index 93eb8c279..9c9128d33 100644
--- a/include/parsing.h
+++ b/include/parsing.h
@@ -19,7 +19,6 @@ std::vector<std::string> parse_algorithm_name(const std::string&);
std::vector<std::string> split_on(const std::string&, char);
std::vector<u32bit> parse_asn1_oid(const std::string&);
bool x500_name_cmp(const std::string&, const std::string&);
-u32bit parse_expr(const std::string&);
/*************************************************
* String/Integer Conversions *
diff --git a/src/config.cpp b/src/config.cpp
index b724f0e02..bcca49bdf 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -122,14 +122,6 @@ std::string Config::option(const std::string& key) const
}
/*************************************************
-* Get the config setting as a u32bit *
-*************************************************/
-u32bit Config::option_as_u32bit(const std::string& key) const
- {
- return parse_expr(option(key));
- }
-
-/*************************************************
* Get the config setting as a time *
*************************************************/
u32bit Config::option_as_time(const std::string& key) const
diff --git a/src/parsing.cpp b/src/parsing.cpp
index 3cb61cb44..59c0e3324 100644
--- a/src/parsing.cpp
+++ b/src/parsing.cpp
@@ -211,34 +211,6 @@ bool x500_name_cmp(const std::string& name1, const std::string& name2)
}
/*************************************************
-* Parse and compute an arithmetic expression *
-*************************************************/
-u32bit parse_expr(const std::string& expr)
- {
- const bool have_add = (expr.find('+') != std::string::npos);
- const bool have_mul = (expr.find('*') != std::string::npos);
-
- if(have_add)
- {
- std::vector<std::string> sub_expr = split_on(expr, '+');
- u32bit result = 0;
- for(u32bit j = 0; j != sub_expr.size(); ++j)
- result += parse_expr(sub_expr[j]);
- return result;
- }
- else if(have_mul)
- {
- std::vector<std::string> sub_expr = split_on(expr, '*');
- u32bit result = 1;
- for(u32bit j = 0; j != sub_expr.size(); ++j)
- result *= parse_expr(sub_expr[j]);
- return result;
- }
- else
- return to_u32bit(expr);
- }
-
-/*************************************************
* Convert a decimal-dotted string to binary IP *
*************************************************/
u32bit string_to_ipv4(const std::string& str)
diff --git a/src/pk_core.cpp b/src/pk_core.cpp
index 14b55543e..09170ff37 100644
--- a/src/pk_core.cpp
+++ b/src/pk_core.cpp
@@ -7,6 +7,7 @@
#include <botan/numthry.h>
#include <botan/engine.h>
#include <botan/config.h>
+#include <botan/parsing.h>
#include <algorithm>
namespace Botan {
@@ -19,7 +20,7 @@ namespace {
BigInt blinding_factor(u32bit modulus_size)
{
const u32bit BLINDING_BITS =
- global_config().option_as_u32bit("pk/blinder_size");
+ to_u32bit(global_config().option("pk/blinder_size"));
if(BLINDING_BITS == 0)
return 0;
diff --git a/src/pkcs8.cpp b/src/pkcs8.cpp
index c99be316c..b3366acd2 100644
--- a/src/pkcs8.cpp
+++ b/src/pkcs8.cpp
@@ -77,8 +77,7 @@ SecureVector<byte> PKCS8_decode(DataSource& source, const User_Interface& ui,
if(!is_encrypted)
key = key_data;
- const u32bit MAX_TRIES =
- global_config().option_as_u32bit("base/pkcs8_tries");
+ const u32bit MAX_TRIES = 3;
u32bit tries = 0;
while(true)
diff --git a/src/policy.cpp b/src/policy.cpp
index f58e1ba99..57fdb139e 100644
--- a/src/policy.cpp
+++ b/src/policy.cpp
@@ -212,7 +212,6 @@ void set_default_aliases(Config& config)
*************************************************/
void set_default_config(Config& config)
{
- config.set_option("base/pkcs8_tries", "3");
config.set_option("base/default_pbe",
"PBE-PKCS5v20(SHA-1,TripleDES/CBC)");
config.set_option("base/default_allocator", "malloc");