aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/block
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/block')
-rw-r--r--src/lib/block/block_cipher.cpp11
-rw-r--r--src/lib/block/block_cipher.h13
2 files changed, 24 insertions, 0 deletions
diff --git a/src/lib/block/block_cipher.cpp b/src/lib/block/block_cipher.cpp
index 616c6df5b..60e6d0db2 100644
--- a/src/lib/block/block_cipher.cpp
+++ b/src/lib/block/block_cipher.cpp
@@ -151,6 +151,17 @@ namespace Botan {
BlockCipher::~BlockCipher() {}
+std::unique_ptr<BlockCipher> BlockCipher::create(const std::string& algo_spec,
+ const std::string& provider)
+ {
+ return std::unique_ptr<BlockCipher>(make_a<BlockCipher>(algo_spec, provider));
+ }
+
+std::vector<std::string> BlockCipher::providers(const std::string& algo_spec)
+ {
+ return providers_of<BlockCipher>(BlockCipher::Spec(algo_spec));
+ }
+
#if defined(BOTAN_HAS_AES)
BOTAN_REGISTER_BLOCK_CIPHER_NAMED_NOARGS(AES_128, "AES-128");
BOTAN_REGISTER_BLOCK_CIPHER_NAMED_NOARGS(AES_192, "AES-192");
diff --git a/src/lib/block/block_cipher.h b/src/lib/block/block_cipher.h
index 3f017dc89..cea07ac2d 100644
--- a/src/lib/block/block_cipher.h
+++ b/src/lib/block/block_cipher.h
@@ -22,6 +22,19 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm
typedef SCAN_Name Spec;
/**
+ * Create an instance based on a name
+ * Will return a null pointer if the algo/provider combination cannot
+ * be found. If providers is empty then best available is chosen.
+ */
+ static std::unique_ptr<BlockCipher> create(const std::string& algo_spec,
+ const std::string& provider = "");
+
+ /**
+ * Returns the list of available providers for this algorithm, empty if not available
+ */
+ static std::vector<std::string> providers(const std::string& algo_spec);
+
+ /**
* @return block size of this algorithm
*/
virtual size_t block_size() const = 0;