Botan 1.10.17
pk_keys.cpp
Go to the documentation of this file.
1/*
2* PK Key Types
3* (C) 1999-2007 Jack Lloyd
4*
5* Distributed under the terms of the Botan license
6*/
7
8#include <botan/pk_keys.h>
9#include <botan/der_enc.h>
10#include <botan/oids.h>
11
12namespace Botan {
13
14/*
15* Default OID access
16*/
18 {
19 try {
20 return OIDS::lookup(algo_name());
21 }
22 catch(Lookup_Error)
23 {
24 throw Lookup_Error("PK algo " + algo_name() + " has no defined OIDs");
25 }
26 }
27
28/*
29* Run checks on a loaded public key
30*/
32 {
33 if(!check_key(rng, BOTAN_PUBLIC_KEY_STRONG_CHECKS_ON_LOAD))
34 throw Invalid_Argument(algo_name() + ": Invalid public key");
35 }
36
37/*
38* Run checks on a loaded private key
39*/
41 {
42 if(!check_key(rng, BOTAN_PRIVATE_KEY_STRONG_CHECKS_ON_LOAD))
43 throw Invalid_Argument(algo_name() + ": Invalid private key");
44 }
45
46/*
47* Run checks on a generated private key
48*/
50 {
51 if(!check_key(rng, BOTAN_PRIVATE_KEY_STRONG_CHECKS_ON_GENERATE))
52 throw Self_Test_Failure(algo_name() + " private key generation failed");
53 }
54
55}
void gen_check(RandomNumberGenerator &rng) const
Definition pk_keys.cpp:49
void load_check(RandomNumberGenerator &rng) const
Definition pk_keys.cpp:40
virtual OID get_oid() const
Definition pk_keys.cpp:17
virtual void load_check(RandomNumberGenerator &rng) const
Definition pk_keys.cpp:31
virtual bool check_key(RandomNumberGenerator &rng, bool strong) const =0
virtual std::string algo_name() const =0
std::string lookup(const OID &oid)
Definition oids.cpp:31
std::invalid_argument Invalid_Argument
Definition exceptn.h:20
Lookup_Error(const std::string &err)
Definition exceptn.h:37
Self_Test_Failure(const std::string &err)
Definition exceptn.h:177