Botan
1.11.15
|
00001 /* 00002 * Algorithm Retrieval 00003 * (C) 1999-2007,2015 Jack Lloyd 00004 * 00005 * Botan is released under the Simplified BSD License (see license.txt) 00006 */ 00007 00008 #include <botan/lookup.h> 00009 #include <botan/internal/algo_registry.h> 00010 #include <botan/cipher_mode.h> 00011 #include <botan/block_cipher.h> 00012 #include <botan/stream_cipher.h> 00013 #include <botan/hash.h> 00014 #include <botan/mac.h> 00015 #include <botan/pbkdf.h> 00016 00017 namespace Botan { 00018 00019 Transform* get_transform(const std::string& specstr, 00020 const std::string& provider, 00021 const std::string& dirstr) 00022 { 00023 Algo_Registry<Transform>::Spec spec(specstr, dirstr); 00024 return Algo_Registry<Transform>::global_registry().make(spec, provider); 00025 } 00026 00027 BlockCipher* get_block_cipher(const std::string& algo_spec, const std::string& provider) 00028 { 00029 return make_a<BlockCipher>(algo_spec, provider); 00030 } 00031 00032 StreamCipher* get_stream_cipher(const std::string& algo_spec, const std::string& provider) 00033 { 00034 return make_a<StreamCipher>(algo_spec, provider); 00035 } 00036 00037 HashFunction* get_hash_function(const std::string& algo_spec, const std::string& provider) 00038 { 00039 return make_a<HashFunction>(algo_spec, provider); 00040 } 00041 00042 MessageAuthenticationCode* get_mac(const std::string& algo_spec, const std::string& provider) 00043 { 00044 return make_a<MessageAuthenticationCode>(algo_spec, provider); 00045 } 00046 00047 std::vector<std::string> get_block_cipher_providers(const std::string& algo_spec) 00048 { 00049 return providers_of<BlockCipher>(BlockCipher::Spec(algo_spec)); 00050 } 00051 00052 std::vector<std::string> get_stream_cipher_providers(const std::string& algo_spec) 00053 { 00054 return providers_of<StreamCipher>(StreamCipher::Spec(algo_spec)); 00055 } 00056 00057 std::vector<std::string> get_hash_function_providers(const std::string& algo_spec) 00058 { 00059 return providers_of<HashFunction>(HashFunction::Spec(algo_spec)); 00060 } 00061 00062 std::vector<std::string> get_mac_providers(const std::string& algo_spec) 00063 { 00064 return providers_of<MessageAuthenticationCode>(MessageAuthenticationCode::Spec(algo_spec)); 00065 } 00066 00067 /* 00068 * Get a PBKDF algorithm by name 00069 */ 00070 PBKDF* get_pbkdf(const std::string& algo_spec, const std::string& provider) 00071 { 00072 if(PBKDF* pbkdf = make_a<PBKDF>(algo_spec, provider)) 00073 return pbkdf; 00074 throw Algorithm_Not_Found(algo_spec); 00075 } 00076 00077 }