/* * Algorithm Retrieval * (C) 1999-2007,2015 Jack Lloyd * * Botan is released under the Simplified BSD License (see license.txt) */ #include #include #include #include #include #include #include #include namespace Botan { Transform* get_transform(const std::string& specstr, const std::string& provider, const std::string& dirstr) { Algo_Registry::Spec spec(specstr, dirstr); return Algo_Registry::global_registry().make(spec, provider); } BlockCipher* get_block_cipher(const std::string& algo_spec, const std::string& provider) { return make_a(algo_spec, provider); } StreamCipher* get_stream_cipher(const std::string& algo_spec, const std::string& provider) { return make_a(algo_spec, provider); } HashFunction* get_hash_function(const std::string& algo_spec, const std::string& provider) { return make_a(algo_spec, provider); } MessageAuthenticationCode* get_mac(const std::string& algo_spec, const std::string& provider) { return make_a(algo_spec, provider); } std::unique_ptr make_block_cipher(const std::string& algo_spec, const std::string& provider) { if(auto x = get_block_cipher(algo_spec, provider)) return std::unique_ptr(x); throw Algorithm_Not_Found(algo_spec); } std::unique_ptr make_stream_cipher(const std::string& algo_spec, const std::string& provider) { if(auto x = get_stream_cipher(algo_spec, provider)) return std::unique_ptr(x); throw Algorithm_Not_Found(algo_spec); } std::unique_ptr make_hash_function(const std::string& algo_spec, const std::string& provider) { if(auto x = get_hash_function(algo_spec, provider)) return std::unique_ptr(x); throw Algorithm_Not_Found(algo_spec); } std::unique_ptr make_message_auth(const std::string& algo_spec, const std::string& provider) { if(auto x = get_mac(algo_spec, provider)) return std::unique_ptr(x); throw Algorithm_Not_Found(algo_spec); } std::vector get_block_cipher_providers(const std::string& algo_spec) { return providers_of(BlockCipher::Spec(algo_spec)); } std::vector get_stream_cipher_providers(const std::string& algo_spec) { return providers_of(StreamCipher::Spec(algo_spec)); } std::vector get_hash_function_providers(const std::string& algo_spec) { return providers_of(HashFunction::Spec(algo_spec)); } std::vector get_mac_providers(const std::string& algo_spec) { return providers_of(MessageAuthenticationCode::Spec(algo_spec)); } /* * Get a PBKDF algorithm by name */ PBKDF* get_pbkdf(const std::string& algo_spec, const std::string& provider) { if(PBKDF* pbkdf = make_a(algo_spec, provider)) return pbkdf; throw Algorithm_Not_Found(algo_spec); } }