From 66d92bc063a4cbb69e4242a15c3a90daa3db069e Mon Sep 17 00:00:00 2001 From: lloyd Date: Sat, 12 Apr 2008 03:08:18 +0000 Subject: 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. --- include/config.h | 1 - include/parsing.h | 1 - src/config.cpp | 8 -------- src/parsing.cpp | 28 ---------------------------- src/pk_core.cpp | 3 ++- src/pkcs8.cpp | 3 +-- src/policy.cpp | 1 - 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 parse_algorithm_name(const std::string&); std::vector split_on(const std::string&, char); std::vector 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 @@ -121,14 +121,6 @@ std::string Config::option(const std::string& key) const return get("conf", key); } -/************************************************* -* 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 * *************************************************/ diff --git a/src/parsing.cpp b/src/parsing.cpp index 3cb61cb44..59c0e3324 100644 --- a/src/parsing.cpp +++ b/src/parsing.cpp @@ -210,34 +210,6 @@ bool x500_name_cmp(const std::string& name1, const std::string& name2) return true; } -/************************************************* -* 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 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 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 * *************************************************/ 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 #include #include +#include #include 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 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"); -- cgit v1.2.3