aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/modes
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/modes')
-rw-r--r--src/lib/modes/cbc/cbc.cpp7
-rw-r--r--src/lib/modes/ecb/ecb.cpp7
-rw-r--r--src/lib/modes/mode_utils.h13
3 files changed, 9 insertions, 18 deletions
diff --git a/src/lib/modes/cbc/cbc.cpp b/src/lib/modes/cbc/cbc.cpp
index e54553d16..1fb27f2e0 100644
--- a/src/lib/modes/cbc/cbc.cpp
+++ b/src/lib/modes/cbc/cbc.cpp
@@ -14,17 +14,16 @@ namespace Botan {
template<typename CBC_T, typename CTS_T>
Transform* make_cbc_mode(const Transform::Spec& spec)
{
- Algorithm_Factory& af = global_state().algorithm_factory();
- const BlockCipher* bc = af.prototype_block_cipher(spec.arg(0));
+ std::unique_ptr<BlockCipher> bc(Algo_Registry<BlockCipher>::global_registry().make(spec.arg(0)));
if(bc)
{
const std::string padding = spec.arg(1, "PKCS7");
if(padding == "CTS")
- return new CTS_T(bc->clone());
+ return new CTS_T(bc.release());
else
- return new CBC_T(bc->clone(), get_bc_pad(padding));
+ return new CBC_T(bc.release(), get_bc_pad(padding));
}
return nullptr;
diff --git a/src/lib/modes/ecb/ecb.cpp b/src/lib/modes/ecb/ecb.cpp
index 1db272d12..6318671ca 100644
--- a/src/lib/modes/ecb/ecb.cpp
+++ b/src/lib/modes/ecb/ecb.cpp
@@ -13,11 +13,10 @@ namespace Botan {
template<typename T>
Transform* make_ecb_mode(const Transform::Spec& spec)
{
- Algorithm_Factory& af = global_state().algorithm_factory();
- const BlockCipher* bc = af.prototype_block_cipher(spec.arg(0));
- BlockCipherModePaddingMethod* pad = get_bc_pad(spec.arg(1, "NoPadding"));
+ std::unique_ptr<BlockCipher> bc(Algo_Registry<BlockCipher>::global_registry().make(spec.arg(0)));
+ std::unique_ptr<BlockCipherModePaddingMethod> pad(get_bc_pad(spec.arg(1, "NoPadding")));
if(bc && pad)
- return new T(bc->clone(), pad);
+ return new T(bc.release(), pad.release());
return nullptr;
}
diff --git a/src/lib/modes/mode_utils.h b/src/lib/modes/mode_utils.h
index 0333403a3..70c996428 100644
--- a/src/lib/modes/mode_utils.h
+++ b/src/lib/modes/mode_utils.h
@@ -11,7 +11,6 @@
#include <botan/cipher_mode.h>
#include <botan/algo_registry.h>
#include <botan/block_cipher.h>
-#include <botan/libstate.h>
#include <botan/loadstor.h>
#include <botan/internal/xor_buf.h>
#include <botan/internal/rounding.h>
@@ -23,9 +22,7 @@ namespace Botan {
template<typename T>
T* make_block_cipher_mode(const Transform::Spec& spec)
{
- Algorithm_Factory& af = global_state().algorithm_factory();
-
- if(const BlockCipher* bc = af.prototype_block_cipher(spec.arg(0)))
+ if(BlockCipher* bc = Algo_Registry<BlockCipher>::global_registry().make(spec.arg(0)))
return new T(bc->clone());
return nullptr;
}
@@ -33,9 +30,7 @@ T* make_block_cipher_mode(const Transform::Spec& spec)
template<typename T, size_t LEN1>
T* make_block_cipher_mode_len(const Transform::Spec& spec)
{
- Algorithm_Factory& af = global_state().algorithm_factory();
-
- if(const BlockCipher* bc = af.prototype_block_cipher(spec.arg(0)))
+ if(BlockCipher* bc = Algo_Registry<BlockCipher>::global_registry().make(spec.arg(0)))
{
const size_t len1 = spec.arg_as_integer(1, LEN1);
return new T(bc->clone(), len1);
@@ -47,9 +42,7 @@ T* make_block_cipher_mode_len(const Transform::Spec& spec)
template<typename T, size_t LEN1, size_t LEN2>
T* make_block_cipher_mode_len2(const Transform::Spec& spec)
{
- Algorithm_Factory& af = global_state().algorithm_factory();
-
- if(const BlockCipher* bc = af.prototype_block_cipher(spec.arg(0)))
+ if(BlockCipher* bc = Algo_Registry<BlockCipher>::global_registry().make(spec.arg(0)))
{
const size_t len1 = spec.arg_as_integer(1, LEN1);
const size_t len2 = spec.arg_as_integer(2, LEN2);