diff options
author | Jack Lloyd <[email protected]> | 2016-11-03 13:11:18 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-11-03 13:11:18 -0400 |
commit | 660d985e92d030f4ec0c3503bc14363825183371 (patch) | |
tree | 8daeec407eab8f5dc7c00f83b08fc687abe9a8d9 /src/lib/base | |
parent | e42d1513fd6f80dcd2ae4109fddf53b61e935116 (diff) |
Simplify some code by using T::create_or_throw
Diffstat (limited to 'src/lib/base')
-rw-r--r-- | src/lib/base/lookup.h | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/src/lib/base/lookup.h b/src/lib/base/lookup.h index 391891d09..5237ec77a 100644 --- a/src/lib/base/lookup.h +++ b/src/lib/base/lookup.h @@ -44,14 +44,11 @@ inline BlockCipher* get_block_cipher(const std::string& algo_spec, return BlockCipher::create(algo_spec, provider).release(); } -BOTAN_DEPRECATED("Use BlockCipher::create") +BOTAN_DEPRECATED("Use BlockCipher::create_or_throw") inline std::unique_ptr<BlockCipher> make_block_cipher(const std::string& algo_spec, const std::string& provider = "") { - std::unique_ptr<BlockCipher> p(BlockCipher::create(algo_spec, provider)); - if(p) - return p; - throw Algorithm_Not_Found(algo_spec); + return BlockCipher::create_or_throw(algo_spec, provider); } BOTAN_DEPRECATED("Use BlockCipher::providers") @@ -74,14 +71,11 @@ inline StreamCipher* get_stream_cipher(const std::string& algo_spec, return StreamCipher::create(algo_spec, provider).release(); } -BOTAN_DEPRECATED("Use StreamCipher::create") +BOTAN_DEPRECATED("Use StreamCipher::create_or_throw") inline std::unique_ptr<StreamCipher> make_stream_cipher(const std::string& algo_spec, const std::string& provider = "") { - std::unique_ptr<StreamCipher> p(StreamCipher::create(algo_spec, provider)); - if(p) - return p; - throw Algorithm_Not_Found(algo_spec); + return StreamCipher::create_or_throw(algo_spec, provider)); } BOTAN_DEPRECATED("Use StreamCipher::providers") @@ -104,14 +98,11 @@ inline HashFunction* get_hash_function(const std::string& algo_spec, return HashFunction::create(algo_spec, provider).release(); } -BOTAN_DEPRECATED("Use HashFunction::create") +BOTAN_DEPRECATED("Use HashFunction::create_or_throw") inline std::unique_ptr<HashFunction> make_hash_function(const std::string& algo_spec, const std::string& provider = "") { - std::unique_ptr<HashFunction> p(HashFunction::create(algo_spec, provider)); - if(p) - return p; - throw Algorithm_Not_Found(algo_spec); + return HashFunction::create_or_throw(algo_spec, provider)); } BOTAN_DEPRECATED("Use HashFunction::create") @@ -141,14 +132,11 @@ inline MessageAuthenticationCode* get_mac(const std::string& algo_spec, return MessageAuthenticationCode::create(algo_spec, provider).release(); } -BOTAN_DEPRECATED("MessageAuthenticationCode::create") +BOTAN_DEPRECATED("MessageAuthenticationCode::create_or_throw") inline std::unique_ptr<MessageAuthenticationCode> make_message_auth(const std::string& algo_spec, const std::string& provider = "") { - std::unique_ptr<MessageAuthenticationCode> p(MessageAuthenticationCode::create(algo_spec, provider)); - if(p) - return p; - throw Algorithm_Not_Found(algo_spec); + return MessageAuthenticationCode::create(algo_spec, provider); } BOTAN_DEPRECATED("MessageAuthenticationCode::providers") |