aboutsummaryrefslogtreecommitdiffstats
path: root/src/pubkey/pk_algs.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-07-21 04:28:09 +0000
committerlloyd <[email protected]>2009-07-21 04:28:09 +0000
commitabcfd1cf4b351f856c2df11ed1cd972a3a5155a9 (patch)
tree7b05ce4f33fe8c1c94d77ce235b4cd6b9bedc3b0 /src/pubkey/pk_algs.cpp
parentb1fc3ff3fe19152eaf1adbdd9f503dfaf2b8a500 (diff)
parent57d64c1026cfa0fba775d393920aebaa02bf0f56 (diff)
propagate from branch 'net.randombit.botan' (head 95eb8083f5884531e5ca0667388f8a6fb6d05c41)
to branch 'net.randombit.botan.c++0x' (head 56e105e678540c8bcafa4d0198c19a9489fbf8d1)
Diffstat (limited to 'src/pubkey/pk_algs.cpp')
-rw-r--r--src/pubkey/pk_algs.cpp112
1 files changed, 112 insertions, 0 deletions
diff --git a/src/pubkey/pk_algs.cpp b/src/pubkey/pk_algs.cpp
new file mode 100644
index 000000000..99d7294f0
--- /dev/null
+++ b/src/pubkey/pk_algs.cpp
@@ -0,0 +1,112 @@
+/*
+* PK Key
+* (C) 1999-2007 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#include <botan/pk_algs.h>
+
+#if defined(BOTAN_HAS_RSA)
+ #include <botan/rsa.h>
+#endif
+
+#if defined(BOTAN_HAS_DSA)
+ #include <botan/dsa.h>
+#endif
+
+#if defined(BOTAN_HAS_DIFFIE_HELLMAN)
+ #include <botan/dh.h>
+#endif
+
+#if defined(BOTAN_HAS_ECDSA)
+ #include <botan/ecdsa.h>
+#endif
+
+#if defined(BOTAN_HAS_NYBERG_RUEPPEL)
+ #include <botan/nr.h>
+#endif
+
+#if defined(BOTAN_HAS_RW)
+ #include <botan/rw.h>
+#endif
+
+#if defined(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_DIFFIE_HELLMAN)
+ if(alg_name == "DH") return new DH_PublicKey;
+#endif
+
+#if defined(BOTAN_HAS_NYBERG_RUEPPEL)
+ 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_DIFFIE_HELLMAN)
+ if(alg_name == "DH") return new DH_PrivateKey;
+#endif
+
+#if defined(BOTAN_HAS_NYBERG_RUEPPEL)
+ 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;
+ }
+
+}