~ubuntu-branches/debian/sid/botan/sid

« back to all changes in this revision

Viewing changes to src/pk_keys.cpp

  • Committer: Package Import Robot
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2018-03-01 22:23:25 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20180301222325-7p7vc45gu3hta34d
Tags: 2.4.0-2
* Don't remove .doctrees from the manual if it doesn't exist.
* Don't specify parallel to debhelper.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
 
10
 
namespace Botan {
11
 
 
12
 
namespace {
13
 
 
14
 
/*************************************************
15
 
* Find out how much testing should be performed  *
16
 
*************************************************/
17
 
bool 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
 
*************************************************/
30
 
OID 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
 
*************************************************/
44
 
void 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
 
*************************************************/
53
 
void 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
 
*************************************************/
62
 
void 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
 
}