Botan
1.11.15
|
00001 /* 00002 * PK Key Types 00003 * (C) 1999-2007 Jack Lloyd 00004 * 00005 * Botan is released under the Simplified BSD License (see license.txt) 00006 */ 00007 00008 #include <botan/pk_keys.h> 00009 #include <botan/der_enc.h> 00010 #include <botan/oids.h> 00011 00012 namespace Botan { 00013 00014 /* 00015 * Default OID access 00016 */ 00017 OID Public_Key::get_oid() const 00018 { 00019 try { 00020 return OIDS::lookup(algo_name()); 00021 } 00022 catch(Lookup_Error) 00023 { 00024 throw Lookup_Error("PK algo " + algo_name() + " has no defined OIDs"); 00025 } 00026 } 00027 00028 /* 00029 * Run checks on a loaded public key 00030 */ 00031 void Public_Key::load_check(RandomNumberGenerator& rng) const 00032 { 00033 if(!check_key(rng, BOTAN_PUBLIC_KEY_STRONG_CHECKS_ON_LOAD)) 00034 throw Invalid_Argument(algo_name() + ": Invalid public key"); 00035 } 00036 00037 /* 00038 * Run checks on a loaded private key 00039 */ 00040 void Private_Key::load_check(RandomNumberGenerator& rng) const 00041 { 00042 if(!check_key(rng, BOTAN_PRIVATE_KEY_STRONG_CHECKS_ON_LOAD)) 00043 throw Invalid_Argument(algo_name() + ": Invalid private key"); 00044 } 00045 00046 /* 00047 * Run checks on a generated private key 00048 */ 00049 void Private_Key::gen_check(RandomNumberGenerator& rng) const 00050 { 00051 if(!check_key(rng, BOTAN_PRIVATE_KEY_STRONG_CHECKS_ON_GENERATE)) 00052 throw Self_Test_Failure(algo_name() + " private key generation failed"); 00053 } 00054 00055 }