Botan  2.4.0
Crypto and TLS for C++11
key_filt.cpp
Go to the documentation of this file.
1 /*
2 * (C) 2015 Jack Lloyd
3 *
4 * Botan is released under the Simplified BSD License (see license.txt)
5 */
6 
7 #include <botan/key_filt.h>
8 #include <botan/cipher_filter.h>
9 
10 namespace Botan {
11 
12 Keyed_Filter* get_cipher(const std::string& algo_spec,
13  Cipher_Dir direction)
14  {
15  std::unique_ptr<Cipher_Mode> c(get_cipher_mode(algo_spec, direction));
16  if(c)
17  return new Cipher_Mode_Filter(c.release());
18  throw Algorithm_Not_Found(algo_spec);
19  }
20 
21 Keyed_Filter* get_cipher(const std::string& algo_spec,
22  const SymmetricKey& key,
23  const InitializationVector& iv,
24  Cipher_Dir direction)
25  {
26  Keyed_Filter* cipher = get_cipher(algo_spec, key, direction);
27  if(iv.length())
28  cipher->set_iv(iv);
29  return cipher;
30  }
31 
32 Keyed_Filter* get_cipher(const std::string& algo_spec,
33  const SymmetricKey& key,
34  Cipher_Dir direction)
35  {
36  Keyed_Filter* cipher = get_cipher(algo_spec, direction);
37  cipher->set_key(key);
38  return cipher;
39  }
40 
41 }
virtual void set_iv(const InitializationVector &iv)
Definition: basefilt.cpp:13
virtual void set_key(const SymmetricKey &key)=0
Definition: alg_id.cpp:13
size_t length() const
Definition: symkey.h:25
Cipher_Mode * get_cipher_mode(const std::string &algo, Cipher_Dir direction, const std::string &provider)
Definition: cipher_mode.cpp:40
Keyed_Filter * get_cipher(const std::string &algo_spec, Cipher_Dir direction)
Definition: key_filt.cpp:12