diff options
author | lloyd <[email protected]> | 2006-05-18 18:33:19 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2006-05-18 18:33:19 +0000 |
commit | a2c99d3270eb73ef2db5704fc54356c6b75096f8 (patch) | |
tree | ad3d6c4fcc8dd0f403f8105598943616246fe172 /src/pk_keys.cpp |
Initial checkin1.5.6
Diffstat (limited to 'src/pk_keys.cpp')
-rw-r--r-- | src/pk_keys.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/pk_keys.cpp b/src/pk_keys.cpp new file mode 100644 index 000000000..6d6f784b2 --- /dev/null +++ b/src/pk_keys.cpp @@ -0,0 +1,68 @@ +/************************************************* +* PK Key Types Source File * +* (C) 1999-2006 The Botan Project * +*************************************************/ + +#include <botan/pk_keys.h> +#include <botan/conf.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 = Config::get_string("pk/test/" + type); + if(setting == "basic") + return false; + return true; + } + +} + +/************************************************* +* Default OID access * +*************************************************/ +OID PK_Key::get_oid() const + { + try { + return OIDS::lookup(algo_name()); + } + catch(Lookup_Error) + { + throw Lookup_Error("PK algo " + algo_name() + " has no defined OIDs"); + } + } + +/************************************************* +* Run checks on a loaded public key * +*************************************************/ +void PK_Key::check_loaded_public() const + { + if(!check_key(key_check_level("public"))) + throw Invalid_Argument(algo_name() + ": Invalid public key"); + } + +/************************************************* +* Run checks on a loaded private key * +*************************************************/ +void PK_Key::check_loaded_private() const + { + if(!check_key(key_check_level("private"))) + throw Invalid_Argument(algo_name() + ": Invalid private key"); + } + +/************************************************* +* Run checks on a generated private key * +*************************************************/ +void PK_Key::check_generated_private() const + { + if(!check_key(key_check_level("private_gen"))) + throw Self_Test_Failure(algo_name() + " private key generation failed"); + } + +} |