From 04319af23bf8ed467b17f9b74c814343e051ab6b Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Mon, 21 Sep 2015 14:59:01 -0400 Subject: Remove use of lookup.h in favor of new T::create API. --- src/lib/modes/aead/aead.cpp | 1 - src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp | 9 ++++++--- src/lib/modes/cipher_mode.cpp | 9 ++++----- src/lib/modes/mode_utils.h | 13 ++++++------- 4 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src/lib/modes') diff --git a/src/lib/modes/aead/aead.cpp b/src/lib/modes/aead/aead.cpp index 1e66dbd43..61918c310 100644 --- a/src/lib/modes/aead/aead.cpp +++ b/src/lib/modes/aead/aead.cpp @@ -6,7 +6,6 @@ #include #include -#include #if defined(BOTAN_HAS_AEAD_CCM) #include diff --git a/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp b/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp index 329e2e713..0aef6a747 100644 --- a/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp +++ b/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp @@ -11,9 +11,12 @@ namespace Botan { ChaCha20Poly1305_Mode::ChaCha20Poly1305_Mode() : - m_chacha(make_stream_cipher("ChaCha")), - m_poly1305(make_message_auth("Poly1305")) - {} + m_chacha(StreamCipher::create("ChaCha")), + m_poly1305(MessageAuthenticationCode::create("Poly1305")) + { + if(!m_chacha || !m_poly1305) + throw Algorithm_Not_Found("ChaCha20Poly1305"); + } bool ChaCha20Poly1305_Mode::valid_nonce_length(size_t n) const { diff --git a/src/lib/modes/cipher_mode.cpp b/src/lib/modes/cipher_mode.cpp index 262c41434..27ee26327 100644 --- a/src/lib/modes/cipher_mode.cpp +++ b/src/lib/modes/cipher_mode.cpp @@ -7,7 +7,6 @@ #include #include -#include #include #include @@ -34,7 +33,7 @@ namespace Botan { template Transform* make_ecb_mode(const Transform::Spec& spec) { - std::unique_ptr bc(get_block_cipher(spec.arg(0))); + std::unique_ptr bc(BlockCipher::create(spec.arg(0))); std::unique_ptr pad(get_bc_pad(spec.arg(1, "NoPadding"))); if(bc && pad) return new T(bc.release(), pad.release()); @@ -50,7 +49,7 @@ BOTAN_REGISTER_TRANSFORM(ECB_Decryption, make_ecb_mode); template Transform* make_cbc_mode(const Transform::Spec& spec) { - std::unique_ptr bc(get_block_cipher(spec.arg(0))); + std::unique_ptr bc(BlockCipher::create(spec.arg(0))); if(bc) { @@ -131,8 +130,8 @@ Cipher_Mode* get_cipher_mode(const std::string& algo_spec, Cipher_Dir direction) return cipher; } - if(StreamCipher* stream_cipher = get_stream_cipher(mode_name, provider)) - return new Stream_Cipher_Mode(stream_cipher); + if(auto sc = StreamCipher::create(mode_name, provider)) + return new Stream_Cipher_Mode(sc.release()); return nullptr; } diff --git a/src/lib/modes/mode_utils.h b/src/lib/modes/mode_utils.h index b93884206..a61c22a4f 100644 --- a/src/lib/modes/mode_utils.h +++ b/src/lib/modes/mode_utils.h @@ -10,7 +10,6 @@ #include #include -#include #include #include #include @@ -22,18 +21,18 @@ namespace Botan { template T* make_block_cipher_mode(const Transform::Spec& spec) { - if(BlockCipher* bc = get_block_cipher(spec.arg(0))) - return new T(bc); + if(std::unique_ptr bc = BlockCipher::create(spec.arg(0))) + return new T(bc.release()); return nullptr; } template T* make_block_cipher_mode_len(const Transform::Spec& spec) { - if(BlockCipher* bc = get_block_cipher(spec.arg(0))) + if(std::unique_ptr bc = BlockCipher::create(spec.arg(0))) { const size_t len1 = spec.arg_as_integer(1, LEN1); - return new T(bc, len1); + return new T(bc.release(), len1); } return nullptr; @@ -42,11 +41,11 @@ T* make_block_cipher_mode_len(const Transform::Spec& spec) template T* make_block_cipher_mode_len2(const Transform::Spec& spec) { - if(BlockCipher* bc = get_block_cipher(spec.arg(0))) + if(std::unique_ptr bc = BlockCipher::create(spec.arg(0))) { const size_t len1 = spec.arg_as_integer(1, LEN1); const size_t len2 = spec.arg_as_integer(2, LEN2); - return new T(bc, len1, len2); + return new T(bc.release(), len1, len2); } return nullptr; -- cgit v1.2.3