diff options
author | lloyd <[email protected]> | 2015-02-04 04:29:11 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2015-02-04 04:29:11 +0000 |
commit | fde85db0ec7b31d3d8a2cb1c13b2ef1e3a3205a4 (patch) | |
tree | d46e6ad6aa3d5c56a3475b9c50820ef53ee2a85e /src | |
parent | 0dd060fed07b0060f94e3bae62e125a85c1bb877 (diff) |
Add missing file
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/filters/key_filt.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/lib/filters/key_filt.cpp b/src/lib/filters/key_filt.cpp new file mode 100644 index 000000000..ca554ae2c --- /dev/null +++ b/src/lib/filters/key_filt.cpp @@ -0,0 +1,42 @@ +/* +* (C) 2015 Jack Lloyd +* +* Botan is released under the Simplified BSD License (see license.txt) +*/ + +#include <botan/key_filt.h> +#include <botan/cipher_mode.h> +#include <botan/transform_filter.h> + +namespace Botan { + +Keyed_Filter* get_cipher(const std::string& algo_spec, + Cipher_Dir direction) + { + std::unique_ptr<Cipher_Mode> c(get_cipher_mode(algo_spec, direction)); + if(c) + return new Transform_Filter(c.release()); + throw Algorithm_Not_Found(algo_spec); + } + +Keyed_Filter* get_cipher(const std::string& algo_spec, + const SymmetricKey& key, + const InitializationVector& iv, + Cipher_Dir direction) + { + Keyed_Filter* cipher = get_cipher(algo_spec, key, direction); + if(iv.length()) + cipher->set_iv(iv); + return cipher; + } + +Keyed_Filter* get_cipher(const std::string& algo_spec, + const SymmetricKey& key, + Cipher_Dir direction) + { + Keyed_Filter* cipher = get_cipher(algo_spec, direction); + cipher->set_key(key); + return cipher; + } + +} |