diff options
author | lloyd <[email protected]> | 2009-07-15 15:12:20 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-07-15 15:12:20 +0000 |
commit | 6fd01228840942ad122d1adabb3f7971a4e3b244 (patch) | |
tree | 57df224bd849d325e9747a374c85784abdd0e76c /src/pubkey/pk_keys.cpp | |
parent | 11470400cd77cbd20f60247f0a07fcac45772646 (diff) |
Move the contents of pubkey/pubkey (which was kind of a catch-all to
just toplevel pubkey). This was a convention I realized made sense sometime
on when I was first doing the modularization changes.
Move pkcs8.* and x509_key.* to pk_codecs
Diffstat (limited to 'src/pubkey/pk_keys.cpp')
-rw-r--r-- | src/pubkey/pk_keys.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/pubkey/pk_keys.cpp b/src/pubkey/pk_keys.cpp new file mode 100644 index 000000000..b93158558 --- /dev/null +++ b/src/pubkey/pk_keys.cpp @@ -0,0 +1,54 @@ +/* +* PK Key Types +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#include <botan/pk_keys.h> +#include <botan/oids.h> + +namespace Botan { + +/* +* Default OID access +*/ +OID Public_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 Public_Key::load_check(RandomNumberGenerator& rng) const + { + if(!check_key(rng, BOTAN_PUBLIC_KEY_STRONG_CHECKS_ON_LOAD)) + throw Invalid_Argument(algo_name() + ": Invalid public key"); + } + +/* +* Run checks on a loaded private key +*/ +void Private_Key::load_check(RandomNumberGenerator& rng) const + { + if(!check_key(rng, BOTAN_PRIVATE_KEY_STRONG_CHECKS_ON_LOAD)) + throw Invalid_Argument(algo_name() + ": Invalid private key"); + } + +/* +* Run checks on a generated private key +*/ +void Private_Key::gen_check(RandomNumberGenerator& rng) const + { + if(!check_key(rng, BOTAN_PRIVATE_KEY_STRONG_CHECKS_ON_GENERATE)) + throw Self_Test_Failure(algo_name() + " private key generation failed"); + } + +} |