aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/engine
diff options
context:
space:
mode:
authorlloyd <[email protected]>2015-02-03 08:11:45 +0000
committerlloyd <[email protected]>2015-02-03 08:11:45 +0000
commitf9a7c85b74be0f4a7273e8e0591703af83036e81 (patch)
tree075dbe119fc16863cad99b432ca6251778bd8fd1 /src/lib/engine
parent69d2cd919c698a6b138b2ccba0de5d5aa2a33a03 (diff)
Convert PK operations to using Algo_Registry instead of Engine.
Remove global PRNG.
Diffstat (limited to 'src/lib/engine')
-rw-r--r--src/lib/engine/core_engine/core_engine.h16
-rw-r--r--src/lib/engine/core_engine/def_pk_ops.cpp179
-rw-r--r--src/lib/engine/core_engine/def_powm.cpp24
-rw-r--r--src/lib/engine/core_engine/info.txt5
-rw-r--r--src/lib/engine/dyn_engine/dyn_engine.h36
-rw-r--r--src/lib/engine/engine.cpp37
-rw-r--r--src/lib/engine/engine.h50
7 files changed, 0 insertions, 347 deletions
diff --git a/src/lib/engine/core_engine/core_engine.h b/src/lib/engine/core_engine/core_engine.h
index 9c914da66..c98ee031b 100644
--- a/src/lib/engine/core_engine/core_engine.h
+++ b/src/lib/engine/core_engine/core_engine.h
@@ -20,22 +20,6 @@ class Core_Engine : public Engine
public:
std::string provider_name() const override { return "core"; }
- PK_Ops::Key_Agreement*
- get_key_agreement_op(const Private_Key& key, RandomNumberGenerator& rng) const override;
-
- PK_Ops::Signature* get_signature_op(const Private_Key& key, const std::string& emsa,
- RandomNumberGenerator& rng) const override;
-
- PK_Ops::Verification* get_verify_op(const Public_Key& key, const std::string& emsa,
- RandomNumberGenerator& rng) const override;
-
- PK_Ops::Encryption* get_encryption_op(const Public_Key& key, RandomNumberGenerator& rng) const override;
-
- PK_Ops::Decryption* get_decryption_op(const Private_Key& key, RandomNumberGenerator& rng) const override;
-
- Modular_Exponentiator* mod_exp(const BigInt& n,
- Power_Mod::Usage_Hints) const override;
-
BlockCipher* find_block_cipher(const SCAN_Name&,
Algorithm_Factory&) const override;
diff --git a/src/lib/engine/core_engine/def_pk_ops.cpp b/src/lib/engine/core_engine/def_pk_ops.cpp
deleted file mode 100644
index f941245fb..000000000
--- a/src/lib/engine/core_engine/def_pk_ops.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
-* PK Operations
-* (C) 1999-2010 Jack Lloyd
-*
-* Botan is released under the Simplified BSD License (see license.txt)
-*/
-
-#include <botan/internal/core_engine.h>
-
-#if defined(BOTAN_HAS_RSA)
- #include <botan/rsa.h>
-#endif
-
-#if defined(BOTAN_HAS_RW)
- #include <botan/rw.h>
-#endif
-
-#if defined(BOTAN_HAS_DSA)
- #include <botan/dsa.h>
-#endif
-
-#if defined(BOTAN_HAS_ECDSA)
- #include <botan/ecdsa.h>
-#endif
-
-#if defined(BOTAN_HAS_ELGAMAL)
- #include <botan/elgamal.h>
-#endif
-
-#if defined(BOTAN_HAS_GOST_34_10_2001)
- #include <botan/gost_3410.h>
-#endif
-
-#if defined(BOTAN_HAS_NYBERG_RUEPPEL)
- #include <botan/nr.h>
-#endif
-
-#if defined(BOTAN_HAS_DIFFIE_HELLMAN)
- #include <botan/dh.h>
-#endif
-
-#if defined(BOTAN_HAS_ECDH)
- #include <botan/ecdh.h>
-#endif
-
-#if defined(BOTAN_HAS_CURVE_25519)
- #include <botan/curve25519.h>
-#endif
-
-namespace Botan {
-
-PK_Ops::Encryption*
-Core_Engine::get_encryption_op(const Public_Key& key, RandomNumberGenerator&) const
- {
-#if defined(BOTAN_HAS_RSA)
- if(const RSA_PublicKey* s = dynamic_cast<const RSA_PublicKey*>(&key))
- return new RSA_Public_Operation(*s);
-#endif
-
-#if defined(BOTAN_HAS_ELGAMAL)
- if(const ElGamal_PublicKey* s = dynamic_cast<const ElGamal_PublicKey*>(&key))
- return new ElGamal_Encryption_Operation(*s);
-#endif
-
- return nullptr;
- }
-
-PK_Ops::Decryption*
-Core_Engine::get_decryption_op(const Private_Key& key, RandomNumberGenerator& rng) const
- {
-#if defined(BOTAN_HAS_RSA)
- if(const RSA_PrivateKey* s = dynamic_cast<const RSA_PrivateKey*>(&key))
- return new RSA_Private_Operation(*s, rng);
-#endif
-
-#if defined(BOTAN_HAS_ELGAMAL)
- if(const ElGamal_PrivateKey* s = dynamic_cast<const ElGamal_PrivateKey*>(&key))
- return new ElGamal_Decryption_Operation(*s, rng);
-#endif
-
- return nullptr;
- }
-
-PK_Ops::Key_Agreement*
-Core_Engine::get_key_agreement_op(const Private_Key& key, RandomNumberGenerator& rng) const
- {
-#if defined(BOTAN_HAS_DIFFIE_HELLMAN)
- if(const DH_PrivateKey* dh = dynamic_cast<const DH_PrivateKey*>(&key))
- return new DH_KA_Operation(*dh, rng);
-#endif
-
-#if defined(BOTAN_HAS_ECDH)
- if(const ECDH_PrivateKey* ecdh = dynamic_cast<const ECDH_PrivateKey*>(&key))
- return new ECDH_KA_Operation(*ecdh);
-#endif
-
-#if defined(BOTAN_HAS_CURVE_25519)
- if(const Curve25519_PrivateKey* c25519 = dynamic_cast<const Curve25519_PrivateKey*>(&key))
- return new Curve25519_KA_Operation(*c25519);
-#endif
-
- return nullptr;
- }
-
-PK_Ops::Signature*
-Core_Engine::get_signature_op(const Private_Key& key, const std::string& emsa, RandomNumberGenerator& rng) const
- {
-#if defined(BOTAN_HAS_RSA)
- if(const RSA_PrivateKey* s = dynamic_cast<const RSA_PrivateKey*>(&key))
- return new RSA_Private_Operation(*s, rng);
-#endif
-
-#if defined(BOTAN_HAS_RW)
- if(const RW_PrivateKey* s = dynamic_cast<const RW_PrivateKey*>(&key))
- return new RW_Signature_Operation(*s);
-#endif
-
-#if defined(BOTAN_HAS_DSA)
- if(const DSA_PrivateKey* s = dynamic_cast<const DSA_PrivateKey*>(&key))
- return new DSA_Signature_Operation(*s, emsa);
-#endif
-
-#if defined(BOTAN_HAS_ECDSA)
- if(const ECDSA_PrivateKey* s = dynamic_cast<const ECDSA_PrivateKey*>(&key))
- return new ECDSA_Signature_Operation(*s, emsa);
-#endif
-
-#if defined(BOTAN_HAS_GOST_34_10_2001)
- if(const GOST_3410_PrivateKey* s =
- dynamic_cast<const GOST_3410_PrivateKey*>(&key))
- return new GOST_3410_Signature_Operation(*s);
-#endif
-
-#if defined(BOTAN_HAS_NYBERG_RUEPPEL)
- if(const NR_PrivateKey* s = dynamic_cast<const NR_PrivateKey*>(&key))
- return new NR_Signature_Operation(*s);
-#endif
-
- return nullptr;
- }
-
-PK_Ops::Verification*
-Core_Engine::get_verify_op(const Public_Key& key, const std::string& emsa, RandomNumberGenerator&) const
- {
-#if defined(BOTAN_HAS_RSA)
- if(const RSA_PublicKey* s = dynamic_cast<const RSA_PublicKey*>(&key))
- return new RSA_Public_Operation(*s);
-#endif
-
-#if defined(BOTAN_HAS_RW)
- if(const RW_PublicKey* s = dynamic_cast<const RW_PublicKey*>(&key))
- return new RW_Verification_Operation(*s);
-#endif
-
-#if defined(BOTAN_HAS_DSA)
- if(const DSA_PublicKey* s = dynamic_cast<const DSA_PublicKey*>(&key))
- return new DSA_Verification_Operation(*s);
-#endif
-
-#if defined(BOTAN_HAS_ECDSA)
- if(const ECDSA_PublicKey* s = dynamic_cast<const ECDSA_PublicKey*>(&key))
- return new ECDSA_Verification_Operation(*s);
-#endif
-
-#if defined(BOTAN_HAS_GOST_34_10_2001)
- if(const GOST_3410_PublicKey* s =
- dynamic_cast<const GOST_3410_PublicKey*>(&key))
- return new GOST_3410_Verification_Operation(*s);
-#endif
-
-#if defined(BOTAN_HAS_NYBERG_RUEPPEL)
- if(const NR_PublicKey* s = dynamic_cast<const NR_PublicKey*>(&key))
- return new NR_Verification_Operation(*s);
-#endif
-
- return nullptr;
- }
-
-}
diff --git a/src/lib/engine/core_engine/def_powm.cpp b/src/lib/engine/core_engine/def_powm.cpp
deleted file mode 100644
index 541f18c04..000000000
--- a/src/lib/engine/core_engine/def_powm.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
-* Modular Exponentiation
-* (C) 1999-2007 Jack Lloyd
-*
-* Botan is released under the Simplified BSD License (see license.txt)
-*/
-
-#include <botan/internal/core_engine.h>
-#include <botan/internal/def_powm.h>
-
-namespace Botan {
-
-/*
-* Choose a modular exponentation algorithm
-*/
-Modular_Exponentiator*
-Core_Engine::mod_exp(const BigInt& n, Power_Mod::Usage_Hints hints) const
- {
- if(n.is_odd())
- return new Montgomery_Exponentiator(n, hints);
- return new Fixed_Window_Exponentiator(n, hints);
- }
-
-}
diff --git a/src/lib/engine/core_engine/info.txt b/src/lib/engine/core_engine/info.txt
index 1343ad5e7..c726464f4 100644
--- a/src/lib/engine/core_engine/info.txt
+++ b/src/lib/engine/core_engine/info.txt
@@ -5,8 +5,6 @@ core_engine.h
</header:internal>
<source>
-def_pk_ops.cpp
-def_powm.cpp
lookup_block.cpp
lookup_hash.cpp
lookup_mac.cpp
@@ -16,8 +14,5 @@ lookup_pbkdf.cpp
<requires>
algo_factory
-filters
libstate
-mode_pad
-numbertheory
</requires>
diff --git a/src/lib/engine/dyn_engine/dyn_engine.h b/src/lib/engine/dyn_engine/dyn_engine.h
index d559a518a..d40df5663 100644
--- a/src/lib/engine/dyn_engine/dyn_engine.h
+++ b/src/lib/engine/dyn_engine/dyn_engine.h
@@ -62,42 +62,6 @@ class BOTAN_DLL Dynamically_Loaded_Engine : public Engine
return engine->find_pbkdf(algo_spec, af);
}
- Modular_Exponentiator* mod_exp(const BigInt& n,
- Power_Mod::Usage_Hints hints) const override
- {
- return engine->mod_exp(n, hints);
- }
-
- PK_Ops::Key_Agreement*
- get_key_agreement_op(const Private_Key& key, RandomNumberGenerator& rng) const override
- {
- return engine->get_key_agreement_op(key, rng);
- }
-
- PK_Ops::Signature*
- get_signature_op(const Private_Key& key, const std::string& emsa, RandomNumberGenerator& rng) const override
- {
- return engine->get_signature_op(key, emsa, rng);
- }
-
- PK_Ops::Verification*
- get_verify_op(const Public_Key& key, const std::string& emsa, RandomNumberGenerator& rng) const override
- {
- return engine->get_verify_op(key, emsa, rng);
- }
-
- PK_Ops::Encryption*
- get_encryption_op(const Public_Key& key, RandomNumberGenerator& rng) const override
- {
- return engine->get_encryption_op(key, rng);
- }
-
- PK_Ops::Decryption*
- get_decryption_op(const Private_Key& key, RandomNumberGenerator& rng) const override
- {
- return engine->get_decryption_op(key, rng);
- }
-
private:
class Dynamically_Loaded_Library* lib;
Engine* engine;
diff --git a/src/lib/engine/engine.cpp b/src/lib/engine/engine.cpp
index 15543b289..7aab64cad 100644
--- a/src/lib/engine/engine.cpp
+++ b/src/lib/engine/engine.cpp
@@ -44,41 +44,4 @@ Engine::find_pbkdf(const SCAN_Name&,
return nullptr;
}
-Modular_Exponentiator*
-Engine::mod_exp(const BigInt&,
- Power_Mod::Usage_Hints) const
- {
- return nullptr;
- }
-
-PK_Ops::Key_Agreement*
-Engine::get_key_agreement_op(const Private_Key&, RandomNumberGenerator&) const
- {
- return nullptr;
- }
-
-PK_Ops::Signature*
-Engine::get_signature_op(const Private_Key&, const std::string&, RandomNumberGenerator&) const
- {
- return nullptr;
- }
-
-PK_Ops::Verification*
-Engine::get_verify_op(const Public_Key&, const std::string&, RandomNumberGenerator&) const
- {
- return nullptr;
- }
-
-PK_Ops::Encryption*
-Engine::get_encryption_op(const Public_Key&, RandomNumberGenerator&) const
- {
- return nullptr;
- }
-
-PK_Ops::Decryption*
-Engine::get_decryption_op(const Private_Key&, RandomNumberGenerator&) const
- {
- return nullptr;
- }
-
}
diff --git a/src/lib/engine/engine.h b/src/lib/engine/engine.h
index ba8c02f93..7fe11c12e 100644
--- a/src/lib/engine/engine.h
+++ b/src/lib/engine/engine.h
@@ -16,7 +16,6 @@
#include <botan/pbkdf.h>
#include <botan/pow_mod.h>
#include <botan/pk_keys.h>
-#include <botan/pk_ops.h>
namespace Botan {
@@ -82,55 +81,6 @@ class BOTAN_DLL Engine
*/
virtual PBKDF* find_pbkdf(const SCAN_Name& algo_spec,
Algorithm_Factory& af) const;
-
- /**
- * @param n the modulus
- * @param hints any use hints
- * @return newly allocated object, or NULL
- */
- virtual Modular_Exponentiator*
- mod_exp(const BigInt& n,
- Power_Mod::Usage_Hints hints) const;
-
- /**
- * Return a new operator object for this key, if possible
- * @param key the key we want an operator for
- * @return newly allocated operator object, or NULL
- */
- virtual PK_Ops::Key_Agreement*
- get_key_agreement_op(const Private_Key& key, RandomNumberGenerator& rng) const;
-
- /**
- * Return a new operator object for this key, if possible
- * @param key the key we want an operator for
- * @return newly allocated operator object, or NULL
- */
- virtual PK_Ops::Signature*
- get_signature_op(const Private_Key& key, const std::string& hash, RandomNumberGenerator& rng) const;
-
- /**
- * Return a new operator object for this key, if possible
- * @param key the key we want an operator for
- * @return newly allocated operator object, or NULL
- */
- virtual PK_Ops::Verification*
- get_verify_op(const Public_Key& key, const std::string& hash, RandomNumberGenerator& rng) const;
-
- /**
- * Return a new operator object for this key, if possible
- * @param key the key we want an operator for
- * @return newly allocated operator object, or NULL
- */
- virtual PK_Ops::Encryption*
- get_encryption_op(const Public_Key& key, RandomNumberGenerator& rng) const;
-
- /**
- * Return a new operator object for this key, if possible
- * @param key the key we want an operator for
- * @return newly allocated operator object, or NULL
- */
- virtual PK_Ops::Decryption*
- get_decryption_op(const Private_Key& key, RandomNumberGenerator& rng) const;
};
}