Botan  1.11.15
src/lib/filters/key_filt.cpp
Go to the documentation of this file.
00001 /*
00002 * (C) 2015 Jack Lloyd
00003 *
00004 * Botan is released under the Simplified BSD License (see license.txt)
00005 */
00006 
00007 #include <botan/key_filt.h>
00008 #include <botan/transform_filter.h>
00009 
00010 namespace Botan {
00011 
00012 Keyed_Filter* get_cipher(const std::string& algo_spec,
00013                          Cipher_Dir direction)
00014    {
00015    std::unique_ptr<Cipher_Mode> c(get_cipher_mode(algo_spec, direction));
00016    if(c)
00017       return new Transform_Filter(c.release());
00018    throw Algorithm_Not_Found(algo_spec);
00019    }
00020 
00021 Keyed_Filter* get_cipher(const std::string& algo_spec,
00022                          const SymmetricKey& key,
00023                          const InitializationVector& iv,
00024                          Cipher_Dir direction)
00025    {
00026    Keyed_Filter* cipher = get_cipher(algo_spec, key, direction);
00027    if(iv.length())
00028       cipher->set_iv(iv);
00029    return cipher;
00030    }
00031 
00032 Keyed_Filter* get_cipher(const std::string& algo_spec,
00033                          const SymmetricKey& key,
00034                          Cipher_Dir direction)
00035    {
00036    Keyed_Filter* cipher = get_cipher(algo_spec, direction);
00037    cipher->set_key(key);
00038    return cipher;
00039    }
00040 
00041 }