aboutsummaryrefslogtreecommitdiffstats
path: root/src/pk/pubkey/pk_algs.cpp
blob: 3c1b81ba994bb28794ac8a676dd7ccab070af737 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*************************************************
* PK Key Source File                             *
* (C) 1999-2007 Jack Lloyd                       *
*************************************************/

#include <botan/pk_algs.h>

#ifdef BOTAN_HAS_RSA
  #include <botan/rsa.h>
#endif

#ifdef BOTAN_HAS_DSA
  #include <botan/dsa.h>
#endif

#ifdef BOTAN_HAS_DH
  #include <botan/dh.h>
#endif

#ifdef BOTAN_HAS_ECDSA
  #include <botan/ec.h>
#endif

#ifdef BOTAN_HAS_NR
  #include <botan/nr.h>
#endif

#ifdef BOTAN_HAS_RW
  #include <botan/rw.h>
#endif

#ifdef BOTAN_HAS_ELGAMAL
  #include <botan/elgamal.h>
#endif

namespace Botan {

/*************************************************
* Get an PK public key object                    *
*************************************************/
Public_Key* get_public_key(const std::string& alg_name)
   {
#if defined(BOTAN_HAS_RSA)
   if(alg_name == "RSA") return new RSA_PublicKey;
#endif

#if defined(BOTAN_HAS_DSA)
   if(alg_name == "DSA") return new DSA_PublicKey;
#endif

#if defined(BOTAN_HAS_DH)
   if(alg_name == "DH")  return new DH_PublicKey;
#endif

#if defined(BOTAN_HAS_NR)
   if(alg_name == "NR")  return new NR_PublicKey;
#endif

#if defined(BOTAN_HAS_RW)
   if(alg_name == "RW")  return new RW_PublicKey;
#endif

#if defined(BOTAN_HAS_ELG)
   if(alg_name == "ELG") return new ElGamal_PublicKey;
#endif

#if defined(BOTAN_HAS_ECDSA)
   if(alg_name == "ECDSA") return new ECDSA_PublicKey;
#endif

   return 0;
   }

/*************************************************
* Get an PK private key object                   *
*************************************************/
Private_Key* get_private_key(const std::string& alg_name)
   {
#if defined(BOTAN_HAS_RSA)
   if(alg_name == "RSA") return new RSA_PrivateKey;
#endif

#if defined(BOTAN_HAS_DSA)
   if(alg_name == "DSA") return new DSA_PrivateKey;
#endif

#if defined(BOTAN_HAS_DH)
   if(alg_name == "DH")  return new DH_PrivateKey;
#endif

#if defined(BOTAN_HAS_NR)
   if(alg_name == "NR")  return new NR_PrivateKey;
#endif

#if defined(BOTAN_HAS_RW)
   if(alg_name == "RW")  return new RW_PrivateKey;
#endif

#if defined(BOTAN_HAS_ELG)
   if(alg_name == "ELG") return new ElGamal_PrivateKey;
#endif

#if defined(BOTAN_HAS_ECDSA)
   if(alg_name == "ECDSA") return new ECDSA_PrivateKey;
#endif

   return 0;
   }

}