diff options
author | lloyd <[email protected]> | 2015-01-28 04:32:10 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2015-01-28 04:32:10 +0000 |
commit | 7b56f1bd570dc684ffd7c945dee0d9b5480354ff (patch) | |
tree | 0c50ad534280a292a1b76daee9a19b34cfd96367 /src/lib/algo_base/transform.h | |
parent | b8fa304ec981d273c45d7ef31705d65ccfb00cc1 (diff) |
Add a runtime map of string->func() which when called return
Transforms and BlockCiphers. Registration for all types is done at
startup but is very cheap as just a std::function and a std::map entry
are created, no actual objects are created until needed. This is a
huge improvement over Algorithm_Factory which used T::clone() as the
function and thus kept a prototype object of each type in memory.
Replace existing lookup mechanisms for ciphers, AEADs, and compression
to use the transform lookup. The existing Engine framework remains in
place for BlockCipher, but the engines now just call to the registry
instead of having hardcoded lookups.
s/Transformation/Transform/ with typedefs for compatability.
Remove lib/selftest code (for runtime selftesting): not the right approach.
Diffstat (limited to 'src/lib/algo_base/transform.h')
-rw-r--r-- | src/lib/algo_base/transform.h | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/lib/algo_base/transform.h b/src/lib/algo_base/transform.h index 444622b74..75bd5004a 100644 --- a/src/lib/algo_base/transform.h +++ b/src/lib/algo_base/transform.h @@ -1,5 +1,5 @@ /* -* Transformations of data +* Transforms of data * (C) 2013 Jack Lloyd * * Botan is released under the Simplified BSD License (see license.txt) @@ -12,6 +12,7 @@ #include <botan/key_spec.h> #include <botan/exceptn.h> #include <botan/symkey.h> +#include <botan/scan_name.h> #include <string> #include <vector> @@ -20,9 +21,11 @@ namespace Botan { /** * Interface for general transformations on data */ -class BOTAN_DLL Transformation +class BOTAN_DLL Transform { public: + typedef SCAN_Name Spec; + /** * Begin processing a message. * @param nonce the per message nonce @@ -38,7 +41,7 @@ class BOTAN_DLL Transformation * @param nonce the per message nonce */ template<typename Alloc> - BOTAN_DEPRECATED("Use Transformation::start") + BOTAN_DEPRECATED("Use Transform::start") secure_vector<byte> start_vec(const std::vector<byte, Alloc>& nonce) { return start(&nonce[0], nonce.size()); @@ -120,10 +123,10 @@ class BOTAN_DLL Transformation virtual void clear() = 0; - virtual ~Transformation() {} + virtual ~Transform() {} }; -class BOTAN_DLL Keyed_Transform : public Transformation +class BOTAN_DLL Keyed_Transform : public Transform { public: /** @@ -168,6 +171,12 @@ class BOTAN_DLL Keyed_Transform : public Transformation virtual void key_schedule(const byte key[], size_t length) = 0; }; +typedef Transform Transformation; + +BOTAN_DLL Transform* get_transform(const std::string& specstr, + const std::string& provider = "", + const std::string& dirstr = ""); + } #endif |