Botan 1.10.17

def_pk_ops.cpp
Go to the documentation of this file.
1 /*
2 * PK Operations
3 * (C) 1999-2010 Jack Lloyd
4 *
5 * Distributed under the terms of the Botan license
6 */
7
8 #include <botan/internal/core_engine.h>
9
10 #if defined(BOTAN_HAS_RSA)
11 #include <botan/rsa.h>
12 #endif
13
14 #if defined(BOTAN_HAS_RW)
15 #include <botan/rw.h>
16 #endif
17
18 #if defined(BOTAN_HAS_DSA)
19 #include <botan/dsa.h>
20 #endif
21
22 #if defined(BOTAN_HAS_ECDSA)
23 #include <botan/ecdsa.h>
24 #endif
25
26 #if defined(BOTAN_HAS_ELGAMAL)
27 #include <botan/elgamal.h>
28 #endif
29
30 #if defined(BOTAN_HAS_GOST_34_10_2001)
31 #include <botan/gost_3410.h>
32 #endif
33
34 #if defined(BOTAN_HAS_NYBERG_RUEPPEL)
35 #include <botan/nr.h>
36 #endif
37
38 #if defined(BOTAN_HAS_DIFFIE_HELLMAN)
39 #include <botan/dh.h>
40 #endif
41
42 #if defined(BOTAN_HAS_ECDH)
43 #include <botan/ecdh.h>
44 #endif
45
46 namespace Botan {
47
48 PK_Ops::Encryption*
49 Core_Engine::get_encryption_op(const Public_Key& key) const
50 {
51 #if defined(BOTAN_HAS_RSA)
52 if(const RSA_PublicKey* s = dynamic_cast<const RSA_PublicKey*>(&key))
53 return new RSA_Public_Operation(*s);
54 #endif
55
56 #if defined(BOTAN_HAS_ELGAMAL)
57 if(const ElGamal_PublicKey* s = dynamic_cast<const ElGamal_PublicKey*>(&key))
58 return new ElGamal_Encryption_Operation(*s);
59 #endif
60
61 return 0;
62 }
63
64 PK_Ops::Decryption*
65 Core_Engine::get_decryption_op(const Private_Key& key) const
66 {
67 #if defined(BOTAN_HAS_RSA)
68 if(const RSA_PrivateKey* s = dynamic_cast<const RSA_PrivateKey*>(&key))
69 return new RSA_Private_Operation(*s);
70 #endif
71
72 #if defined(BOTAN_HAS_ELGAMAL)
73 if(const ElGamal_PrivateKey* s = dynamic_cast<const ElGamal_PrivateKey*>(&key))
74 return new ElGamal_Decryption_Operation(*s);
75 #endif
76
77 return 0;
78 }
79
80 PK_Ops::Key_Agreement*
81 Core_Engine::get_key_agreement_op(const Private_Key& key) const
82 {
83 #if defined(BOTAN_HAS_DIFFIE_HELLMAN)
84 if(const DH_PrivateKey* dh = dynamic_cast<const DH_PrivateKey*>(&key))
85 return new DH_KA_Operation(*dh);
86 #endif
87
88 #if defined(BOTAN_HAS_ECDH)
89 if(const ECDH_PrivateKey* ecdh = dynamic_cast<const ECDH_PrivateKey*>(&key))
90 return new ECDH_KA_Operation(*ecdh);
91 #endif
92
93 return 0;
94 }
95
96 PK_Ops::Signature*
97 Core_Engine::get_signature_op(const Private_Key& key) const
98 {
99 #if defined(BOTAN_HAS_RSA)
100 if(const RSA_PrivateKey* s = dynamic_cast<const RSA_PrivateKey*>(&key))
101 return new RSA_Private_Operation(*s);
102 #endif
103
104 #if defined(BOTAN_HAS_RW)
105 if(const RW_PrivateKey* s = dynamic_cast<const RW_PrivateKey*>(&key))
106 return new RW_Signature_Operation(*s);
107 #endif
108
109 #if defined(BOTAN_HAS_DSA)
110 if(const DSA_PrivateKey* s = dynamic_cast<const DSA_PrivateKey*>(&key))
111 return new DSA_Signature_Operation(*s);
112 #endif
113
114 #if defined(BOTAN_HAS_ECDSA)
115 if(const ECDSA_PrivateKey* s = dynamic_cast<const ECDSA_PrivateKey*>(&key))
116 return new ECDSA_Signature_Operation(*s);
117 #endif
118
119 #if defined(BOTAN_HAS_GOST_34_10_2001)
120 if(const GOST_3410_PrivateKey* s =
121 dynamic_cast<const GOST_3410_PrivateKey*>(&key))
122 return new GOST_3410_Signature_Operation(*s);
123 #endif
124
125 #if defined(BOTAN_HAS_NYBERG_RUEPPEL)
126 if(const NR_PrivateKey* s = dynamic_cast<const NR_PrivateKey*>(&key))
127 return new NR_Signature_Operation(*s);
128 #endif
129
130 return 0;
131 }
132
133 PK_Ops::Verification*
134 Core_Engine::get_verify_op(const Public_Key& key) const
135 {
136 #if defined(BOTAN_HAS_RSA)
137 if(const RSA_PublicKey* s = dynamic_cast<const RSA_PublicKey*>(&key))
138 return new RSA_Public_Operation(*s);
139 #endif
140
141 #if defined(BOTAN_HAS_RW)
142 if(const RW_PublicKey* s = dynamic_cast<const RW_PublicKey*>(&key))
143 return new RW_Verification_Operation(*s);
144 #endif
145
146 #if defined(BOTAN_HAS_DSA)
147 if(const DSA_PublicKey* s = dynamic_cast<const DSA_PublicKey*>(&key))
148 return new DSA_Verification_Operation(*s);
149 #endif
150
151 #if defined(BOTAN_HAS_ECDSA)
152 if(const ECDSA_PublicKey* s = dynamic_cast<const ECDSA_PublicKey*>(&key))
153 return new ECDSA_Verification_Operation(*s);
154 #endif
155
156 #if defined(BOTAN_HAS_GOST_34_10_2001)
157 if(const GOST_3410_PublicKey* s =
158 dynamic_cast<const GOST_3410_PublicKey*>(&key))
159 return new GOST_3410_Verification_Operation(*s);
160 #endif
161
162 #if defined(BOTAN_HAS_NYBERG_RUEPPEL)
163 if(const NR_PublicKey* s = dynamic_cast<const NR_PublicKey*>(&key))
164 return new NR_Verification_Operation(*s);
165 #endif
166
167 return 0;
168 }
169
170 }
Botan::Core_Engine::get_verify_op
PK_Ops::Verification * get_verify_op(const Public_Key &key) const
Definition: def_pk_ops.cpp:134
Botan::Core_Engine::get_decryption_op
PK_Ops::Decryption * get_decryption_op(const Private_Key &key) const
Definition: def_pk_ops.cpp:65
Botan::DSA_Signature_Operation
Definition: dsa.h:63
Botan::Core_Engine::get_signature_op
PK_Ops::Signature * get_signature_op(const Private_Key &key) const
Definition: def_pk_ops.cpp:97
Botan::Private_Key
Definition: pk_keys.h:86
Botan::ElGamal_PublicKey
Definition: elgamal.h:22
Botan::ECDH_KA_Operation
Definition: ecdh.h:93
Botan::PK_Ops::Signature
Definition: pk_ops.h:49
Botan::NR_Signature_Operation
Definition: nr.h:61
Botan::RSA_Public_Operation
Definition: rsa.h:116
Botan::ElGamal_PrivateKey
Definition: elgamal.h:43
Botan::NR_Verification_Operation
Definition: nr.h:82
Botan::ECDSA_Signature_Operation
Definition: ecdsa.h:95
Botan::RSA_Private_Operation
Definition: rsa.h:89
Botan::Core_Engine::get_key_agreement_op
PK_Ops::Key_Agreement * get_key_agreement_op(const Private_Key &key) const
Definition: def_pk_ops.cpp:81
Botan::NR_PrivateKey
Definition: nr.h:43
Botan::DSA_Verification_Operation
Definition: dsa.h:84
Botan::ECDSA_PublicKey
Definition: ecdsa.h:22
Botan::DSA_PrivateKey
Definition: dsa.h:45
Botan::DH_KA_Operation
Definition: dh.h:78
Botan::RW_PublicKey
Definition: rw.h:21
Botan::ElGamal_Decryption_Operation
Definition: elgamal.h:79
Botan::RSA_PrivateKey
Definition: rsa.h:47
Botan
Definition: algo_base.h:14
Botan::Core_Engine::get_encryption_op
PK_Ops::Encryption * get_encryption_op(const Public_Key &key) const
Definition: def_pk_ops.cpp:49
Botan::NR_PublicKey
Definition: nr.h:21
Botan::PK_Ops::Key_Agreement
Definition: pk_ops.h:145
Botan::Public_Key
Definition: pk_keys.h:21
Botan::DSA_PublicKey
Definition: dsa.h:21
Botan::RW_PrivateKey
Definition: rw.h:42
Botan::RW_Verification_Operation
Definition: rw.h:88
Botan::ECDSA_PrivateKey
Definition: ecdsa.h:64
Botan::ElGamal_Encryption_Operation
Definition: elgamal.h:61
Botan::ECDH_PrivateKey
Definition: ecdh.h:65
Botan::PK_Ops::Decryption
Definition: pk_ops.h:35
Botan::DH_PrivateKey
Definition: dh.h:48
Botan::RW_Signature_Operation
Definition: rw.h:65
Botan::ECDSA_Verification_Operation
Definition: ecdsa.h:117
Botan::PK_Ops::Verification
Definition: pk_ops.h:85
Botan::RSA_PublicKey
Definition: rsa.h:21