monotone

monotone Mtn Source Tree

Root/botan/pk_keys.cpp

1/*************************************************
2* PK Key Types Source File *
3* (C) 1999-2007 The Botan Project *
4*************************************************/
5
6#include <botan/pk_keys.h>
7#include <botan/config.h>
8#include <botan/oids.h>
9
10namespace Botan {
11
12namespace {
13
14/*************************************************
15* Find out how much testing should be performed *
16*************************************************/
17bool key_check_level(const std::string& type)
18 {
19 const std::string setting = global_config().option("pk/test/" + type);
20 if(setting == "basic")
21 return false;
22 return true;
23 }
24
25}
26
27/*************************************************
28* Default OID access *
29*************************************************/
30OID Public_Key::get_oid() const
31 {
32 try {
33 return OIDS::lookup(algo_name());
34 }
35 catch(Lookup_Error)
36 {
37 throw Lookup_Error("PK algo " + algo_name() + " has no defined OIDs");
38 }
39 }
40
41/*************************************************
42* Run checks on a loaded public key *
43*************************************************/
44void Public_Key::load_check() const
45 {
46 if(!check_key(key_check_level("public")))
47 throw Invalid_Argument(algo_name() + ": Invalid public key");
48 }
49
50/*************************************************
51* Run checks on a loaded private key *
52*************************************************/
53void Private_Key::load_check() const
54 {
55 if(!check_key(key_check_level("private")))
56 throw Invalid_Argument(algo_name() + ": Invalid private key");
57 }
58
59/*************************************************
60* Run checks on a generated private key *
61*************************************************/
62void Private_Key::gen_check() const
63 {
64 if(!check_key(key_check_level("private_gen")))
65 throw Self_Test_Failure(algo_name() + " private key generation failed");
66 }
67
68}

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status