diff options
author | lloyd <[email protected]> | 2008-11-11 02:20:08 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-11-11 02:20:08 +0000 |
commit | daffc235589fb8ec2f4090ba5fb8511462b4a843 (patch) | |
tree | 22649e0764d0bf280aa89b5eca5316d6082e37f0 /src | |
parent | 3dbf2df27a12fd3daf8f42d58659f327fbd5609c (diff) |
Make the level of key consistency checking performed be a build constant
instead of runtime configurable.
Diffstat (limited to 'src')
-rw-r--r-- | src/build-data/buildh.in | 5 | ||||
-rw-r--r-- | src/pubkey/pubkey/pk_keys.cpp | 22 |
2 files changed, 8 insertions, 19 deletions
diff --git a/src/build-data/buildh.in b/src/build-data/buildh.in index 87ff62b72..d49f976fb 100644 --- a/src/build-data/buildh.in +++ b/src/build-data/buildh.in @@ -22,6 +22,11 @@ #define BOTAN_KARAT_SQR_THRESHOLD 32 #define BOTAN_PRIVATE_KEY_OP_BLINDING_BITS 64 +/* PK key consistency checking toggles */ +#define BOTAN_PUBLIC_KEY_STRONG_CHECKS_ON_LOAD 1 +#define BOTAN_PRIVATE_KEY_STRONG_CHECKS_ON_LOAD 1 +#define BOTAN_PRIVATE_KEY_STRONG_CHECKS_ON_GENERATE 1 + /* Should we use GCC-style inline assembler? */ #if !defined(BOTAN_USE_GCC_INLINE_ASM) && defined(__GNUG__) #define BOTAN_USE_GCC_INLINE_ASM 1 diff --git a/src/pubkey/pubkey/pk_keys.cpp b/src/pubkey/pubkey/pk_keys.cpp index d991f3788..758d34dee 100644 --- a/src/pubkey/pubkey/pk_keys.cpp +++ b/src/pubkey/pubkey/pk_keys.cpp @@ -4,26 +4,10 @@ *************************************************/ #include <botan/pk_keys.h> -#include <botan/libstate.h> #include <botan/oids.h> namespace Botan { -namespace { - -/************************************************* -* Find out how much testing should be performed * -*************************************************/ -bool key_check_level(const std::string& type) - { - const std::string setting = global_state().option("pk/test/" + type); - if(setting == "basic") - return false; - return true; - } - -} - /************************************************* * Default OID access * *************************************************/ @@ -43,7 +27,7 @@ OID Public_Key::get_oid() const *************************************************/ void Public_Key::load_check(RandomNumberGenerator& rng) const { - if(!check_key(rng, key_check_level("public"))) + if(!check_key(rng, BOTAN_PUBLIC_KEY_STRONG_CHECKS_ON_LOAD)) throw Invalid_Argument(algo_name() + ": Invalid public key"); } @@ -52,7 +36,7 @@ void Public_Key::load_check(RandomNumberGenerator& rng) const *************************************************/ void Private_Key::load_check(RandomNumberGenerator& rng) const { - if(!check_key(rng, key_check_level("private"))) + if(!check_key(rng, BOTAN_PRIVATE_KEY_STRONG_CHECKS_ON_LOAD)) throw Invalid_Argument(algo_name() + ": Invalid private key"); } @@ -61,7 +45,7 @@ void Private_Key::load_check(RandomNumberGenerator& rng) const *************************************************/ void Private_Key::gen_check(RandomNumberGenerator& rng) const { - if(!check_key(rng, key_check_level("private_gen"))) + if(!check_key(rng, BOTAN_PRIVATE_KEY_STRONG_CHECKS_ON_GENERATE)) throw Self_Test_Failure(algo_name() + " private key generation failed"); } |