diff options
Diffstat (limited to 'src/pubkey/pk_lookup')
-rw-r--r-- | src/pubkey/pk_lookup/info.txt | 18 | ||||
-rw-r--r-- | src/pubkey/pk_lookup/look_pk.cpp | 74 | ||||
-rw-r--r-- | src/pubkey/pk_lookup/look_pk.h | 39 | ||||
-rw-r--r-- | src/pubkey/pk_lookup/pk_algs.cpp | 110 | ||||
-rw-r--r-- | src/pubkey/pk_lookup/pk_algs.h | 22 |
5 files changed, 263 insertions, 0 deletions
diff --git a/src/pubkey/pk_lookup/info.txt b/src/pubkey/pk_lookup/info.txt new file mode 100644 index 000000000..39dd4dfc2 --- /dev/null +++ b/src/pubkey/pk_lookup/info.txt @@ -0,0 +1,18 @@ +realname "Public Key Lookup" + +define PUBLIC_KEY_LOOKUP + +load_on dep + +<requires> +asn1 +bigint +numbertheory +</requires> + +<add> +look_pk.cpp +look_pk.h +pk_algs.cpp +pk_algs.h +</add> diff --git a/src/pubkey/pk_lookup/look_pk.cpp b/src/pubkey/pk_lookup/look_pk.cpp new file mode 100644 index 000000000..a4062b57c --- /dev/null +++ b/src/pubkey/pk_lookup/look_pk.cpp @@ -0,0 +1,74 @@ +/************************************************* +* PK Algorithm Lookup Source File * +* (C) 1999-2007 Jack Lloyd * +*************************************************/ + +#include <botan/look_pk.h> +#include <botan/lookup.h> + +namespace Botan { + +/************************************************* +* Get a PK_Encryptor object * +*************************************************/ +PK_Encryptor* get_pk_encryptor(const PK_Encrypting_Key& key, + const std::string& eme) + { + return new PK_Encryptor_MR_with_EME(key, eme); + } + +/************************************************* +* Get a PK_Decryptor object * +*************************************************/ +PK_Decryptor* get_pk_decryptor(const PK_Decrypting_Key& key, + const std::string& eme) + { + return new PK_Decryptor_MR_with_EME(key, eme); + } + +/************************************************* +* Get a PK_Signer object * +*************************************************/ +PK_Signer* get_pk_signer(const PK_Signing_Key& key, + const std::string& encoding, + Signature_Format sig_format) + { + PK_Signer* signer = new PK_Signer(key, encoding); + signer->set_output_format(sig_format); + return signer; + } + +/************************************************* +* Get a PK_Verifier object * +*************************************************/ +PK_Verifier* get_pk_verifier(const PK_Verifying_with_MR_Key& key, + const std::string& encoding, + Signature_Format sig_format) + { + PK_Verifier* verifier = new PK_Verifier_with_MR(key, encoding); + verifier->set_input_format(sig_format); + return verifier; + } + +/************************************************* +* Get a PK_Verifier object * +*************************************************/ +PK_Verifier* get_pk_verifier(const PK_Verifying_wo_MR_Key& key, + const std::string& encoding, + Signature_Format sig_format) + { + PK_Verifier* verifier = new PK_Verifier_wo_MR(key, encoding); + verifier->set_input_format(sig_format); + return verifier; + } + +/************************************************* +* Get a PK_Key_Agreement object * +*************************************************/ +PK_Key_Agreement* get_pk_kas(const PK_Key_Agreement_Key& key, + const std::string& kdf) + { + return new PK_Key_Agreement(key, kdf); + } + +} diff --git a/src/pubkey/pk_lookup/look_pk.h b/src/pubkey/pk_lookup/look_pk.h new file mode 100644 index 000000000..28a56f2b3 --- /dev/null +++ b/src/pubkey/pk_lookup/look_pk.h @@ -0,0 +1,39 @@ +/************************************************* +* PK Algorithm Lookup Header File * +* (C) 1999-2007 Jack Lloyd * +*************************************************/ + +#ifndef BOTAN_PK_LOOKUP_H__ +#define BOTAN_PK_LOOKUP_H__ + +#include <botan/build.h> +#include <botan/pubkey.h> + +namespace Botan { + +/************************************************* +* Get an PK algorithm object * +*************************************************/ +BOTAN_DLL PK_Encryptor* get_pk_encryptor(const PK_Encrypting_Key&, + const std::string&); + +BOTAN_DLL PK_Decryptor* get_pk_decryptor(const PK_Decrypting_Key&, + const std::string&); + +BOTAN_DLL PK_Signer* get_pk_signer(const PK_Signing_Key&, + const std::string&, + Signature_Format = IEEE_1363); + +BOTAN_DLL PK_Verifier* get_pk_verifier(const PK_Verifying_with_MR_Key&, + const std::string&, + Signature_Format = IEEE_1363); +BOTAN_DLL PK_Verifier* get_pk_verifier(const PK_Verifying_wo_MR_Key&, + const std::string&, + Signature_Format = IEEE_1363); + +BOTAN_DLL PK_Key_Agreement* get_pk_kas(const PK_Key_Agreement_Key&, + const std::string&); + +} + +#endif diff --git a/src/pubkey/pk_lookup/pk_algs.cpp b/src/pubkey/pk_lookup/pk_algs.cpp new file mode 100644 index 000000000..c1fc569a0 --- /dev/null +++ b/src/pubkey/pk_lookup/pk_algs.cpp @@ -0,0 +1,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_DIFFIE_HELLMAN + #include <botan/dh.h> +#endif + +#ifdef BOTAN_HAS_ECDSA + #include <botan/ec.h> +#endif + +#ifdef BOTAN_HAS_NYBERG_RUEPPEL + #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_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; + } + +} diff --git a/src/pubkey/pk_lookup/pk_algs.h b/src/pubkey/pk_lookup/pk_algs.h new file mode 100644 index 000000000..a8fa5f176 --- /dev/null +++ b/src/pubkey/pk_lookup/pk_algs.h @@ -0,0 +1,22 @@ +/************************************************* +* PK Key Factory Header File * +* (C) 1999-2007 Jack Lloyd * +*************************************************/ + +#ifndef BOTAN_PK_KEY_FACTORY_H__ +#define BOTAN_PK_KEY_FACTORY_H__ + +#include <botan/x509_key.h> +#include <botan/pkcs8.h> + +namespace Botan { + +/************************************************* +* Get an PK key object * +*************************************************/ +BOTAN_DLL Public_Key* get_public_key(const std::string&); +BOTAN_DLL Private_Key* get_private_key(const std::string&); + +} + +#endif |